mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: Unscale line
Line thickness will be increased to N pixels (N is the upscaling factor). Code will also be enabled by UserHacks_unscale_point_line = 1
This commit is contained in:
parent
018895067b
commit
1fb2c66a21
|
@ -1319,16 +1319,29 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
|
||||
|
||||
// GS
|
||||
#if 1
|
||||
if (UserHacks_unscale_pt_ln && m_vt.m_primclass == GS_POINT_CLASS) {
|
||||
// Upscaling point will create aliasing because point has a size of 0 pixels.
|
||||
// This code tries to replace point with sprite. So a point in 4x will be replaced by
|
||||
// a 4x4 flat sprite.
|
||||
bool unscale_hack = UserHacks_unscale_pt_ln & (GetUpscaleMultiplier() > 1) & GLLoader::found_geometry_shader;
|
||||
switch(m_vt.m_primclass)
|
||||
{
|
||||
case GS_POINT_CLASS:
|
||||
if (unscale_hack) {
|
||||
m_gs_sel.point = 1;
|
||||
vs_cb.PointSize = GSVector2(2.0f * rtscale.x / rtsize.x, 2.0f * rtscale.y / rtsize.y);
|
||||
}
|
||||
#endif
|
||||
m_gs_sel.sprite = m_vt.m_primclass == GS_SPRITE_CLASS;
|
||||
break;
|
||||
case GS_LINE_CLASS:
|
||||
if (unscale_hack) {
|
||||
m_gs_sel.line = 1;
|
||||
vs_cb.PointSize = GSVector2(2.0f * rtscale.x / rtsize.x, 2.0f * rtscale.y / rtsize.y);
|
||||
}
|
||||
break;
|
||||
case GS_SPRITE_CLASS:
|
||||
m_gs_sel.sprite = 1;
|
||||
break;
|
||||
case GS_TRIANGLE_CLASS:
|
||||
break;
|
||||
default:
|
||||
__assume(0);
|
||||
}
|
||||
|
||||
dev->SetupPipeline(m_vs_sel, m_gs_sel, m_ps_sel);
|
||||
|
||||
|
|
|
@ -144,6 +144,47 @@ void gs_main()
|
|||
EndPrimitive();
|
||||
}
|
||||
|
||||
#elif GS_LINE == 1
|
||||
|
||||
void gs_main()
|
||||
{
|
||||
// Transform a line to a thick line-sprite
|
||||
vertex right = vertex(GSin[1].t_float, GSin[1].t_int, GSin[1].c);
|
||||
vertex left = vertex(GSin[0].t_float, GSin[0].t_int, GSin[0].c);
|
||||
vec4 lt_p = gl_in[0].gl_Position;
|
||||
vec4 rt_p = gl_in[1].gl_Position;
|
||||
|
||||
// Potentially there is faster math
|
||||
vec2 line_vector = normalize(rt_p.xy - lt_p.xy);
|
||||
vec2 line_normal = vec2(line_vector.y, -line_vector.x);
|
||||
vec2 line_width = line_normal * PointSize;
|
||||
|
||||
vec4 lb_p = gl_in[0].gl_Position + vec4(line_width, 0.0f, 0.0f);
|
||||
vec4 rb_p = gl_in[1].gl_Position + vec4(line_width, 0.0f, 0.0f);
|
||||
|
||||
// Triangle 1
|
||||
gl_Position = lt_p;
|
||||
out_vertex(left);
|
||||
|
||||
gl_Position = lb_p;
|
||||
out_vertex(left);
|
||||
|
||||
gl_Position = rt_p;
|
||||
out_vertex(right);
|
||||
EndPrimitive();
|
||||
|
||||
// Triangle 2
|
||||
gl_Position = lb_p;
|
||||
out_vertex(left);
|
||||
|
||||
gl_Position = rt_p;
|
||||
out_vertex(right);
|
||||
|
||||
gl_Position = rb_p;
|
||||
out_vertex(right);
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void gs_main()
|
||||
|
|
|
@ -811,6 +811,47 @@ static const char* const tfx_vgs_glsl =
|
|||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#elif GS_LINE == 1\n"
|
||||
"\n"
|
||||
"void gs_main()\n"
|
||||
"{\n"
|
||||
" // Transform a line to a thick line-sprite\n"
|
||||
" vertex right = vertex(GSin[1].t_float, GSin[1].t_int, GSin[1].c);\n"
|
||||
" vertex left = vertex(GSin[0].t_float, GSin[0].t_int, GSin[0].c);\n"
|
||||
" vec4 lt_p = gl_in[0].gl_Position;\n"
|
||||
" vec4 rt_p = gl_in[1].gl_Position;\n"
|
||||
"\n"
|
||||
" // Potentially there is faster math\n"
|
||||
" vec2 line_vector = normalize(rt_p.xy - lt_p.xy);\n"
|
||||
" vec2 line_normal = vec2(line_vector.y, -line_vector.x);\n"
|
||||
" vec2 line_width = line_normal * PointSize;\n"
|
||||
"\n"
|
||||
" vec4 lb_p = gl_in[0].gl_Position + vec4(line_width, 0.0f, 0.0f);\n"
|
||||
" vec4 rb_p = gl_in[1].gl_Position + vec4(line_width, 0.0f, 0.0f);\n"
|
||||
"\n"
|
||||
" // Triangle 1\n"
|
||||
" gl_Position = lt_p;\n"
|
||||
" out_vertex(left);\n"
|
||||
"\n"
|
||||
" gl_Position = lb_p;\n"
|
||||
" out_vertex(left);\n"
|
||||
"\n"
|
||||
" gl_Position = rt_p;\n"
|
||||
" out_vertex(right);\n"
|
||||
" EndPrimitive();\n"
|
||||
"\n"
|
||||
" // Triangle 2\n"
|
||||
" gl_Position = lb_p;\n"
|
||||
" out_vertex(left);\n"
|
||||
"\n"
|
||||
" gl_Position = rt_p;\n"
|
||||
" out_vertex(right);\n"
|
||||
"\n"
|
||||
" gl_Position = rb_p;\n"
|
||||
" out_vertex(right);\n"
|
||||
" EndPrimitive();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
"void gs_main()\n"
|
||||
|
|
Loading…
Reference in New Issue