Small fixes (nw)

- fixed not used u_humbar_hertz_rate parameter
- fixed half pixel shift of the shadow mask along the screen diagonal
This commit is contained in:
ImJezze 2016-04-22 13:16:37 +02:00
parent 4c9c6c8c16
commit dba12a31ad
7 changed files with 23 additions and 23 deletions

View file

@ -99,12 +99,12 @@ 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.5f / TargetDims; // fix half texel offset correction (DX9)
: 0.5f / TargetDims; // fix half texel offset (DX9)
Output.ScreenCoord = Input.Position.xy / ScreenDims;
Output.SourceCoord = Input.TexCoord;
Output.SourceCoord += 0.5f / TargetDims;
Output.SourceCoord += 0.5f / TargetDims; // fix half texel offset (DX9)
Output.Color = Input.Color;
@ -141,19 +141,19 @@ uniform float2 ShadowUV = float2(0.25f, 0.25f);
uniform float3 Power = float3(1.0f, 1.0f, 1.0f);
uniform float3 Floor = float3(0.0f, 0.0f, 0.0f);
float2 GetAdjustedCoords(float2 coord, float2 centerOffset)
float2 GetAdjustedCoords(float2 coord)
{
// center coordinates
coord -= centerOffset;
coord -= 0.5f;
// apply screen scale
coord *= ScreenScale;
// un-center coordinates
coord += centerOffset;
coord += 0.5f;
// apply screen offset
coord += (centerOffset * 2.0) * ScreenOffset;
coord += ScreenOffset;
return coord;
}
@ -195,7 +195,7 @@ float2 GetShadowCoord(float2 QuadCoord, float2 SourceCoord)
: shadowFrac.xy;
float2 shadowCoord = (shadowFrac * shadowUV);
shadowCoord += 0.5f / shadowDims; // half texel offset
shadowCoord += 0.5f / shadowDims; // fix half texel offset (DX9)
return shadowCoord;
}
@ -203,8 +203,8 @@ float2 GetShadowCoord(float2 QuadCoord, float2 SourceCoord)
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 ScreenCoord = Input.ScreenCoord;
float2 TexCoord = GetAdjustedCoords(Input.TexCoord, 0.5f);
float2 SourceCoord = GetAdjustedCoords(Input.SourceCoord, 0.5f);
float2 TexCoord = GetAdjustedCoords(Input.TexCoord);
float2 SourceCoord = GetAdjustedCoords(Input.SourceCoord);
// Color
float4 BaseColor = tex2D(DiffuseSampler, TexCoord);

View file

@ -3,7 +3,7 @@ $input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz,ImJezze
//-----------------------------------------------------------------------------
// Defocus Effect
// Scanline & Shadowmask Effect
//-----------------------------------------------------------------------------
#include "common.sh"
@ -33,7 +33,7 @@ uniform vec4 u_power;
uniform vec4 u_floor;
// Parametric
uniform vec4 u_time;
uniform vec4 u_time; // milliseconds
uniform vec4 u_jitter_amount;
// Samplers
@ -44,19 +44,19 @@ SAMPLER2D(s_shadow, 1);
// Scanline & Shadowmask Pixel Shader
//-----------------------------------------------------------------------------
vec2 GetAdjustedCoords(vec2 coord, vec2 center_offset)
vec2 GetAdjustedCoords(vec2 coord)
{
// center coordinates
coord -= center_offset;
coord -= 0.5;
// apply screen scale
coord *= u_screen_scale.xy;
// un-center coordinates
coord += center_offset;
coord += 0.5;
// apply screen offset
coord += (center_offset * 2.0) * u_screen_offset.xy;
coord += u_screen_offset.xy;
return coord;
}
@ -64,19 +64,19 @@ vec2 GetAdjustedCoords(vec2 coord, vec2 center_offset)
// vector screen has the same quad texture coordinates for every screen orientation, raster screen differs
vec2 GetShadowCoord(vec2 QuadCoord, vec2 SourceCoord)
{
vec2 QuadTexel = vec2(1.0, 1.0) / u_quad_dims.xy;
vec2 QuadTexel = vec2(1.0, 1.0) / (u_quad_dims.xy - 0.5f);
vec2 canvasCoord = QuadCoord + u_shadow_uv_offset.xy / u_quad_dims.xy;
vec2 shadowUV = u_shadow_uv.xy;
vec2 shadowCount = u_shadow_count.xy;
// swap x/y vector and raster in screen mode (not source mode)
// swap x/y in screen mode (not source mode)
canvasCoord = u_swap_xy.x > 0.0
? canvasCoord.yx
: canvasCoord.xy;
// swap x/y vector and raster in screen mode (not source mode)
// swap x/y in screen mode (not source mode)
shadowCount = u_swap_xy.x > 0.0
? shadowCount.yx
: shadowCount.xy;
@ -85,7 +85,7 @@ vec2 GetShadowCoord(vec2 QuadCoord, vec2 SourceCoord)
vec2 shadowFrac = fract(canvasCoord / shadowTile);
// swap x/y raster in screen mode (not vector and not source mode)
// swap x/y in screen mode (not source mode)
shadowFrac = u_swap_xy.x > 0.0
? shadowFrac.yx
: shadowFrac.xy;
@ -97,7 +97,7 @@ vec2 GetShadowCoord(vec2 QuadCoord, vec2 SourceCoord)
void main()
{
vec2 BaseCoord = GetAdjustedCoords(v_texcoord0, vec2(0.5, 0.5));
vec2 BaseCoord = GetAdjustedCoords(v_texcoord0);
// Color
vec4 BaseColor = texture2D(s_tex, BaseCoord);
@ -136,8 +136,8 @@ 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;
float ScanCoordJitter = u_scanline_jitter.x * u_jitter_amount.x * 1.618034;
float ScanCoord = BaseCoord.y * 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);
float ScanSineScaled = pow(ScanSine * ScanSine, ScanlineWide);
@ -149,7 +149,7 @@ void main()
// Hum Bar Simulation
if (u_humbar_alpha.x > 0.0f)
{
float HumTimeStep = fract(u_time.x * 0.001);
float HumTimeStep = fract(u_time.x * u_humbar_hertz_rate.x);
float HumBrightness = 1.0 - fract(BaseCoord.y + HumTimeStep) * u_humbar_alpha.x;
BaseColor.rgb *= HumBrightness;
}