Skip to content

Commit

Permalink
style: 🎨 apply clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlum authored and github-actions[bot] committed Nov 24, 2024
1 parent 82dc4ac commit d283a23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
38 changes: 17 additions & 21 deletions package/Shaders/ISReflectionsRayTracing.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,25 @@ float4 GetReflectionColor(
{
float3 prevRaySample;
float3 raySample = projPosition;

for (int i = 0; i < iterations - 1; i++)
{
prevRaySample = raySample;

for (int i = 0; i < iterations - 1; i++) {
prevRaySample = raySample;
raySample = projPosition + (float(i) / float(iterations)) * projReflectionDirection;

if (FrameBuffer::isOutsideFrame(raySample.xy, true))
return 0.0;

float iterationDepth = DepthTex.SampleLevel(DepthSampler, ConvertRaySample(raySample.xy, eyeIndex), 0);

if (saturate((raySample.z - iterationDepth) / SSRParams.y) > 0.0)
{

if (saturate((raySample.z - iterationDepth) / SSRParams.y) > 0.0) {
float3 binaryMinRaySample = prevRaySample;
float3 binaryMaxRaySample = raySample;
float3 binaryRaySample = raySample;
uint2 binaryRaySampleDims = round(ConvertRaySample(binaryRaySample.xy, eyeIndex) * BufferDim);
uint2 prevBinaryRaySampleDims;
float depthThicknessFactor;

for (int k = i; k < iterations; k++)
{
for (int k = i; k < iterations; k++) {
prevBinaryRaySampleDims = binaryRaySampleDims;
binaryRaySample = lerp(binaryMinRaySample, binaryMaxRaySample, 0.5);
binaryRaySampleDims = round(ConvertRaySample(binaryRaySample.xy, eyeIndex) * BufferDim);
Expand All @@ -78,8 +75,8 @@ float4 GetReflectionColor(
if (all(binaryRaySampleDims == prevBinaryRaySampleDims))
break;

iterationDepth = DepthTex.SampleLevel(DepthSampler, ConvertRaySample(binaryRaySample.xy, eyeIndex), 0);
iterationDepth = DepthTex.SampleLevel(DepthSampler, ConvertRaySample(binaryRaySample.xy, eyeIndex), 0);

// Compute expected depth vs actual depth
depthThicknessFactor = 1.0 - saturate((binaryRaySample.z - iterationDepth) / SSRParams.y);

Expand All @@ -92,38 +89,37 @@ float4 GetReflectionColor(
// Early exit
if (depthThicknessFactor <= 0.0)
return 0.0;

// Cubemap skies blend better
float4 skyDepths = DepthTex.GatherRed(DepthSampler, ConvertRaySample(binaryRaySample.xy, eyeIndex), 0);
float skyFadeFactor = dot(skyDepths != 1.0, 0.25);

// Early exit
if (skyFadeFactor <= 0.0)
return 0.0;

// Fade based on ray length)
float ssrMarchingRadiusFadeFactor = 1.0 - saturate(length(binaryRaySample - projPosition) / rayLength);

float2 uvResultScreenCenterOffset = binaryRaySample.xy - 0.5;

# ifdef VR
# ifdef VR
float centerDistance = abs(uvResultScreenCenterOffset.xy * 2.0);

// Make VR fades consistent by taking the closer of the two eyes
// Based on concepts from https://cuteloong.github.io/publications/scssr24/
float2 otherEyeUvResultScreenCenterOffset = Stereo::ConvertMonoUVToOtherEye(float3(binaryRaySample.xy, iterationDepth), eyeIndex).xy - 0.5;
centerDistance = min(centerDistance, abs(otherEyeUvResultScreenCenterOffset * 2.0));
# else
# else
float2 centerDistance = abs(uvResultScreenCenterOffset.xy * 2.0);
# endif
# endif

// Fade out around screen edges
float2 centerDistanceFadeFactor = sqrt(saturate(1.0 - centerDistance));

float fadeFactor = depthThicknessFactor * skyFadeFactor * sqrt(ssrMarchingRadiusFadeFactor) * min(centerDistanceFadeFactor.x, centerDistanceFadeFactor.y);

if (fadeFactor > 0.0)
{

if (fadeFactor > 0.0) {
float3 color = ColorTex.SampleLevel(ColorSampler, ConvertRaySample(binaryRaySample.xy, eyeIndex), 0);

// Final sample to world-space
Expand Down Expand Up @@ -180,7 +176,7 @@ PS_OUTPUT main(PS_INPUT input)

float3 viewPosition = positionVS;
float3 viewDirection = normalize(viewPosition);

float3 reflectionDirection = reflect(viewDirection, viewNormal);
float viewAttenuation = saturate(dot(viewDirection, reflectionDirection));
[branch] if (viewAttenuation < 0)
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Water.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ float3 GetWaterSpecularColor(PS_INPUT input, float3 normal, float3 viewDirection
# if !defined(LOD) && NUM_SPECULAR_LIGHTS == 0
if (PixelShaderDescriptor & WaterFlags::Cubemap) {
float pointingDirection = saturate(dot(viewDirection, R));
if (SSRParams.x > 0.0 && pointingDirection > 0.0){
if (SSRParams.x > 0.0 && pointingDirection > 0.0) {
float2 ssrReflectionUv = ((DynamicResolutionParams2.xy * input.HPosition.xy) * SSRParams.zw) + SSRParams2.x * normal.xy;
float2 ssrReflectionUvDR = FrameBuffer::GetDynamicResolutionAdjustedScreenPosition(ssrReflectionUv);
float4 ssrReflectionColorBlurred = SSRReflectionTex.Sample(SSRReflectionSampler, ssrReflectionUvDR);
Expand Down

0 comments on commit d283a23

Please sign in to comment.