- Home /
Setting and storing vertex locations in a shader
this question is a follow up from http://answers.unity3d.com/questions/543558/moving-vertices-in-shaders.html#
Hi there,
I have am able to move a single vertex to my desired position, but on 1 plane, i have 100 vertices, and once they have been moved, I would like them stored there.
My initial thought is to make a multidimensional float array like this:
uniform float2 coords[10][10]; //this already gives an error
And then just iterate through them using 2 for loops. So they are saved in the shader and will not reset the next call
But i can't seem to get a 2D array in my shader without getting "syntax error". Is there a way to achieve this so that my final vert function will look a bit like:
void vert(inout appdata_full v)
{
float4 castToWorld = round(mul(_Object2World, v.vertex) );
v.vertex.y = coord[castToWorld.x][castToWorld.z];
}
This might be a stretch, but it would be so awesome if it was possible. I guess the main question is, how do I declare a 2D array in the shader? Any help or alternative methods are much appreciated :)
Your answer
Follow this Question
Related Questions
Moving vertices in shaders 1 Answer
How to move vertices up/down randomly in shader. 1 Answer
Getting model bounds in vertex shader 0 Answers