WebGL - Textured terrain with heightmap

前端 未结 5 1628
滥情空心
滥情空心 2020-12-31 08:23

I\'m trying to create a 3D terrain using WebGL. I have a jpg with the texture for the terrain, and another jpg with the height values (-1 to 1).

I\'ve looked at vari

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 08:55

    Depending on your GLSL skills, you can write a GLSL vertex shader, assign the texture to one of your texture channels, and read the value in the vertex shader (I believe you need a modern card to read textures in a vertex shader but that may just be me showing my age :P )

    In the vertex shader, translate the z value of the vertex based on the value read from the texture.

提交回复
热议问题