Height Map in Vertex Shader

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,714
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 21, 2010

This is a Vertex Shader technical demo with 2 height maps, multi lighting and texture supported.

This program loads two (2) height maps of 192×192 and create a grid with 191×191 quads. Then, it morphs between two calculates (2) height maps and the original plain. Heights of each vertex and normals of each triangle are calculated in Vertex Shader during each frame of morphing.

Heights and normals are calculated in Vertex Shader, based on View Matrix, Projection Matrix and morphing parameters hard-coded in the program. For lights, intensities are specified in Vertex Shader but directions are hard-coded in program. For simplicity, we do not have any configuration files for light directions.

In this program, key 1 to key 5 are used as switches. 1 and 2 for turning on/off two lights. 3 for wire-frame mode. 4 for texture. 5 for shader. If you turn off shader, you could see only some meaningless black pixels.

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (ChenZheChina)

  • ok I've thought an easy way, the ddx cross! ddy could be calculated in the vertex through a shift of a pixel(texcoord.xy) and a minus of the two plus a subsequent normalization, could be?

  • @xdxxdy For each vertex in a triangle, I passed x coord, y coord and height value of other two vertices into vertex shader. Therefore, when the vertex shader calculates normal for a vertex, it first calculates exact positions of all three vertices of the triangle, and then calculate the normal by crossing v0v1 and v0v2.

see all

All Comments (5)

Sign In or Sign Up now to post a comment!
  • hi, I'm interested about the method you have uset to calculate the normals in the vertex shader(dx9? 10? 11?), I've tried tex2Dlod to manipulate the position.z but have no idea about the method used to obtain a normal, in the pixel shader could be made by ddx(dot)ddy. If you have a method to interpolate the calculated normals in the vertex shader please reply.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more