Skip to content

Commit

Permalink
chore: cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlum authored Dec 5, 2024
2 parents a90e3de + 10c4327 commit 2127676
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace DynamicCubemaps
horizon *= horizon * horizon;

float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz;
specularIrradiance *= horizon;
specularIrradiance = Color::GammaToLinear(specularIrradiance);
specularIrradiance *= horizon;

return specularIrradiance;
}
Expand All @@ -47,37 +47,14 @@ namespace DynamicCubemaps
float horizon = min(1.0 + dot(R, VN), 1.0);
horizon *= horizon * horizon;

// Roughness dependent fresnel
// https://www.jcgt.org/published/0008/01/03/paper.pdf
float3 Fr = max(1.0.xxx - roughness.xxx, F0) - F0;
float3 S = Fr * pow(1.0 - NoV, 5.0);

# if defined(DEFERRED)
return horizon * ((F0 + S) * specularBRDF.x + specularBRDF.y);
return horizon * (1 + F0 * (1 / (specularBRDF.x + specularBRDF.y) - 1));
# else
float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz;
specularIrradiance = Color::GammaToLinear(specularIrradiance);

return specularIrradiance * ((F0 + S) * specularBRDF.x + specularBRDF.y);
return specularIrradiance * (1 + F0 * (1 / (specularBRDF.x + specularBRDF.y) - 1));
# endif
}

float3 GetDynamicCubemapFresnel(float2 uv, float3 N, float3 VN, float3 V, float roughness, float level, float3 diffuseColor, float distance)
{
float NoV = saturate(dot(N, V));
float2 specularBRDF = EnvBRDFApprox(roughness, NoV);
if (specularBRDF.y > 0.001) {
float3 R = reflect(-V, N);
float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz;

// Horizon specular occlusion
// https://marmosetco.tumblr.com/post/81245981087
float horizon = min(1.0 + dot(R, VN), 1.0);
specularIrradiance *= horizon * horizon;

return specularIrradiance * specularBRDF.y;
}
return 0.0;
}
#endif // !WATER
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray<float4> OutputTextu
float mipLevel = 0.0;

#if !defined(REFLECTIONS)
float k = 2;
float k = 1.5;
float brightness = k;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,23 @@ float4 SSSSBlurCS(
float scale = distanceToProjectionWindow / depthM;

// Calculate the final step to fetch the surrounding pixels:
float2 finalStep = scale * BufferDim.xy * dir;
float2 finalStep = scale * SharedData::BufferDim.xy * dir;
finalStep *= sssAmount;
finalStep *= profile.x; // Modulate it using the profile
finalStep *= 1.0 / 3.0; // Divide by 3 as the kernels range from -3 to 3.

#if defined(VR)
finalStep.x *= 0.5; // Halve horizontal screen resolution
uint eyeIndex = texcoord >= 0.5; // 0 = left 1 = right
uint bufferDimHalfX = uint(BufferDim.x * 0.5);
uint bufferDimHalfX = uint(SharedData::BufferDim.x * 0.5);
uint2 minCoord = uint2(eyeIndex ? bufferDimHalfX : 0, 0);
uint2 maxCoord = uint2(eyeIndex ? BufferDim.x : bufferDimHalfX, BufferDim.y);
uint2 maxCoord = uint2(eyeIndex ? SharedData::BufferDim.x : bufferDimHalfX, SharedData::BufferDim.y);
#else
uint2 minCoord = uint2(0, 0);
uint2 maxCoord = uint2(BufferDim.x, BufferDim.y);
uint2 maxCoord = uint2(SharedData::BufferDim.x, SharedData::BufferDim.y);
#endif

float jitter = Random::InterleavedGradientNoise(DTid.xy, FrameCount) * Math::TAU;
float jitter = Random::InterleavedGradientNoise(DTid.xy, SharedData::FrameCount) * Math::TAU;
float2x2 rotationMatrix = float2x2((jitter), sin(jitter), -sin(jitter), cos(jitter));
float2x2 identityMatrix = float2x2(1.0, 0.0, 0.0, 1.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cbuffer PerFrameSSS : register(b1)

[numthreads(8, 8, 1)] void main(uint3 DTid
: SV_DispatchThreadID) {
float2 texCoord = (DTid.xy + 0.5) * BufferDim.zw;
float2 texCoord = (DTid.xy + 0.5) * SharedData::BufferDim.zw;

#if defined(HORIZONTAL)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
namespace WaterEffects
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PARALLAX
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// https://github.com/tgjones/slimshader-cpp/blob/master/src/Shaders/Sdk/Direct3D11/DetailTessellation11/POM.hlsl
// https://github.com/alandtse/SSEShaderTools/blob/main/shaders_vr/ParallaxEffect.h

Expand Down Expand Up @@ -46,7 +42,8 @@ namespace WaterEffects
heights.x = Normals01Tex.SampleLevel(Normals01Sampler, input.TexCoord1.xy + currentOffset * normalScalesRcp.x, mipLevels.x).w;
heights.y = Normals02Tex.SampleLevel(Normals02Sampler, input.TexCoord1.zw + currentOffset * normalScalesRcp.y, mipLevels.y).w;
heights.z = Normals03Tex.SampleLevel(Normals03Sampler, input.TexCoord2.xy + currentOffset * normalScalesRcp.z, mipLevels.z).w;
return 1.0 - length(heights);
heights *= NormalsAmplitude.xyz;
return 1.0 - (heights.x + heights.y + heights.z);
}

float2 GetParallaxOffset(PS_INPUT input, float3 normalScalesRcp)
Expand Down
2 changes: 1 addition & 1 deletion src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void LightLimitFix::UpdateLights()
light.color = Saturation(light.color, settings.ParticleLightsSaturation);

light.color *= particleLight.color.alpha * settings.BillboardBrightness;
light.radius = particleLight.node->worldBound.radius * particleLight.color.alpha * settings.BillboardRadius;
light.radius = particleLight.node->worldBound.radius * particleLight.color.alpha * settings.BillboardRadius * 0.5f;

auto position = particleLight.node->world.translate;

Expand Down

0 comments on commit 2127676

Please sign in to comment.