Is there any way I can convert my terrain height map into a normal map that I can use for ambient occlusion and terrain shadowing in the vertex shader?
Here is my current vertex shader code.
PS_INPUT vert; float offset = dist*-39.0f; vert.t.x = 1.0f-(input.pos.x *0.0125f); vert.t.y = input.pos.y *0.0125f; vert.p = float4((input.pos.x*dist)+offset, 0, (input.pos.y*dist)+offset, 1); vert.p.y = HMap.SampleLevel(linearSampler, vert.t, 0); vert.p = mul(vert.p, view); vert.p = mul(vert.p, prj); return vert;
I am sending a 80x80 grid of vertices to the shader. I first calculate the offset used to position the verts around the center point where the camera will be when it initially starts.
Then I convert the grid coordinates into texture coordinates, followed by repositioning the verts, then sampling the height map (single 32bit channel per pixel cuz the vertex positions are all in meters as it is a terrain model of the earth).
Since I can predict the vertex positions surrounding current vert using the height map, how would I go about this?
Edited by Naruto-kun, 28 July 2014 - 05:29 AM.