Shader: Notes on two simple effects

Briefly record the implementation of two simple shaders recently encountered.
The length of a single article is too short, so the two articles are combined into one article.

The handle is broken through the wall

This effect is common in XR manufacturer's protection center software (or safety zone, play zone, etc.), and its main features are:

  • By default, the dynamic wall effect (water ripple, breathing clouds) of Techno Beauty is displayed
  • When the handle/hand/head is close to the wall, a hole will be opened on the wall, supplemented by a red warning prompt
  • The closer to the wall, the larger the opening

A friend asked me before, and I used ShaderGraph to spell a simplified example for him. The following is the rendering (GIF):

The principle is simple. The logical frame passes Shader.SetGlobalXXX The global Pose is updated, and the shards are colored or clipped according to the distance (square).

 Shader.SetGlobalVector(LeftHandPosition, Pose.LeftHand);

Gaussian blur

Each slice element is sampled several times along the periphery and mixed through the proportion of normal distribution.

Multiple iterations can obtain increasingly blurred images, but the bandwidth and performance consumption are also increasing.

The following is the effect of sampling the rendering results of the opaque queue and iterating once using the common 3 × 3 mixed values:

be in suspense

Although the principle is very simple, there is one problem that is not easy to solve: the blurring when interpenetrating with semi transparent queue objects.

For 2D screen effects and full screen effects, it is OK to directly sample the final rendered results, regardless of depth.

If it is a patch in 3D space, users can walk around and observe it 360 degrees, then the above problems cannot be ignored.

DirectX has native support for OIT (order independent transparency), but if you consider the compatibility, performance, and use difficulty of Android OpenGLES and other platforms, it is almost unavailable.

Therefore, we should try to avoid the occurrence of semi transparent overlapping.

Related articles

Zimiao haunting blog (azimiao. com) All rights reserved. Please note the link when reprinting: https://www.azimiao.com/10357.html
Welcome to the Zimiao haunting blog exchange group: three hundred and thirteen million seven hundred and thirty-two thousand

Comment

*

*