hello!
Is there a way that I can store and reuse height map data into a shader?
I know I can read out world position of vertex but I need to store that data ones and reuse it, instead of that it constant updates with new information.
Basically, ‘bake’ Y info into a variable.
I’m not sure I understand the question… but if you want to make it so your shader runs only when you specifically tell it to, use the Graphics.Blit() function.
Shaders inherently do not do this. They take data from one end and spit out data on the other. They save no state between frames on their own. If you want this you need to supply the data on your own.
There’s many ways to go about this, depending on what’s needed and what changes in your mesh.
You could bake out the information you need into the vertex information (either color or use a UV channel) on the CPU side or in an external art tool.
You could render a depth buffer using a replacement shader and render to texture and feed that into the shader.
You could store off the object2world matrix transform from the moment you want to recall and supply it to the shader as another input to use it to transform the vertex data into the correct position.
Run that once at the time you want to store, then use that matrix in your shader to mul the vertex info and pull the .y from that.
This won’t work on skinned meshes or any mesh that is modified dynamically on the CPU side. This basically just lets you recall an orientation and offset position at a specific point in time.