fix grid offset
This commit is contained in:
parent
a5111c5b51
commit
9549897e6b
@ -34,17 +34,15 @@ ps_input vs_main(vs_input input)
|
||||
|
||||
float4 ps_main(ps_input input) : SV_TARGET
|
||||
{
|
||||
float2 screen_pos = input.screen_pos.xy;
|
||||
float2 screen_pos = input.screen_pos.xy + input.offset;
|
||||
float thickness = input.line_thickness;
|
||||
float spacing = input.line_spacing;
|
||||
float2 offset = input.offset;
|
||||
float4 color = 0;
|
||||
|
||||
float xmod = fmod(abs(screen_pos.x + offset.x), spacing);
|
||||
float ymod = fmod(abs(screen_pos.y + offset.y), spacing);
|
||||
float2 v = abs(round(screen_pos / spacing) * spacing - screen_pos);
|
||||
float dist = min(v.x, v.y);
|
||||
|
||||
bool should_draw = (xmod < thickness || xmod > spacing - thickness) || (ymod < thickness || ymod > spacing - thickness);
|
||||
|
||||
float4 color = input.col * should_draw;
|
||||
color = input.col * step(dist, thickness / 2);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -872,10 +872,10 @@ INTERNAL void user_update(void)
|
||||
* ========================== */
|
||||
|
||||
{
|
||||
f32 thickness = 1;
|
||||
f32 thickness = 2;
|
||||
u32 color = RGBA_32(0x3f, 0x3f, 0x3f, 0xFF);
|
||||
|
||||
struct v2 offset = v2_neg(G.world_view.og);
|
||||
struct v2 offset = v2_sub(v2_neg(xform_mul_v2(G.world_view, V2(0, 0))), G.viewport_screen_offset);
|
||||
f32 spacing = xform_get_scale(G.world_view).x;
|
||||
|
||||
draw_grid(G.viewport_bg_canvas, RECT(0, 0, G.viewport_size.x, G.viewport_size.y), color, thickness, spacing, offset);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user