fix flipped y transform application in upgraded shader

This commit is contained in:
Ryan Fleury
2024-01-23 12:50:26 -08:00
parent 6a91505317
commit 6e5f518cf3
3 changed files with 41 additions and 39 deletions
+20 -19
View File
@@ -63,12 +63,12 @@ str8_lit_comp(
"\n"
"struct Vertex2Pixel\n"
"{\n"
" float4 position : SV_POSITION;\n"
" float4 position : SV_POSITION;\n"
" nointerpolation float2 rect_half_size_px : PSIZE;\n"
" float2 texcoord_pct : TEX;\n"
" float2 sdf_sample_pos : SDF;\n"
" float4 tint : TINT;\n"
" float corner_radius_px : CRAD;\n"
" float2 texcoord_pct : TEX;\n"
" float2 sdf_sample_pos : SDF;\n"
" float4 tint : TINT;\n"
" float corner_radius_px : CRAD;\n"
" nointerpolation float border_thickness_px : BTHC;\n"
" nointerpolation float softness_px : SFT;\n"
" nointerpolation float omit_texture : OTX;\n"
@@ -102,10 +102,10 @@ str8_lit_comp(
" //- rjf: prep per-vertex arrays to sample from (p: position, t: texcoord, c: colorcoord, r: cornerradius)\n"
" float2 dst_p_verts_px[] =\n"
" {\n"
" float2(dst_p0_px.x, viewport_size_px.y - dst_p1_px.y),\n"
" float2(dst_p0_px.x, viewport_size_px.y - dst_p0_px.y),\n"
" float2(dst_p1_px.x, viewport_size_px.y - dst_p1_px.y),\n"
" float2(dst_p1_px.x, viewport_size_px.y - dst_p0_px.y),\n"
" float2(dst_p0_px.x, dst_p1_px.y),\n"
" float2(dst_p0_px.x, dst_p0_px.y),\n"
" float2(dst_p1_px.x, dst_p1_px.y),\n"
" float2(dst_p1_px.x, dst_p0_px.y),\n"
" };\n"
" float2 src_p_verts_px[] =\n"
" {\n"
@@ -127,14 +127,15 @@ str8_lit_comp(
" cpu2vertex.color11,\n"
" cpu2vertex.color10,\n"
" };\n"
" float2 dst_verts_pct = float2(\n"
" (cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,\n"
" (cpu2vertex.vertex_id & 1) ? 0.f : 1.f);\n"
" float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,\n"
" (cpu2vertex.vertex_id & 1) ? 0.f : 1.f);\n"
" \n"
" // rjf: fill vertex -> pixel data\n"
" Vertex2Pixel vertex2pixel;\n"
" {\n"
" vertex2pixel.position.xy = 2.f * mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy / viewport_size_px - 1.f;\n"
" float2 xformed_pos = mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy;\n"
" xformed_pos.y = viewport_size_px.y - xformed_pos.y;\n"
" vertex2pixel.position.xy = 2.f * xformed_pos/viewport_size_px - 1.f;\n"
" vertex2pixel.position.z = 0.f;\n"
" vertex2pixel.position.w = 1.f;\n"
" vertex2pixel.rect_half_size_px = dst_size_px / 2.f * xform_scale;\n"
@@ -257,14 +258,14 @@ str8_lit_comp(
" corner_radii_px.z,\n"
" };\n"
" float2 cornercoords__pct = float2(\n"
" (c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
" (c2v.vertex_id & 1) ? 0.f : 1.f);\n"
"\n"
" (c2v.vertex_id >> 1) ? 1.f : 0.f,\n"
" (c2v.vertex_id & 1) ? 0.f : 1.f);\n"
" \n"
" float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;\n"
" float2 vertex_position__scr = 2.f * vertex_position__pct - 1.f;\n"
"\n"
" \n"
" float2 rect_half_size = float2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
"\n"
" \n"
" Vertex2Pixel v2p;\n"
" {\n"
" v2p.position = float4(vertex_position__scr.x, -vertex_position__scr.y, 0.f, 1.f);\n"
@@ -283,7 +284,7 @@ str8_lit_comp(
" // rjf: blend weighted texture samples into color\n"
" float4 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
" color.a = kernel[0].x;\n"
"\n"
" \n"
" for(uint i = 1; i < blur_count; i += 1)\n"
" {\n"
" float weight = kernel[i].x;\n"