diff options
author | 2015-12-26 12:27:07 +0100 | |
---|---|---|
committer | 2015-12-26 12:27:07 +0100 | |
commit | ff77b7897bcf0a967f7e275b289a1f8fd18ecd7e (patch) | |
tree | aeb9666f35abd4c843a8011af426b6dd4c8243b9 /hlsl | |
parent | 1b373eb812d11dfeb0fead627f7df4e827e27f8f (diff) |
Cleanup (nw)
- renamed shadow_mask_type to shadow_mask_tile_mode
- renamed bloom_type to bloom_blend_mode
- implemented "Source" shadow mask tile mode for artwork_support/post.fx
Diffstat (limited to 'hlsl')
-rw-r--r-- | hlsl/artwork_support/post.fx | 28 | ||||
-rw-r--r-- | hlsl/bloom.fx | 4 | ||||
-rw-r--r-- | hlsl/deconverge.fx | 8 | ||||
-rw-r--r-- | hlsl/distortion.fx | 6 | ||||
-rw-r--r-- | hlsl/post.fx | 6 |
5 files changed, 28 insertions, 24 deletions
diff --git a/hlsl/artwork_support/post.fx b/hlsl/artwork_support/post.fx index 4e11cc9f2d7..e7618bafd0e 100644 --- a/hlsl/artwork_support/post.fx +++ b/hlsl/artwork_support/post.fx @@ -162,12 +162,15 @@ 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 float CurvatureAmount = 1.0f; uniform float RoundCornerAmount = 0.0f; uniform float SmoothBorderAmount = 0.0f; uniform float VignettingAmount = 0.0f; uniform float ReflectionAmount = 0.0f; +uniform int ShadowTileMode = 0; // 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); @@ -248,7 +251,7 @@ float GetSpotAddend(float2 coord, float amount) float SpotRadius = amount * 0.75f; float Spot = smoothstep(SpotRadius, SpotRadius - SpotBlur, length(SpotCoord)); - float SigmoidSpot = normalizedSigmoid(Spot, 0.75) * amount; + float SigmoidSpot = amount * normalizedSigmoid(Spot, 0.75); // increase strength by 100% SigmoidSpot = SigmoidSpot * 2.0f; @@ -292,8 +295,6 @@ float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount) // www.francois-tarlier.com/blog/cubic-lens-distortion-shader/ float2 GetDistortedCoords(float2 centerCoord, float amount) { - amount *= 0.25f; // reduced amount - // lens distortion coefficient float k = amount; @@ -368,19 +369,20 @@ float2 GetAdjustedCoords(float2 coord, float2 centerOffset, float distortionAmou 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) : SourceRect * 0.5f; float2 ScreenCoord = Input.ScreenCoord / ScreenDims; - ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount); + ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount * 0.25f); // reduced amount float2 DistortionCoord = Input.TexCoord; - DistortionCoord = GetCoords(DistortionCoord, HalfSourceRect, CurvatureAmount); + DistortionCoord = GetCoords(DistortionCoord, HalfSourceRect, CurvatureAmount * 0.25f); // reduced amount float2 BaseCoord = Input.TexCoord; - BaseCoord = GetAdjustedCoords(BaseCoord, HalfSourceRect, CurvatureAmount); + BaseCoord = GetAdjustedCoords(BaseCoord, HalfSourceRect, CurvatureAmount * 0.25f); // reduced amount float2 DistortionCoordCentered = DistortionCoord; DistortionCoordCentered -= HalfSourceRect; @@ -409,7 +411,7 @@ float4 ps_main(PS_INPUT Input) : COLOR // ? shadowUV.yx // : shadowUV.xy; - float2 screenCoord = ScreenCoord; + float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord; screenCoord = xor(OrientationSwapXY, RotationSwapXY) ? screenCoord.yx : screenCoord.xy; @@ -419,7 +421,7 @@ float4 ps_main(PS_INPUT Input) : COLOR ? shadowCount.yx : shadowCount.xy; - float2 shadowTile = (ScreenTexelDims * shadowCount); + float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount); shadowTile = xor(OrientationSwapXY, RotationSwapXY) ? shadowTile.yx : shadowTile.xy; @@ -431,10 +433,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) diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx index 61ffa4091f8..f766bf9ee39 100644 --- a/hlsl/bloom.fx +++ b/hlsl/bloom.fx @@ -240,7 +240,7 @@ uniform float4 Level0123Weight; uniform float4 Level4567Weight; uniform float3 Level89AWeight; -uniform int BloomType = 1; // blend mode: 0 addition, 1 darken +uniform int BloomBlendMode = 1; // 0 addition, 1 darken uniform float BloomScale; uniform float3 BloomOverdrive; @@ -267,7 +267,7 @@ float4 ps_main(PS_INPUT Input) : COLOR float3 blend; // addition - if (BloomType == 0) + if (BloomBlendMode == 0) { texel0 *= Level0123Weight.x; texel1 *= Level0123Weight.y; diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx index 341d614873b..3de37764e4f 100644 --- a/hlsl/deconverge.fx +++ b/hlsl/deconverge.fx @@ -71,7 +71,7 @@ uniform float Prescale; VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; - + float2 invDims = 1.0f / SourceDims; float2 Ratios = SourceRect; Output.Position = float4(Input.Position.xyz, 1.0f); @@ -92,7 +92,7 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / SourceDims.x) + 0.5f) * Ratios.x + ConvergeX * invDims.x; Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / SourceDims.y) + 0.5f) * Ratios.y + ConvergeY * invDims.y; - Output.TexCoord = TexCoord; + Output.TexCoord = TexCoord; return Output; } @@ -103,11 +103,11 @@ VS_OUTPUT vs_main(VS_INPUT Input) float4 ps_main(PS_INPUT Input) : COLOR { - float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a; + float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a; float RedTexel = tex2D(DiffuseSampler, float2(Input.CoordX.x, Input.CoordY.x)).r; float GrnTexel = tex2D(DiffuseSampler, float2(Input.CoordX.y, Input.CoordY.y)).g; float BluTexel = tex2D(DiffuseSampler, float2(Input.CoordX.z, Input.CoordY.z)).b; - + return float4(RedTexel, GrnTexel, BluTexel, Alpha); } diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx index 1524f27757c..77c7ddcd3e1 100644 --- a/hlsl/distortion.fx +++ b/hlsl/distortion.fx @@ -181,7 +181,7 @@ float GetSpotAddend(float2 coord, float amount) float SpotRadius = amount * 0.75f; float Spot = smoothstep(SpotRadius, SpotRadius - SpotBlur, length(SpotCoord)); - float SigmoidSpot = normalizedSigmoid(Spot, 0.75) * amount; + float SigmoidSpot = amount * normalizedSigmoid(Spot, 0.75); // increase strength by 100% SigmoidSpot = SigmoidSpot * 2.0f; @@ -215,8 +215,6 @@ float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount) // www.francois-tarlier.com/blog/cubic-lens-distortion-shader/ float2 GetDistortedCoords(float2 centerCoord, float amount) { - amount *= 0.25f; // reduced amount - // lens distortion coefficient float k = amount; @@ -266,7 +264,7 @@ float4 ps_main(PS_INPUT Input) : COLOR float2 BaseCoord = TexCoord; // Screen Curvature - BaseCoord = GetCoords(BaseCoord, CurvatureAmount); + BaseCoord = GetCoords(BaseCoord, CurvatureAmount * 0.25f); // reduced amount float2 BaseCoordCentered = BaseCoord; BaseCoordCentered -= 0.5f; diff --git a/hlsl/post.fx b/hlsl/post.fx index eed41168d33..39548bcf73a 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -136,7 +136,7 @@ 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 int ShadowTileMode = 0; // 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); @@ -195,7 +195,7 @@ float4 ps_main(PS_INPUT Input) : COLOR // ? shadowUV.yx // : shadowUV.xy; - float2 screenCoord = ShadowType == 0 ? ScreenCoord : BaseCoord; + float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord; screenCoord = xor(OrientationSwapXY, RotationSwapXY) ? screenCoord.yx : screenCoord.xy; @@ -205,7 +205,7 @@ float4 ps_main(PS_INPUT Input) : COLOR ? shadowCount.yx : shadowCount.xy; - float2 shadowTile = ((ShadowType == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount); + float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount); shadowTile = xor(OrientationSwapXY, RotationSwapXY) ? shadowTile.yx : shadowTile.xy; |