|
@@ -8,12 +8,26 @@ geometry.position = - vViewPosition;
|
|
geometry.normal = normal;
|
|
geometry.normal = normal;
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
|
|
|
|
-#ifdef CLEARCOAT
|
|
|
|
|
|
+#ifdef USE_CLEARCOAT
|
|
|
|
|
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef USE_IRIDESCENCE
|
|
|
|
+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
|
|
+ if ( material.iridescenceThickness == 0.0 ) {
|
|
|
|
+ material.iridescence = 0.0;
|
|
|
|
+ } else {
|
|
|
|
+ material.iridescence = saturate( material.iridescence );
|
|
|
|
+ }
|
|
|
|
+ if ( material.iridescence > 0.0 ) {
|
|
|
|
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
|
|
+ // Iridescence F0 approximation
|
|
|
|
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
IncidentLight directLight;
|
|
IncidentLight directLight;
|
|
|
|
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
@@ -45,6 +59,10 @@ IncidentLight directLight;
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
|
|
|
|
SpotLight spotLight;
|
|
SpotLight spotLight;
|
|
|
|
+ vec4 spotColor;
|
|
|
|
+ vec3 spotLightCoord;
|
|
|
|
+ bool inSpotLightMap;
|
|
|
|
+
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#endif
|
|
@@ -56,6 +74,22 @@ IncidentLight directLight;
|
|
|
|
|
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
|
|
|
|
|
|
+ // spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]
|
|
|
|
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
|
|
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
|
|
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
|
|
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
|
|
+ #else
|
|
|
|
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
|
|
+ #endif
|
|
|
|
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
|
|
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
|
|
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
|
|
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
|
|
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
|
|
+ #endif
|
|
|
|
+ #undef SPOT_LIGHT_MAP_INDEX
|
|
|
|
+
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|