|
|
|
|
|
|
|
|
|
|
// SSS parameters |
|
|
|
#define SSS_N_PROFILES 8 |
|
|
|
#define SSS_UNIT_CONVERSION (1.0 / 300.0) // From meters to 1/3 centimeters |
|
|
|
#define SSS_UNIT_CONVERSION (1.0 / 300.0) // From 1/3 centimeters to meters |
|
|
|
uint _EnableSSS; // Globally toggles subsurface scattering on/off |
|
|
|
uint _TransmissionFlags; // 1 bit/profile; 0 = inf. thick, 1 = supports transmission |
|
|
|
uint _TexturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter |
|
|
|
|
|
|
[branch] if (lightData.shadowIndex >= 0 && illuminance > 0.0) |
|
|
|
{ |
|
|
|
// TODO: factor out the biased position? |
|
|
|
float3 biasedPositionWS = positionWS + bsdfData.normalWS * bsdfData.thickness; |
|
|
|
float3 biasedPositionWS = positionWS - bsdfData.normalWS * bsdfData.thickness; |
|
|
|
#ifdef SHADOWS_USE_SHADOWCTXT |
|
|
|
float shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, biasedPositionWS, lightData.shadowIndex, L, posInput.unPositionSS); |
|
|
|
#else |
|
|
|
|
|
|
[branch] if (lightData.shadowIndex >= 0 && illuminance > 0.0) |
|
|
|
{ |
|
|
|
// TODO: factor out the common biased position? |
|
|
|
float3 biasedPositionWS = positionWS + bsdfData.normalWS * bsdfData.thickness; |
|
|
|
float3 biasedPositionWS = positionWS - bsdfData.normalWS * bsdfData.thickness; |
|
|
|
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal); |
|
|
|
#ifdef SHADOWS_USE_SHADOWCTXT |
|
|
|
float shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, biasedPositionWS + offset, lightData.shadowIndex, L, posInput.unPositionSS); |
|
|
|
|
|
|
[branch] if (bsdfData.enableTransmission) |
|
|
|
{ |
|
|
|
// Reverse the normal. |
|
|
|
illuminance = saturate(dot(-bsdfData.normalWS, L)); |
|
|
|
illuminance = saturate(dot(-bsdfData.normalWS, L) * clipFactor); |
|
|
|
// TODO: these shadows do not work yet! |
|
|
|
float3 biasedPositionWS = positionWS + bsdfData.normalWS * bsdfData.thickness; |
|
|
|
float3 biasedPositionWS = positionWS - bsdfData.normalWS * bsdfData.thickness; |
|
|
|
#ifdef SHADOWS_USE_SHADOWCTXT |
|
|
|
float shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, biasedPositionWS, lightData.shadowIndex, L, posInput.unPositionSS); |
|
|
|
#else |
|
|
|