提交 f8786307 编写于 作者: M Mr.doob

WebGLRenderer: Moved material.combine to define based. See #5741.

上级 d932d63c
......@@ -4109,6 +4109,8 @@ THREE.WebGLRenderer = function ( parameters ) {
specularMap: !! material.specularMap,
alphaMap: !! material.alphaMap,
combine: material.combine,
vertexColors: material.vertexColors,
fog: fog,
......@@ -4603,7 +4605,6 @@ THREE.WebGLRenderer = function ( parameters ) {
}
uniforms.refractionRatio.value = material.refractionRatio;
uniforms.combine.value = material.combine;
uniforms.useRefract.value = material.envMap && (
material.envMap.mapping === THREE.CubeRefractionMapping ||
material.envMap.mapping === THREE.EquirectangularRefractionMapping );
......
......@@ -53,18 +53,18 @@
#endif
if ( combine == 1 ) {
#ifdef ENVMAP_BLENDING_MULTIPLY
gl_FragColor.xyz = mix( gl_FragColor.xyz, envColor.xyz, specularStrength * reflectivity );
gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * envColor.xyz, specularStrength * reflectivity );
} else if ( combine == 2 ) {
#elif defined( ENVMAP_BLENDING_MIX )
gl_FragColor.xyz += envColor.xyz * specularStrength * reflectivity;
gl_FragColor.xyz = mix( gl_FragColor.xyz, envColor.xyz, specularStrength * reflectivity );
} else {
#elif defined( ENVMAP_BLENDING_ADD )
gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * envColor.xyz, specularStrength * reflectivity );
gl_FragColor.xyz += envColor.xyz * specularStrength * reflectivity;
}
#endif
#endif
\ No newline at end of file
#endif
......@@ -7,7 +7,6 @@
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform int combine;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
......@@ -20,4 +19,4 @@
#endif
#endif
\ No newline at end of file
#endif
......@@ -21,7 +21,6 @@ THREE.UniformsLib = {
"useRefract" : { type: "i", value: 0 },
"reflectivity" : { type: "f", value: 1.0 },
"refractionRatio" : { type: "f", value: 0.98 },
"combine" : { type: "i", value: 0 },
"morphTargetInfluences" : { type: "f", value: 0 }
......
......@@ -84,7 +84,8 @@ THREE.WebGLProgram = ( function () {
}
var envMapTypeDefine = null;
var envMapTypeDefine = "ENVMAP_TYPE_CUBE";
var envMapBlendingDefine = "ENVMAP_BLENDING_MULTIPLY";
if ( parameters.envMap ) {
......@@ -104,8 +105,20 @@ THREE.WebGLProgram = ( function () {
envMapTypeDefine = "ENVMAP_TYPE_SPHERE";
break;
default:
envMapTypeDefine = "ENVMAP_TYPE_CUBE";
}
switch ( material.combine ) {
case THREE.MultiplyOperation:
envMapBlendingDefine = "ENVMAP_BLENDING_MULTIPLY";
break;
case THREE.MixOperation:
envMapBlendingDefine = "ENVMAP_BLENDING_MIX";
break;
case THREE.AddOperation:
envMapBlendingDefine = "ENVMAP_BLENDING_ADD";
break;
}
......@@ -261,7 +274,8 @@ THREE.WebGLProgram = ( function () {
parameters.map ? "#define USE_MAP" : "",
parameters.envMap ? "#define USE_ENVMAP" : "",
envMapTypeDefine ? "#define " + envMapTypeDefine : "",
parameters.envMap ? "#define " + envMapTypeDefine : "",
parameters.envMap ? "#define " + envMapBlendingDefine : "",
parameters.lightMap ? "#define USE_LIGHTMAP" : "",
parameters.bumpMap ? "#define USE_BUMPMAP" : "",
parameters.normalMap ? "#define USE_NORMALMAP" : "",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册