Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package/Shaders/Common/PBR.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,20 @@ namespace PBR
}

[branch] if ((PBRFlags & Flags::Subsurface) != 0)
# if !defined(TREE_ANIM)
{
const float subsurfacePower = 12.234;
float forwardScatter = exp2(saturate(-VdotL) * subsurfacePower - subsurfacePower);
float backScatter = saturate(satNdotL * material.Thickness + (1.0 - material.Thickness)) * 0.5;
float subsurface = lerp(backScatter, 1, forwardScatter) * (1.0 - material.Thickness);
lightingOutput.transmission += material.SubsurfaceColor * subsurface * softLightColor * BRDF::Diffuse_Lambert() * kD;
}
# else
{
float subsurfaceFoliage = saturate(-NdotL) * (1.0 - material.Thickness);
lightingOutput.transmission += material.SubsurfaceColor * subsurfaceFoliage * detailedLightColor * BRDF::Diffuse_Lambert() * kD;
}
# endif
else if ((PBRFlags & Flags::TwoLayer) != 0)
{
float coatNdotL = satNdotL;
Expand Down
7 changes: 6 additions & 1 deletion package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,11 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
float3x3 tbnTr = ReconstructTBN(input.WorldPosition.xyz, worldNormal, screenUV);
# else
float3 worldNormal = normalize(mul(tbn, normal.xyz));
# if defined(TREE_ANIM)
float3 viewNormal = normalize(FrameBuffer::WorldToView(worldNormal, false, eyeIndex));
viewNormal = float3(viewNormal.xy, -abs(viewNormal.z));
worldNormal = normalize(FrameBuffer::ViewToWorld(viewNormal, false, eyeIndex));
# endif

# if defined(SPARKLE)
float3 projectedNormal = normalize(mul(tbn, float3(ProjectedUVParams2.xx * normal.xy, normal.z)));
Expand Down Expand Up @@ -2512,7 +2517,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
}

# if defined(SCREEN_SPACE_SHADOWS) && defined(DEFERRED)
if (!SharedData::InInterior)
if (!SharedData::InInterior && dirLightAngle >= 0.0)
dirDetailedShadow *= ScreenSpaceShadows::GetScreenSpaceShadow(input.Position.xyz, screenUV, screenNoise, eyeIndex);
# endif

Expand Down
Loading