Fix indentation and shader compilation for blue console
This commit is contained in:
BIN
Content/Shaders/PostProcessing.flax
(Stored with Git LFS)
BIN
Content/Shaders/PostProcessing.flax
(Stored with Git LFS)
Binary file not shown.
@@ -96,12 +96,12 @@ static const float permTexUnit = 1.0 / 256.0; // Perm texture texel-size
|
|||||||
static const float permTexUnitHalf = 0.5 / 256.0; // Half perm texture texel-size
|
static const float permTexUnitHalf = 0.5 / 256.0; // Half perm texture texel-size
|
||||||
|
|
||||||
// Input textures
|
// Input textures
|
||||||
Texture2D Input0 : register(t0);
|
Texture2D Input0 : register(t0);
|
||||||
Texture2D Input1 : register(t1);
|
Texture2D Input1 : register(t1);
|
||||||
Texture2D Input2 : register(t2);
|
Texture2D Input2 : register(t2);
|
||||||
Texture2D Input3 : register(t3);
|
Texture2D Input3 : register(t3);
|
||||||
Texture2D LensDirt : register(t4);
|
Texture2D LensDirt : register(t4);
|
||||||
Texture2D LensStar : register(t5);
|
Texture2D LensStar : register(t5);
|
||||||
Texture2D LensColor : register(t6);
|
Texture2D LensColor : register(t6);
|
||||||
#if USE_VOLUME_LUT
|
#if USE_VOLUME_LUT
|
||||||
Texture3D ColorGradingLUT : register(t7);
|
Texture3D ColorGradingLUT : register(t7);
|
||||||
@@ -261,63 +261,63 @@ float2 coordRot(in float2 tc, in float angle)
|
|||||||
META_PS(true, FEATURE_LEVEL_ES2)
|
META_PS(true, FEATURE_LEVEL_ES2)
|
||||||
float4 PS_BloomBrightPass(Quad_VS2PS input) : SV_Target
|
float4 PS_BloomBrightPass(Quad_VS2PS input) : SV_Target
|
||||||
{
|
{
|
||||||
// Get dimensions for precise texel calculations
|
// Get dimensions for precise texel calculations
|
||||||
uint width, height;
|
uint width, height;
|
||||||
Input0.GetDimensions(width, height);
|
Input0.GetDimensions(width, height);
|
||||||
float2 texelSize = 1.0 / float2(width, height);
|
float2 texelSize = 1.0 / float2(width, height);
|
||||||
// Use fixed 13-tap sample pattern for initial bright pass
|
// Use fixed 13-tap sample pattern for initial bright pass
|
||||||
float3 color = 0;
|
float3 color = 0;
|
||||||
float totalWeight = 0;
|
float totalWeight = 0;
|
||||||
|
|
||||||
// Center sample with high weight for energy preservation
|
|
||||||
float3 center = Input0.Sample(SamplerLinearClamp, input.TexCoord).rgb;
|
|
||||||
|
|
||||||
// Apply Karis average to prevent bright pixels from dominating
|
|
||||||
float centerLuma = max(dot(center, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
|
||||||
center = center / (1.0 + centerLuma);
|
|
||||||
|
|
||||||
float centerWeight = 4.0;
|
// Center sample with high weight for energy preservation
|
||||||
color += center * centerWeight;
|
float3 center = Input0.Sample(SamplerLinearClamp, input.TexCoord).rgb;
|
||||||
totalWeight += centerWeight;
|
|
||||||
|
|
||||||
// Inner ring - fixed offset at 1.0 texel distance
|
// Apply Karis average to prevent bright pixels from dominating
|
||||||
UNROLL
|
float centerLuma = max(dot(center, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
||||||
for (int i = 0; i < 4; i++)
|
center = center / (1.0 + centerLuma);
|
||||||
{
|
|
||||||
float angle = i * (PI / 2.0);
|
|
||||||
float2 offset = float2(cos(angle), sin(angle)) * texelSize;
|
|
||||||
float3 sample = Input0.Sample(SamplerLinearClamp, input.TexCoord + offset).rgb;
|
|
||||||
|
|
||||||
// Apply Karis average
|
|
||||||
float sampleLuma = max(dot(sample, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
|
||||||
sample = sample / (1.0 + sampleLuma);
|
|
||||||
|
|
||||||
float weight = 2.0;
|
float centerWeight = 4.0;
|
||||||
color += sample * weight;
|
color += center * centerWeight;
|
||||||
totalWeight += weight;
|
totalWeight += centerWeight;
|
||||||
}
|
|
||||||
|
|
||||||
// Outer ring - fixed offset at 1.4142 texel distance (diagonal)
|
// Inner ring - fixed offset at 1.0 texel distance
|
||||||
UNROLL
|
UNROLL
|
||||||
for (int j = 0; j < 8; j++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
float angle = j * (PI / 4.0);
|
float angle = i * (PI / 2.0);
|
||||||
float2 offset = float2(cos(angle), sin(angle)) * texelSize * 1.4142;
|
float2 offset = float2(cos(angle), sin(angle)) * texelSize;
|
||||||
float3 sample = Input0.Sample(SamplerLinearClamp, input.TexCoord + offset).rgb;
|
float3 sampleColor = Input0.Sample(SamplerLinearClamp, input.TexCoord).rgb;
|
||||||
|
|
||||||
// Apply Karis average
|
// Apply Karis average
|
||||||
float sampleLuma = max(dot(sample, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
float sampleLuma = max(dot(sampleColor, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
||||||
sample = sample / (1.0 + sampleLuma);
|
sampleColor = sampleColor / (1.0 + sampleLuma);
|
||||||
|
|
||||||
float weight = 1.0;
|
float weight = 2.0;
|
||||||
color += sample * weight;
|
color += sampleColor * weight;
|
||||||
totalWeight += weight;
|
totalWeight += weight;
|
||||||
}
|
}
|
||||||
color /= totalWeight;
|
|
||||||
|
// Outer ring - fixed offset at 1.4142 texel distance (diagonal)
|
||||||
// Un-apply Karis average to maintain energy
|
UNROLL
|
||||||
float finalLuma = max(dot(color, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
for (int j = 0; j < 8; j++)
|
||||||
color = color * (1.0 + finalLuma);
|
{
|
||||||
|
float angle = j * (PI / 4.0);
|
||||||
|
float2 offset = float2(cos(angle), sin(angle)) * texelSize * 1.4142;
|
||||||
|
float3 sampleColor = Input0.Sample(SamplerLinearClamp, input.TexCoord + offset).rgb;
|
||||||
|
|
||||||
|
// Apply Karis average
|
||||||
|
float sampleLuma = max(dot(sampleColor, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
||||||
|
sampleColor = sampleColor / (1.0 + sampleLuma);
|
||||||
|
|
||||||
|
float weight = 1.0;
|
||||||
|
color += sampleColor * weight;
|
||||||
|
totalWeight += weight;
|
||||||
|
}
|
||||||
|
color /= totalWeight;
|
||||||
|
|
||||||
|
// Un-apply Karis average to maintain energy
|
||||||
|
float finalLuma = max(dot(color, float3(0.2126, 0.7152, 0.0722)), 0.0001);
|
||||||
|
color = color * (1.0 + finalLuma);
|
||||||
|
|
||||||
// Apply threshold with quadratic rolloff for smoother transition
|
// Apply threshold with quadratic rolloff for smoother transition
|
||||||
float luminance = dot(color, float3(0.2126, 0.7152, 0.0722));
|
float luminance = dot(color, float3(0.2126, 0.7152, 0.0722));
|
||||||
@@ -325,30 +325,30 @@ float4 PS_BloomBrightPass(Quad_VS2PS input) : SV_Target
|
|||||||
float knee = threshold * BloomThresholdKnee;
|
float knee = threshold * BloomThresholdKnee;
|
||||||
float softMax = threshold + knee;
|
float softMax = threshold + knee;
|
||||||
|
|
||||||
float contribution = 0;
|
float contribution = 0;
|
||||||
if (luminance > threshold)
|
if (luminance > threshold)
|
||||||
{
|
{
|
||||||
if (luminance < softMax)
|
if (luminance < softMax)
|
||||||
{
|
{
|
||||||
// Quadratic softening between threshold and (threshold + knee)
|
// Quadratic softening between threshold and (threshold + knee)
|
||||||
float x = (luminance - threshold) / knee;
|
float x = (luminance - threshold) / knee;
|
||||||
contribution = x * x * 0.5;
|
contribution = x * x * 0.5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Full contribution above softMax
|
// Full contribution above softMax
|
||||||
contribution = luminance - threshold;
|
contribution = luminance - threshold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float testc = BloomClamp;
|
float testc = BloomClamp;
|
||||||
float3 clamped = (color * contribution);
|
float3 clamped = (color * contribution);
|
||||||
clamped.r = min(clamped.r, testc);
|
clamped.r = min(clamped.r, testc);
|
||||||
clamped.g = min(clamped.g, testc);
|
clamped.g = min(clamped.g, testc);
|
||||||
clamped.b = min(clamped.b, testc);
|
clamped.b = min(clamped.b, testc);
|
||||||
|
|
||||||
// Store threshold result in alpha for downsample chain
|
// Store threshold result in alpha for downsample chain
|
||||||
return float4(clamped, luminance);
|
return float4(clamped, luminance);
|
||||||
}
|
}
|
||||||
|
|
||||||
META_PS(true, FEATURE_LEVEL_ES2)
|
META_PS(true, FEATURE_LEVEL_ES2)
|
||||||
@@ -394,8 +394,8 @@ float4 PS_BloomDownsample(Quad_VS2PS input) : SV_Target
|
|||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
float2 offset = offsets[i] * texelSize * 2.0; // Fixed scale factor for stability
|
float2 offset = offsets[i] * texelSize * 2.0; // Fixed scale factor for stability
|
||||||
float4 sample = Input0.Sample(SamplerLinearClamp, input.TexCoord + offset);
|
float4 sampleColor = Input0.Sample(SamplerLinearClamp, input.TexCoord + offset);
|
||||||
color += sample.rgb * weights[i];
|
color += sampleColor.rgb * weights[i];
|
||||||
totalWeight += weights[i];
|
totalWeight += weights[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,9 +433,9 @@ float4 PS_BloomDualFilterUpsample(Quad_VS2PS input) : SV_Target
|
|||||||
UNROLL
|
UNROLL
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
float4 sample = Input0.Sample(SamplerLinearClamp, input.TexCoord + crossOffsets[i] * texelSize);
|
float4 sampleColor = Input0.Sample(SamplerLinearClamp, input.TexCoord + crossOffsets[i] * texelSize);
|
||||||
float weight = 2.0;
|
float weight = 2.0;
|
||||||
color += sample.rgb * weight;
|
color += sampleColor.rgb * weight;
|
||||||
totalWeight += weight;
|
totalWeight += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,9 +451,9 @@ float4 PS_BloomDualFilterUpsample(Quad_VS2PS input) : SV_Target
|
|||||||
UNROLL
|
UNROLL
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
float4 sample = Input0.Sample(SamplerLinearClamp, input.TexCoord + cornerOffsets[j] * texelSize);
|
float4 sampleColor = Input0.Sample(SamplerLinearClamp, input.TexCoord + cornerOffsets[j] * texelSize);
|
||||||
float weight = 1.0;
|
float weight = 1.0;
|
||||||
color += sample.rgb * weight;
|
color += sampleColor.rgb * weight;
|
||||||
totalWeight += weight;
|
totalWeight += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user