mirror of
https://github.com/holub/mame
synced 2025-06-07 21:33:45 +03:00
Refactoring and Fixes
- removed position offset in post.fx - fixed texture offset caused by 0th level of bloom.fx - fixed texture offset caused by focus.fx - changed Passthrough parameter in phosphor.fx to boolean - simplified defocus pass function and calling it twice - removed CU_PHOSPHOR_IGNORE (Passthrough) uniform, which was only used in phosphor pass function and is now directly set - added CU_TARGET_DIMS (TargetDims) uniform based on the current render target - fixed missing Prescal parameter in downsample pass function - some code cleanup
This commit is contained in:
parent
4bcb0c13f5
commit
37f6ff0b65
@ -186,27 +186,27 @@ uniform float4 Level67Size;
|
|||||||
uniform float4 Level89Size;
|
uniform float4 Level89Size;
|
||||||
uniform float2 LevelASize;
|
uniform float2 LevelASize;
|
||||||
|
|
||||||
uniform bool PrepareVector = false;
|
|
||||||
|
|
||||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y;
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f;
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f;
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
float2 TexCoord = Input.Position.xy / ScreenDims;
|
float2 TexCoord = Input.Position.xy / ScreenDims;
|
||||||
Output.TexCoord01 = TexCoord.xyxy + Prescale.xyxy / Level01Size;
|
|
||||||
|
Output.TexCoord01.xy = TexCoord.xy;
|
||||||
|
Output.TexCoord01.zw = TexCoord.xy + Prescale.xy / Level01Size.zw;
|
||||||
Output.TexCoord23 = TexCoord.xyxy + Prescale.xyxy / Level23Size;
|
Output.TexCoord23 = TexCoord.xyxy + Prescale.xyxy / Level23Size;
|
||||||
Output.TexCoord45 = TexCoord.xyxy + Prescale.xyxy / Level45Size;
|
Output.TexCoord45 = TexCoord.xyxy + Prescale.xyxy / Level45Size;
|
||||||
Output.TexCoord67 = TexCoord.xyxy + Prescale.xyxy / Level67Size;
|
Output.TexCoord67 = TexCoord.xyxy + Prescale.xyxy / Level67Size;
|
||||||
Output.TexCoord89 = TexCoord.xyxy + Prescale.xyxy / Level89Size;
|
Output.TexCoord89 = TexCoord.xyxy + Prescale.xyxy / Level89Size;
|
||||||
Output.TexCoordA = TexCoord.xy + Prescale.xy / LevelASize;
|
Output.TexCoordA = TexCoord.xy + Prescale.xy / LevelASize;
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
@ -60,13 +60,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y;
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f;
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f;
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
float2 TexCoord = Input.Position.xy / ScreenDims;
|
float2 TexCoord = Input.Position.xy / ScreenDims;
|
||||||
|
|
||||||
Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize * Prescale;
|
Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize * Prescale;
|
||||||
Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize * Prescale;
|
Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize * Prescale;
|
||||||
Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize * Prescale;
|
Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize * Prescale;
|
||||||
|
@ -40,7 +40,6 @@ struct VS_INPUT
|
|||||||
float3 Position : POSITION;
|
float3 Position : POSITION;
|
||||||
float4 Color : COLOR0;
|
float4 Color : COLOR0;
|
||||||
float2 TexCoord : TEXCOORD0;
|
float2 TexCoord : TEXCOORD0;
|
||||||
float2 Unused : TEXCOORD1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
@ -61,12 +60,10 @@ struct PS_INPUT
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
uniform float2 ScreenDims;
|
uniform float2 ScreenDims;
|
||||||
|
uniform float2 TargetDims;
|
||||||
|
|
||||||
uniform float2 Defocus = float2(0.0f, 0.0f);
|
uniform float2 Defocus = float2(0.0f, 0.0f);
|
||||||
|
|
||||||
uniform float2 Prescale = float2(8.0f, 8.0f);
|
|
||||||
|
|
||||||
float2 Coord0Offset = float2( 0.0f, 0.0f);
|
|
||||||
float2 Coord1Offset = float2(-0.2f, -0.6f);
|
float2 Coord1Offset = float2(-0.2f, -0.6f);
|
||||||
float2 Coord2Offset = float2( 0.4f, -0.4f);
|
float2 Coord2Offset = float2( 0.4f, -0.4f);
|
||||||
float2 Coord3Offset = float2( 0.6f, 0.2f);
|
float2 Coord3Offset = float2( 0.6f, 0.2f);
|
||||||
@ -79,28 +76,24 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
|
|
||||||
float2 ScreenTexelDims = 1.0f / ScreenDims;
|
float2 TargetTexelDims = 1.0f / TargetDims;
|
||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y;
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f;
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f;
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
// todo: there is an offset which can be noticed at lower prescale in high-resolution
|
float2 TexCoord = Input.TexCoord + 0.5f / TargetDims;
|
||||||
float2 FocusPrescaleOffset = ScreenTexelDims / Prescale;
|
|
||||||
|
|
||||||
float2 TexCoord = Input.TexCoord;
|
Output.TexCoord0 = TexCoord;
|
||||||
TexCoord += FocusPrescaleOffset;
|
Output.TexCoord1 = TexCoord + Coord1Offset * TargetTexelDims * Defocus;
|
||||||
|
Output.TexCoord2 = TexCoord + Coord2Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord0 = TexCoord + Coord0Offset * ScreenTexelDims * Defocus;
|
Output.TexCoord3 = TexCoord + Coord3Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord1 = TexCoord + Coord1Offset * ScreenTexelDims * Defocus;
|
Output.TexCoord4 = TexCoord + Coord4Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord2 = TexCoord + Coord2Offset * ScreenTexelDims * Defocus;
|
Output.TexCoord5 = TexCoord + Coord5Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord3 = TexCoord + Coord3Offset * ScreenTexelDims * Defocus;
|
Output.TexCoord6 = TexCoord + Coord6Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord4 = TexCoord + Coord4Offset * ScreenTexelDims * Defocus;
|
Output.TexCoord7 = TexCoord + Coord7Offset * TargetTexelDims * Defocus;
|
||||||
Output.TexCoord5 = TexCoord + Coord5Offset * ScreenTexelDims * Defocus;
|
|
||||||
Output.TexCoord6 = TexCoord + Coord6Offset * ScreenTexelDims * Defocus;
|
|
||||||
Output.TexCoord7 = TexCoord + Coord7Offset * ScreenTexelDims * Defocus;
|
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
@ -123,13 +116,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||||||
float3 d7 = tex2D(DiffuseSampler, Input.TexCoord7).rgb;
|
float3 d7 = tex2D(DiffuseSampler, Input.TexCoord7).rgb;
|
||||||
|
|
||||||
float3 blurred = (d0.rgb + d1 + d2 + d3 + d4 + d5 + d6 + d7) / 8.0f;
|
float3 blurred = (d0.rgb + d1 + d2 + d3 + d4 + d5 + d6 + d7) / 8.0f;
|
||||||
|
|
||||||
blurred = lerp(d0.rgb, blurred, 1.0f);
|
blurred = lerp(d0.rgb, blurred, 1.0f);
|
||||||
|
|
||||||
return float4(blurred, d0.a);
|
return float4(blurred, d0.a);
|
||||||
|
|
||||||
// float4 texel = tex2D(DiffuseSampler, Input.TexCoord0);
|
|
||||||
|
|
||||||
// return float4(texel.rgb, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -47,7 +47,6 @@ struct VS_INPUT
|
|||||||
float3 Position : POSITION;
|
float3 Position : POSITION;
|
||||||
float4 Color : COLOR0;
|
float4 Color : COLOR0;
|
||||||
float2 TexCoord : TEXCOORD0;
|
float2 TexCoord : TEXCOORD0;
|
||||||
float2 Unused : TEXCOORD1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
@ -62,10 +61,9 @@ struct PS_INPUT
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
uniform float2 ScreenDims;
|
uniform float2 ScreenDims;
|
||||||
|
|
||||||
uniform float2 TargetDims;
|
uniform float2 TargetDims;
|
||||||
|
|
||||||
uniform float Passthrough;
|
uniform bool Passthrough;
|
||||||
|
|
||||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||||
{
|
{
|
||||||
@ -73,14 +71,15 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y;
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f;
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
Output.Color = Input.Color;
|
|
||||||
|
|
||||||
Output.TexCoord = Input.TexCoord + 0.5f / TargetDims;
|
Output.TexCoord = Input.TexCoord + 0.5f / TargetDims;
|
||||||
Output.PrevCoord = Output.TexCoord;
|
Output.PrevCoord = Output.TexCoord;
|
||||||
|
|
||||||
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +98,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||||||
float GreenMax = max(CurrPix.g, PrevPix.g);
|
float GreenMax = max(CurrPix.g, PrevPix.g);
|
||||||
float BlueMax = max(CurrPix.b, PrevPix.b);
|
float BlueMax = max(CurrPix.b, PrevPix.b);
|
||||||
|
|
||||||
return lerp(float4(RedMax, GreenMax, BlueMax, CurrPix.a), CurrPix, Passthrough);
|
return Passthrough
|
||||||
|
? CurrPix
|
||||||
|
: float4(RedMax, GreenMax, BlueMax, CurrPix.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
12
hlsl/post.fx
12
hlsl/post.fx
@ -88,10 +88,6 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
|
|
||||||
float4 Position = Input.Position;
|
|
||||||
Position.xy *= (ScreenDims + 1.0f) / ScreenDims;
|
|
||||||
Position.xy -= 0.5f / ScreenDims;
|
|
||||||
|
|
||||||
float2 shadowUVOffset = ShadowUVOffset;
|
float2 shadowUVOffset = ShadowUVOffset;
|
||||||
shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
|
shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
|
||||||
? shadowUVOffset.yx
|
? shadowUVOffset.yx
|
||||||
@ -101,16 +97,18 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
float2 ScreenCoordPrescaleOffset = 0.0f;
|
float2 ScreenCoordPrescaleOffset = 0.0f;
|
||||||
ScreenCoordPrescaleOffset += shadowUVOffset;
|
ScreenCoordPrescaleOffset += shadowUVOffset;
|
||||||
|
|
||||||
Output.ScreenCoord = Position.xy;
|
Output.ScreenCoord = Input.Position.xy;
|
||||||
Output.ScreenCoord += ScreenCoordPrescaleOffset;
|
Output.ScreenCoord += ScreenCoordPrescaleOffset;
|
||||||
|
|
||||||
Output.Position = float4(Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f; // center
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f; // zoom
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
Output.TexCoord = PrepareVector ? (Input.Position.xy / ScreenDims) : Input.TexCoord;
|
Output.TexCoord = PrepareVector
|
||||||
|
? Input.Position.xy / ScreenDims
|
||||||
|
: Input.TexCoord; // + 0.5f / TargetDims;
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ struct VS_INPUT
|
|||||||
float3 Position : POSITION;
|
float3 Position : POSITION;
|
||||||
float4 Color : COLOR0;
|
float4 Color : COLOR0;
|
||||||
float2 TexCoord : TEXCOORD0;
|
float2 TexCoord : TEXCOORD0;
|
||||||
float2 Unused : TEXCOORD1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
@ -47,6 +46,7 @@ struct PS_INPUT
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
uniform float2 ScreenDims;
|
uniform float2 ScreenDims;
|
||||||
|
|
||||||
uniform bool PostPass;
|
uniform bool PostPass;
|
||||||
uniform float Brighten;
|
uniform float Brighten;
|
||||||
|
|
||||||
@ -56,11 +56,13 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y;
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f;
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f;
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
Output.TexCoord = PostPass ? (Input.Position.xy / ScreenDims) : Input.TexCoord;
|
Output.TexCoord = PostPass
|
||||||
|
? Input.Position.xy / ScreenDims
|
||||||
|
: Input.TexCoord;
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
@ -87,6 +89,8 @@ technique TestTechnique
|
|||||||
{
|
{
|
||||||
Lighting = FALSE;
|
Lighting = FALSE;
|
||||||
|
|
||||||
|
Sampler[0] = <DiffuseSampler>;
|
||||||
|
|
||||||
VertexShader = compile vs_2_0 vs_main();
|
VertexShader = compile vs_2_0 vs_main();
|
||||||
PixelShader = compile ps_2_0 ps_main();
|
PixelShader = compile ps_2_0 ps_main();
|
||||||
}
|
}
|
||||||
|
@ -1066,11 +1066,12 @@ int shaders::create_resources(bool reset)
|
|||||||
deconverge_effect->add_uniform("RadialConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_Y);
|
deconverge_effect->add_uniform("RadialConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_Y);
|
||||||
|
|
||||||
focus_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
focus_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
||||||
|
focus_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
|
||||||
focus_effect->add_uniform("Defocus", uniform::UT_VEC2, uniform::CU_FOCUS_SIZE);
|
focus_effect->add_uniform("Defocus", uniform::UT_VEC2, uniform::CU_FOCUS_SIZE);
|
||||||
|
|
||||||
phosphor_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
phosphor_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
||||||
|
phosphor_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
|
||||||
phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE);
|
phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE);
|
||||||
phosphor_effect->add_uniform("Passthrough", uniform::UT_FLOAT, uniform::CU_PHOSPHOR_IGNORE);
|
|
||||||
|
|
||||||
downsample_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
downsample_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
|
||||||
|
|
||||||
@ -1386,23 +1387,13 @@ int shaders::defocus_pass(render_target *rt, int source_index, poly_info *poly,
|
|||||||
return next_index;
|
return next_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
float prescale[2] = { (float)hlsl_prescale_x, (float)hlsl_prescale_y };
|
|
||||||
|
|
||||||
// Defocus pass 1
|
|
||||||
curr_effect = focus_effect;
|
curr_effect = focus_effect;
|
||||||
curr_effect->update_uniforms();
|
curr_effect->update_uniforms();
|
||||||
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
||||||
curr_effect->set_vector("Prescale", 2, prescale);
|
|
||||||
|
|
||||||
next_index = rt->next_index(next_index);
|
next_index = rt->next_index(next_index);
|
||||||
blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2);
|
blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2);
|
||||||
|
|
||||||
// Defocus pass 2
|
|
||||||
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
|
||||||
|
|
||||||
next_index = rt->next_index(next_index);
|
|
||||||
blit(rt->prescale_target[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
|
|
||||||
|
|
||||||
return next_index;
|
return next_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,25 +1401,20 @@ int shaders::phosphor_pass(render_target *rt, cache_target *ct, int source_index
|
|||||||
{
|
{
|
||||||
int next_index = source_index;
|
int next_index = source_index;
|
||||||
|
|
||||||
phosphor_passthrough = false;
|
|
||||||
|
|
||||||
curr_effect = phosphor_effect;
|
curr_effect = phosphor_effect;
|
||||||
curr_effect->update_uniforms();
|
curr_effect->update_uniforms();
|
||||||
|
|
||||||
float rtsize[2] = { rt->target_width, rt->target_height };
|
|
||||||
curr_effect->set_vector("TargetDims", 2, rtsize);
|
|
||||||
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
||||||
curr_effect->set_texture("LastPass", ct->last_texture);
|
curr_effect->set_texture("LastPass", ct->last_texture);
|
||||||
|
curr_effect->set_bool("Passthrough", false);
|
||||||
|
|
||||||
next_index = rt->next_index(next_index);
|
next_index = rt->next_index(next_index);
|
||||||
blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2);
|
blit(rt->prescale_target[next_index], true, D3DPT_TRIANGLELIST, 0, 2);
|
||||||
|
|
||||||
phosphor_passthrough = true;
|
|
||||||
|
|
||||||
// Pass along our phosphor'd screen
|
// Pass along our phosphor'd screen
|
||||||
curr_effect->update_uniforms();
|
curr_effect->update_uniforms();
|
||||||
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
|
||||||
curr_effect->set_texture("LastPass", rt->prescale_texture[next_index]);
|
curr_effect->set_texture("LastPass", rt->prescale_texture[next_index]);
|
||||||
|
curr_effect->set_bool("Passthrough", true);
|
||||||
|
|
||||||
// Avoid changing targets due to page flipping
|
// Avoid changing targets due to page flipping
|
||||||
blit(ct->last_target, true, D3DPT_TRIANGLELIST, 0, 2);
|
blit(ct->last_target, true, D3DPT_TRIANGLELIST, 0, 2);
|
||||||
@ -1442,7 +1428,8 @@ int shaders::post_pass(render_target *rt, int source_index, poly_info *poly, int
|
|||||||
|
|
||||||
texture_info *texture = poly->get_texture();
|
texture_info *texture = poly->get_texture();
|
||||||
|
|
||||||
bool prepare_vector = PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable;
|
bool prepare_vector =
|
||||||
|
PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable;
|
||||||
float prescale[2] = {
|
float prescale[2] = {
|
||||||
prepare_vector ? 1.0f : (float)hlsl_prescale_x,
|
prepare_vector ? 1.0f : (float)hlsl_prescale_x,
|
||||||
prepare_vector ? 1.0f : (float)hlsl_prescale_y };
|
prepare_vector ? 1.0f : (float)hlsl_prescale_y };
|
||||||
@ -1496,8 +1483,15 @@ int shaders::downsample_pass(render_target *rt, int source_index, poly_info *pol
|
|||||||
{
|
{
|
||||||
int next_index = source_index;
|
int next_index = source_index;
|
||||||
|
|
||||||
|
bool prepare_vector =
|
||||||
|
PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable;
|
||||||
|
float prescale[2] = {
|
||||||
|
prepare_vector ? 1.0f : (float)hlsl_prescale_x, // no prescale for vector
|
||||||
|
prepare_vector ? 1.0f : (float)hlsl_prescale_y }; // full prescale for raster
|
||||||
|
|
||||||
curr_effect = downsample_effect;
|
curr_effect = downsample_effect;
|
||||||
curr_effect->update_uniforms();
|
curr_effect->update_uniforms();
|
||||||
|
curr_effect->set_vector("Prescale", 2, prescale);
|
||||||
|
|
||||||
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||||
int bloom_index = 0;
|
int bloom_index = 0;
|
||||||
@ -1529,8 +1523,8 @@ int shaders::bloom_pass(render_target *rt, int source_index, poly_info *poly, in
|
|||||||
|
|
||||||
bool prepare_vector = PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable;
|
bool prepare_vector = PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable;
|
||||||
float prescale[2] = {
|
float prescale[2] = {
|
||||||
prepare_vector ? 1.0f : (float)hlsl_prescale_x / 2.0f,
|
prepare_vector ? 1.0f : (float)hlsl_prescale_x / 2.0f, // no prescale for vector
|
||||||
prepare_vector ? 1.0f : (float)hlsl_prescale_y / 2.0f }; // no prescale for vector, half prescale for raster
|
prepare_vector ? 1.0f : (float)hlsl_prescale_y / 2.0f }; // half prescale for raster
|
||||||
float bloom_rescale = prepare_vector
|
float bloom_rescale = prepare_vector
|
||||||
? options->vector_bloom_scale
|
? options->vector_bloom_scale
|
||||||
: options->raster_bloom_scale;
|
: options->raster_bloom_scale;
|
||||||
@ -1599,7 +1593,8 @@ int shaders::screen_pass(render_target *rt, int source_index, poly_info *poly, i
|
|||||||
curr_effect->set_bool("PostPass", true);
|
curr_effect->set_bool("PostPass", true);
|
||||||
curr_effect->set_float("Brighten", prepare_vector ? 1.0f : 0.0f);
|
curr_effect->set_float("Brighten", prepare_vector ? 1.0f : 0.0f);
|
||||||
|
|
||||||
blit(backbuffer, true, poly->get_type(), vertnum, poly->get_count());
|
// we do not clear the backbuffe here because multiple screens might rendered into
|
||||||
|
blit(backbuffer, false, poly->get_type(), vertnum, poly->get_count());
|
||||||
|
|
||||||
if (avi_output_file != NULL)
|
if (avi_output_file != NULL)
|
||||||
{
|
{
|
||||||
@ -1632,7 +1627,9 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||||||
|
|
||||||
if (PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && curr_texture != NULL)
|
if (PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && curr_texture != NULL)
|
||||||
{
|
{
|
||||||
render_target *rt = find_render_target(curr_texture);
|
curr_render_target = find_render_target(curr_texture);
|
||||||
|
|
||||||
|
render_target *rt = curr_render_target;
|
||||||
if (rt == NULL)
|
if (rt == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1646,7 +1643,8 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||||||
next_index = color_convolution_pass(rt, next_index, poly, vertnum);
|
next_index = color_convolution_pass(rt, next_index, poly, vertnum);
|
||||||
next_index = prescale_pass(rt, next_index, poly, vertnum);
|
next_index = prescale_pass(rt, next_index, poly, vertnum);
|
||||||
next_index = deconverge_pass(rt, next_index, poly, vertnum);
|
next_index = deconverge_pass(rt, next_index, poly, vertnum);
|
||||||
next_index = defocus_pass(rt, next_index, poly, vertnum);
|
next_index = defocus_pass(rt, next_index, poly, vertnum); // 1st pass
|
||||||
|
next_index = defocus_pass(rt, next_index, poly, vertnum); // 2nd pass
|
||||||
next_index = phosphor_pass(rt, ct, next_index, poly, vertnum);
|
next_index = phosphor_pass(rt, ct, next_index, poly, vertnum);
|
||||||
|
|
||||||
// create bloom textures
|
// create bloom textures
|
||||||
@ -1669,7 +1667,9 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||||||
}
|
}
|
||||||
else if (PRIMFLAG_GET_VECTOR(poly->get_flags()) && vector_enable)
|
else if (PRIMFLAG_GET_VECTOR(poly->get_flags()) && vector_enable)
|
||||||
{
|
{
|
||||||
render_target *rt = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
|
curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
|
||||||
|
|
||||||
|
render_target *rt = curr_render_target;
|
||||||
if (rt == NULL)
|
if (rt == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1697,7 +1697,9 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||||||
}
|
}
|
||||||
else if (PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable)
|
else if (PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable)
|
||||||
{
|
{
|
||||||
render_target *rt = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
|
curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
|
||||||
|
|
||||||
|
render_target *rt = curr_render_target;
|
||||||
if (rt == NULL)
|
if (rt == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1750,6 +1752,7 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
|||||||
blit(NULL, false, poly->get_type(), vertnum, poly->get_count());
|
blit(NULL, false, poly->get_type(), vertnum, poly->get_count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curr_render_target = NULL;
|
||||||
curr_texture = NULL;
|
curr_texture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2811,6 +2814,12 @@ void uniform::update()
|
|||||||
m_shader->set_vector("SourceRect", 2, &delta.c.x);
|
m_shader->set_vector("SourceRect", 2, &delta.c.x);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CU_TARGET_DIMS:
|
||||||
|
{
|
||||||
|
float rtsize[2] = { shadersys->curr_render_target->target_width, shadersys->curr_render_target->target_height };
|
||||||
|
m_shader->set_vector("TargetDims", 2, rtsize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case CU_NTSC_CCFREQ:
|
case CU_NTSC_CCFREQ:
|
||||||
m_shader->set_float("CCValue", options->yiq_cc);
|
m_shader->set_float("CCValue", options->yiq_cc);
|
||||||
@ -2885,9 +2894,6 @@ void uniform::update()
|
|||||||
case CU_PHOSPHOR_LIFE:
|
case CU_PHOSPHOR_LIFE:
|
||||||
m_shader->set_vector("Phosphor", 3, options->phosphor);
|
m_shader->set_vector("Phosphor", 3, options->phosphor);
|
||||||
break;
|
break;
|
||||||
case CU_PHOSPHOR_IGNORE:
|
|
||||||
m_shader->set_float("Passthrough", shadersys->phosphor_passthrough ? 1.0f : 0.0f);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CU_POST_REFLECTION:
|
case CU_POST_REFLECTION:
|
||||||
m_shader->set_float("ReflectionAmount", options->reflection);
|
m_shader->set_float("ReflectionAmount", options->reflection);
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
CU_SCREEN_DIMS = 0,
|
CU_SCREEN_DIMS = 0,
|
||||||
CU_SOURCE_DIMS,
|
CU_SOURCE_DIMS,
|
||||||
CU_SOURCE_RECT,
|
CU_SOURCE_RECT,
|
||||||
|
CU_TARGET_DIMS,
|
||||||
|
|
||||||
CU_NTSC_CCFREQ,
|
CU_NTSC_CCFREQ,
|
||||||
CU_NTSC_A,
|
CU_NTSC_A,
|
||||||
@ -411,7 +412,7 @@ private:
|
|||||||
vertex * fsfx_vertices; // pointer to our full-screen-quad object
|
vertex * fsfx_vertices; // pointer to our full-screen-quad object
|
||||||
|
|
||||||
texture_info * curr_texture;
|
texture_info * curr_texture;
|
||||||
bool phosphor_passthrough;
|
render_target * curr_render_target;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
render_target * targethead;
|
render_target * targethead;
|
||||||
|
@ -2838,8 +2838,6 @@ render_target::~render_target()
|
|||||||
|
|
||||||
bool render_target::init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y)
|
bool render_target::init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y)
|
||||||
{
|
{
|
||||||
D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
||||||
|
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
|
||||||
for (int index = 0; index < 2; index++)
|
for (int index = 0; index < 2; index++)
|
||||||
|
Loading…
Reference in New Issue
Block a user