Fixed scanlines if the screen output is less than twice the size of the host source

This commit is contained in:
ImJezze 2016-06-06 19:40:10 +02:00
parent 6e35713b48
commit 758aaa496a
7 changed files with 15 additions and 3 deletions

View file

@ -98,7 +98,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.TexCoord = Input.TexCoord;
Output.TexCoord += PrepareBloom
? 0.0f / TargetDims // use half texel offset (DX9) to do the blur for first bloom layer
? 0.0f // use half texel offset (DX9) to do the blur for first bloom layer
: 0.5f / TargetDims; // fix half texel offset (DX9)
Output.ScreenCoord = Input.Position.xy / ScreenDims;
@ -252,7 +252,13 @@ float4 ps_main(PS_INPUT Input) : COLOR
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
float ScanlineCoord = SourceCoord.y * SourceDims.y * ScanlineScale * PI;
float ScanlineCoord = SourceCoord.y;
ScanlineCoord += QuadDims.y <= SourceDims.y * 2.0f
? 0.5f / QuadDims.y // uncenter scanlines if the quad is less than twice the size of the source
: 0.0f;
ScanlineCoord *= SourceDims.y * ScanlineScale * PI;
float ScanlineCoordJitter = ScanlineOffset * PHI;
float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
float ScanlineWide = ScanlineHeight + ScanlineVariation * max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);

View file

@ -148,7 +148,13 @@ void main()
float ColorBrightness = 0.299 * BaseColor.r + 0.587 * BaseColor.g + 0.114 * BaseColor.b;
float ScanCoord = BaseCoord.y * u_source_dims.y * u_scanline_scale.x * 3.1415927; // PI
float ScanCoord = BaseCoord.y;
ScanCoord += u_quad_dims.y <= u_source_dims.y * 2.0f
? 0.5f / u_quad_dims.y // uncenter scanlines if the quad is less than twice the size of the source
: 0.0f;
ScanCoord *= u_source_dims.y * u_scanline_scale.x * 3.1415927; // PI
float ScanCoordJitter = u_scanline_jitter.x * u_jitter_amount.x * 1.618034; // PHI
float ScanSine = sin(ScanCoord + ScanCoordJitter);
float ScanlineWide = u_scanline_height.x + u_scanline_variation.x * max(1.0, u_scanline_height.x) * (1.0 - ColorBrightness);