|
|
|
|
|
|
uint _TransmissionFlags; // 2 bit/profile; 0 = inf. thick, 1 = thin, 2 = regular |
|
|
|
float _ThicknessRemaps[SSS_N_PROFILES][2]; // Remap: 0 = start, 1 = end - start |
|
|
|
float4 _ShapeParameters[SSS_N_PROFILES]; // RGB = S = 1 / D; A = filter radius |
|
|
|
float4 _SurfaceAlbedos[SSS_N_PROFILES]; // RGB = color, A = unused |
|
|
|
|
|
|
|
//----------------------------------------------------------------------------- |
|
|
|
// Helper functions/variable specific to this material |
|
|
|
|
|
|
// Computes the fraction of light passing through the object. |
|
|
|
// N.b.: it is not just zero scattering (light traveling in a straight path)! |
|
|
|
// Ref: Approximate Reflectance Profiles for Efficient Subsurface Scattering by Pixar (BSSRDF only). |
|
|
|
float3 ComputeTransmittance(float3 S, float thickness, float radiusScale) |
|
|
|
float3 ComputeTransmittance(float3 S, float3 surfaceAlbedo, float thickness, float radiusScale) |
|
|
|
{ |
|
|
|
// Thickness and SSS radius are decoupled for artists. |
|
|
|
// In theory, we should modify the thickness by the inverse of the radius scale of the profile. |
|
|
|
|
|
|
|
|
|
|
return 0.5 * (expOneThird + expOneThird * expOneThird * expOneThird); |
|
|
|
return 0.5 * (expOneThird + expOneThird * expOneThird * expOneThird) * surfaceAlbedo; |
|
|
|
} |
|
|
|
|
|
|
|
void FillMaterialIdStandardData(float3 baseColor, float specular, float metallic, float roughness, float3 normalWS, float3 tangentWS, float anisotropy, inout BSDFData bsdfData) |
|
|
|
|
|
|
|
|
|
|
if (bsdfData.enableTransmission) |
|
|
|
{ |
|
|
|
bsdfData.transmittance = ComputeTransmittance(_ShapeParameters[subsurfaceProfile].rgb, bsdfData.thickness, bsdfData.subsurfaceRadius); |
|
|
|
bsdfData.transmittance = ComputeTransmittance(_ShapeParameters[subsurfaceProfile].rgb, |
|
|
|
_SurfaceAlbedos[subsurfaceProfile].rgb, |
|
|
|
bsdfData.thickness, bsdfData.subsurfaceRadius); |
|
|
|
} |
|
|
|
|
|
|
|
bool performPostScatterTexturing = IsBitSet(_TexturingModeFlags, subsurfaceProfile); |
|
|
|