Download

Creating a global Vertex / Deformation shader?

Does anybody have experience in creating a special shader that effects every object in the level, and can be used to offset vertices / apply deformation to them?

Essentially I’m thinking of ways to develop a global ‘melt’ system. Essentially, I need every object in my level to be affected by a little hot ball (or perhaps multiple heat sources). Every object in the scene needs to be able to ‘melt’ away based on this world-space effect. The effect is temporary and all objects go back to their original state after a short period. My current idea, is to draw the ‘heat’ information into a 3D 32-bit Render Target (RGB is both direction from heat source and intensity). All ‘heat’ in the shader blends back to a normalized value over time so that objects will slowly restore to their original state.

I want to then add a flag to a material that allows it to ‘read’ from this 3D Texture (similarly to how you can toggle fog on/off for translucent materials), and then each material can apply deformation to vertices or displacement as it chooses.

I can’t see anyway to do this with 2D render targets unless I use something like Ryan’s volume texture stuff he’s been showing recently (but it might not be high enough res for the whole level), and I think this is probably more efficient than creating a material function and adding it to all my materials. Any ideas?

Hi, do you mean something like this - Blueprint or vertex shader mesh deformers - Content Creation - Unreal Engine Forums ?

To clarify, you want to store heat emission from objects and be able to read the temperature at the world position location of a pixel/vertex?

To me, doing it for every material does not seem bad at all. Not sure if implementing it on lower level would be worth the effort.
As to storing the effect, depending on the viewing perspective and size of the level, and general type of the project,perhaps you could:

  1. Instead of using 3d target, encode Z information into a channel/channels of 2d render target.(Works marvelously if your level is somewhat flat, but might be complicated if the heat ball can occasionally move strictly vertically
  2. Instead of covering whole world with a texture, cover the region in camera’s frustum plus safety margin, while stabilizing the texture in world space.

For now there is no way to paint vertex colors in game for regular meshes. But maybe it is possible to extend procedural mesh for this?

I think with it you can draw some direction vectors into vertices and use it for melting in wpo.
But anyway this requires some highly tesselated meshes…

Essentially yeah. Materials should be able to read from that and act accordingly.

Yeah I thought about doing it this way and although my levels are small, the issue becomes one of how many layers can I store in a 2D render target until the resolution is practically unuseable. For the size of my levels relative to the detail that I want, I probably want an RT about 1K units across to cover one 2D plane. So in a 4K texture I get a maximum of 16 layers, and interpolation between those layers would probably suck somewhat. Doing it the same was as the new volumetric fog might be easier.

Oh also, I need this to run on PS4 at least - so small savings count.

Just in case there is a misunderstanding, I was not offering storing layers in a 2d texture, alike some sort of pseudo-volumetric textures. It was more about storing additional data per pixel in 2d texture, so that you would lookup 2d texture based on your vertex world XY, and then read W channel, that would store center point of the effect Z-axis position, softly comparing vertex Z with this value.

That’s not a bad idea. Only issue there is that since my levels have multiple ‘layers’, a new ‘Z’ value would overwrite the old one. I suppose another approach would be to apply the 2D texture based on a volume or some kind, so I would place a box volume around one of the ‘levels’, and have objects inside that volume only respond to texture information from that volume.

Might be tricky and would undoubtedly require some CPU-side implementation, but certainly possible.

Yeah, if the levels have some vertical leeway, it becomes problematic.