GPU/D3D11: Fix non-vertical line rendering at >1x scale
This commit is contained in:
parent
34ae0dae13
commit
e19175edae
|
@ -642,7 +642,7 @@ std::string GPU_HW_ShaderGen::GenerateBatchLineExpandGeometryShader()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ss << R"(
|
ss << R"(
|
||||||
CONSTANT float2 OFFSET = (1.0 / float2(VRAM_SIZE)) * float2(RESOLUTION_SCALE, RESOLUTION_SCALE);
|
CONSTANT float2 WIDTH = (1.0 / float2(VRAM_SIZE)) * float2(RESOLUTION_SCALE, RESOLUTION_SCALE);
|
||||||
|
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
|
@ -655,24 +655,28 @@ void main(line Vertex input[2], inout TriangleStream<Vertex> output)
|
||||||
{
|
{
|
||||||
Vertex v;
|
Vertex v;
|
||||||
|
|
||||||
|
float2 dir = normalize(input[1].pos.xy - input[0].pos.xy);
|
||||||
|
float2 normal = cross(float3(dir, 0.0), float3(0.0, 0.0, 1.0)).xy * WIDTH;
|
||||||
|
float4 offset = float4(normal, 0.0, 0.0);
|
||||||
|
|
||||||
// top-left
|
// top-left
|
||||||
v.col0 = input[0].col0;
|
v.col0 = input[0].col0;
|
||||||
v.pos = input[0].pos + float4(-OFFSET.x, +OFFSET.y, 0.0, 0.0);
|
v.pos = input[0].pos - offset;
|
||||||
output.Append(v);
|
output.Append(v);
|
||||||
|
|
||||||
// top-right
|
// top-right
|
||||||
v.col0 = input[0].col0;
|
v.col0 = input[0].col0;
|
||||||
v.pos = input[0].pos + float4(+OFFSET.x, +OFFSET.y, 0.0, 0.0);
|
v.pos = input[0].pos + offset;
|
||||||
output.Append(v);
|
output.Append(v);
|
||||||
|
|
||||||
// bottom-left
|
// bottom-left
|
||||||
v.col0 = input[1].col0;
|
v.col0 = input[1].col0;
|
||||||
v.pos = input[1].pos + float4(-OFFSET.x, -OFFSET.y, 0.0, 0.0);
|
v.pos = input[1].pos - offset;
|
||||||
output.Append(v);
|
output.Append(v);
|
||||||
|
|
||||||
// bottom-right
|
// bottom-right
|
||||||
v.col0 = input[1].col0;
|
v.col0 = input[1].col0;
|
||||||
v.pos = input[1].pos + float4(+OFFSET.x, -OFFSET.y, 0.0, 0.0);
|
v.pos = input[1].pos + offset;
|
||||||
output.Append(v);
|
output.Append(v);
|
||||||
|
|
||||||
output.RestartStrip();
|
output.RestartStrip();
|
||||||
|
|
Loading…
Reference in New Issue