HLSL Updates: [Ryan Holtz, Bat Country Entertainment]

- Switched to point-sampling through most of the shader chain to avoid non-intentional pixel smearing
- Corrected alignment and scaling on the shadow mask and scanlines; dramatically reduces rainbow banding at non-oversampled resolutions.
This commit is contained in:
Ryan Holtz 2011-05-27 10:07:11 +00:00
parent 10583a2dfb
commit c8ef077d5b
4 changed files with 16 additions and 15 deletions

View File

@ -7,9 +7,9 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;

View File

@ -7,9 +7,9 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;

View File

@ -7,9 +7,9 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
@ -20,9 +20,9 @@ texture LastPass;
sampler PreviousSampler = sampler_state
{
Texture = <LastPass>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;

View File

@ -154,18 +154,19 @@ float4 ps_main(PS_INPUT Input) : COLOR
clip((BaseCoord.y > (1.0f / HeightRatio + 1.0f / RawHeight)) ? -1 : 1);
// -- Scanline Simulation --
float3 ScanBrightness = lerp(1.0f, abs(sin(((BaseCoord.y * Ratios.y * RawHeight * ScanlineScale) * PI + ScanlineOffset * RawHeight))) * ScanlineBrightScale + ScanlineBrightOffset, ScanlineAmount);
float InnerSine = BaseCoord.y * RawHeight * ScanlineScale + 0.5f;
float3 ScanBrightness = lerp(1.0f, sin(InnerSine * PI * 2.0f + ScanlineOffset * RawHeight) * ScanlineBrightScale + 1.0f, ScanlineAmount);
float3 Scanned = BaseTexel.rgb * ScanBrightness;
float2 ShadowDims = float2(ShadowWidth, ShadowHeight);
float2 ShadowUV = float2(ShadowU, ShadowV);
float2 ShadowMaskSize = float2(ShadowMaskSizeX, ShadowMaskSizeY);
float2 ShadowFrac = frac(ScreenCurveCoord * ShadowMaskSize * Ratios * 0.5f);
float2 ShadowFrac = frac((ScreenCurveCoord * ShadowMaskSize * 0.5f) / Ratios);
float2 ShadowCoord = ShadowFrac * ShadowUV + 1.5f / ShadowDims;
float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord), UseShadow);
// -- Final Pixel --
float4 Output = float4(Scanned * lerp(1.0f, ShadowTexel * 1.25f, ShadowBrightness), BaseTexel.a) * Input.Color;
float4 Output = float4(Scanned * lerp(1.0f, ShadowTexel, ShadowBrightness), BaseTexel.a) * Input.Color;
return Output;
}