fix flipped y transform application in upgraded shader

This commit is contained in:
Ryan Fleury
2024-01-23 12:50:26 -08:00
parent 37a0d9e148
commit 4e561b1b38
3 changed files with 41 additions and 39 deletions
+1 -1
View File
@@ -8232,7 +8232,7 @@ df_box_equip_fuzzy_match_range_list_vis(UI_Box *box, DF_FuzzyMatchRangeList rang
f_dim_from_tag_size_string(box->font, box->font_size, str8_prefix(display_string, match_n->range.max)).x,
};
ui_set_next_fixed_x(match_pixel_range.min + box->text_padding + 2.f);
ui_set_next_fixed_y(box->font_size/4.f);
ui_set_next_fixed_y(box->font_size/2.f);
ui_set_next_fixed_width(match_pixel_range.max-match_pixel_range.min);
ui_set_next_fixed_height(line_height*1.2f);
ui_set_next_corner_radius_00(box->font_size/2.f);
+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"
+20 -19
View File
@@ -62,12 +62,12 @@ struct CPU2Vertex
struct Vertex2Pixel
{
float4 position : SV_POSITION;
float4 position : SV_POSITION;
nointerpolation float2 rect_half_size_px : PSIZE;
float2 texcoord_pct : TEX;
float2 sdf_sample_pos : SDF;
float4 tint : TINT;
float corner_radius_px : CRAD;
float2 texcoord_pct : TEX;
float2 sdf_sample_pos : SDF;
float4 tint : TINT;
float corner_radius_px : CRAD;
nointerpolation float border_thickness_px : BTHC;
nointerpolation float softness_px : SFT;
nointerpolation float omit_texture : OTX;
@@ -101,10 +101,10 @@ vs_main(CPU2Vertex cpu2vertex)
//- rjf: prep per-vertex arrays to sample from (p: position, t: texcoord, c: colorcoord, r: cornerradius)
float2 dst_p_verts_px[] =
{
float2(dst_p0_px.x, viewport_size_px.y - dst_p1_px.y),
float2(dst_p0_px.x, viewport_size_px.y - dst_p0_px.y),
float2(dst_p1_px.x, viewport_size_px.y - dst_p1_px.y),
float2(dst_p1_px.x, viewport_size_px.y - dst_p0_px.y),
float2(dst_p0_px.x, dst_p1_px.y),
float2(dst_p0_px.x, dst_p0_px.y),
float2(dst_p1_px.x, dst_p1_px.y),
float2(dst_p1_px.x, dst_p0_px.y),
};
float2 src_p_verts_px[] =
{
@@ -126,14 +126,15 @@ vs_main(CPU2Vertex cpu2vertex)
cpu2vertex.color11,
cpu2vertex.color10,
};
float2 dst_verts_pct = float2(
(cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,
(cpu2vertex.vertex_id & 1) ? 0.f : 1.f);
float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,
(cpu2vertex.vertex_id & 1) ? 0.f : 1.f);
// rjf: fill vertex -> pixel data
Vertex2Pixel vertex2pixel;
{
vertex2pixel.position.xy = 2.f * mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy / viewport_size_px - 1.f;
float2 xformed_pos = mul(xform, float3(dst_p_verts_px[cpu2vertex.vertex_id], 1.f)).xy;
xformed_pos.y = viewport_size_px.y - xformed_pos.y;
vertex2pixel.position.xy = 2.f * xformed_pos/viewport_size_px - 1.f;
vertex2pixel.position.z = 0.f;
vertex2pixel.position.w = 1.f;
vertex2pixel.rect_half_size_px = dst_size_px / 2.f * xform_scale;
@@ -256,14 +257,14 @@ vs_main(CPU2Vertex c2v)
corner_radii_px.z,
};
float2 cornercoords__pct = float2(
(c2v.vertex_id >> 1) ? 1.f : 0.f,
(c2v.vertex_id & 1) ? 0.f : 1.f);
(c2v.vertex_id >> 1) ? 1.f : 0.f,
(c2v.vertex_id & 1) ? 0.f : 1.f);
float2 vertex_position__pct = vertex_positions__scrn[c2v.vertex_id] / viewport_size;
float2 vertex_position__scr = 2.f * vertex_position__pct - 1.f;
float2 rect_half_size = float2((rect.z-rect.x)/2, (rect.w-rect.y)/2);
Vertex2Pixel v2p;
{
v2p.position = float4(vertex_position__scr.x, -vertex_position__scr.y, 0.f, 1.f);
@@ -282,7 +283,7 @@ ps_main(Vertex2Pixel v2p) : SV_TARGET
// rjf: blend weighted texture samples into color
float4 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord);
color.a = kernel[0].x;
for(uint i = 1; i < blur_count; i += 1)
{
float weight = kernel[i].x;