浏览代码

Fill the diffusion profile in the BSDFData

/main
Evgenii Golubev 7 年前
当前提交
4762c664
共有 3 个文件被更改,包括 12 次插入12 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs.hlsl
  3. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs


// SSS
[SurfaceDataAttributes("Diffusion Profile")]
public int diffusionProfile;
public uint diffusionProfile;
[SurfaceDataAttributes("Subsurface Mask")]
public float subsurfaceMask;

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs.hlsl


float3 normalWS;
float perceptualRoughness;
float coatMask;
int diffusionProfile;
uint diffusionProfile;
float subsurfaceMask;
float thickness;
bool useThickObjectMode;

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


}
// 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);
}
}

正在加载...
取消
保存