|
@@ -46,8 +46,6 @@ THREE.NormalDisplacementShader = {
|
|
"uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) },
|
|
"uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) },
|
|
"uRepeat" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
|
|
"uRepeat" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
|
|
|
|
|
|
- "wrapRGB" : { type: "v3", value: new THREE.Vector3( 1, 1, 1 ) }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
] ),
|
|
] ),
|
|
@@ -117,12 +115,6 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
"#endif",
|
|
"#endif",
|
|
|
|
|
|
- "#ifdef WRAP_AROUND",
|
|
|
|
-
|
|
|
|
- " uniform vec3 wrapRGB;",
|
|
|
|
-
|
|
|
|
- "#endif",
|
|
|
|
-
|
|
|
|
"varying vec3 vWorldPosition;",
|
|
"varying vec3 vWorldPosition;",
|
|
"varying vec3 vViewPosition;",
|
|
"varying vec3 vViewPosition;",
|
|
|
|
|
|
@@ -132,9 +124,11 @@ THREE.NormalDisplacementShader = {
|
|
THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
|
|
THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
|
|
|
|
|
|
"void main() {",
|
|
"void main() {",
|
|
|
|
+
|
|
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
|
|
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
|
|
|
|
|
|
- " vec3 outgoingLight = vec3( 0.0 );", // outgoing light does not have an alpha, the surface does
|
|
|
|
|
|
+ " vec3 outgoingLight = vec3( 0.0 );",
|
|
|
|
+
|
|
" vec4 diffuseColor = vec4( diffuse, opacity );",
|
|
" vec4 diffuseColor = vec4( diffuse, opacity );",
|
|
|
|
|
|
" vec3 specularTex = vec3( 1.0 );",
|
|
" vec3 specularTex = vec3( 1.0 );",
|
|
@@ -162,22 +156,11 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
" if( enableAO ) {",
|
|
" if( enableAO ) {",
|
|
|
|
|
|
- " #ifdef GAMMA_INPUT",
|
|
|
|
-
|
|
|
|
- " vec4 aoColor = texture2D( tAO, vUv );",
|
|
|
|
- " aoColor.xyz *= aoColor.xyz;",
|
|
|
|
-
|
|
|
|
- " diffuseColor.rgb *= aoColor.xyz;",
|
|
|
|
-
|
|
|
|
- " #else",
|
|
|
|
-
|
|
|
|
- " diffuseColor.rgb *= texture2D( tAO, vUv ).xyz;",
|
|
|
|
-
|
|
|
|
- " #endif",
|
|
|
|
-
|
|
|
|
|
|
+ " diffuseColor.rgb *= texture2D( tAO, vUv ).xyz;", // actually, the AOmap should be modulating ambient light sources only,
|
|
|
|
+ // and should use the second set of UVs, as is done elsewhere in the library
|
|
" }",
|
|
" }",
|
|
|
|
|
|
- THREE.ShaderChunk[ "alphatest_fragment" ],
|
|
|
|
|
|
+ THREE.ShaderChunk[ "alphatest_fragment" ],
|
|
|
|
|
|
" if( enableSpecular )",
|
|
" if( enableSpecular )",
|
|
" specularTex = texture2D( tSpecular, vUv ).xyz;",
|
|
" specularTex = texture2D( tSpecular, vUv ).xyz;",
|
|
@@ -187,7 +170,7 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
" #ifdef FLIP_SIDED",
|
|
" #ifdef FLIP_SIDED",
|
|
|
|
|
|
- " finalNormal = -finalNormal;",
|
|
|
|
|
|
+ " finalNormal = - finalNormal;",
|
|
|
|
|
|
" #endif",
|
|
" #endif",
|
|
|
|
|
|
@@ -214,18 +197,7 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
// diffuse
|
|
// diffuse
|
|
|
|
|
|
- " #ifdef WRAP_AROUND",
|
|
|
|
-
|
|
|
|
- " float pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );",
|
|
|
|
- " float pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );",
|
|
|
|
-
|
|
|
|
- " vec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );",
|
|
|
|
-
|
|
|
|
- " #else",
|
|
|
|
-
|
|
|
|
- " float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
|
|
|
|
-
|
|
|
|
- " #endif",
|
|
|
|
|
|
+ " float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
|
|
|
|
|
|
" totalDiffuseLight += pointDistance * pointLightColor[ i ] * pointDiffuseWeight;",
|
|
" totalDiffuseLight += pointDistance * pointLightColor[ i ] * pointDiffuseWeight;",
|
|
|
|
|
|
@@ -267,18 +239,8 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
// diffuse
|
|
// diffuse
|
|
|
|
|
|
- " #ifdef WRAP_AROUND",
|
|
|
|
-
|
|
|
|
- " float spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );",
|
|
|
|
- " float spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );",
|
|
|
|
|
|
|
|
- " vec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );",
|
|
|
|
-
|
|
|
|
- " #else",
|
|
|
|
-
|
|
|
|
- " float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );",
|
|
|
|
-
|
|
|
|
- " #endif",
|
|
|
|
|
|
+ " float spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );",
|
|
|
|
|
|
" totalDiffuseLight += spotDistance * spotLightColor[ i ] * spotDiffuseWeight * spotEffect;",
|
|
" totalDiffuseLight += spotDistance * spotLightColor[ i ] * spotDiffuseWeight * spotEffect;",
|
|
|
|
|
|
@@ -303,25 +265,14 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
" #if MAX_DIR_LIGHTS > 0",
|
|
" #if MAX_DIR_LIGHTS > 0",
|
|
|
|
|
|
- " for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {",
|
|
|
|
|
|
+ " for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {",
|
|
|
|
|
|
" vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
|
|
" vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
|
|
" vec3 dirVector = normalize( lDirection.xyz );",
|
|
" vec3 dirVector = normalize( lDirection.xyz );",
|
|
|
|
|
|
// diffuse
|
|
// diffuse
|
|
|
|
|
|
- " #ifdef WRAP_AROUND",
|
|
|
|
-
|
|
|
|
- " float directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );",
|
|
|
|
- " float directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );",
|
|
|
|
-
|
|
|
|
- " vec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );",
|
|
|
|
-
|
|
|
|
- " #else",
|
|
|
|
-
|
|
|
|
- " float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
|
|
|
|
-
|
|
|
|
- " #endif",
|
|
|
|
|
|
+ " float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
|
|
|
|
|
|
" totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;",
|
|
" totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;",
|
|
|
|
|
|
@@ -360,26 +311,16 @@ THREE.NormalDisplacementShader = {
|
|
|
|
|
|
// specular (sky light)
|
|
// specular (sky light)
|
|
|
|
|
|
-
|
|
|
|
" 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( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );",
|
|
" float hemiSpecularWeightSky = specularTex.r * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );",
|
|
|
|
|
|
- // specular (ground light)
|
|
|
|
-
|
|
|
|
- " vec3 lVectorGround = -lVector;",
|
|
|
|
-
|
|
|
|
- " vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );",
|
|
|
|
- " float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;",
|
|
|
|
- " float hemiSpecularWeightGround = specularTex.r * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );",
|
|
|
|
-
|
|
|
|
- " 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( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 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 );",
|
|
|
|
- " totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );",
|
|
|
|
|
|
+ " totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) );",
|
|
|
|
|
|
" }",
|
|
" }",
|
|
|
|
|
|
@@ -427,7 +368,7 @@ THREE.NormalDisplacementShader = {
|
|
THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
|
|
THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
|
|
THREE.ShaderChunk[ "fog_fragment" ],
|
|
THREE.ShaderChunk[ "fog_fragment" ],
|
|
|
|
|
|
- " gl_FragColor = vec4( outgoingLight, diffuseColor.a );", // TODO, this should be pre-multiplied to allow for bright highlights on very transparent objects
|
|
|
|
|
|
+ " gl_FragColor = vec4( outgoingLight, diffuseColor.a );",
|
|
|
|
|
|
"}"
|
|
"}"
|
|
|
|
|
|
@@ -557,7 +498,7 @@ THREE.NormalDisplacementShader = {
|
|
//
|
|
//
|
|
|
|
|
|
" vWorldPosition = worldPosition.xyz;",
|
|
" vWorldPosition = worldPosition.xyz;",
|
|
- " vViewPosition = -mvPosition.xyz;",
|
|
|
|
|
|
+ " vViewPosition = - mvPosition.xyz;",
|
|
|
|
|
|
// shadows
|
|
// shadows
|
|
|
|
|