Giter Site home page Giter Site logo

Comments (4)

IceCreamYou avatar IceCreamYou commented on August 25, 2024

generateBlendedMaterial was written as a demo in 2014, basically a copy of the Lambert material in Three.js r67. 5 years later, at Three.js r107, generateBlendedMaterial has not kept up. But as much as I'd like it to work well for everyone, it's not the focus of this library, and I'm not actively developing THREE.Terrain anyway, so I don't expect to be the person who changes that.

The good news is that there's actually not that much that generateBlendedMaterial does. It's basically just a copy of Lambert material with a small edit to interpolate colors. So if you want to explore doing something similar with a different base material, hopefully it wouldn't be too much work. I would certainly accept a PR 🙂

from three.terrain.

campbellgoe avatar campbellgoe commented on August 25, 2024

MeshStandardMaterial supports displacements maps:

.displacementMap : Texture
The displacement map affects the position of the mesh's vertices. Unlike other maps which only affect the light and shade of the material the displaced vertices can cast shadows, block other objects, and otherwise act as real geometry. The displacement texture is an image where the value of each pixel (white being the highest) is mapped against, and repositions, the vertices of the mesh.

and displacementScale.

Additionally it supports normal maps, enabling nicer looking textures with directional lights.

I believe the functionality of terrain generation could be implementation by creating a set of 2d noise and using that as the displacementMap of a Standard material on a plane.

I have yet to play with it, but I plan on doing so.

from three.terrain.

IceCreamYou avatar IceCreamYou commented on August 25, 2024

THREE.Terrain supports exporting the generated terrain to an image. This image can be passed to the THREE.Texture constructor to create a texture that can be used for a MeshStandardMaterial.displacementMap. That won't help with blending materials but it's a roundabout way to get a terrain shape. The caveat is that you lose some precision, because displacement maps have only 256 possible values for each pixel, whereas terrains generated the normal way can place vertices at any height. This can be noticeable if your camera is closer to the ground than about 4% of the terrain's height range.

from three.terrain.

IceCreamYou avatar IceCreamYou commented on August 25, 2024

Thanks to #29 for making it possible, I just pushed a change to allow passing a material instance as a second parameter to generateBlendedMaterial. You can now do something like generateBlendedMaterial(textures, new MeshStandardMaterial()) and it will use a standard material as the base. No guarantees that everything will work as expected, but it doesn't seem to break anything!

from three.terrain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.