Add terrain heights

This commit is contained in:
Fuhrmann 2025-03-13 15:11:08 +01:00
commit d2987d07c4
5 changed files with 108 additions and 98 deletions

View file

@ -84,9 +84,6 @@ export class CustomMapHeightNodeShader extends MapHeightNode {
new MeshPhongMaterial({
map: MapNode.defaultTexture,
color: 0xffffff,
transparent: true,
opacity: 1.0,
depthTest: true,
})
);
@ -109,7 +106,7 @@ export class CustomMapHeightNodeShader extends MapHeightNode {
material
);
this.frustumCulled = false;
this.frustumCulled = true;
}
/**
@ -147,9 +144,10 @@ export class CustomMapHeightNodeShader extends MapHeightNode {
vec4 _theight = texture(heightMap, vMapUv);
float _height = ((_theight.r * 255.0 * 65536.0 + _theight.g * 255.0 * 256.0 + _theight.b * 255.0) * 0.1) - 10000.0;
// Apply height displacement
vec3 _transformed = position + _height * normal;
// Vertex position based on height
gl_Position = projectionMatrix * modelViewMatrix * vec4(_transformed, 1.0);
`
);