Hi there, i`m trying to create terrain with height map file. But when i apply gayscale image as displacement-map i get wrong scaling terrain. I’m not an expert in 3D graphics so I can’t write my own vertex shader. I found this solutions for BoxGeometry ( https://codesandbox.io/s/youthful-meadow-0swsm?file=/src/js/TerrainCutout.js ). Maybe someone know how refactoring this code for PlaneGeometry
Yep. Try these changes:
Line 2: replace what geometry is imported
BoxGeometry,
PlaneGeometry,
Line 13: fix the constructor
this.geometry = new BoxGeometry(width, height, depth, segW, 1, segD);
this.geometry = new PlaneGeometry(width, depth, segW, segD).rotateX(-Math.PI/2);
Lines 19-20: set the flags to 1
Math.sign(pos.getY(i)), // point can be displaced
Math.sign(nor.getY(i)) // normal needs to be re-computed
1, // point can be displaced
1 // normal needs to be re-computed
2 Likes
Thanks! You helped me a lot!