Compare commits

...

23 Commits

Author SHA1 Message Date
Sven Balzer ecd6571785 rename Tree to placeable and dynamically load size
buildbot/windows Build done.
buildbot/linux Build done.
add stone variants as placeables
2026-08-06 19:45:47 +02:00
Sven Balzer ff82f59fdf add world list editor
buildbot/windows Build done.
buildbot/linux Build done.
change default tree ti tree_standard_tile_angle.png
2026-08-06 18:20:04 +02:00
Sven Balzer 963ccc4ec8 change rendering offsets for character, character shadow and trees
buildbot/windows Build done.
buildbot/linux Build done.
change default camera tilt
2026-08-05 21:50:13 +02:00
Sven Balzer 4c158f25f0 add trees into the game
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-05 20:48:57 +02:00
Sven Balzer 6a984b40d9 remove vertex_buffer and index_buffer for characters and character shadows
refactor world shader vertex position calculation
2026-08-05 20:48:57 +02:00
Ammerhai 74d55cb087 update female character sprite sheet
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-05 20:39:59 +02:00
Ammerhai 8f277c4d08 add correct tree angle
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-05 20:39:09 +02:00
Sven Balzer 3366008d59 replace placeholder character with female
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-03 18:36:40 +02:00
Ammerhai e49683eb7b update tree again
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-03 18:34:49 +02:00
Ammerhai d04e231f4d update tree
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-03 18:28:41 +02:00
Ammerhai 198ed44bbf add character female
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-03 18:28:14 +02:00
Sven Balzer 7fe5419b02 fix leak of frame_fence in sdlgpu renderer
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-03 17:32:57 +02:00
Sven Balzer 6aa530daea rename basic shader to character
buildbot/windows Build done.
buildbot/linux Build done.
add character shadow
make animation play twice as fast when sprinting
2026-08-03 13:32:52 +02:00
Ammerhai 4f4ec3cfd5 remove map layout
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-02 13:20:08 +02:00
Sven Balzer e5cc22cb95 also respect arrow keys for continuous movement
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-02 13:06:37 +02:00
Ammerhai b9eb121663 add last tile and tree
buildbot/windows Build done.
buildbot/linux Build done.
add water starter

#8
2026-08-02 12:56:13 +02:00
Sven Balzer f72ca9def5 add basic animation
buildbot/windows Build done.
buildbot/linux Build done.
2026-08-02 12:40:24 +02:00
Sven Balzer 70fac5bd72 fix clamping character movement to map boundaries 2026-08-02 10:57:59 +02:00
Ammerhai ab79875263 remove placeholder tiles
buildbot/windows Build done.
#8
2026-08-01 20:23:42 +02:00
Ammerhai 3a012fc564 fix incorrect tile corner infos
#8
2026-08-01 20:09:47 +02:00
Ammerhai bd727a6505 add correct tile values
#8
2026-08-01 19:39:07 +02:00
Ammerhai da801d1937 add region map day/night
add first two starter mons

- fire/feuer
- grass/pflanze
2026-08-01 19:38:10 +02:00
Ammerhai 1b03990f92 add new tiles and change paths to new ones
#8
2026-08-01 19:37:41 +02:00
65 changed files with 1654 additions and 295 deletions
+3 -1
View File
@@ -105,8 +105,10 @@ function(add_shader name)
set(SHADERS_WGSL ${SHADERS_WGSL} "${CMAKE_CURRENT_SOURCE_DIR}/src/shaders/wgsl/${name}.wgsl" PARENT_SCOPE)
endfunction()
add_shader(basic)
add_shader(character)
add_shader(character_shadow)
add_shader(world)
add_shader(placeable)
add_shader(grid)
add_custom_target(shaders-spv DEPENDS ${SHADERS_SPV})
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
#ifndef WORLDS_H
#define WORLDS_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
static const char *world_names[] = {
"map",
};
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // WORLDS_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.
+582 -171
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -8,8 +8,10 @@ extern "C" {
#endif // __cplusplus
typedef enum : Uint32 {
R_SHADER_BASIC,
R_SHADER_CHARACTER,
R_SHADER_CHARACTER_SHADOW,
R_SHADER_WORLD,
R_SHADER_PLACEABLE,
R_SHADER_GRID,
R_SHADER_COUNT,
} R_Shader;
+283 -34
View File
@@ -287,6 +287,7 @@ void renderer_frame_end() {
SDL_GPUFence *frame_fence = SDL_SubmitGPUCommandBufferAndAcquireFence(render_command_buffer);
SDL_WaitForGPUFences(device, true, &frame_fence, 1);
SDL_ReleaseGPUFence(device, frame_fence);
copy_command_buffer = SDL_AcquireGPUCommandBuffer(device);
render_command_buffer = SDL_AcquireGPUCommandBuffer(device);
@@ -342,8 +343,8 @@ void renderer_frame_draw(R_Buffer vertex_buffer, R_Buffer index_buffer, R_Buffer
for (int i = 0; i < resources->num_fragment_storage_buffers; i++) SDL_BindGPUFragmentStorageBuffers(render_pass, i, &resources->fragment_storage_buffers[i]->buffer, 1);
for (int i = 0; i < resources->num_fragment_uniform_buffers; i++) SDL_PushGPUFragmentUniformData(render_command_buffer, i, resources->fragment_uniform_buffers[i]->cpu_uniform_data, resources->fragment_uniform_buffers[i]->num_bytes);
if (vertex_buffer) SDL_BindGPUVertexBuffers(render_pass, 0, &(SDL_GPUBufferBinding){ .buffer = vertex_buffer->buffer, .offset = 0 }, 1);
if (instance_buffer) SDL_BindGPUVertexBuffers(render_pass, 1, &(SDL_GPUBufferBinding){ .buffer = instance_buffer->buffer, .offset = 0 }, 1);
if (vertex_buffer) SDL_BindGPUVertexBuffers(render_pass, 0, &(SDL_GPUBufferBinding){ .buffer = vertex_buffer->buffer, .offset = 0 }, 1);
if (instance_buffer) SDL_BindGPUVertexBuffers(render_pass, vertex_buffer ? 1 : 0, &(SDL_GPUBufferBinding){ .buffer = instance_buffer->buffer, .offset = 0 }, 1);
if (index_buffer) {
SDL_BindGPUIndexBuffer(render_pass, &(SDL_GPUBufferBinding){ .buffer = index_buffer->buffer, .offset = 0 }, SDL_GPU_INDEXELEMENTSIZE_16BIT);
@@ -409,9 +410,9 @@ bool renderer_init(SDL_Window *window_) {
});
// Shaders
{ // Basic
{ // Character
const Uint8 shader_source[] = {
#embed "shaders/spirv/basic.spv"
#embed "shaders/spirv/character.spv"
};
SDL_GPUShader *vertex_shader = SDL_CreateGPUShader(device, &(SDL_GPUShaderCreateInfo){
@@ -443,9 +444,9 @@ bool renderer_init(SDL_Window *window_) {
});
SDL_PropertiesID properties = SDL_CreateProperties();
SDL_SetStringProperty(properties, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, "R_SHADER basic");
SDL_SetStringProperty(properties, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, "R_SHADER character");
shaders[R_SHADER_BASIC] = SDL_CreateGPUGraphicsPipeline(device, &(SDL_GPUGraphicsPipelineCreateInfo){
shaders[R_SHADER_CHARACTER] = SDL_CreateGPUGraphicsPipeline(device, &(SDL_GPUGraphicsPipelineCreateInfo){
.vertex_shader = vertex_shader,
.fragment_shader = fragment_shader,
@@ -453,42 +454,167 @@ bool renderer_init(SDL_Window *window_) {
.vertex_buffer_descriptions = (SDL_GPUVertexBufferDescription[]){
{
.slot = 0,
.pitch = 20,
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
.instance_step_rate = 0,
},
{
.slot = 1,
.pitch = 8,
.pitch = 12,
.input_rate = SDL_GPU_VERTEXINPUTRATE_INSTANCE,
.instance_step_rate = 0,
},
},
.num_vertex_buffers = 2,
.num_vertex_buffers = 1,
.vertex_attributes = (SDL_GPUVertexAttribute[]){
{
.location = 0,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
.offset = 0,
},
{
.location = 1,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
.offset = 12,
},
{
.location = 2,
.buffer_slot = 1,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
.offset = 0,
},
{
.location = 3,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_UINT,
.offset = 8,
},
},
.num_vertex_attributes = 3,
.num_vertex_attributes = 2,
},
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
.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);
}
{ // Character Shadow
const Uint8 shader_source[] = {
#embed "shaders/spirv/character_shadow.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 = 0,
.num_storage_buffers = 0,
.num_uniform_buffers = 1,
});
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 = 1,
.num_storage_textures = 0,
.num_storage_buffers = 0,
.num_uniform_buffers = 1,
});
SDL_PropertiesID properties = SDL_CreateProperties();
SDL_SetStringProperty(properties, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, "R_SHADER character_shadow");
shaders[R_SHADER_CHARACTER_SHADOW] = SDL_CreateGPUGraphicsPipeline(device, &(SDL_GPUGraphicsPipelineCreateInfo){
.vertex_shader = vertex_shader,
.fragment_shader = fragment_shader,
.vertex_input_state = {
.vertex_buffer_descriptions = (SDL_GPUVertexBufferDescription[]){
{
.slot = 0,
.pitch = 12,
.input_rate = SDL_GPU_VERTEXINPUTRATE_INSTANCE,
.instance_step_rate = 0,
},
},
.num_vertex_buffers = 1,
.vertex_attributes = (SDL_GPUVertexAttribute[]){
{
.location = 2,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
.offset = 0,
},
{
.location = 3,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_UINT,
.offset = 8,
},
},
.num_vertex_attributes = 2,
},
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
@@ -600,12 +726,129 @@ bool renderer_init(SDL_Window *window_) {
.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_TRIANGLELIST,
.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);
}
{ // Placeable
const Uint8 shader_source[] = {
#embed "shaders/spirv/placeable.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 = 0,
.num_storage_buffers = 1,
.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 = 1,
.num_storage_textures = 0,
.num_storage_buffers = 1,
.num_uniform_buffers = 1,
});
SDL_PropertiesID properties = SDL_CreateProperties();
SDL_SetStringProperty(properties, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, "R_SHADER placeable");
shaders[R_SHADER_PLACEABLE] = SDL_CreateGPUGraphicsPipeline(device, &(SDL_GPUGraphicsPipelineCreateInfo){
.vertex_shader = vertex_shader,
.fragment_shader = fragment_shader,
.vertex_input_state = {
.vertex_buffer_descriptions = (SDL_GPUVertexBufferDescription[]){
{
.slot = 0,
.pitch = 20,
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
.pitch = 12,
.input_rate = SDL_GPU_VERTEXINPUTRATE_INSTANCE,
.instance_step_rate = 0,
},
@@ -616,11 +859,17 @@ bool renderer_init(SDL_Window *window_) {
{
.location = 0,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
.format = SDL_GPU_VERTEXELEMENTFORMAT_UINT2,
.offset = 0,
},
{
.location = 1,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_UINT,
.offset = 8,
},
},
.num_vertex_attributes = 1,
.num_vertex_attributes = 2,
},
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
@@ -815,7 +1064,7 @@ bool renderer_init(SDL_Window *window_) {
transfer_buffer = SDL_CreateGPUTransferBuffer(device, &(SDL_GPUTransferBufferCreateInfo){
.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
.size = 64 * 1024,
.size = 512 * 1024,
});
copy_command_buffer = SDL_AcquireGPUCommandBuffer(device);
+226 -28
View File
@@ -475,8 +475,8 @@ void renderer_frame_draw(R_Buffer vertex_buffer, R_Buffer index_buffer, R_Buffer
wgpuRenderPassEncoderSetBindGroup(pass_encoder, 3, NULL, 0, NULL);
}
if (vertex_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 0, vertex_buffer->buffer, 0, WGPU_WHOLE_SIZE);
if (instance_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 1, instance_buffer->buffer, 0, WGPU_WHOLE_SIZE);
if (vertex_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 0, vertex_buffer->buffer, 0, WGPU_WHOLE_SIZE);
if (instance_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, vertex_buffer ? 1 : 0, instance_buffer->buffer, 0, WGPU_WHOLE_SIZE);
if (index_buffer) {
wgpuRenderPassEncoderSetIndexBuffer(pass_encoder, index_buffer->buffer, WGPUIndexFormat_Uint16, 0, WGPU_WHOLE_SIZE);
@@ -673,9 +673,9 @@ bool renderer_init(SDL_Window *window_) {
};
// Shaders
{ // Basic
{ // Character
const char shader_source[] = {
#embed "shaders/wgsl/basic.wgsl"
#embed "shaders/wgsl/character.wgsl"
};
WGPUShaderModule shader = wgpuDeviceCreateShaderModule(device, &(WGPUShaderModuleDescriptor){
@@ -683,14 +683,14 @@ bool renderer_init(SDL_Window *window_) {
.chain = { .next = NULL, .sType = WGPUSType_ShaderSourceWGSL },
.code = { .data = shader_source, .length = SDL_arraysize(shader_source) },
},
.label = { .data = "basic shader", .length = WGPU_STRLEN }
.label = { .data = "character shader", .length = WGPU_STRLEN }
});
shaders[R_SHADER_BASIC] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
.label = { .data = "basic render_pipeline", .length = WGPU_STRLEN },
shaders[R_SHADER_CHARACTER] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
.label = { .data = "character render_pipeline", .length = WGPU_STRLEN },
.layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){
.label = { .data = "basic pipeline_layout", .length = WGPU_STRLEN },
.label = { .data = "character pipeline_layout", .length = WGPU_STRLEN },
.bindGroupLayoutCount = 4,
.bindGroupLayouts = (WGPUBindGroupLayout[]){
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
@@ -726,35 +726,127 @@ bool renderer_init(SDL_Window *window_) {
.entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN },
.constantCount = 0,
.constants = NULL,
.bufferCount = 2,
.bufferCount = 1,
.buffers = (WGPUVertexBufferLayout[]){
{
.stepMode = WGPUVertexStepMode_Vertex,
.arrayStride = 20,
.attributeCount = 2,
.attributes = (WGPUVertexAttribute[]){
{
.format = WGPUVertexFormat_Float32x3,
.offset = 0,
.shaderLocation = 0,
},
{
.format = WGPUVertexFormat_Float32x2,
.offset = 12,
.shaderLocation = 1,
},
},
},
{
.stepMode = WGPUVertexStepMode_Instance,
.arrayStride = 8,
.attributeCount = 1,
.arrayStride = 12,
.attributeCount = 2,
.attributes = (WGPUVertexAttribute[]){
{
.format = WGPUVertexFormat_Float32x2,
.offset = 0,
.shaderLocation = 2,
},
{
.format = WGPUVertexFormat_Uint32,
.offset = 8,
.shaderLocation = 3,
},
},
},
},
},
.primitive = {
.topology = WGPUPrimitiveTopology_TriangleList,
.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);
}
{ // Character Shadow
const char shader_source[] = {
#embed "shaders/wgsl/character_shadow.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 = "character_shadow shader", .length = WGPU_STRLEN }
});
shaders[R_SHADER_CHARACTER_SHADOW] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
.label = { .data = "character_shadow render_pipeline", .length = WGPU_STRLEN },
.layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){
.label = { .data = "character_shadow pipeline_layout", .length = WGPU_STRLEN },
.bindGroupLayoutCount = 4,
.bindGroupLayouts = (WGPUBindGroupLayout[]){
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 0,
.entries = (WGPUBindGroupLayoutEntry[]){
},
}),
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 1,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Vertex, .buffer = { .type = WGPUBufferBindingType_Uniform } },
},
}),
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 2,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Fragment, .texture = { .sampleType = WGPUTextureSampleType_Float, .viewDimension = WGPUTextureViewDimension_2D } },
{ .binding = 1, .visibility = WGPUShaderStage_Fragment, .sampler = { .type = WGPUSamplerBindingType_Filtering } },
},
}),
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 1,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Fragment, .buffer = { .type = WGPUBufferBindingType_Uniform } },
},
}),
},
}),
.vertex = {
.module = shader,
.entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN },
.constantCount = 0,
.constants = NULL,
.bufferCount = 1,
.buffers = (WGPUVertexBufferLayout[]){
{
.stepMode = WGPUVertexStepMode_Instance,
.arrayStride = 12,
.attributeCount = 2,
.attributes = (WGPUVertexAttribute[]){
{
.format = WGPUVertexFormat_Float32x2,
.offset = 0,
.shaderLocation = 2,
},
{
.format = WGPUVertexFormat_Uint32,
.offset = 8,
.shaderLocation = 3,
},
},
},
},
@@ -879,6 +971,112 @@ bool renderer_init(SDL_Window *window_) {
wgpuShaderModuleRelease(shader);
}
{ // Placeable
const char shader_source[] = {
#embed "shaders/wgsl/placeable.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 = "placeable shader", .length = WGPU_STRLEN }
});
shaders[R_SHADER_PLACEABLE] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
.label = { .data = "placeable render_pipeline", .length = WGPU_STRLEN },
.layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){
.label = { .data = "placeable pipeline_layout", .length = WGPU_STRLEN },
.bindGroupLayoutCount = 4,
.bindGroupLayouts = (WGPUBindGroupLayout[]){
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 1,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Vertex, .buffer = { .type = WGPUBufferBindingType_ReadOnlyStorage } },
},
}),
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 = 3,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Fragment, .texture = { .sampleType = WGPUTextureSampleType_Float, .viewDimension = WGPUTextureViewDimension_2D } },
{ .binding = 1, .visibility = WGPUShaderStage_Fragment, .sampler = { .type = WGPUSamplerBindingType_Filtering } },
{ .binding = 2, .visibility = WGPUShaderStage_Fragment, .buffer = { .type = WGPUBufferBindingType_ReadOnlyStorage } },
},
}),
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
.entryCount = 1,
.entries = (WGPUBindGroupLayoutEntry[]){
{ .binding = 0, .visibility = WGPUShaderStage_Fragment, .buffer = { .type = WGPUBufferBindingType_Uniform } },
},
}),
},
}),
.vertex = {
.module = shader,
.entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN },
.constantCount = 0,
.constants = NULL,
.bufferCount = 1,
.buffers = (WGPUVertexBufferLayout[]){
{
.stepMode = WGPUVertexStepMode_Instance,
.arrayStride = 12,
.attributeCount = 2,
.attributes = (WGPUVertexAttribute[]){
{
.format = WGPUVertexFormat_Uint32x2,
.offset = 0,
.shaderLocation = 0,
},
{
.format = WGPUVertexFormat_Uint32,
.offset = 8,
.shaderLocation = 1,
},
},
},
},
},
.primitive = {
.topology = WGPUPrimitiveTopology_TriangleList,
.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);
}
{ // Grid
const char shader_source[] = {
#embed "shaders/wgsl/grid.wgsl"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+83
View File
@@ -0,0 +1,83 @@
#language 2026
#include "shared.slang"
struct VertexShaderInput {
uint32_t vertex_index : SV_VulkanVertexID;
// Per Instance
[vk::location(2)] float2 world_pos;
[vk::location(3)] uint sprite_selection;
};
struct VertexShaderOutput {
float4 pos : SV_Position;
float2 uv;
};
struct FragmentShaderOutput {
float4 color : SV_Target;
};
[shader("vertex")]
VertexShaderOutput main_vertex(VertexShaderInput input) {
var output: VertexShaderOutput;
var vertex_pos = float2(0, 0);
var vertex_uv = float2(0, 0);
switch (input.vertex_index) {
case 0: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 1: { vertex_pos = float2(-0.5, -0.5); vertex_uv = float2(0, 1); } break;
case 2: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 3: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 4: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 5: { vertex_pos = float2( 0.5, 0.5); vertex_uv = float2(1, 0); } break;
default: {}
}
output.pos = mul(float4(input.world_pos + vertex_pos + float2(0, 0.35), 0, 1), view_projection_matrix);
uint sprite_x = bitfieldExtract(input.sprite_selection, 16, 16);
uint sprite_y = bitfieldExtract(input.sprite_selection, 0, 16);
output.uv = (float2(sprite_x, sprite_y) + vertex_uv) * (1.0 / 4.0);
return output;
}
[vk::binding(0, 2)] Sampler2D<float4> texture1 : register(t0, space2);
[vk::binding(0, 3)] ConstantBuffer<float3> tint : register(b0, space3);
[shader("pixel")]
FragmentShaderOutput main_fragment(VertexShaderOutput input) {
var output: FragmentShaderOutput;
output.color = pixel_art_sample(texture1, input.uv);
output.color = float4(output.color.rgb * tint.rgb, output.color.a);
return output;
}
void GetDimensions(Sampler2D<float4> texture, out float width, out float height) {
__target_switch {
case wgsl: {
texture.__getTexture().GetDimensions(width, height);
} break;
default: {
texture.GetDimensions(width, height);
} break;
}
}
float4 pixel_art_sample(Sampler2D<float4> input_texture, float2 input_uv) {
var dimensions : float2;
GetDimensions(input_texture, dimensions.x, dimensions.y);
let texture_uv = input_uv * dimensions.xy;
let sample_uv = (floor(texture_uv) + min(fract(texture_uv) / fwidth(texture_uv), float2(1.0, 1.0)) - 0.5) / dimensions.xy;
return input_texture.Sample(sample_uv);
}
@@ -5,9 +5,6 @@
struct VertexShaderInput {
uint32_t vertex_index : SV_VulkanVertexID;
[vk::location(0)] float3 pos;
[vk::location(1)] float2 uv;
// Per Instance
[vk::location(2)] float2 world_pos;
};
@@ -26,8 +23,23 @@ struct FragmentShaderOutput {
VertexShaderOutput main_vertex(VertexShaderInput input) {
var output: VertexShaderOutput;
output.pos = mul(float4(input.world_pos + input.pos.xy, 0, 1), view_projection_matrix);
output.uv = input.uv;
var vertex_pos = float2(0, 0);
var vertex_uv = float2(0, 0);
switch (input.vertex_index) {
case 0: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 1: { vertex_pos = float2(-0.5, -0.5); vertex_uv = float2(0, 1); } break;
case 2: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 3: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 4: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 5: { vertex_pos = float2( 0.5, 0.5); vertex_uv = float2(1, 0); } break;
default: {}
}
vertex_pos *= 0.5;
output.pos = mul(float4(input.world_pos + vertex_pos, 0, 1), view_projection_matrix);
output.uv = vertex_uv;
return output;
}
+86
View File
@@ -0,0 +1,86 @@
#language 2026
#include "shared.slang"
#include "wgsl_workaround.slang"
struct VertexShaderInput {
uint32_t vertex_index : SV_VulkanVertexID;
uint32_t instance_index : SV_VulkanInstanceID;
// Per Instance
[vk::location(0)] uint32_t2 pos;
[vk::location(1)] uint32_t kind;
};
struct VertexShaderOutput {
float4 pos : SV_Position;
float2 uv;
uint32_t kind;
};
struct FragmentShaderOutput {
float4 color : SV_Target;
};
[vk::binding(0, 0)] StructuredBuffer<float4> placeable_sizes_and_offsets;
[shader("vertex")]
VertexShaderOutput main_vertex(VertexShaderInput input) {
var output: VertexShaderOutput;
var vertex_pos = float2(0, 0);
var vertex_uv = float2(0, 0);
switch (input.vertex_index) {
case 0: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 1: { vertex_pos = float2(-0.5, -0.5); vertex_uv = float2(0, 1); } break;
case 2: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 3: { vertex_pos = float2(-0.5, 0.5); vertex_uv = float2(0, 0); } break;
case 4: { vertex_pos = float2( 0.5, -0.5); vertex_uv = float2(1, 1); } break;
case 5: { vertex_pos = float2( 0.5, 0.5); vertex_uv = float2(1, 0); } break;
default: {}
}
vertex_pos = vertex_pos * placeable_sizes_and_offsets[input.kind].xy + placeable_sizes_and_offsets[input.kind].zw;
output.pos = mul(float4(input.pos + vertex_pos, 0, 1), view_projection_matrix);
output.uv = vertex_uv;
output.kind = input.kind;
return output;
}
struct Block2 {
CombinedTextureSampler placeable_atlas;
StructuredBuffer<float4> placeable_uvs;
};
struct Block3 {
ConstantBuffer<float3> tint;
};
[vk::binding(0, 2)] ParameterBlock<Block2> block2;
[vk::binding(0, 3)] ParameterBlock<Block3> block3;
[shader("pixel")]
FragmentShaderOutput main_fragment(VertexShaderOutput input) {
var output: FragmentShaderOutput;
output.color = pixel_art_sample(block2.placeable_atlas, input.uv, block2.placeable_uvs[input.kind]);
output.color = float4(output.color.rgb * block3.tint.rgb, output.color.a);
return output;
}
float4 pixel_art_sample(CombinedTextureSampler input_texture, float2 input_uv, float4 tree_uv) {
var dimensions : float2;
input_texture.getTexture().GetDimensions(dimensions.x, dimensions.y);
let texture_uv = lerp(tree_uv.xy, tree_uv.zw, input_uv);
let sample_uv = (floor(texture_uv) + saturate(fract(texture_uv) / fwidth(texture_uv)) - 0.5) / dimensions;
let uv = clamp(sample_uv, (tree_uv.xy + 0.5) / dimensions, (tree_uv.zw - 0.5) / dimensions);
return input_texture.Sample(uv);
}
+14 -8
View File
@@ -26,19 +26,25 @@ struct FragmentShaderOutput {
VertexShaderOutput main_vertex(VertexShaderInput input) {
var output: VertexShaderOutput;
let tile_pos = uint32_t2(input.instance_index % per_frame.map_width, input.instance_index / per_frame.map_width);
output.tile = map_texture.Load(uint32_t3(tile_pos, 0));
var vertex_pos = float2(0, 0);
var vertex_uv = float2(0, 0);
switch (input.vertex_index) {
case 0: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2(-0.5, 0.5), 0, 1), view_projection_matrix); output.uv = float2(0, 0); } break;
case 1: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2(-0.5, -0.5), 0, 1), view_projection_matrix); output.uv = float2(0, 1); } break;
case 2: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2( 0.5, -0.5), 0, 1), view_projection_matrix); output.uv = float2(1, 1); } break;
case 3: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2(-0.5, 0.5), 0, 1), view_projection_matrix); output.uv = float2(0, 0); } break;
case 4: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2( 0.5, -0.5), 0, 1), view_projection_matrix); output.uv = float2(1, 1); } break;
case 5: { output.pos = mul(float4(float2(tile_pos) - float2(0.5, 0.5) + float2( 0.5, 0.5), 0, 1), view_projection_matrix); output.uv = float2(1, 0); } break;
case 0: { vertex_pos = float2(-1.0, 0.0); vertex_uv = float2(0, 0); } break;
case 1: { vertex_pos = float2(-1.0, -1.0); vertex_uv = float2(0, 1); } break;
case 2: { vertex_pos = float2( 0.0, -1.0); vertex_uv = float2(1, 1); } break;
case 3: { vertex_pos = float2(-1.0, 0.0); vertex_uv = float2(0, 0); } break;
case 4: { vertex_pos = float2( 0.0, -1.0); vertex_uv = float2(1, 1); } break;
case 5: { vertex_pos = float2( 0.0, 0.0); vertex_uv = float2(1, 0); } break;
default: {}
}
let tile_pos = uint32_t2(input.instance_index % per_frame.map_width, input.instance_index / per_frame.map_width);
output.tile = map_texture.Load(uint32_t3(tile_pos, 0));
output.pos = mul(float4(tile_pos + vertex_pos, 0, 1), view_projection_matrix);
output.uv = vertex_uv;
return output;
}
+116
View File
@@ -0,0 +1,116 @@
struct _MatrixStorage_float4x4_ColMajorstd140_0
{
@align(16) data_0 : array<vec4<f32>, i32(4)>,
};
@binding(0) @group(1) var<uniform> view_projection_matrix_0 : _MatrixStorage_float4x4_ColMajorstd140_0;
@binding(0) @group(2) var texture1_texture_0 : texture_2d<f32>;
@binding(1) @group(2) var texture1_sampler_0 : sampler;
@binding(0) @group(3) var<uniform> tint_0 : vec3<f32>;
struct VertexShaderOutput_0
{
@builtin(position) pos_0 : vec4<f32>,
@location(0) uv_0 : vec2<f32>,
};
struct vertexInput_0
{
@location(2) world_pos_0 : vec2<f32>,
@location(3) sprite_selection_0 : u32,
};
@vertex
fn main_vertex( _S1 : vertexInput_0, @builtin(vertex_index) vertex_index_0 : u32) -> VertexShaderOutput_0
{
var output_0 : VertexShaderOutput_0;
const _S2 : vec2<f32> = vec2<f32>(0.0f, 0.0f);
var vertex_pos_0 : vec2<f32>;
var vertex_uv_0 : vec2<f32>;
switch(vertex_index_0)
{
case u32(0):
{
vertex_pos_0 = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
}
case u32(1):
{
const _S3 : vec2<f32> = vec2<f32>(0.0f, 1.0f);
vertex_pos_0 = vec2<f32>(-0.5f, -0.5f);
vertex_uv_0 = _S3;
}
case u32(2):
{
const _S4 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = _S4;
}
case u32(3):
{
vertex_pos_0 = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
}
case u32(4):
{
const _S5 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = _S5;
}
case u32(5):
{
const _S6 : vec2<f32> = vec2<f32>(1.0f, 0.0f);
vertex_pos_0 = vec2<f32>(0.5f, 0.5f);
vertex_uv_0 = _S6;
}
default :
{
vertex_pos_0 = _S2;
vertex_uv_0 = _S2;
}
}
output_0.pos_0 = (((mat4x4<f32>(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<f32>(_S1.world_pos_0 + vertex_pos_0 + vec2<f32>(0.0f, 0.34999999403953552f), 0.0f, 1.0f))));
output_0.uv_0 = (vec2<f32>(f32((u32(_S1.sprite_selection_0>>(u32(16)))&((((u32(1)<<u32(16))-u32(1)))))), f32((u32(_S1.sprite_selection_0>>(u32(0)))&((((u32(1)<<u32(16))-u32(1))))))) + vertex_uv_0) * vec2<f32>(0.25f);
return output_0;
}
fn GetDimensions_0( texture_texture_0 : texture_2d<f32>, texture_sampler_0 : sampler, width_0 : ptr<function, f32>, height_0 : ptr<function, f32>)
{
{var dim = textureDimensions((texture_texture_0));(((*width_0))) = f32(dim.x);(((*height_0))) = f32(dim.y);};
return;
}
fn pixel_art_sample_0( input_texture_texture_0 : texture_2d<f32>, input_texture_sampler_0 : sampler, input_uv_0 : vec2<f32>) -> vec4<f32>
{
var dimensions_0 : vec2<f32>;
var _S7 : f32 = dimensions_0[i32(0)];
var _S8 : f32 = dimensions_0[i32(1)];
GetDimensions_0(input_texture_texture_0, input_texture_sampler_0, &(_S7), &(_S8));
dimensions_0[i32(0)] = _S7;
dimensions_0[i32(1)] = _S8;
var _S9 : vec2<f32> = input_uv_0 * dimensions_0.xy;
var _S10 : vec2<f32> = (floor(_S9) + min(fract(_S9) / (fwidth((_S9))), vec2<f32>(1.0f, 1.0f)) - vec2<f32>(0.5f)) / dimensions_0.xy;
;
return (textureSample((input_texture_texture_0), (input_texture_sampler_0), (_S10)));
}
struct FragmentShaderOutput_0
{
@location(0) color_0 : vec4<f32>,
};
struct pixelInput_0
{
@location(0) uv_1 : vec2<f32>,
};
@fragment
fn main_fragment( _S11 : pixelInput_0, @builtin(position) pos_1 : vec4<f32>) -> FragmentShaderOutput_0
{
var output_1 : FragmentShaderOutput_0;
var _S12 : vec4<f32> = pixel_art_sample_0(texture1_texture_0, texture1_sampler_0, _S11.uv_1);
output_1.color_0 = vec4<f32>(_S12.xyz * tint_0.xyz, _S12.w);
return output_1;
}
@@ -17,8 +17,6 @@ struct VertexShaderOutput_0
struct vertexInput_0
{
@location(0) pos_1 : vec3<f32>,
@location(1) uv_1 : vec2<f32>,
@location(2) world_pos_0 : vec2<f32>,
};
@@ -26,8 +24,55 @@ struct vertexInput_0
fn main_vertex( _S1 : vertexInput_0, @builtin(vertex_index) vertex_index_0 : u32) -> VertexShaderOutput_0
{
var output_0 : VertexShaderOutput_0;
output_0.pos_0 = (((mat4x4<f32>(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<f32>(_S1.world_pos_0 + _S1.pos_1.xy, 0.0f, 1.0f))));
output_0.uv_0 = _S1.uv_1;
const _S2 : vec2<f32> = vec2<f32>(0.0f, 0.0f);
var vertex_uv_0 : vec2<f32>;
var vertex_pos_0 : vec2<f32>;
switch(vertex_index_0)
{
case u32(0):
{
const _S3 : vec2<f32> = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
vertex_pos_0 = _S3;
}
case u32(1):
{
const _S4 : vec2<f32> = vec2<f32>(-0.5f, -0.5f);
vertex_uv_0 = vec2<f32>(0.0f, 1.0f);
vertex_pos_0 = _S4;
}
case u32(2):
{
const _S5 : vec2<f32> = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = _S5;
}
case u32(3):
{
const _S6 : vec2<f32> = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
vertex_pos_0 = _S6;
}
case u32(4):
{
const _S7 : vec2<f32> = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = _S7;
}
case u32(5):
{
const _S8 : vec2<f32> = vec2<f32>(0.5f, 0.5f);
vertex_uv_0 = vec2<f32>(1.0f, 0.0f);
vertex_pos_0 = _S8;
}
default :
{
vertex_uv_0 = _S2;
vertex_pos_0 = _S2;
}
}
output_0.pos_0 = (((mat4x4<f32>(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<f32>(_S1.world_pos_0 + vertex_pos_0 * vec2<f32>(0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vertex_uv_0;
return output_0;
}
@@ -40,15 +85,15 @@ fn GetDimensions_0( texture_texture_0 : texture_2d<f32>, texture_sampler_0 : sa
fn pixel_art_sample_0( input_texture_texture_0 : texture_2d<f32>, input_texture_sampler_0 : sampler, input_uv_0 : vec2<f32>) -> vec4<f32>
{
var dimensions_0 : vec2<f32>;
var _S2 : f32 = dimensions_0[i32(0)];
var _S3 : f32 = dimensions_0[i32(1)];
GetDimensions_0(input_texture_texture_0, input_texture_sampler_0, &(_S2), &(_S3));
dimensions_0[i32(0)] = _S2;
dimensions_0[i32(1)] = _S3;
var _S4 : vec2<f32> = input_uv_0 * dimensions_0.xy;
var _S5 : vec2<f32> = (floor(_S4) + min(fract(_S4) / (fwidth((_S4))), vec2<f32>(1.0f, 1.0f)) - vec2<f32>(0.5f)) / dimensions_0.xy;
var _S9 : f32 = dimensions_0[i32(0)];
var _S10 : f32 = dimensions_0[i32(1)];
GetDimensions_0(input_texture_texture_0, input_texture_sampler_0, &(_S9), &(_S10));
dimensions_0[i32(0)] = _S9;
dimensions_0[i32(1)] = _S10;
var _S11 : vec2<f32> = input_uv_0 * dimensions_0.xy;
var _S12 : vec2<f32> = (floor(_S11) + min(fract(_S11) / (fwidth((_S11))), vec2<f32>(1.0f, 1.0f)) - vec2<f32>(0.5f)) / dimensions_0.xy;
;
return (textureSample((input_texture_texture_0), (input_texture_sampler_0), (_S5)));
return (textureSample((input_texture_texture_0), (input_texture_sampler_0), (_S12)));
}
struct FragmentShaderOutput_0
@@ -58,15 +103,15 @@ struct FragmentShaderOutput_0
struct pixelInput_0
{
@location(0) uv_2 : vec2<f32>,
@location(0) uv_1 : vec2<f32>,
};
@fragment
fn main_fragment( _S6 : pixelInput_0, @builtin(position) pos_2 : vec4<f32>) -> FragmentShaderOutput_0
fn main_fragment( _S13 : pixelInput_0, @builtin(position) pos_1 : vec4<f32>) -> FragmentShaderOutput_0
{
var output_1 : FragmentShaderOutput_0;
var _S7 : vec4<f32> = pixel_art_sample_0(texture1_texture_0, texture1_sampler_0, _S6.uv_2);
output_1.color_0 = vec4<f32>(_S7.xyz * tint_0.xyz, _S7.w);
var _S14 : vec4<f32> = pixel_art_sample_0(texture1_texture_0, texture1_sampler_0, _S13.uv_1);
output_1.color_0 = vec4<f32>(_S14.xyz * tint_0.xyz, _S14.w);
return output_1;
}
+123
View File
@@ -0,0 +1,123 @@
@binding(0) @group(0) var<storage, read> placeable_sizes_and_offsets_0 : array<vec4<f32>>;
struct _MatrixStorage_float4x4_ColMajorstd140_0
{
@align(16) data_0 : array<vec4<f32>, i32(4)>,
};
@binding(0) @group(1) var<uniform> view_projection_matrix_0 : _MatrixStorage_float4x4_ColMajorstd140_0;
@binding(0) @group(2) var block2_placeable_atlas_texture_0 : texture_2d<f32>;
@binding(1) @group(2) var block2_placeable_atlas_sampler_0 : sampler;
@binding(2) @group(2) var<storage, read> block2_placeable_uvs_0 : array<vec4<f32>>;
@binding(0) @group(3) var<uniform> block3_tint_0 : vec3<f32>;
struct VertexShaderOutput_0
{
@builtin(position) pos_0 : vec4<f32>,
@location(0) uv_0 : vec2<f32>,
@location(1) kind_0 : u32,
};
struct vertexInput_0
{
@location(0) pos_1 : vec2<u32>,
@location(1) kind_1 : u32,
};
@vertex
fn main_vertex( _S1 : vertexInput_0, @builtin(vertex_index) vertex_index_0 : u32, @builtin(instance_index) instance_index_0 : u32) -> VertexShaderOutput_0
{
var output_0 : VertexShaderOutput_0;
const _S2 : vec2<f32> = vec2<f32>(0.0f, 0.0f);
var vertex_pos_0 : vec2<f32>;
var vertex_uv_0 : vec2<f32>;
switch(vertex_index_0)
{
case u32(0):
{
vertex_pos_0 = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
}
case u32(1):
{
const _S3 : vec2<f32> = vec2<f32>(0.0f, 1.0f);
vertex_pos_0 = vec2<f32>(-0.5f, -0.5f);
vertex_uv_0 = _S3;
}
case u32(2):
{
const _S4 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = _S4;
}
case u32(3):
{
vertex_pos_0 = vec2<f32>(-0.5f, 0.5f);
vertex_uv_0 = _S2;
}
case u32(4):
{
const _S5 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.5f, -0.5f);
vertex_uv_0 = _S5;
}
case u32(5):
{
const _S6 : vec2<f32> = vec2<f32>(1.0f, 0.0f);
vertex_pos_0 = vec2<f32>(0.5f, 0.5f);
vertex_uv_0 = _S6;
}
default :
{
vertex_pos_0 = _S2;
vertex_uv_0 = _S2;
}
}
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S1.pos_1) + (vertex_pos_0 * placeable_sizes_and_offsets_0[_S1.kind_1].xy + placeable_sizes_and_offsets_0[_S1.kind_1].zw), 0.0f, 1.0f))));
output_0.uv_0 = vertex_uv_0;
output_0.kind_0 = _S1.kind_1;
return output_0;
}
fn CombinedTextureSampler_Sample_0( this_texture_0 : texture_2d<f32>, this_sampler_0 : sampler, location_0 : vec2<f32>) -> vec4<f32>
{
return (textureSample((this_texture_0), (this_sampler_0), (location_0)));
}
fn pixel_art_sample_0( input_texture_texture_0 : texture_2d<f32>, input_texture_sampler_0 : sampler, input_uv_0 : vec2<f32>, tree_uv_0 : vec4<f32>) -> vec4<f32>
{
var dimensions_0 : vec2<f32>;
var _S7 : f32 = dimensions_0[i32(0)];
var _S8 : f32 = dimensions_0[i32(1)];
{var dim = textureDimensions((input_texture_texture_0));((_S7)) = f32(dim.x);((_S8)) = f32(dim.y);};
dimensions_0[i32(0)] = _S7;
dimensions_0[i32(1)] = _S8;
var _S9 : vec2<f32> = tree_uv_0.xy;
var _S10 : vec2<f32> = tree_uv_0.zw;
var _S11 : vec2<f32> = mix(_S9, _S10, input_uv_0);
var _S12 : vec2<f32> = vec2<f32>(0.5f);
return CombinedTextureSampler_Sample_0(input_texture_texture_0, input_texture_sampler_0, clamp((floor(_S11) + saturate(fract(_S11) / (fwidth((_S11)))) - _S12) / dimensions_0, (_S9 + _S12) / dimensions_0, (_S10 - _S12) / dimensions_0));
}
struct FragmentShaderOutput_0
{
@location(0) color_0 : vec4<f32>,
};
struct pixelInput_0
{
@location(0) uv_1 : vec2<f32>,
@location(1) kind_2 : u32,
};
@fragment
fn main_fragment( _S13 : pixelInput_0, @builtin(position) pos_2 : vec4<f32>) -> FragmentShaderOutput_0
{
var output_1 : FragmentShaderOutput_0;
var _S14 : vec4<f32> = pixel_art_sample_0(block2_placeable_atlas_texture_0, block2_placeable_atlas_sampler_0, _S13.uv_1, block2_placeable_uvs_0[_S13.kind_2]);
output_1.color_0 = vec4<f32>(_S14.xyz * block3_tint_0.xyz, _S14.w);
return output_1;
}
+41 -31
View File
@@ -34,49 +34,59 @@ struct VertexShaderOutput_0
@vertex
fn main_vertex(@builtin(vertex_index) vertex_index_0 : u32, @builtin(instance_index) instance_index_0 : u32) -> VertexShaderOutput_0
{
var _S1 : u32 = instance_index_0 % per_frame_0.map_width_0;
var _S2 : u32 = instance_index_0 / per_frame_0.map_width_0;
var _S3 : vec2<u32> = vec2<u32>(_S1, _S2);
var output_0 : VertexShaderOutput_0;
var _S4 : vec3<i32> = vec3<i32>(vec3<u32>(_S3, u32(0)));
output_0.tile_0 = (textureLoad((map_texture_0), ((_S4)).xy, ((_S4)).z).x);
const _S1 : vec2<f32> = vec2<f32>(0.0f, 0.0f);
var vertex_pos_0 : vec2<f32>;
var vertex_uv_0 : vec2<f32>;
switch(vertex_index_0)
{
case u32(0):
{
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - vec2<f32>(0.5f, 0.5f) + vec2<f32>(-0.5f, 0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(0.0f, 0.0f);
vertex_pos_0 = vec2<f32>(-1.0f, 0.0f);
vertex_uv_0 = _S1;
}
case u32(1):
{
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - vec2<f32>(0.5f, 0.5f) + vec2<f32>(-0.5f, -0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(0.0f, 1.0f);
const _S2 : vec2<f32> = vec2<f32>(0.0f, 1.0f);
vertex_pos_0 = vec2<f32>(-1.0f, -1.0f);
vertex_uv_0 = _S2;
}
case u32(2):
{
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - vec2<f32>(0.5f, 0.5f) + vec2<f32>(0.5f, -0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(1.0f, 1.0f);
const _S3 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.0f, -1.0f);
vertex_uv_0 = _S3;
}
case u32(3):
{
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - vec2<f32>(0.5f, 0.5f) + vec2<f32>(-0.5f, 0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(0.0f, 0.0f);
vertex_pos_0 = vec2<f32>(-1.0f, 0.0f);
vertex_uv_0 = _S1;
}
case u32(4):
{
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - vec2<f32>(0.5f, 0.5f) + vec2<f32>(0.5f, -0.5f), 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(1.0f, 1.0f);
const _S4 : vec2<f32> = vec2<f32>(1.0f, 1.0f);
vertex_pos_0 = vec2<f32>(0.0f, -1.0f);
vertex_uv_0 = _S4;
}
case u32(5):
{
const _S5 : vec2<f32> = vec2<f32>(0.5f, 0.5f);
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S3) - _S5 + _S5, 0.0f, 1.0f))));
output_0.uv_0 = vec2<f32>(1.0f, 0.0f);
const _S5 : vec2<f32> = vec2<f32>(1.0f, 0.0f);
vertex_pos_0 = _S1;
vertex_uv_0 = _S5;
}
default :
{
vertex_pos_0 = _S1;
vertex_uv_0 = _S1;
}
}
var _S6 : u32 = instance_index_0 % per_frame_0.map_width_0;
var _S7 : u32 = instance_index_0 / per_frame_0.map_width_0;
var _S8 : vec2<u32> = vec2<u32>(_S6, _S7);
var _S9 : vec3<i32> = vec3<i32>(vec3<u32>(_S8, u32(0)));
output_0.tile_0 = (textureLoad((map_texture_0), ((_S9)).xy, ((_S9)).z).x);
output_0.pos_0 = (((mat4x4<f32>(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<f32>(vec2<f32>(_S8) + vertex_pos_0, 0.0f, 1.0f))));
output_0.uv_0 = vertex_uv_0;
return output_0;
}
@@ -88,16 +98,16 @@ fn CombinedTextureSampler_Sample_0( this_texture_0 : texture_2d<f32>, this_samp
fn pixel_art_sample_0( input_texture_texture_0 : texture_2d<f32>, input_texture_sampler_0 : sampler, input_uv_0 : vec2<f32>, tile_uv_0 : vec4<f32>) -> vec4<f32>
{
var dimensions_0 : vec2<f32>;
var _S6 : f32 = dimensions_0[i32(0)];
var _S7 : f32 = dimensions_0[i32(1)];
{var dim = textureDimensions((input_texture_texture_0));((_S6)) = f32(dim.x);((_S7)) = f32(dim.y);};
dimensions_0[i32(0)] = _S6;
dimensions_0[i32(1)] = _S7;
var _S8 : vec2<f32> = tile_uv_0.xy;
var _S9 : vec2<f32> = tile_uv_0.zw;
var _S10 : vec2<f32> = mix(_S8, _S9, input_uv_0);
var _S11 : vec2<f32> = vec2<f32>(0.5f);
return CombinedTextureSampler_Sample_0(input_texture_texture_0, input_texture_sampler_0, clamp((floor(_S10) + saturate(fract(_S10) / (fwidth((_S10)))) - _S11) / dimensions_0, (_S8 + _S11) / dimensions_0, (_S9 - _S11) / dimensions_0));
var _S10 : f32 = dimensions_0[i32(0)];
var _S11 : f32 = dimensions_0[i32(1)];
{var dim = textureDimensions((input_texture_texture_0));((_S10)) = f32(dim.x);((_S11)) = f32(dim.y);};
dimensions_0[i32(0)] = _S10;
dimensions_0[i32(1)] = _S11;
var _S12 : vec2<f32> = tile_uv_0.xy;
var _S13 : vec2<f32> = tile_uv_0.zw;
var _S14 : vec2<f32> = mix(_S12, _S13, input_uv_0);
var _S15 : vec2<f32> = vec2<f32>(0.5f);
return CombinedTextureSampler_Sample_0(input_texture_texture_0, input_texture_sampler_0, clamp((floor(_S14) + saturate(fract(_S14) / (fwidth((_S14)))) - _S15) / dimensions_0, (_S12 + _S15) / dimensions_0, (_S13 - _S15) / dimensions_0));
}
struct FragmentShaderOutput_0
@@ -112,11 +122,11 @@ struct pixelInput_0
};
@fragment
fn main_fragment( _S12 : pixelInput_0, @builtin(position) pos_1 : vec4<f32>) -> FragmentShaderOutput_0
fn main_fragment( _S16 : pixelInput_0, @builtin(position) pos_1 : vec4<f32>) -> FragmentShaderOutput_0
{
var output_1 : FragmentShaderOutput_0;
var _S13 : vec4<f32> = pixel_art_sample_0(block2_tile_atlas_texture_0, block2_tile_atlas_sampler_0, _S12.uv_1, block2_tile_uvs_0[_S12.tile_1]);
output_1.color_0 = vec4<f32>(_S13.xyz * block3_tint_0.xyz, _S13.w);
var _S17 : vec4<f32> = pixel_art_sample_0(block2_tile_atlas_texture_0, block2_tile_atlas_sampler_0, _S16.uv_1, block2_tile_uvs_0[_S16.tile_1]);
output_1.color_0 = vec4<f32>(_S17.xyz * block3_tint_0.xyz, _S17.w);
return output_1;
}