|
@@ -13,7 +13,6 @@ import {
|
|
UnsignedByteType,
|
|
UnsignedByteType,
|
|
LinearEncoding,
|
|
LinearEncoding,
|
|
NoToneMapping,
|
|
NoToneMapping,
|
|
- BackSide
|
|
|
|
} from '../constants.js';
|
|
} from '../constants.js';
|
|
import { MathUtils } from '../math/MathUtils.js';
|
|
import { MathUtils } from '../math/MathUtils.js';
|
|
import { DataTexture } from '../textures/DataTexture.js';
|
|
import { DataTexture } from '../textures/DataTexture.js';
|
|
@@ -46,6 +45,7 @@ import { WebGLTextures } from './webgl/WebGLTextures.js';
|
|
import { WebGLUniforms } from './webgl/WebGLUniforms.js';
|
|
import { WebGLUniforms } from './webgl/WebGLUniforms.js';
|
|
import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
|
|
+import { WebGLMaterials } from "./webgl/WebGLMaterials.js";
|
|
|
|
|
|
function WebGLRenderer( parameters ) {
|
|
function WebGLRenderer( parameters ) {
|
|
|
|
|
|
@@ -242,7 +242,7 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
var extensions, capabilities, state, info;
|
|
var extensions, capabilities, state, info;
|
|
var properties, textures, attributes, geometries, objects;
|
|
var properties, textures, attributes, geometries, objects;
|
|
- var programCache, renderLists, renderStates;
|
|
|
|
|
|
+ var programCache, materials, renderLists, renderStates;
|
|
|
|
|
|
var background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
var background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
|
|
|
|
@@ -282,6 +282,7 @@ function WebGLRenderer( parameters ) {
|
|
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
morphtargets = new WebGLMorphtargets( _gl );
|
|
morphtargets = new WebGLMorphtargets( _gl );
|
|
programCache = new WebGLPrograms( _this, extensions, capabilities );
|
|
programCache = new WebGLPrograms( _this, extensions, capabilities );
|
|
|
|
+ materials = new WebGLMaterials( properties );
|
|
renderLists = new WebGLRenderLists();
|
|
renderLists = new WebGLRenderLists();
|
|
renderStates = new WebGLRenderStates();
|
|
renderStates = new WebGLRenderStates();
|
|
|
|
|
|
@@ -1860,87 +1861,11 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
if ( fog && material.fog ) {
|
|
if ( fog && material.fog ) {
|
|
|
|
|
|
- refreshUniformsFog( m_uniforms, fog );
|
|
|
|
|
|
+ materials.refreshUniformsFog( m_uniforms, fog );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ( material.isMeshBasicMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshLambertMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsLambert( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshToonMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsToon( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshPhongMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsPhong( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshStandardMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material, environment );
|
|
|
|
-
|
|
|
|
- if ( material.isMeshPhysicalMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsPhysical( m_uniforms, material, environment );
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- refreshUniformsStandard( m_uniforms, material, environment );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshMatcapMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsMatcap( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshDepthMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsDepth( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshDistanceMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsDistance( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isMeshNormalMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsCommon( m_uniforms, material );
|
|
|
|
- refreshUniformsNormal( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isLineBasicMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsLine( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- if ( material.isLineDashedMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsDash( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if ( material.isPointsMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsPoints( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isSpriteMaterial ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsSprites( m_uniforms, material );
|
|
|
|
-
|
|
|
|
- } else if ( material.isShadowMaterial ) {
|
|
|
|
-
|
|
|
|
- m_uniforms.color.value.copy( material.color );
|
|
|
|
- m_uniforms.opacity.value = material.opacity;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ materials.refreshUniforms( m_uniforms, material, environment, _pixelRatio, _height );
|
|
|
|
|
|
// RectAreaLight Texture
|
|
// RectAreaLight Texture
|
|
// TODO (mrdoob): Find a nicer implementation
|
|
// TODO (mrdoob): Find a nicer implementation
|
|
@@ -1950,12 +1875,6 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
|
|
WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
|
|
|
|
|
|
- if ( material.isShaderMaterial ) {
|
|
|
|
-
|
|
|
|
- material.uniformsNeedUpdate = false; // #15581
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
|
|
if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
|
|
@@ -1981,579 +1900,6 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // Uniforms (refresh uniforms objects)
|
|
|
|
-
|
|
|
|
- function refreshUniformsCommon( uniforms, material, environment ) {
|
|
|
|
-
|
|
|
|
- uniforms.opacity.value = material.opacity;
|
|
|
|
-
|
|
|
|
- if ( material.color ) {
|
|
|
|
-
|
|
|
|
- uniforms.diffuse.value.copy( material.color );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.emissive ) {
|
|
|
|
-
|
|
|
|
- uniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uniforms.map.value = material.map;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.alphaMap.value = material.alphaMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.specularMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.specularMap.value = material.specularMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var envMap = material.envMap || environment;
|
|
|
|
-
|
|
|
|
- if ( envMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.envMap.value = envMap;
|
|
|
|
-
|
|
|
|
- uniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;
|
|
|
|
-
|
|
|
|
- uniforms.reflectivity.value = material.reflectivity;
|
|
|
|
- uniforms.refractionRatio.value = material.refractionRatio;
|
|
|
|
-
|
|
|
|
- uniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.lightMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.lightMap.value = material.lightMap;
|
|
|
|
- uniforms.lightMapIntensity.value = material.lightMapIntensity;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.aoMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.aoMap.value = material.aoMap;
|
|
|
|
- uniforms.aoMapIntensity.value = material.aoMapIntensity;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // uv repeat and offset setting priorities
|
|
|
|
- // 1. color map
|
|
|
|
- // 2. specular map
|
|
|
|
- // 3. normal map
|
|
|
|
- // 4. bump map
|
|
|
|
- // 5. alpha map
|
|
|
|
- // 6. emissive map
|
|
|
|
-
|
|
|
|
- var uvScaleMap;
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.map;
|
|
|
|
-
|
|
|
|
- } else if ( material.specularMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.specularMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.displacementMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.normalMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.bumpMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.roughnessMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.roughnessMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.metalnessMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.metalnessMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.alphaMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.emissiveMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.emissiveMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap !== undefined ) {
|
|
|
|
-
|
|
|
|
- // backwards compatibility
|
|
|
|
- if ( uvScaleMap.isWebGLRenderTarget ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = uvScaleMap.texture;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap.matrixAutoUpdate === true ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap.updateMatrix();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.uvTransform.value.copy( uvScaleMap.matrix );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // uv repeat and offset setting priorities for uv2
|
|
|
|
- // 1. ao map
|
|
|
|
- // 2. light map
|
|
|
|
-
|
|
|
|
- var uv2ScaleMap;
|
|
|
|
-
|
|
|
|
- if ( material.aoMap ) {
|
|
|
|
-
|
|
|
|
- uv2ScaleMap = material.aoMap;
|
|
|
|
-
|
|
|
|
- } else if ( material.lightMap ) {
|
|
|
|
-
|
|
|
|
- uv2ScaleMap = material.lightMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uv2ScaleMap !== undefined ) {
|
|
|
|
-
|
|
|
|
- // backwards compatibility
|
|
|
|
- if ( uv2ScaleMap.isWebGLRenderTarget ) {
|
|
|
|
-
|
|
|
|
- uv2ScaleMap = uv2ScaleMap.texture;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uv2ScaleMap.matrixAutoUpdate === true ) {
|
|
|
|
-
|
|
|
|
- uv2ScaleMap.updateMatrix();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsLine( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.diffuse.value.copy( material.color );
|
|
|
|
- uniforms.opacity.value = material.opacity;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsDash( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.dashSize.value = material.dashSize;
|
|
|
|
- uniforms.totalSize.value = material.dashSize + material.gapSize;
|
|
|
|
- uniforms.scale.value = material.scale;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsPoints( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.diffuse.value.copy( material.color );
|
|
|
|
- uniforms.opacity.value = material.opacity;
|
|
|
|
- uniforms.size.value = material.size * _pixelRatio;
|
|
|
|
- uniforms.scale.value = _height * 0.5;
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uniforms.map.value = material.map;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.alphaMap.value = material.alphaMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // uv repeat and offset setting priorities
|
|
|
|
- // 1. color map
|
|
|
|
- // 2. alpha map
|
|
|
|
-
|
|
|
|
- var uvScaleMap;
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.map;
|
|
|
|
-
|
|
|
|
- } else if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.alphaMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap !== undefined ) {
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap.matrixAutoUpdate === true ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap.updateMatrix();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.uvTransform.value.copy( uvScaleMap.matrix );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsSprites( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.diffuse.value.copy( material.color );
|
|
|
|
- uniforms.opacity.value = material.opacity;
|
|
|
|
- uniforms.rotation.value = material.rotation;
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uniforms.map.value = material.map;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.alphaMap.value = material.alphaMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // uv repeat and offset setting priorities
|
|
|
|
- // 1. color map
|
|
|
|
- // 2. alpha map
|
|
|
|
-
|
|
|
|
- var uvScaleMap;
|
|
|
|
-
|
|
|
|
- if ( material.map ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.map;
|
|
|
|
-
|
|
|
|
- } else if ( material.alphaMap ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap = material.alphaMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap !== undefined ) {
|
|
|
|
-
|
|
|
|
- if ( uvScaleMap.matrixAutoUpdate === true ) {
|
|
|
|
-
|
|
|
|
- uvScaleMap.updateMatrix();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.uvTransform.value.copy( uvScaleMap.matrix );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsFog( uniforms, fog ) {
|
|
|
|
-
|
|
|
|
- uniforms.fogColor.value.copy( fog.color );
|
|
|
|
-
|
|
|
|
- if ( fog.isFog ) {
|
|
|
|
-
|
|
|
|
- uniforms.fogNear.value = fog.near;
|
|
|
|
- uniforms.fogFar.value = fog.far;
|
|
|
|
-
|
|
|
|
- } else if ( fog.isFogExp2 ) {
|
|
|
|
-
|
|
|
|
- uniforms.fogDensity.value = fog.density;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsLambert( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- if ( material.emissiveMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.emissiveMap.value = material.emissiveMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsPhong( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.specular.value.copy( material.specular );
|
|
|
|
- uniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )
|
|
|
|
-
|
|
|
|
- if ( material.emissiveMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.emissiveMap.value = material.emissiveMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.bumpMap.value = material.bumpMap;
|
|
|
|
- uniforms.bumpScale.value = material.bumpScale;
|
|
|
|
- if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.normalMap.value = material.normalMap;
|
|
|
|
- uniforms.normalScale.value.copy( material.normalScale );
|
|
|
|
- if ( material.side === BackSide ) uniforms.normalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsToon( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- uniforms.specular.value.copy( material.specular );
|
|
|
|
- uniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )
|
|
|
|
-
|
|
|
|
- if ( material.gradientMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.gradientMap.value = material.gradientMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.emissiveMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.emissiveMap.value = material.emissiveMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.bumpMap.value = material.bumpMap;
|
|
|
|
- uniforms.bumpScale.value = material.bumpScale;
|
|
|
|
- if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.normalMap.value = material.normalMap;
|
|
|
|
- uniforms.normalScale.value.copy( material.normalScale );
|
|
|
|
- if ( material.side === BackSide ) uniforms.normalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsStandard( uniforms, material, environment ) {
|
|
|
|
-
|
|
|
|
- uniforms.roughness.value = material.roughness;
|
|
|
|
- uniforms.metalness.value = material.metalness;
|
|
|
|
-
|
|
|
|
- if ( material.roughnessMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.roughnessMap.value = material.roughnessMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.metalnessMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.metalnessMap.value = material.metalnessMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.emissiveMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.emissiveMap.value = material.emissiveMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.bumpMap.value = material.bumpMap;
|
|
|
|
- uniforms.bumpScale.value = material.bumpScale;
|
|
|
|
- if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.normalMap.value = material.normalMap;
|
|
|
|
- uniforms.normalScale.value.copy( material.normalScale );
|
|
|
|
- if ( material.side === BackSide ) uniforms.normalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.envMap || environment ) {
|
|
|
|
-
|
|
|
|
- //uniforms.envMap.value = material.envMap; // part of uniforms common
|
|
|
|
- uniforms.envMapIntensity.value = material.envMapIntensity;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsPhysical( uniforms, material, environment ) {
|
|
|
|
-
|
|
|
|
- refreshUniformsStandard( uniforms, material, environment );
|
|
|
|
-
|
|
|
|
- uniforms.reflectivity.value = material.reflectivity; // also part of uniforms common
|
|
|
|
-
|
|
|
|
- uniforms.clearcoat.value = material.clearcoat;
|
|
|
|
- uniforms.clearcoatRoughness.value = material.clearcoatRoughness;
|
|
|
|
- if ( material.sheen ) uniforms.sheen.value.copy( material.sheen );
|
|
|
|
-
|
|
|
|
- if ( material.clearcoatMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.clearcoatMap.value = material.clearcoatMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.clearcoatRoughnessMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.clearcoatNormalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale );
|
|
|
|
- uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;
|
|
|
|
-
|
|
|
|
- if ( material.side === BackSide ) {
|
|
|
|
-
|
|
|
|
- uniforms.clearcoatNormalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.transparency.value = material.transparency;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsMatcap( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- if ( material.matcap ) {
|
|
|
|
-
|
|
|
|
- uniforms.matcap.value = material.matcap;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.bumpMap.value = material.bumpMap;
|
|
|
|
- uniforms.bumpScale.value = material.bumpScale;
|
|
|
|
- if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.normalMap.value = material.normalMap;
|
|
|
|
- uniforms.normalScale.value.copy( material.normalScale );
|
|
|
|
- if ( material.side === BackSide ) uniforms.normalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsDepth( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsDistance( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- uniforms.referencePosition.value.copy( material.referencePosition );
|
|
|
|
- uniforms.nearDistance.value = material.nearDistance;
|
|
|
|
- uniforms.farDistance.value = material.farDistance;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function refreshUniformsNormal( uniforms, material ) {
|
|
|
|
-
|
|
|
|
- if ( material.bumpMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.bumpMap.value = material.bumpMap;
|
|
|
|
- uniforms.bumpScale.value = material.bumpScale;
|
|
|
|
- if ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.normalMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.normalMap.value = material.normalMap;
|
|
|
|
- uniforms.normalScale.value.copy( material.normalScale );
|
|
|
|
- if ( material.side === BackSide ) uniforms.normalScale.value.negate();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ( material.displacementMap ) {
|
|
|
|
-
|
|
|
|
- uniforms.displacementMap.value = material.displacementMap;
|
|
|
|
- uniforms.displacementScale.value = material.displacementScale;
|
|
|
|
- uniforms.displacementBias.value = material.displacementBias;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// If uniforms are marked as clean, they don't need to be loaded to the GPU.
|
|
// If uniforms are marked as clean, they don't need to be loaded to the GPU.
|
|
|
|
|
|
function markUniformsLightsNeedsUpdate( uniforms, value ) {
|
|
function markUniformsLightsNeedsUpdate( uniforms, value ) {
|