Cards of emission materials three.js

I am currently experimenting a bit with three. js and I would like to use an emission card. I tried to just load the texture into the emission property of the phong material, but unfortunately this does not work. Here is my code:

var params = {
    emissive: THREE.ImageUtils.loadTexture( emissive ),
    shininess: shininess,
    map: THREE.ImageUtils.loadTexture( map ),
    normalMap: THREE.ImageUtils.loadTexture( normalMap ),
    normalScale: new THREE.Vector2(0,-1),
    envMap: this.reflectionCube,
    combine: THREE.MixOperation,
    reflectivity: 0.05
};
var material = new THREE.MeshPhongMaterial(params);

Can someone point me in the right direction to get an emission card?

+4
source share
1 answer

You can create material that supports emission (light) maps by expanding the shaders from existing three.js materials (MeshPhong, MeshLambert, etc.).

, three.js, .

three.js:

  • "PhongGlowShader", ( UniformsLib/ShaderChunk) Phong shader
  • :

    "glowMap" : { type: "t", value: null },
    "glowIntensity": { type: "f", value: 1 },
    
  • :

    float glow = texture2D(glowMap, vUv).x * glowIntensity * 2.0; // optional * 2.0 and clamp
    gl_FragColor.xyz = texelColor.xyz * clamp(emissive + totalDiffuse + ambientLightColor * ambient + glow, 0.0, 2.0) + totalSpecular;
    
  • THREE.ShaderMaterial, ,

. : http://jsfiddle.net/Qr7Bb/2/.

, MeshPhongGlowMaterial, THREE.ShaderMaterial. ; , THREE.ShaderMaterial .

"emissive" , ( "glowIntensity" ).

+5

Source: https://habr.com/ru/post/1540999/


All Articles