diff options
Diffstat (limited to 'hlsl/post.fx')
-rw-r--r-- | hlsl/post.fx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/hlsl/post.fx b/hlsl/post.fx index c794d0b01af..eed41168d33 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -127,13 +127,16 @@ VS_OUTPUT vs_main(VS_INPUT Input) uniform float2 ScreenScale = float2(1.0f, 1.0f); uniform float2 ScreenOffset = float2(0.0f, 0.0f); -uniform float ScanlineAlpha = 1.0f; +uniform float ScanlineAlpha = 0.0f; uniform float ScanlineScale = 1.0f; uniform float ScanlineBrightScale = 1.0f; uniform float ScanlineBrightOffset = 1.0f; uniform float ScanlineOffset = 1.0f; uniform float ScanlineHeight = 1.0f; +uniform float3 BackColor = float3(0.0f, 0.0f, 0.0f); + +uniform int ShadowType = 0; // tile mode: 0 based on screen dimension, 1 based on source dimension uniform float ShadowAlpha = 0.0f; uniform float2 ShadowCount = float2(6.0f, 6.0f); uniform float2 ShadowUV = float2(0.25f, 0.25f); @@ -161,6 +164,7 @@ float2 GetAdjustedCoords(float2 coord, float2 centerOffset) float4 ps_main(PS_INPUT Input) : COLOR { float2 ScreenTexelDims = 1.0f / ScreenDims; + float2 SourceTexelDims = 1.0f / SourceDims; float2 HalfSourceRect = PrepareVector ? float2(0.5f, 0.5f) @@ -191,7 +195,7 @@ float4 ps_main(PS_INPUT Input) : COLOR // ? shadowUV.yx // : shadowUV.xy; - float2 screenCoord = ScreenCoord; + float2 screenCoord = ShadowType == 0 ? ScreenCoord : BaseCoord; screenCoord = xor(OrientationSwapXY, RotationSwapXY) ? screenCoord.yx : screenCoord.xy; @@ -201,7 +205,7 @@ float4 ps_main(PS_INPUT Input) : COLOR ? shadowCount.yx : shadowCount.xy; - float2 shadowTile = (ScreenTexelDims * shadowCount); + float2 shadowTile = ((ShadowType == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount); shadowTile = xor(OrientationSwapXY, RotationSwapXY) ? shadowTile.yx : shadowTile.xy; @@ -213,10 +217,14 @@ float4 ps_main(PS_INPUT Input) : COLOR // ? ShadowCoord.yx // : ShadowCoord.xy; - float3 ShadowColor = tex2D(ShadowSampler, ShadowCoord).rgb; - ShadowColor = lerp(1.0f, ShadowColor, ShadowAlpha); + float4 ShadowColor = tex2D(ShadowSampler, ShadowCoord); + float3 ShadowMaskColor = lerp(1.0f, ShadowColor.rgb, ShadowAlpha); + float ShadowMaskClear = (1.0f - ShadowColor.a) * ShadowAlpha; - BaseColor.rgb *= ShadowColor; + // apply shadow mask color + BaseColor.rgb *= ShadowMaskColor; + // clear shadow mask by background color + BaseColor.rgb = lerp(BaseColor.rgb, BackColor, ShadowMaskClear); } // Color Compression (may not affect bloom) |