Skip to content

Commit

Permalink
chore: further SSS revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlum committed Sep 16, 2023
1 parent 370bbec commit edb6328
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ float RGBToLuminance(float3 color)
float InterleavedGradientNoise(float2 uv)
{
if (FrameCount == 0)
return 0.5;
return 1.0;
// Temporal factor
float frameStep = float(FrameCount % 16) * 0.0625f;
uv.x += frameStep * 4.7526;
uv.y += frameStep * 3.1914;

float3 magic = float3(0.06711056f, 0.00583715f, 52.9829189f);
return frac(magic.z * frac(dot(uv, magic.xy)));
return frac(magic.z * frac(dot(uv, magic.xy))) * 1.5;
}

#define SSSS_N_SAMPLES 25
Expand Down Expand Up @@ -222,7 +222,6 @@ float4 SSSSBlurPS(
colorM.a = sss.x;
if (colorM.a == 0)
return colorM;
colorM.a = 1;

// Fetch linear depth of current pixel:
float depthM = DepthTexture.SampleLevel(PointSampler, texcoord, 0).r;
Expand Down Expand Up @@ -265,8 +264,8 @@ float4 SSSSBlurPS(
float scale = distanceToProjectionWindow / depthM;

// Calculate the final step to fetch the surrounding pixels:
float2 finalStep = scale * dir;
finalStep *= colorM.a; // Modulate it using the alpha channel.
float2 finalStep = scale * dir / 3.0;
finalStep *= 1; // Modulate it using the alpha channel.
finalStep *= InterleavedGradientNoise(texcoord * BufferDim); // Randomise width to fix banding

// Accumulate the other samples:
Expand All @@ -291,9 +290,9 @@ float4 SSSSBlurPS(
colorBlurred.rgb += kernel[i].rgb * color.rgb;
}

// colorBlurred = lerp(colorM, colorBlurred, 1.0 - (sss.x * sss.x));
colorBlurred = lerp(colorM, colorBlurred, colorM.a);

return lerp(colorM, colorBlurred, sss.x);
return colorBlurred;
}

//-----------------------------------------------------------------------------
13 changes: 7 additions & 6 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2165,14 +2165,15 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
psout.Albedo.xyz = Lin2sRGB(psout.Albedo.xyz);
#endif

#if defined(SKIN_SHADING)

float3 albedo = baseColor.xyz * input.Color.xyz;
float ao;
Material2PBR(albedo, albedo, ao);
psout.Deferred.x = ao;
#if defined(SKIN_SHADING)
// float3 albedo = baseColor.xyz * input.Color.xyz;
// float ao;
// Material2PBR(albedo, albedo, ao);
psout.Deferred = 1;
#endif
psout.Deferred.w = 0;

psout.Deferred.w = psout.Albedo.w;

psout.Specular.xyz = 0;
#if defined(SKIN_SHADING)
Expand Down

0 comments on commit edb6328

Please sign in to comment.