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
12 changes: 12 additions & 0 deletions package/Shaders/Common/PBR.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ namespace PBR
static const uint LandTile5HasGlint = (1 << 17);
}

namespace Constants
{
static const float MinRoughness = 0.04f;
static const float MaxRoughness = 1.0f;
static const float MinGlintDensity = 1.0f;
static const float MaxGlintDensity = 40.0f;
static const float MinGlintRoughness = 0.005f;
static const float MaxGlintRoughness = 0.3f;
static const float MinGlintDensityRandomization = 0.0f;
static const float MaxGlintDensityRandomization = 5.0f;
}

#if defined(GLINT)
# include "Common/Glints/Glints2023.hlsli"
#else
Expand Down
8 changes: 4 additions & 4 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2105,15 +2105,15 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)

pbrSurfaceProperties.Noise = screenNoise;

pbrSurfaceProperties.Roughness = clamp(rawRMAOS.x, 0.04, 1.0);
pbrSurfaceProperties.Roughness = clamp(rawRMAOS.x, PBR::Constants::MinRoughness, PBR::Constants::MaxRoughness);
pbrSurfaceProperties.Metallic = saturate(rawRMAOS.y);
pbrSurfaceProperties.AO = rawRMAOS.z;
pbrSurfaceProperties.F0 = lerp(saturate(rawRMAOS.w), Color::GammaToLinear(baseColor.xyz), pbrSurfaceProperties.Metallic);

pbrSurfaceProperties.GlintScreenSpaceScale = max(1, glintParameters.x);
pbrSurfaceProperties.GlintLogMicrofacetDensity = clamp(40.f - glintParameters.y, 1, 40);
pbrSurfaceProperties.GlintMicrofacetRoughness = clamp(glintParameters.z, 0.005, 0.3);
pbrSurfaceProperties.GlintDensityRandomization = clamp(glintParameters.w, 0, 5);
pbrSurfaceProperties.GlintLogMicrofacetDensity = clamp(PBR::Constants::MaxGlintDensity - glintParameters.y, PBR::Constants::MinGlintDensity, PBR::Constants::MaxGlintDensity);
pbrSurfaceProperties.GlintMicrofacetRoughness = clamp(glintParameters.z, PBR::Constants::MinGlintRoughness, PBR::Constants::MaxGlintRoughness);
pbrSurfaceProperties.GlintDensityRandomization = clamp(glintParameters.w, PBR::Constants::MinGlintDensityRandomization, PBR::Constants::MaxGlintDensityRandomization);

# if defined(GLINT)
float glintNoise = Random::R1Modified(float(SharedData::FrameCount), (Random::pcg2d(uint2(input.Position.xy)) / 4294967296.0).x);
Expand Down