From b410136b8347e6e9829fab1c4cd14dd7538b2b54 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Sat, 8 Aug 2026 13:37:08 +0200 Subject: [PATCH] add debug ui for collision grids --- CMakeLists.txt | 1 + src/main.cpp | 49 +++++++++-- src/renderer.h | 2 + src/renderer_sdlgpu.c | 119 +++++++++++++++++++++++++++ src/renderer_wgpu.c | 86 +++++++++++++++++++ src/shaders/spirv/collision_grid.spv | Bin 0 -> 2984 bytes src/shaders/src/collision_grid.slang | 53 ++++++++++++ src/shaders/wgsl/collision_grid.wgsl | 90 ++++++++++++++++++++ 8 files changed, 395 insertions(+), 5 deletions(-) create mode 100644 src/shaders/spirv/collision_grid.spv create mode 100644 src/shaders/src/collision_grid.slang create mode 100644 src/shaders/wgsl/collision_grid.wgsl diff --git a/CMakeLists.txt b/CMakeLists.txt index 53eebbc..a770ed0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,7 @@ add_shader(character_shadow) add_shader(world) add_shader(placeable) add_shader(grid) +add_shader(collision_grid) add_custom_target(shaders-spv DEPENDS ${SHADERS_SPV}) add_custom_target(shaders-wgsl DEPENDS ${SHADERS_WGSL}) diff --git a/src/main.cpp b/src/main.cpp index d114e0f..b51c21e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -91,6 +91,8 @@ static vec2 mouse_pos; static bool in_editor; static bool show_grid = true; +static bool show_static_collision_grid; +static bool show_water_collision_grid; static vec2 editor_camera_position; static float editor_camera_distance = 30.0f; @@ -206,6 +208,9 @@ struct Map { R_Texture texture; R_Buffer placeables_buffer; + + R_Texture debug_static_collision_grid_texture; + R_Texture debug_water_collision_grid_texture; }; static Uint32 num_loaded_maps; @@ -490,8 +495,11 @@ static void recalculate_static_collision_grid(Map *world) { for (int i = 0; i < world->num_placeables; i++) { u32vec2 pos = world->placeables[i].pos; - world->static_collision_grid[pos.y * (world->size.x - 2) + pos.x] = 1; + world->static_collision_grid[pos.y * (world->size.x - 1) + pos.x] = 1; } + + if (world->debug_static_collision_grid_texture) renderer_texture_destroy(world->debug_static_collision_grid_texture); + world->debug_static_collision_grid_texture = renderer_texture_create(R_TEXTURE_FORMAT_R8_UINT, R_TEXTURE_USAGE_STORAGE, false, world->size.x - 1, world->size.y - 1, world->static_collision_grid, "debug_static_collision_grid_texture"); } static void recalculate_water_collision_grid(Map *world) { @@ -500,15 +508,18 @@ static void recalculate_water_collision_grid(Map *world) { for (Sint32 y = 0; y < world->size.y - 2; y++){ for (Sint32 x = 0; x < world->size.x - 2; x++) { - Uint32 grid_corner_info = + Uint32 grid_corner_info = (get_corner_info(world, x + 0, y + 0) & (0xff << 16)) | (get_corner_info(world, x + 1, y + 0) & (0xff << 24)) | (get_corner_info(world, x + 0, y + 1) & (0xff << 8)) | (get_corner_info(world, x + 1, y + 1) & (0xff << 0)); - world->water_collision_grid[y * (world->size.x - 2) + x] = grid_corner_info == ((TILEKIND_WATER << 24) | (TILEKIND_WATER << 16) | (TILEKIND_WATER << 8) | (TILEKIND_WATER << 0)); + world->water_collision_grid[y * (world->size.x - 1) + x] = grid_corner_info == ((TILEKIND_WATER << 24) | (TILEKIND_WATER << 16) | (TILEKIND_WATER << 8) | (TILEKIND_WATER << 0)); } } + + if (world->debug_water_collision_grid_texture) renderer_texture_destroy(world->debug_water_collision_grid_texture); + world->debug_water_collision_grid_texture = renderer_texture_create(R_TEXTURE_FORMAT_R8_UINT, R_TEXTURE_USAGE_STORAGE, false, world->size.x - 1, world->size.y - 1, world->water_collision_grid, "debug_water_collision_grid_texture"); } static bool save_worlds_list() { @@ -1631,6 +1642,8 @@ static void update_state_editor() { ImGui::SetNextWindowPos({ viewport->WorkPos.x + viewport->WorkSize.x - 10.0f, viewport->WorkPos.y + 10.0f }, ImGuiCond_Always, { 1.0f, 0.0f }); if (ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { ImGui::Checkbox("Grid", &show_grid); + ImGui::Checkbox("Static Collision", &show_static_collision_grid); + ImGui::Checkbox("Water Collision", &show_water_collision_grid); } ImGui::End(); @@ -1762,6 +1775,32 @@ static void render_editor() { }); } + if (show_static_collision_grid) { + ZoneScopedN("Draw Static Collision Grid"); + + renderer_frame_set_shader(R_SHADER_COLLISION_GRID); + renderer_frame_draw(NULL, NULL, NULL, 4, (current_map->size.x - 1) * (current_map->size.y - 1), &(R_Draw_Resources){ + .vertex_storage_textures = (R_Texture[]){ current_map->debug_static_collision_grid_texture }, + .vertex_uniform_buffers = (R_Buffer[]){ view_projection_matrix_buffer, per_frame_buffer }, + + .num_vertex_storage_textures = 1, + .num_vertex_uniform_buffers = 2, + }); + } + + if (show_water_collision_grid) { + ZoneScopedN("Draw Water Collision Grid"); + + renderer_frame_set_shader(R_SHADER_COLLISION_GRID); + renderer_frame_draw(NULL, NULL, NULL, 4, (current_map->size.x - 1) * (current_map->size.y - 1), &(R_Draw_Resources){ + .vertex_storage_textures = (R_Texture[]){ current_map->debug_water_collision_grid_texture }, + .vertex_uniform_buffers = (R_Buffer[]){ view_projection_matrix_buffer, per_frame_buffer }, + + .num_vertex_storage_textures = 1, + .num_vertex_uniform_buffers = 2, + }); + } + { ZoneScopedN("ImGui Render"); ImGui::Render(); @@ -1783,10 +1822,10 @@ static bool try_queued_move() { } if (target_position != player.position) { - if (current_map->static_collision_grid[target_position.y * (current_map->size.x - 2) + target_position.x] == 1) + if (current_map->static_collision_grid[target_position.y * (current_map->size.x - 1) + target_position.x] == 1) return false; - if (current_map->water_collision_grid[target_position.y * (current_map->size.x - 2) + target_position.x] == 1) + if (current_map->water_collision_grid[target_position.y * (current_map->size.x - 1) + target_position.x] == 1) return false; player.target_position = target_position; diff --git a/src/renderer.h b/src/renderer.h index 4cf308e..9578014 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -13,6 +13,7 @@ typedef enum : Uint32 { R_SHADER_WORLD, R_SHADER_PLACEABLE, R_SHADER_GRID, + R_SHADER_COLLISION_GRID, R_SHADER_COUNT, } R_Shader; @@ -32,6 +33,7 @@ typedef enum : Uint32 { } R_Texture_Usage; typedef enum : Uint32 { + R_TEXTURE_FORMAT_R8_UINT, R_TEXTURE_FORMAT_R8_UNORM, R_TEXTURE_FORMAT_R16_UINT, R_TEXTURE_FORMAT_RGBA8_UNORM, diff --git a/src/renderer_sdlgpu.c b/src/renderer_sdlgpu.c index cc4f032..bdc25ba 100644 --- a/src/renderer_sdlgpu.c +++ b/src/renderer_sdlgpu.c @@ -41,6 +41,7 @@ static SDL_GPUSampler *bilinear_sampler; static SDL_GPUGraphicsPipeline *shaders[R_SHADER_COUNT]; static SDL_GPUTextureFormat texture_formats[] = { + [R_TEXTURE_FORMAT_R8_UINT] = SDL_GPU_TEXTUREFORMAT_R8_UINT, [R_TEXTURE_FORMAT_R8_UNORM] = SDL_GPU_TEXTUREFORMAT_R8_UNORM, [R_TEXTURE_FORMAT_R16_UINT] = SDL_GPU_TEXTUREFORMAT_R16_UINT, [R_TEXTURE_FORMAT_RGBA8_UNORM] = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, @@ -51,6 +52,7 @@ static SDL_GPUTextureFormat texture_formats[] = { static_assert(SDL_arraysize(texture_formats) == R_TEXTURE_FORMAT_COUNT); static Uint32 texel_sizes[] = { + [R_TEXTURE_FORMAT_R8_UINT] = 1, [R_TEXTURE_FORMAT_R8_UNORM] = 1, [R_TEXTURE_FORMAT_R16_UINT] = 2, [R_TEXTURE_FORMAT_RGBA8_UNORM] = 4, @@ -1058,6 +1060,123 @@ bool renderer_init(SDL_Window *window_) { SDL_ReleaseGPUShader(device, fragment_shader); } + { // Collision Grid + const Uint8 shader_source[] = { + #embed "shaders/spirv/collision_grid.spv" + }; + + SDL_GPUShader *vertex_shader = SDL_CreateGPUShader(device, &(SDL_GPUShaderCreateInfo){ + .code_size = sizeof(shader_source), + .code = shader_source, + .entrypoint = "main_vertex", + + .format = SDL_GPU_SHADERFORMAT_SPIRV, + .stage = SDL_GPU_SHADERSTAGE_VERTEX, + + .num_samplers = 0, + .num_storage_textures = 1, + .num_storage_buffers = 0, + .num_uniform_buffers = 2, + }); + + SDL_GPUShader *fragment_shader = SDL_CreateGPUShader(device, &(SDL_GPUShaderCreateInfo){ + .code_size = sizeof(shader_source), + .code = shader_source, + .entrypoint = "main_fragment", + + .format = SDL_GPU_SHADERFORMAT_SPIRV, + .stage = SDL_GPU_SHADERSTAGE_FRAGMENT, + + .num_samplers = 0, + .num_storage_textures = 0, + .num_storage_buffers = 0, + .num_uniform_buffers = 0, + }); + + SDL_PropertiesID properties = SDL_CreateProperties(); + SDL_SetStringProperty(properties, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, "R_SHADER collision_grid"); + + shaders[R_SHADER_COLLISION_GRID] = SDL_CreateGPUGraphicsPipeline(device, &(SDL_GPUGraphicsPipelineCreateInfo){ + .vertex_shader = vertex_shader, + .fragment_shader = fragment_shader, + + .vertex_input_state = { + .vertex_buffer_descriptions = (SDL_GPUVertexBufferDescription[]) {}, + .num_vertex_buffers = 0, + + .vertex_attributes = (SDL_GPUVertexAttribute[]) {}, + .num_vertex_attributes = 0, + }, + + .primitive_type = SDL_GPU_PRIMITIVETYPE_LINELIST, + + .rasterizer_state = { + .fill_mode = SDL_GPU_FILLMODE_FILL, + .cull_mode = SDL_GPU_CULLMODE_BACK, + .front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, + + .depth_bias_constant_factor = 0.0f, + .depth_bias_clamp = 0.0f, + .depth_bias_slope_factor = 0.0f, + + .enable_depth_bias = false, + .enable_depth_clip = false, + }, + + .multisample_state = { + .sample_count = SDL_GPU_SAMPLECOUNT_8, + .sample_mask = 0, + .enable_mask = 0, + + .enable_alpha_to_coverage = false, + }, + + .depth_stencil_state = { + .compare_op = SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, + + .back_stencil_state = { .fail_op = SDL_GPU_STENCILOP_INVALID, .pass_op = SDL_GPU_STENCILOP_INVALID, .depth_fail_op = SDL_GPU_STENCILOP_INVALID, .compare_op = SDL_GPU_COMPAREOP_INVALID, }, + .front_stencil_state = { .fail_op = SDL_GPU_STENCILOP_INVALID, .pass_op = SDL_GPU_STENCILOP_INVALID, .depth_fail_op = SDL_GPU_STENCILOP_INVALID, .compare_op = SDL_GPU_COMPAREOP_INVALID, }, + + .compare_mask = 0, + .write_mask = 0, + + .enable_depth_test = false, + .enable_depth_write = false, + .enable_stencil_test = false, + }, + + .target_info = { + .color_target_descriptions = (SDL_GPUColorTargetDescription[]){ + { + .format = texture_formats[surface.format], + .blend_state = { + .src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA, + .dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .color_blend_op = SDL_GPU_BLENDOP_ADD, + + .src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA, + .dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, + .alpha_blend_op = SDL_GPU_BLENDOP_ADD, + + .color_write_mask = 0, + + .enable_blend = true, + .enable_color_write_mask = false, + }, + } + }, + + .num_color_targets = 1, + + .depth_stencil_format = SDL_GPU_TEXTUREFORMAT_INVALID, + .has_depth_stencil_target = false, + }, + }); + SDL_DestroyProperties(properties); + SDL_ReleaseGPUShader(device, vertex_shader); + SDL_ReleaseGPUShader(device, fragment_shader); + } + for (int i = 0; i < R_SHADER_COUNT; i++) { SDL_assert(shaders[i]); } diff --git a/src/renderer_wgpu.c b/src/renderer_wgpu.c index 8e6f5d7..2ec5d0e 100644 --- a/src/renderer_wgpu.c +++ b/src/renderer_wgpu.c @@ -44,6 +44,7 @@ static R_Shader current_shader; static WGPUSampler bilinear_sampler; static WGPUTextureFormat texture_formats[] = { + [R_TEXTURE_FORMAT_R8_UINT] = WGPUTextureFormat_R8Uint, [R_TEXTURE_FORMAT_R8_UNORM] = WGPUTextureFormat_R8Unorm, [R_TEXTURE_FORMAT_R16_UINT] = WGPUTextureFormat_R16Uint, [R_TEXTURE_FORMAT_RGBA8_UNORM] = WGPUTextureFormat_RGBA8Unorm, @@ -54,6 +55,7 @@ static WGPUTextureFormat texture_formats[] = { static_assert(SDL_arraysize(texture_formats) == R_TEXTURE_FORMAT_COUNT); static Uint32 texel_sizes[] = { + [R_TEXTURE_FORMAT_R8_UINT] = 1, [R_TEXTURE_FORMAT_R8_UNORM] = 1, [R_TEXTURE_FORMAT_R16_UINT] = 2, [R_TEXTURE_FORMAT_RGBA8_UNORM] = 4, @@ -1163,6 +1165,90 @@ bool renderer_init(SDL_Window *window_) { wgpuShaderModuleRelease(shader); } + { // Collision Grid + const char shader_source[] = { + #embed "shaders/wgsl/collision_grid.wgsl" + }; + + WGPUShaderModule shader = wgpuDeviceCreateShaderModule(device, &(WGPUShaderModuleDescriptor){ + .nextInChain = (WGPUChainedStruct *)&(WGPUShaderSourceWGSL){ + .chain = { .next = NULL, .sType = WGPUSType_ShaderSourceWGSL }, + .code = { .data = shader_source, .length = SDL_arraysize(shader_source) }, + }, + .label = { .data = "collision_grid shader", .length = WGPU_STRLEN } + }); + + shaders[R_SHADER_COLLISION_GRID] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){ + .label = { .data = "collision_grid render_pipeline", .length = WGPU_STRLEN }, + + .layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){ + .label = { .data = "collision_grid pipeline_layout", .length = WGPU_STRLEN }, + .bindGroupLayoutCount = 4, + .bindGroupLayouts = (WGPUBindGroupLayout[]){ + wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){ + .entryCount = 1, + .entries = (WGPUBindGroupLayoutEntry[]){ + { .binding = 0, .visibility = WGPUShaderStage_Vertex, .texture = { .sampleType = WGPUTextureSampleType_Uint, .viewDimension = WGPUTextureViewDimension_2D } }, + }, + }), + wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){ + .entryCount = 2, + .entries = (WGPUBindGroupLayoutEntry[]){ + { .binding = 0, .visibility = WGPUShaderStage_Vertex, .buffer = { .type = WGPUBufferBindingType_Uniform } }, + { .binding = 1, .visibility = WGPUShaderStage_Vertex, .buffer = { .type = WGPUBufferBindingType_Uniform } }, + }, + }), + wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){ + .entryCount = 0, + .entries = (WGPUBindGroupLayoutEntry[]){}, + }), + wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){ + .entryCount = 0, + .entries = (WGPUBindGroupLayoutEntry[]){}, + }), + }, + }), + + .vertex = { + .module = shader, + .entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN }, + .constantCount = 0, + .constants = NULL, + .bufferCount = 0, + .buffers = (WGPUVertexBufferLayout[]){ + + }, + }, + + .primitive = { + .topology = WGPUPrimitiveTopology_LineList, + .stripIndexFormat = WGPUIndexFormat_Undefined, + .frontFace = WGPUFrontFace_CCW, + .cullMode = WGPUCullMode_Back, + .unclippedDepth = false, + }, + + .depthStencil = NULL, + + .multisample = { + .count = 4, + .mask = ~0u, + .alphaToCoverageEnabled = false, + }, + + .fragment = &(WGPUFragmentState){ + .module = shader, + .entryPoint = { .data = "main_fragment", .length = WGPU_STRLEN }, + .constantCount = 0, + .constants = NULL, + .targetCount = 1, + .targets = &color_target_state, + }, + }); + + wgpuShaderModuleRelease(shader); + } + for (int i = 0; i < R_SHADER_COUNT; i++) { SDL_assert(shaders[i]); } diff --git a/src/shaders/spirv/collision_grid.spv b/src/shaders/spirv/collision_grid.spv new file mode 100644 index 0000000000000000000000000000000000000000..faebc070e71db380d57cbfc413df26bd4767ddf6 GIT binary patch literal 2984 zcmZ{k`)?Fg6vqc@Yq3BqjQDS zvOnsR&b@}C7xMXT{#(^%J6=uFELn>h=u6-jcnb_id!px%ZIJub(`uuYv@`TgunrCo zS33zX>x+hv?$^(6A95>n-0k%Kj~k5M#;=m3@l0B6CGpj2R*idE?cBsW@B{p`J8Eo? zrJ9n!0P*GBtJPWQCCK3Gxf*G+7I*6PUXpF|-ayXZYu2*Gr~aO?Rqe(Fz3ty0{1=mE zV=>Fm^e$YNT)B#td-mgfE%_%SkQg_C((y7v@*$bz-!tS=wB? zTwm@~v$2V>iOF~?SA86D+)7&WN$NfHM}yIA->&a?vllOPmY18gB+c{NS^s{jXib~#?n?F_Z{rW;HGgLO@Giy)-!b;U zGvCZCugSON8+j9``_9zQ=6YXVQ}dc5N~rs3bVuNdcgXHGlW_i-!X@O;LOD{1>GJpe`8wf@*e8t z9PCx^&7uDiawONbbnEz3@5}4DzwotpgY6KRdd`!1_iml}DDwfhQE-gd=A~}FNBH;N zM}b4Td1&{{qv(5)u94UOaL#YV)_xS-J>}1$yY^+^7|UN;6rEr$CxXwb%o)E2AI~5s zf=_YJQ^ChOlM{hEQ|PV>+#Af*_47>jocVdC5l-w|loOuII|%SherxsB&sqcl*6v-| z*A8{ha~lM^`8R-P&~E-qCEfhjL5Q#aW?{d;8jd}{&RE)98*KJj*=D?8 zJGH~+9>I2Ihs}M1&3-G#bl-5+G3M4LoOPVJ+(+D-ee@o%R_B3hypIb&{wI9Y-!C|O z>~X<;z}#5c!d@RTFYk2;T`t7E%)A`;3c8$ee<|WlGIyP}3Y@(>4ct$goc;VUmOdnY%5c1M@> zL&&edG%%j}*TDC%!5Z~%fIjjSz5u?-Z-Ko1bqiP*`}+>CM{WY++3Qts2mFeUYv+NS zF? grid_texture; + +[shader("vertex")] +VertexShaderOutput main_vertex(VertexShaderInput input) { + var output: VertexShaderOutput; + + var vertex_pos = float2(0, 0); + + switch (input.vertex_index) { + case 0: { vertex_pos = float2(-0.5, -0.5); } break; + case 1: { vertex_pos = float2( 0.5, 0.5); } break; + case 2: { vertex_pos = float2( 0.5, -0.5); } break; + case 3: { vertex_pos = float2(-0.5, 0.5); } break; + default: {} + } + + let tile_pos = uint32_t2(input.instance_index % (per_frame.map_width - 1), input.instance_index / (per_frame.map_width - 1)); + + output.is_collider = grid_texture.Load(uint32_t3(tile_pos, 0)); + output.pos = mul(float4(tile_pos + vertex_pos, 0, 1), view_projection_matrix); + + return output; +} + +[shader("pixel")] +FragmentShaderOutput main_fragment(VertexShaderOutput input) { + var output: FragmentShaderOutput; + + output.color = input.is_collider != 0 ? float4(1, 0, 0, 1) : float4(0, 0, 0, 0); + + return output; +} diff --git a/src/shaders/wgsl/collision_grid.wgsl b/src/shaders/wgsl/collision_grid.wgsl new file mode 100644 index 0000000..11ee127 --- /dev/null +++ b/src/shaders/wgsl/collision_grid.wgsl @@ -0,0 +1,90 @@ +struct Per_Frame_Data_std140_0 +{ + @align(16) drag_start_0 : vec2, + @align(8) mouse_0 : vec2, + @align(16) grid_offset_0 : vec2, + @align(8) grid_width_0 : u32, + @align(4) map_width_0 : u32, + @align(16) grid_height_0 : u32, +}; + +@binding(1) @group(1) var per_frame_0 : Per_Frame_Data_std140_0; +@binding(0) @group(0) var grid_texture_0 : texture_2d; + +struct _MatrixStorage_float4x4_ColMajorstd140_0 +{ + @align(16) data_0 : array, i32(4)>, +}; + +@binding(0) @group(1) var view_projection_matrix_0 : _MatrixStorage_float4x4_ColMajorstd140_0; +struct VertexShaderOutput_0 +{ + @builtin(position) pos_0 : vec4, + @location(0) is_collider_0 : u32, +}; + +@vertex +fn main_vertex(@builtin(vertex_index) vertex_index_0 : u32, @builtin(instance_index) instance_index_0 : u32) -> VertexShaderOutput_0 +{ + var output_0 : VertexShaderOutput_0; + const _S1 : vec2 = vec2(0.0f, 0.0f); + var vertex_pos_0 : vec2; + switch(vertex_index_0) + { + case u32(0): + { + vertex_pos_0 = vec2(-0.5f, -0.5f); + } + case u32(1): + { + vertex_pos_0 = vec2(0.5f, 0.5f); + } + case u32(2): + { + vertex_pos_0 = vec2(0.5f, -0.5f); + } + case u32(3): + { + vertex_pos_0 = vec2(-0.5f, 0.5f); + } + default : + { + vertex_pos_0 = _S1; + } + } + var _S2 : u32 = instance_index_0 % (per_frame_0.map_width_0 - u32(1)); + var _S3 : u32 = instance_index_0 / (per_frame_0.map_width_0 - u32(1)); + var _S4 : vec2 = vec2(_S2, _S3); + var _S5 : vec3 = vec3(vec3(_S4, u32(0))); + output_0.is_collider_0 = (textureLoad((grid_texture_0), ((_S5)).xy, ((_S5)).z).x); + output_0.pos_0 = (((mat4x4(view_projection_matrix_0.data_0[i32(0)][i32(0)], view_projection_matrix_0.data_0[i32(1)][i32(0)], view_projection_matrix_0.data_0[i32(2)][i32(0)], view_projection_matrix_0.data_0[i32(3)][i32(0)], view_projection_matrix_0.data_0[i32(0)][i32(1)], view_projection_matrix_0.data_0[i32(1)][i32(1)], view_projection_matrix_0.data_0[i32(2)][i32(1)], view_projection_matrix_0.data_0[i32(3)][i32(1)], view_projection_matrix_0.data_0[i32(0)][i32(2)], view_projection_matrix_0.data_0[i32(1)][i32(2)], view_projection_matrix_0.data_0[i32(2)][i32(2)], view_projection_matrix_0.data_0[i32(3)][i32(2)], view_projection_matrix_0.data_0[i32(0)][i32(3)], view_projection_matrix_0.data_0[i32(1)][i32(3)], view_projection_matrix_0.data_0[i32(2)][i32(3)], view_projection_matrix_0.data_0[i32(3)][i32(3)])) * (vec4(vec2(_S4) + vertex_pos_0, 0.0f, 1.0f)))); + return output_0; +} + +struct FragmentShaderOutput_0 +{ + @location(0) color_0 : vec4, +}; + +struct pixelInput_0 +{ + @location(0) is_collider_1 : u32, +}; + +@fragment +fn main_fragment( _S6 : pixelInput_0, @builtin(position) pos_1 : vec4) -> FragmentShaderOutput_0 +{ + var output_1 : FragmentShaderOutput_0; + var _S7 : vec4; + if((_S6.is_collider_1) != u32(0)) + { + _S7 = vec4(1.0f, 0.0f, 0.0f, 1.0f); + } + else + { + _S7 = vec4(0.0f, 0.0f, 0.0f, 0.0f); + } + output_1.color_0 = _S7; + return output_1; +} +