|
@@ -658,12 +658,34 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
|
|
|
|
|
// LTC Fresnel Approximation by Stephen Hill
|
|
// LTC Fresnel Approximation by Stephen Hill
|
|
|
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
|
|
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
|
|
|
- const fresnel = specularColorBlended.mul( t2.x ).add( specularColorBlended.oneMinus().mul( t2.y ) ).toVar();
|
|
|
|
|
|
|
+ const fresnel = specularColorBlended.mul( t2.x ).add( specularF90.sub( specularColorBlended ).mul( t2.y ) ).toVar();
|
|
|
|
|
|
|
|
reflectedLight.directSpecular.addAssign( lightColor.mul( fresnel ).mul( LTC_Evaluate( { N, V, P, mInv, p0, p1, p2, p3 } ) ) );
|
|
reflectedLight.directSpecular.addAssign( lightColor.mul( fresnel ).mul( LTC_Evaluate( { N, V, P, mInv, p0, p1, p2, p3 } ) ) );
|
|
|
|
|
|
|
|
reflectedLight.directDiffuse.addAssign( lightColor.mul( diffuseContribution ).mul( LTC_Evaluate( { N, V, P, mInv: mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), p0, p1, p2, p3 } ) ) );
|
|
reflectedLight.directDiffuse.addAssign( lightColor.mul( diffuseContribution ).mul( LTC_Evaluate( { N, V, P, mInv: mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), p0, p1, p2, p3 } ) ) );
|
|
|
|
|
|
|
|
|
|
+ if ( this.clearcoat === true ) {
|
|
|
|
|
+
|
|
|
|
|
+ const Ncc = clearcoatNormalView;
|
|
|
|
|
+
|
|
|
|
|
+ const uvClearcoat = LTC_Uv( { N: Ncc, V, roughness: clearcoatRoughness } );
|
|
|
|
|
+
|
|
|
|
|
+ const t1Clearcoat = ltc_1.sample( uvClearcoat );
|
|
|
|
|
+ const t2Clearcoat = ltc_2.sample( uvClearcoat );
|
|
|
|
|
+
|
|
|
|
|
+ const mInvClearcoat = mat3(
|
|
|
|
|
+ vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
|
|
|
|
|
+ vec3( 0, 1, 0 ),
|
|
|
|
|
+ vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // LTC Fresnel Approximation for clearcoat
|
|
|
|
|
+ const fresnelClearcoat = clearcoatF0.mul( t2Clearcoat.x ).add( clearcoatF90.sub( clearcoatF0 ).mul( t2Clearcoat.y ) );
|
|
|
|
|
+
|
|
|
|
|
+ this.clearcoatSpecularDirect.addAssign( lightColor.mul( fresnelClearcoat ).mul( LTC_Evaluate( { N: Ncc, V, P, mInv: mInvClearcoat, p0, p1, p2, p3 } ) ) );
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|