Does texture splatting works with Three.js or other Javascript 3D rendering framework? If yes I'd like to see example maybe even tutorial on large terrain. If it doesn't work is there any other way mapping large terrains? Thank you.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is GLFW designed to use without LWJGL (in java)?
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
Challenge accepted!
First, you can write a vertex shader that takes a grayscale image and uses it as a heightmap, and includes a varying float (called
vAmount
below) to pass to the fragment shader to determine the texture(s) to display(blend) at that point.Next comes the fragment shader, which can include however many textures you need for different elevations, and there is a great built-in function called
smoothstep
that makes smooth transitions much easier to calculate.An example of code for such a fragment shader:
Then you can use a
THREE.ShaderMaterial
to use this for a given mesh. The above code is implemented at http://stemkoski.github.io/Three.js/Shader-Heightmap-Textures.html and produces a result like this:Hope this helps you get started. Happy coding!