backdrop shader

This commit is contained in:
jacob 2025-12-16 15:11:36 -06:00
parent 778651411a
commit 7a40b0bff2
5 changed files with 58 additions and 2 deletions

View File

@ -91,6 +91,7 @@ void AsyncWorkerEntryPoint(WaveLaneCtx *lane)
//- End tick //- End tick
WaveSync(lane); WaveSync(lane);
ResetArena(tick.arena); ResetArena(tick.arena);
{ {
Arena *tick_arena = tick.arena; Arena *tick_arena = tick.arena;

View File

@ -147,7 +147,7 @@ void V_TickForever(WaveLaneCtx *lane)
////////////////////////////// //////////////////////////////
//- Spawn test ents //- Spawn test ents
if (V.world->tick == 1) if (frame->tick == 1)
{ {
S_Key child_key = S_RandKey(); S_Key child_key = S_RandKey();
S_Key camera_key = S_RandKey(); S_Key camera_key = S_RandKey();
@ -615,8 +615,13 @@ void V_TickForever(WaveLaneCtx *lane)
params.target_ro = draw_target_ro; params.target_ro = draw_target_ro;
params.target_rw = draw_target_rw; params.target_rw = draw_target_rw;
params.shape_verts = dverts_ro; params.shape_verts = dverts_ro;
params.world_to_draw_xf = world_to_draw_xf;
params.target_cursor_pos = draw_cursor; params.target_cursor_pos = draw_cursor;
params.background_color_a = LinearFromSrgb(VEC4(0.30, 0.30, 0.30, 1));
params.background_color_b = LinearFromSrgb(VEC4(0.15, 0.15, 0.15, 1));
params.world_to_draw_xf = world_to_draw_xf;
params.draw_to_world_xf = draw_to_world_xf;
} }
G_ResourceHandle params_buff = G_PushBufferFromString(frame->gpu_arena, frame->cl, StringFromStruct(&params)); G_ResourceHandle params_buff = G_PushBufferFromString(frame->gpu_arena, frame->cl, StringFromStruct(&params));
G_StructuredBufferRef params_ro = G_PushStructuredBufferRef(frame->gpu_arena, params_buff, V_DParams); G_StructuredBufferRef params_ro = G_PushStructuredBufferRef(frame->gpu_arena, params_buff, V_DParams);

View File

@ -13,7 +13,12 @@ Struct(V_DParams)
G_StructuredBufferRef shape_verts; G_StructuredBufferRef shape_verts;
Vec2 target_cursor_pos; Vec2 target_cursor_pos;
Vec4 background_color_a;
Vec4 background_color_b;
Xform world_to_draw_xf; Xform world_to_draw_xf;
Xform draw_to_world_xf;
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -12,6 +12,50 @@ ComputeShader2D(V_BackdropCS, 8, 8)
{ {
Vec4 result = Vec4(0.05, 0.05, 0.05, 1); Vec4 result = Vec4(0.05, 0.05, 0.05, 1);
/* Checkered square color */
{
i32 color_idx = 0;
Vec4 colors[2] = {
params.background_color_a,
params.background_color_b
};
Vec2 world_pos = mul(params.draw_to_world_xf, Vec3(target_pos, 1));
Vec2 world_pos_modded = fmod(abs(world_pos), Vec2(2, 2));
if (world_pos_modded.x < 1)
{
color_idx = !color_idx;
}
if (world_pos_modded.y < 1)
{
color_idx = !color_idx;
}
if (world_pos.x < 0)
{
color_idx = !color_idx;
}
if (world_pos.y < 0)
{
color_idx = !color_idx;
}
result = colors[color_idx];
}
/* Axis color */
{
f32 thickness = 2;
Vec2 zero_screen = mul(params.world_to_draw_xf, Vec3(0, 0, 1));
f32 x_dist = abs(target_pos.x - zero_screen.x);
f32 y_dist = abs(target_pos.y - zero_screen.y);
if (y_dist <= (thickness * 0.5))
{
result = Color_Red;
}
else if (x_dist <= (thickness * 0.5))
{
result = Color_Green;
}
}
target[target_pos] = result; target[target_pos] = result;
} }
} }

View File

@ -54,6 +54,7 @@ String V_StringFromHotkey(Arena *arena, V_Hotkey hotkey)
PushStringToList(scratch.arena, &parts, Lit("Shift")); PushStringToList(scratch.arena, &parts, Lit("Shift"));
} }
PushStringToList(scratch.arena, &parts, StringFromButton(hotkey.button)); PushStringToList(scratch.arena, &parts, StringFromButton(hotkey.button));
EndScratch(scratch);
return StringFromList(arena, parts, Lit(" + ")); return StringFromList(arena, parts, Lit(" + "));
} }