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

Added normal_flip.glsl

上级 fbf9be7a
......@@ -23,11 +23,7 @@
#endif
#ifdef DOUBLE_SIDED
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#else
float flipNormal = 1.0;
#endif
#include <normal_flip>
#ifdef ENVMAP_TYPE_CUBE
......@@ -42,7 +38,7 @@
#elif defined( ENVMAP_TYPE_SPHERE )
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
vec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );
vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
#endif
......
......@@ -165,15 +165,7 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {
#ifdef DOUBLE_SIDED
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#else
float flipNormal = 1.0;
#endif
#include <normal_flip>
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
......@@ -238,15 +230,7 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
#endif
#ifdef DOUBLE_SIDED
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#else
float flipNormal = 1.0;
#endif
#include <normal_flip>
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
......@@ -293,7 +277,7 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
#elif defined( ENVMAP_TYPE_SPHERE )
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
vec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );
#ifdef TEXTURE_LOD_EXT
......
#ifdef DOUBLE_SIDED
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#else
float flipNormal = 1.0;
#endif
......@@ -8,13 +8,9 @@
#else
vec3 normal = normalize( vNormal );
#include <normal_flip>
#ifdef DOUBLE_SIDED
normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
#endif
vec3 normal = normalize( vNormal ) * flipNormal;
#endif
......
......@@ -180,6 +180,7 @@
"src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl",
"src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl",
"src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl",
"src/renderers/shaders/ShaderChunk/normal_flip.glsl",
"src/renderers/shaders/ShaderChunk/normal_fragment.glsl",
"src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl",
"src/renderers/shaders/ShaderChunk/packing.glsl",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册