我正在使用以下顶点着色器(由http://stemkoski.github.io/Three.js/Shader-Heightmap-Textures.html提供)从灰度高度图生成地形:
uniform sampler2D bumpTexture;
uniform float bumpScale;
varying float vAmount;
varying vec2 vUV;
void main()
{
vUV = uv;
vec4 bumpData = texture2D( bumpTexture, uv );
vAmount = bumpData.r; // assuming map is grayscale it doesn't matter if you use r, g, or b.
// move the position along the normal
vec3 newPosition = position + normal * bumpScale * vAmount;
gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0);
}
我想要 32 位的分辨率,并生成了一个将高度编码为 RGBA 的高度图。我不知道如何更改着色器代码以适应这种情况。任何方向或帮助?