|
|
|
|
|
|
// in the auto-thickness mode (but is always be used for indirect lighting). |
|
|
|
#if SHADEROPTIONS_USE_DISNEY_SSS |
|
|
|
bsdfData.transmittance = ComputeTransmittanceDisney(_ShapeParams[diffusionProfile].rgb, |
|
|
|
_TransmissionTintsAndFresnel0[diffusionProfile].rgb, |
|
|
|
bsdfData.thickness); |
|
|
|
_TransmissionTintsAndFresnel0[diffusionProfile].rgb, |
|
|
|
bsdfData.thickness); |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][0].a, |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][1].rgb, |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][1].a, |
|
|
|
_TransmissionTintsAndFresnel0[diffusionProfile].rgb, |
|
|
|
bsdfData.thickness); |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][0].a, |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][1].rgb, |
|
|
|
_HalfRcpVariancesAndWeights[diffusionProfile][1].a, |
|
|
|
_TransmissionTintsAndFresnel0[diffusionProfile].rgb, |
|
|
|
bsdfData.thickness); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
float3 iblR; // Dominant specular direction, used for IBL in EvaluateBSDF_Env() |
|
|
|
float iblPerceptualRoughness; |
|
|
|
|
|
|
|
float3 specularFGD; // Store preconvoled BRDF for both specular and diffuse |
|
|
|
float diffuseFGD; |
|
|
|
float3 specularFGD; // Store preconvoled BRDF for both specular and diffuse |
|
|
|
float diffuseFGD; |
|
|
|
float3x3 orthoBasisViewNormal; // Right-handed view-dependent orthogonal basis around the normal (6x VGPRs) |
|
|
|
float3x3 ltcTransformDiffuse; // Inverse transformation for Lambertian or Disney Diffuse (4x VGPRs) |
|
|
|
float3x3 ltcTransformSpecular; // Inverse transformation for GGX (4x VGPRs) |
|
|
|
float3x3 orthoBasisViewNormal; // Right-handed view-dependent orthogonal basis around the normal (6x VGPRs) |
|
|
|
float3x3 ltcTransformDiffuse; // Inverse transformation for Lambertian or Disney Diffuse (4x VGPRs) |
|
|
|
float3x3 ltcTransformSpecular; // Inverse transformation for GGX (4x VGPRs) |
|
|
|
float ltcMagnitudeDiffuse; |
|
|
|
float3 ltcMagnitudeFresnel; |
|
|
|
|
|
|
|
|
|
|
float coatIblF; // Fresnel term for view vector |
|
|
|
float3x3 ltcTransformCoat; // Inverse transformation for GGX (4x VGPRs) |
|
|
|
float coatIblF; // Fresnel term for view vector |
|
|
|
float3x3 ltcTransformCoat; // Inverse transformation for GGX (4x VGPRs) |
|
|
|
float3 transparentRefractV; // refracted view vector after exiting the shape |
|
|
|
float3 transparentPositionWS; // start of the refracted ray after exiting the shape |
|
|
|
float3 transparentTransmittance; // transmittance due to absorption |
|
|
|
float transparentSSMipLevel; // mip level of the screen space gaussian pyramid for rough refraction |
|
|
|
float3 transparentRefractV; // refracted view vector after exiting the shape |
|
|
|
float3 transparentPositionWS; // start of the refracted ray after exiting the shape |
|
|
|
float3 transparentTransmittance; // transmittance due to absorption |
|
|
|
float transparentSSMipLevel; // mip level of the screen space gaussian pyramid for rough refraction |
|
|
|
}; |
|
|
|
|
|
|
|
PreLightData GetPreLightData(float3 V, PositionInputs posInput, inout BSDFData bsdfData) |
|
|
|
|
|
|
float3 N = bsdfData.normalWS; |
|
|
|
|
|
|
|
// Optimized math. Ref: PBR Diffuse Lighting for GGX + Smith Microsurfaces (slide 114). |
|
|
|
float LdotV = dot(L, V); |
|
|
|
float LdotV = dot(L, V); |
|
|
|
float LdotH = saturate(invLenLV * LdotV + invLenLV); |
|
|
|
float LdotH = saturate(invLenLV * LdotV + invLenLV); |
|
|
|
float NdotV = ClampNdotV(preLightData.NdotV); |
|
|
|
|
|
|
|
float3 F = F_Schlick(bsdfData.fresnel0, LdotH); |
|
|
|
|
|
|
float3 transmittance = bsdfData.transmittance; |
|
|
|
|
|
|
|
if (mixedThicknessMode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Recompute transmittance using the thickness value computed from the shadow map. |
|
|
|
|
|
|
|
// Compute the distance from the light to the back face of the object along the light direction. |
|
|
|
|
|
|
case GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION: |
|
|
|
{ |
|
|
|
#if HAS_REFRACTION |
|
|
|
// Refraction process: |
|
|
|
// 1. Depending on the shape model, we calculate the refracted point in world space and the optical depth |
|
|
|
// 2. We calculate the screen space position of the refracted point |
|
|
|
// 3. If this point is available (ie: in color buffer and point is not in front of the object) |
|
|
|
// a. Get the corresponding color depending on the roughness from the gaussian pyramid of the color buffer |
|
|
|
// b. Multiply by the transmittance for absorption (depends on the optical depth) |
|
|
|
|
|
|
|
|
|
|
|
// Refraction process: |
|
|
|
// 1. Depending on the shape model, we calculate the refracted point in world space and the optical depth |
|
|
|
|
|
|
lighting.specularTransmitted = hit.linearDepth; |
|
|
|
|
|
|
|
#else |
|
|
|
// No refraction, no need to go further |
|
|
|
hierarchyWeight = 1.0; |
|
|
|
// No refraction, no need to go further |
|
|
|
hierarchyWeight = 1.0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return lighting; |
|
|
|