|
@@ -507,7 +507,7 @@ THREE.ShaderLib = {
|
|
"uniform float mNear;",
|
|
"uniform float mNear;",
|
|
"uniform float mFar;",
|
|
"uniform float mFar;",
|
|
"uniform float opacity;",
|
|
"uniform float opacity;",
|
|
-
|
|
|
|
|
|
+
|
|
THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
|
|
THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
|
|
|
|
|
|
"void main() {",
|
|
"void main() {",
|
|
@@ -816,7 +816,7 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
|
|
|
|
- " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );",
|
|
|
|
|
|
+ " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( pointVector, pointHalfVector ), 0.0 ), 5.0 );",
|
|
" pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;",
|
|
" pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;",
|
|
|
|
|
|
" }",
|
|
" }",
|
|
@@ -845,7 +845,7 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" if ( spotEffect > spotLightAngleCos[ i ] ) {",
|
|
" if ( spotEffect > spotLightAngleCos[ i ] ) {",
|
|
|
|
|
|
- " spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );",
|
|
|
|
|
|
+ " spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );",
|
|
|
|
|
|
// diffuse
|
|
// diffuse
|
|
|
|
|
|
@@ -872,7 +872,7 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
|
|
|
|
- " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );",
|
|
|
|
|
|
+ " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( spotVector, spotHalfVector ), 0.0 ), 5.0 );",
|
|
" spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;",
|
|
" spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;",
|
|
|
|
|
|
" }",
|
|
" }",
|
|
@@ -918,7 +918,7 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
|
|
|
|
- " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );",
|
|
|
|
|
|
+ " vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );",
|
|
" dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;",
|
|
" dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;",
|
|
|
|
|
|
" }",
|
|
" }",
|
|
@@ -951,7 +951,7 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );",
|
|
" vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );",
|
|
" float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;",
|
|
" float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;",
|
|
- " float hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );",
|
|
|
|
|
|
+ " float hemiSpecularWeightSky = specularTex.r * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );",
|
|
|
|
|
|
// specular (ground light)
|
|
// specular (ground light)
|
|
|
|
|
|
@@ -959,14 +959,14 @@ THREE.ShaderLib = {
|
|
|
|
|
|
" vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );",
|
|
" vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );",
|
|
" float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;",
|
|
" float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;",
|
|
- " float hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );",
|
|
|
|
|
|
+ " float hemiSpecularWeightGround = specularTex.r * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );",
|
|
|
|
|
|
" float dotProductGround = dot( normal, lVectorGround );",
|
|
" float dotProductGround = dot( normal, lVectorGround );",
|
|
|
|
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
" float specularNormalization = ( shininess + 2.0 ) / 8.0;",
|
|
|
|
|
|
- " vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );",
|
|
|
|
- " vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );",
|
|
|
|
|
|
+ " vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );",
|
|
|
|
+ " vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );",
|
|
" hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );",
|
|
" hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );",
|
|
|
|
|
|
" }",
|
|
" }",
|