Post Pass effects for Vector rendering

- added support for post pass effects for vector rendering (does not
work properly in full screen mode, yet)
- made texture_info::compute_size_subroutine() function public static
This commit is contained in:
ImJezze 2015-07-12 23:28:38 +02:00
parent 6e5f7f5d94
commit 9ce2864141
4 changed files with 43 additions and 21 deletions

View File

@ -78,7 +78,9 @@ uniform float2 Prescale = float2(8.0f, 8.0f);
uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
uniform bool PrepareVector = false;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@ -106,7 +108,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
Output.TexCoord = Input.TexCoord;
Output.TexCoord = PrepareVector ? (Input.Position.xy / ScreenDims) : Input.TexCoord;
Output.Color = Input.Color;
@ -377,7 +379,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
}
// Output
float4 Output = BaseColor * Input.Color;
float4 Output = PrepareVector
? BaseColor * (Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f))
: BaseColor * Input.Color;
Output.a = 1.0f;
// Light Reflection Simulation (may not affect bloom)

View File

@ -146,10 +146,11 @@ public:
vec2f & get_uvstop() { return m_stop; }
vec2f & get_rawdims() { return m_rawdims; }
static void compute_size_subroutine(texture_manager* texture_manager, int texwidth, int texheight, int* p_width, int* p_height);
private:
void prescale();
void compute_size(int texwidth, int texheight);
void compute_size_subroutine(int texwidth, int texheight, int* p_width, int* p_height);
texture_manager * m_texture_manager; // texture manager pointer

View File

@ -1462,6 +1462,24 @@ int shaders::post_pass(render_target *rt, int source_index, poly_info *poly, int
curr_effect->set_bool("RotationSwapXY", rotation_swap_xy);
curr_effect->set_bool("PrepareBloom", prepare_bloom);
if (prepare_vector)
{
int source_width = d3d->get_width();
int source_height = d3d->get_height();
int target_width = 0;
int target_height = 0;
texture_info::compute_size_subroutine(d3d->get_texture_manager(), source_width, source_height, &target_width, &target_height);
// todo: fix fullscreen
float source_dims[2] = { (float)target_width, (float)source_height };
float source_rect[2] = { 1.0f, 1.0f };
curr_effect->set_bool("PrepareVector", prepare_vector);
curr_effect->set_vector("SourceDims", 2, source_dims);
curr_effect->set_vector("SourceRect", 2, source_rect);
}
d3d->set_wrap(D3DTADDRESS_MIRROR);
next_index = rt->next_index(next_index);
@ -1696,21 +1714,20 @@ void shaders::render_quad(poly_info *poly, int vertnum)
next_index = rt->next_index(next_index);
blit(rt->prescale_target[next_index], true, poly->get_type(), vertnum, poly->get_count());
next_index = phosphor_pass(rt, ct, next_index, poly, vertnum);
curr_effect = default_effect;
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
curr_effect->set_bool("PostPass", true);
curr_effect->set_float("Brighten", 1.0f);
next_index = rt->next_index(next_index);
blit(rt->native_target[next_index], true, poly->get_type(), vertnum, poly->get_count());
// create bloom textures
int phosphor_index = next_index;
next_index = post_pass(rt, next_index, poly, vertnum, true);
next_index = downsample_pass(rt, next_index, poly, vertnum);
// apply bloom textures
next_index = phosphor_index;
next_index = post_pass(rt, next_index, poly, vertnum, false);
next_index = bloom_pass(rt, next_index, poly, vertnum);
// render on screen
next_index = screen_pass(rt, next_index, poly, vertnum);
HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, backbuffer);

View File

@ -2074,13 +2074,13 @@ error:
// texture_info::compute_size_subroutine
//============================================================
void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_width, int* p_height)
void texture_info::compute_size_subroutine(texture_manager* texture_manager, int texwidth, int texheight, int* p_width, int* p_height)
{
int finalheight = texheight;
int finalwidth = texwidth;
// round width/height up to nearest power of 2 if we need to
if (!(m_texture_manager->get_texture_caps() & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
if (!(texture_manager->get_texture_caps() & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
{
// first the width
if (finalwidth & (finalwidth - 1))
@ -2104,7 +2104,7 @@ void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_w
}
// round up to square if we need to
if (m_texture_manager->get_texture_caps() & D3DPTEXTURECAPS_SQUAREONLY)
if (texture_manager->get_texture_caps() & D3DPTEXTURECAPS_SQUAREONLY)
{
if (finalwidth < finalheight)
finalwidth = finalheight;
@ -2113,11 +2113,11 @@ void texture_info::compute_size_subroutine(int texwidth, int texheight, int* p_w
}
// adjust the aspect ratio if we need to
while (finalwidth < finalheight && finalheight / finalwidth > m_texture_manager->get_max_texture_aspect())
while (finalwidth < finalheight && finalheight / finalwidth > texture_manager->get_max_texture_aspect())
{
finalwidth *= 2;
}
while (finalheight < finalwidth && finalwidth / finalheight > m_texture_manager->get_max_texture_aspect())
while (finalheight < finalwidth && finalwidth / finalheight > texture_manager->get_max_texture_aspect())
{
finalheight *= 2;
}
@ -2151,7 +2151,7 @@ void texture_info::compute_size(int texwidth, int texheight)
finalwidth += 2 * m_xborderpix;
finalheight += 2 * m_yborderpix;
compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight);
texture_info::compute_size_subroutine(m_texture_manager, finalwidth, finalheight, &finalwidth, &finalheight);
// if we added pixels for the border, and that just barely pushed us over, take it back
if (finalwidth > m_texture_manager->get_max_texture_width() || finalheight > m_texture_manager->get_max_texture_height())
@ -2162,7 +2162,7 @@ void texture_info::compute_size(int texwidth, int texheight)
m_xborderpix = 0;
m_yborderpix = 0;
compute_size_subroutine(finalwidth, finalheight, &finalwidth, &finalheight);
texture_info::compute_size_subroutine(m_texture_manager, finalwidth, finalheight, &finalwidth, &finalheight);
}
// if we're above the max width/height, do what?