How can i get the y world position of a vertex at a given x and z position from a shader graph?
I am making a buoyancy mechanic for my water which uses a shader graph to create waves and noise for the y-value. The waterplane consists of many tiled plane-objects with the same material. I need to get the y world coordinate of the vertices on the plane to calculate the depth and buoyancy. Is it even possible to do this via the shader graph?
I am using Unity 2020.2.2f1
Any advice appreciated!:)
I'm also not very experienced in shader graphing.
Answer by BastianUrbach · Feb 16, 2021 at 06:51 AM
It's impossible to get the vertex position after it has been modified by a vertex shader as this happens on the GPU every frame just before rasterisation. At that point, no information flows back from the GPU to the CPU. However, you can perform the same calculations that your shader graph does in a C# script to reproduce the same vertex position separately. You can view the code used for the gradient noise node in the shader graph documentation: Gradient Noise Node
Your answer
Follow this Question
Related Questions
Shader Graph low poly water normals 1 Answer
Low Poly Water with Proper Buoyancy 2 Answers
Shader for alpha fading 0 Answers
Low poly model looks ugly with normal map 1 Answer
Blender like cavity effect in unity 2020 2 Answers