|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Assume that bsdfData.diffusionProfile is init |
|
|
|
void FillMaterialSSS(float subsurfaceMask, inout BSDFData bsdfData) |
|
|
|
void FillMaterialSSS(uint diffusionProfile, float subsurfaceMask, inout BSDFData bsdfData) |
|
|
|
bsdfData.fresnel0 = _TransmissionTintsAndFresnel0[bsdfData.diffusionProfile].a; |
|
|
|
bsdfData.diffusionProfile = diffusionProfile; |
|
|
|
bsdfData.fresnel0 = _TransmissionTintsAndFresnel0[diffusionProfile].a; |
|
|
|
void FillMaterialTransmission(float thickness, inout BSDFData bsdfData) |
|
|
|
void FillMaterialTransmission(uint diffusionProfile, float thickness, inout BSDFData bsdfData) |
|
|
|
int diffusionProfile = bsdfData.diffusionProfile; |
|
|
|
bsdfData.diffusionProfile = diffusionProfile; |
|
|
|
|
|
|
|
bsdfData.thickness = _ThicknessRemaps[diffusionProfile].x + _ThicknessRemaps[diffusionProfile].y * thickness; |
|
|
|
uint transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u * diffusionProfile, 2u); |
|
|
|
|
|
|
bsdfData.diffuseColor = ComputeDiffuseColor(surfaceData.baseColor, metallic); |
|
|
|
bsdfData.fresnel0 = HasFeatureFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR) ? surfaceData.specularColor : ComputeFresnel0(surfaceData.baseColor, surfaceData.metallic, DEFAULT_SPECULAR_VALUE); |
|
|
|
|
|
|
|
// Always assign even if not used, DIFFUSION_PROFILE_NEUTRAL_ID is 0 |
|
|
|
bsdfData.diffusionProfile = surfaceData.diffusionProfile; |
|
|
|
// Note: DIFFUSION_PROFILE_NEUTRAL_ID is 0 |
|
|
|
|
|
|
|
// In forward everything is statically know and we could theorically cumulate all the material features. So the code reflect it. |
|
|
|
// However in practice we keep parity between deferred and forward, so we should contrain the various features. |
|
|
|
|
|
|
{ |
|
|
|
// Modify fresnel0 |
|
|
|
FillMaterialSSS(surfaceData.subsurfaceMask, bsdfData); |
|
|
|
FillMaterialSSS(surfaceData.diffusionProfile, surfaceData.subsurfaceMask, bsdfData); |
|
|
|
FillMaterialTransmission(surfaceData.thickness, bsdfData); |
|
|
|
FillMaterialTransmission(surfaceData.diffusionProfile, surfaceData.thickness, bsdfData); |
|
|
|
} |
|
|
|
|
|
|
|
if (HasFeatureFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_LIT_ANISOTROPY)) |
|
|
|
|
|
|
if (HasFeatureFlag(pixelFeatureFlags, MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING)) |
|
|
|
{ |
|
|
|
// Overwrite fresnel0 |
|
|
|
FillMaterialSSS(sssData.subsurfaceMask, bsdfData); |
|
|
|
FillMaterialSSS(sssData.diffusionProfile, sssData.subsurfaceMask, bsdfData); |
|
|
|
FillMaterialTransmission(inGBuffer2.g, bsdfData); |
|
|
|
FillMaterialTransmission(sssData.diffusionProfile, inGBuffer2.g, bsdfData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|