Thomson Gunardi Teguh

Games and Graphics Programmer

Dissolve Shader

The dissolve shader is a shader that takes a greyscale noise texture and use one of its color channel as a check against a cutoff value that increases overtime.  For every frame, a CPU side script increments this cutoff value from 0 up till 1.  The shader will then check this cutoff value against the texture value from the noise texture during the fragment shader stage.  If it is below the cutoff value, then the fragment is considered to have dissolved.

To create the dissolving effect, a burn size variable controls the amount of offset that considers a fragment as dissolving.  So if the texture value for that fragment is greater than the cutoff value, but less than cutoff + burn size value, the shader applies the burn color for that fragment.

There are two options for the burn color.  A single High Dynamic Range (HDR) enabled color or a 1 dimensional gradient texture.

Furthermore, there is an option to dissolve into a secondary diffuse texture instead of dissolving into nothing.

DIssolve From Point

An extension of the dissolve shader is to add a world-space point of impact as a parameter to the shader.  A distance weight from the point of impact is then added into the cutoff calculation, forcing fragments that are closer to the point of impact to dissolve faster.  Note that the parchment paper on the right was rendered without a noise texture, causing the dissolve pattern to appear circular due to the distance weight from the point of impact.

Adding a raycast script allows users or players to click on each dissolvable object and trigger the dissolve from the point of impact.  This effect is perfect for use in Sci-fi First Person Shooter (FPS) games.

Next Post

Previous Post

© 2020 Thomson Gunardi Teguh

LinkedIn | GitHub | thomsongunardi@hotmail.com