House Dissolve Shader (UE)

This shader is a result of me wanting to a shader. There was no need for it, I simply wanted to do it. The core idea was to have some kind of magic dissolve shader and I ended up putting it on a house.

Basic Setup

This is what the shader ended up looking like. It’s a simple combination of world position offset and opacity. When the player character enters a sphere collider around the house, a value in the shader fades from 0 to 1. If the player leaves, it goes back to 0.

This value is used to drive the opacity and world position offset. The opacity is dithered, but other than that, it is really taking the custom value as it is.

World Position Offset

The calculation for the position offset is more complex. The base is a RotateAboutWorldAxis_cheap node. The pivot point of that node is simply a zero vector because the calculations are in local space so the center point of the object can be taken as the point to rotate around.

The rotation amount is dependent on the height of each vertex. So the Z component of the local position is first adjusted (having 500 subtracted) and then multiplied with a very small number because Unreal’s unity is a centimeter. Lastly this is multiplied with the invert of our custom visibility value so that it starts at 0 when the visibility is 1 and at 1 when the object is invisible. The result of all this is that the rotation amount starts to increase at the top and moves to the bottom. At the same time it increases over time when the house fades out.

Lastly, there is the world position. The vertex normal is projected on a plane defined by an up vector. The result is multiplied with what ends up in the “Rotation Amount” slot so as to make the rotation amount and offset be equally intense over time and in respect to height. The result is then multiplied by an intensity on its own (5000).

Conclusion

I like what the effect looks like right now, but it could definitely be improved by mixing it with particle effects. What’s also currently missing is making the Material adjustable by introducing parameters were there are currently some hardcoded values. All in all I’m happy with the result especially since it was just playing around.

Leave a comment