diff --git a/src/main.jai b/src/main.jai index 785496a..8962f31 100644 --- a/src/main.jai +++ b/src/main.jai @@ -133,7 +133,7 @@ init_after_asset_pack :: () { // We want to do this last. game_init(); - #if UNCAPPED_FRAMES then sapp_glx_swapinterval(0); + // #if UNCAPPED_FRAMES then sapp_glx_swapinterval(0); } is_in_reflection_pass : bool = false; @@ -168,7 +168,6 @@ frame :: () { while delta_time_accumulator > (1.0/60.0) { game_tick(1.0/60.0); delta_time_accumulator -= (1.0/60.0); - input_per_frame_event_and_flag_update(); } } fonsClearState(state.fons); @@ -196,6 +195,7 @@ frame :: () { reset_temporary_storage(); frame_end_time := get_time(); latest_frametime = frame_end_time - frame_start_time; + input_per_frame_event_and_flag_update(); } cleanup :: () { diff --git a/src/platform_specific/common.jai b/src/platform_specific/common.jai index b85e694..cba7be3 100644 --- a/src/platform_specific/common.jai +++ b/src/platform_specific/common.jai @@ -38,7 +38,6 @@ sapp_init :: () { window_title = wi.title, // icon = .{ sokol_default = true }, logger = .{ func = slog_func }, - swap_interval = 0, sample_count = 1, // I think I'll end up pixelifying the whole thing, so I don't think we need MSAA. })); } diff --git a/src/rendering/backend_sokol.jai b/src/rendering/backend_sokol.jai index 92acd2d..9b7f5f8 100644 --- a/src/rendering/backend_sokol.jai +++ b/src/rendering/backend_sokol.jai @@ -42,7 +42,11 @@ backend_handle_command :: (cmd: *Render_Command) { current_world_config = set_light_command.worldConfig; case .DRAW_BILLBOARD; command := cast(*Render_Command_Draw_Billboard)cmd; - backend_draw_billboard(command.position, command.animation, command.frame, command.flipX); + if !in_gbuffer_pass { + backend_draw_billboard(command.position, command.animation, command.frame, command.flipX); + } else { + backend_gbuffer_draw_billboard(command.position, command.animation, command.frame, command.flipX); + } } } @@ -265,6 +269,38 @@ backend_draw_billboard :: (position: Vector3, anim: *Animation, frame_idx: s32, sg_draw(0, 6, 1); } +backend_gbuffer_draw_billboard :: (position: Vector3, anim: *Animation, frame_idx: s32, flipX: bool) { + if !anim then return; + mvp := create_viewproj(*camera); + view := create_lookat(*camera); + vs_params : Gbuffer_Billboard_Vs_Params; + vs_params.view_matrix = view.floats; + gPipelines.gbuffer_billboard.bind.images[0] = anim.sheet; + frame := anim.frames[frame_idx]; + vs_params.uvs = Vector4.{ + cast(float) frame.x / cast(float)anim.sheet_w, + cast(float) frame.y / cast(float)anim.sheet_h, + cast(float) frame.w / cast(float)anim.sheet_w, + cast(float) frame.h / cast(float)anim.sheet_h, + }.component; + if flipX { + vs_params.uvs[0] += vs_params.uvs[2]; + vs_params.uvs[2] *= -1.0; + } + vs_params.size = Vector2.{cast(float)(frame.w / 16), cast(float)(frame.h / 16)}.component; + vs_params.cam = camera.position.component; + if !in_shadowmap_pass { + vs_params.mvp = mvp.floats; + } else { + vs_params.mvp = shadow_mvp.floats; + } + vs_params.offset = position.component; + sg_apply_pipeline(gPipelines.gbuffer_billboard.pipeline); + sg_apply_bindings(*gPipelines.gbuffer_billboard.bind); + sg_apply_uniforms(UB_gbuffer_billboard_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) })); + sg_draw(0, 6, 1); +} + backend_draw_ground_gbuf :: (wc: *World_Config) { mvp := create_viewproj(*camera); view := create_lookat(*camera); @@ -316,14 +352,14 @@ backend_process_command_buckets :: () { current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. // 4. G-Buffer pass - // in_gbuffer_pass = true; - // sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear_gbuf, attachments = g_gbuf_attachments})); - // for render_command_buckets.gbuffer { - // backend_handle_command(it); - // } - // sg_end_pass(); - // in_gbuffer_pass = false; - // current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. + in_gbuffer_pass = true; + sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear_gbuf, attachments = g_gbuf_attachments})); + for render_command_buckets.gbuffer { + backend_handle_command(it); + } + sg_end_pass(); + in_gbuffer_pass = false; + current_trile_offset_index = 0; // This is not optimal, but it is nice and simple. sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a })); sg_apply_pipeline(gPipelines.ssao.pipeline); diff --git a/src/rendering/helpers.jai b/src/rendering/helpers.jai index f2fb449..1a12e25 100644 --- a/src/rendering/helpers.jai +++ b/src/rendering/helpers.jai @@ -77,8 +77,8 @@ get_low_res :: (width: s32, height: s32, max_dimension: s32 = 720) -> (s32, s32) get_render_size :: () -> (s32, s32) { w,h := get_window_size(); - // wl, hl := get_low_res(w,h, 360); - return w, h; + wl, hl := get_low_res(w,h, 800); + return wl, hl; } flip_y_if_plat :: inline (v: Vector2) -> Vector2 { diff --git a/src/rendering/pipelines.jai b/src/rendering/pipelines.jai index de9eeb9..56ae6ee 100644 --- a/src/rendering/pipelines.jai +++ b/src/rendering/pipelines.jai @@ -65,6 +65,8 @@ gPipelines : struct { mix : Pipeline_Binding; billboard : Pipeline_Binding; + + gbuffer_billboard : Pipeline_Binding; // Renders the SSAO texture using things from the gbuffer pass. ssao: Pipeline_Binding; @@ -74,6 +76,7 @@ create_final_image :: () { // @ToDo: Some smarter logic for this. w,h := get_render_size(); + if g_rendertex.id != INVALID_ID then sg_destroy_image(g_rendertex); if g_rendertex_depth.id != INVALID_ID then sg_destroy_image(g_rendertex); @@ -142,6 +145,7 @@ create_pipelines :: () { create_op_pipeline(); create_mix_pipeline(); create_billboard_pipeline(); + create_gbuffer_billboard_pipeline(); create_shadowmap_image(); create_final_image(); @@ -812,6 +816,64 @@ create_billboard_pipeline :: () { })); } +create_gbuffer_billboard_pipeline :: () { + pipeline: sg_pipeline_desc; + shader_desc := gbuffer_billboard_shader_desc(sg_query_backend()); + pipeline.shader = sg_make_shader(*shader_desc); + pipeline.layout.buffers[0].stride = 4*3; + + pipeline.layout.attrs[ATTR_billboard_position] = .{ format = .FLOAT3, buffer_index = 0 }; + pipeline.index_type = .UINT16; + pipeline.depth = .{ + write_enabled = true, + compare = .LESS_EQUAL, + pixel_format = .DEPTH + }; + + color_state_pos := sg_color_target_state.{ + pixel_format = .RGBA16F, + }; + color_state_normal := sg_color_target_state.{ + pixel_format = .RGBA16F, + }; + + + pipeline.color_count = 2; + pipeline.colors[0] = color_state_pos; + pipeline.colors[1] = color_state_normal; + + vertices: [4]Vector3 = .[ + .{ 0.0, 0.0, 0.0}, + .{ 1.0, 0.0, 0.0}, + .{ 1.0, 1.0, 0.0}, + .{ 0.0, 1.0, 0.0}, + ]; + + indices: [6]u16 = .[ + 0, 1, 2, + 0, 2, 3, + ]; + + pipeline.color_count = 2; + pipeline.colors[0] = color_state_pos; + pipeline.colors[1] = color_state_normal; + + gPipelines.gbuffer_billboard.pipeline = sg_make_pipeline(*pipeline); + + ibuffer := sg_buffer_desc.{ type = .INDEXBUFFER, data = .{ ptr = indices.data, size = 6 * 2 } }; + vbuffer := sg_buffer_desc.{ data = .{ ptr = vertices.data, size = 4 * 3 * 4 } }; + + gPipelines.gbuffer_billboard.bind.index_buffer = sg_make_buffer(*ibuffer); + gPipelines.gbuffer_billboard.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer); + + gPipelines.gbuffer_billboard.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{ + wrap_u = .CLAMP_TO_EDGE, + wrap_v = .CLAMP_TO_EDGE, + min_filter = .NEAREST, + mag_filter = .NEAREST, + })); +} + // Takes in 2-3 textures, and mixes them. create_mix_pipeline :: () { platconf := get_plat_conf(); diff --git a/src/rendering/tasks.jai b/src/rendering/tasks.jai index ce04179..51cc55c 100644 --- a/src/rendering/tasks.jai +++ b/src/rendering/tasks.jai @@ -133,6 +133,7 @@ tasks_to_commands :: () { commandDrawBillboard.flipX = billboardTask.flipX; commandDrawBillboard.flipY = billboardTask.flipY; commandDrawBillboard.animation = billboardTask.animation; + array_add(*render_command_buckets.gbuffer, commandDrawBillboard); array_add(*render_command_buckets.main, commandDrawBillboard); array_add(*render_command_buckets.shadow, commandDrawBillboard); array_add(*render_command_buckets.reflection, commandDrawBillboard); diff --git a/src/shaders/jai/shader_gbuffer_billboard.jai b/src/shaders/jai/shader_gbuffer_billboard.jai new file mode 100644 index 0000000..c7d888f --- /dev/null +++ b/src/shaders/jai/shader_gbuffer_billboard.jai @@ -0,0 +1,646 @@ +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc -i shader_gbuffer_billboard.glsl -o ./jai/shader_gbuffer_billboard.jai -l glsl430:glsl300es:metal_macos -f sokol_jai + + Overview: + ========= + Shader program: 'gbuffer_billboard': + Get shader desc: gbuffer_billboard_shader_desc(sg_query_backend()) + Vertex Shader: vs_gbuffer_billboard + Fragment Shader: fs_gbuffer_billboard + Attributes: + ATTR_gbuffer_billboard_position => 0 + Bindings: + Uniform block 'gbuffer_billboard_vs_params': + Jai struct: Gbuffer_Billboard_Vs_Params + Bind slot: UB_gbuffer_billboard_vs_params => 0 + Image 'gsprite': + Image type: ._2D + Sample type: .FLOAT + Multisampled: false + Bind slot: IMG_gsprite => 0 + Sampler 'gspritesmp': + Type: .FILTERING + Bind slot: SMP_gspritesmp => 0 +*/ +ATTR_gbuffer_billboard_position :: 0; +UB_gbuffer_billboard_vs_params :: 0; +IMG_gsprite :: 0; +SMP_gspritesmp :: 0; +Gbuffer_Billboard_Vs_Params :: struct { + mvp: [16]float; + uvs: [4]float; + offset: [3]float; + _: [4]u8; + size: [2]float; + _: [8]u8; + cam: [3]float; + _: [4]u8; + view_matrix: [16]float; +}; +/* + #version 430 + + uniform vec4 gbuffer_billboard_vs_params[12]; + layout(location = 0) in vec3 position; + layout(location = 1) out vec3 view_space_pos; + layout(location = 2) out vec3 view_space_normal; + layout(location = 0) out vec2 uv_in; + + void main() + { + vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz; + _53.y = 0.0; + vec4 _88 = vec4((gbuffer_billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), normalize(_53))) * ((position.x - 0.5) * gbuffer_billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * gbuffer_billboard_vs_params[6].y)), 1.0); + gl_Position = mat4(gbuffer_billboard_vs_params[0], gbuffer_billboard_vs_params[1], gbuffer_billboard_vs_params[2], gbuffer_billboard_vs_params[3]) * _88; + mat4 _96 = mat4(gbuffer_billboard_vs_params[8], gbuffer_billboard_vs_params[9], gbuffer_billboard_vs_params[10], gbuffer_billboard_vs_params[11]); + view_space_pos = (_96 * _88).xyz; + view_space_normal = mat3(_96[0].xyz, _96[1].xyz, _96[2].xyz) * vec3(0.0, 1.0, 0.0); + uv_in = vec2(gbuffer_billboard_vs_params[4].x + (position.x * gbuffer_billboard_vs_params[4].z), gbuffer_billboard_vs_params[4].y + (position.y * gbuffer_billboard_vs_params[4].w)); + } + +*/ +vs_gbuffer_billboard_source_glsl430 := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x67,0x62,0x75,0x66,0x66, + 0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33, + 0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x32,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76, + 0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20, + 0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69, + 0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f, + 0x35,0x33,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c, + 0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x67,0x62,0x75,0x66,0x66,0x65, + 0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x76,0x65, + 0x63,0x34,0x28,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30, + 0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x6e, + 0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x29,0x29,0x20, + 0x2a,0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d, + 0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x78,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x76, + 0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79, + 0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62, + 0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36, + 0x5d,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d, + 0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d, + 0x61,0x74,0x34,0x20,0x5f,0x39,0x36,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67, + 0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, + 0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x2c,0x20,0x67, + 0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, + 0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x39,0x5d,0x2c,0x20,0x67, + 0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, + 0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x30,0x5d,0x2c,0x20, + 0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, + 0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x31,0x5d,0x29, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65, + 0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x39,0x36,0x20,0x2a,0x20,0x5f,0x38, + 0x38,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77, + 0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20, + 0x6d,0x61,0x74,0x33,0x28,0x5f,0x39,0x36,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c, + 0x20,0x5f,0x39,0x36,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x39,0x36, + 0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28, + 0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32, + 0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61, + 0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e, + 0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20, + 0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f, + 0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x2e,0x7a,0x29,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c, + 0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x5b,0x34,0x5d,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69, + 0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x34,0x5d,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 430 + + layout(binding = 16) uniform sampler2D gsprite_gspritesmp; + + layout(location = 0) in vec2 uv_in; + layout(location = 0) out vec4 out_position; + layout(location = 1) in vec3 view_space_pos; + layout(location = 1) out vec4 out_normal; + layout(location = 2) in vec3 view_space_normal; + + void main() + { + vec2 _12 = uv_in; + _12.y = 1.0 - _12.y; + if (texture(gsprite_gspritesmp, _12).w < 0.00999999977648258209228515625) + { + discard; + } + out_position = vec4(view_space_pos, 1.0); + out_normal = vec4(normalize(view_space_normal), 1.0); + } + +*/ +fs_gbuffer_billboard_source_glsl430 := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61, + 0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31, + 0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x32,0x44,0x20,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73,0x70, + 0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, + 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69, + 0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61, + 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74, + 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69, + 0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63, + 0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f, + 0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20, + 0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69, + 0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b, + 0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75, + 0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20, + 0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x67, + 0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d, + 0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30, + 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32, + 0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20, + 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61, + 0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75, + 0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63, + 0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73, + 0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f, + 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6e,0x6f, + 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61, + 0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 300 es + + uniform vec4 gbuffer_billboard_vs_params[12]; + layout(location = 0) in vec3 position; + out vec3 view_space_pos; + out vec3 view_space_normal; + out vec2 uv_in; + + void main() + { + vec3 _53 = gbuffer_billboard_vs_params[5].xyz - gbuffer_billboard_vs_params[7].xyz; + _53.y = 0.0; + vec4 _88 = vec4((gbuffer_billboard_vs_params[5].xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), normalize(_53))) * ((position.x - 0.5) * gbuffer_billboard_vs_params[6].x))) + (vec3(0.0, 1.0, 0.0) * (position.y * gbuffer_billboard_vs_params[6].y)), 1.0); + gl_Position = mat4(gbuffer_billboard_vs_params[0], gbuffer_billboard_vs_params[1], gbuffer_billboard_vs_params[2], gbuffer_billboard_vs_params[3]) * _88; + mat4 _96 = mat4(gbuffer_billboard_vs_params[8], gbuffer_billboard_vs_params[9], gbuffer_billboard_vs_params[10], gbuffer_billboard_vs_params[11]); + view_space_pos = (_96 * _88).xyz; + view_space_normal = mat3(_96[0].xyz, _96[1].xyz, _96[2].xyz) * vec3(0.0, 1.0, 0.0); + uv_in = vec2(gbuffer_billboard_vs_params[4].x + (position.x * gbuffer_billboard_vs_params[4].z), gbuffer_billboard_vs_params[4].y + (position.y * gbuffer_billboard_vs_params[4].w)); + } + +*/ +vs_gbuffer_billboard_source_glsl300es := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x67,0x62, + 0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x32,0x5d,0x3b,0x0a,0x6c, + 0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d, + 0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76, + 0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6f, + 0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61, + 0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, + 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65, + 0x63,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72, + 0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x67,0x62, + 0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x2e,0x78,0x79,0x7a, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e, + 0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x38,0x38,0x20, + 0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f, + 0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65, + 0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30, + 0x29,0x2c,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x35,0x33, + 0x29,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x67,0x62,0x75,0x66, + 0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x78,0x29,0x29,0x29,0x20, + 0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, + 0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62, + 0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61, + 0x6d,0x73,0x5b,0x36,0x5d,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f, + 0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,0x39,0x36,0x20,0x3d,0x20,0x6d,0x61, + 0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62, + 0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38, + 0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62, + 0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x39, + 0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62, + 0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31, + 0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c, + 0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x31,0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73, + 0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x39,0x36,0x20, + 0x2a,0x20,0x5f,0x38,0x38,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61, + 0x6c,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x5f,0x39,0x36,0x5b,0x30,0x5d,0x2e, + 0x78,0x79,0x7a,0x2c,0x20,0x5f,0x39,0x36,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c, + 0x20,0x5f,0x39,0x36,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x76, + 0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x32,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c, + 0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x5b,0x34,0x5d,0x2e,0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x2e,0x78,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69, + 0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x34,0x5d,0x2e,0x7a,0x29,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72, + 0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x67,0x62,0x75,0x66,0x66,0x65, + 0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f,0x76,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, +]; +/* + #version 300 es + precision mediump float; + precision highp int; + + uniform highp sampler2D gsprite_gspritesmp; + + in highp vec2 uv_in; + layout(location = 0) out highp vec4 out_position; + in highp vec3 view_space_pos; + layout(location = 1) out highp vec4 out_normal; + in highp vec3 view_space_normal; + + void main() + { + highp vec2 _12 = uv_in; + _12.y = 1.0 - _12.y; + if (texture(gsprite_gspritesmp, _12).w < 0.00999999977648258209228515625) + { + discard; + } + out_position = vec4(view_space_pos, 1.0); + out_normal = vec4(normalize(view_space_normal), 1.0); + } + +*/ +fs_gbuffer_billboard_source_glsl300es := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67, + 0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20, + 0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33, + 0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20, + 0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b, + 0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x76, + 0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20, + 0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,0x20,0x5f, + 0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x74,0x65, + 0x78,0x74,0x75,0x72,0x65,0x28,0x67,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x67,0x73, + 0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x2e,0x77, + 0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37, + 0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36, + 0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d, + 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x69,0x65,0x77,0x5f,0x73,0x70, + 0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x34,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76, + 0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #include + #include + + using namespace metal; + + struct gbuffer_billboard_vs_params + { + float4x4 mvp; + float4 uvs; + float3 offset; + float2 size; + float3 cam; + float4x4 view_matrix; + }; + + struct main0_out + { + float2 uv_in [[user(locn0)]]; + float3 view_space_pos [[user(locn1)]]; + float3 view_space_normal [[user(locn2)]]; + float4 gl_Position [[position]]; + }; + + struct main0_in + { + float3 position [[attribute(0)]]; + }; + + vertex main0_out main0(main0_in in [[stage_in]], constant gbuffer_billboard_vs_params& _24 [[buffer(0)]]) + { + main0_out out = {}; + float3 _53 = _24.offset - _24.cam; + _53.y = 0.0; + float4 _88 = float4((_24.offset + (fast::normalize(cross(float3(0.0, 1.0, 0.0), fast::normalize(_53))) * ((in.position.x - 0.5) * _24.size.x))) + (float3(0.0, 1.0, 0.0) * (in.position.y * _24.size.y)), 1.0); + out.gl_Position = _24.mvp * _88; + out.view_space_pos = (_24.view_matrix * _88).xyz; + out.view_space_normal = float3x3(_24.view_matrix[0].xyz, _24.view_matrix[1].xyz, _24.view_matrix[2].xyz) * float3(0.0, 1.0, 0.0); + out.uv_in = float2(_24.uvs.x + (in.position.x * _24.uvs.z), _24.uvs.y + (in.position.y * _24.uvs.w)); + return out; + } + +*/ +vs_gbuffer_billboard_source_metal_macos := u8.[ + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x67, + 0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, + 0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x75,0x76,0x73,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6f,0x66,0x66,0x73,0x65,0x74, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x73,0x69,0x7a, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x63,0x61, + 0x6d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20, + 0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x3b,0x0a,0x7d,0x3b,0x0a, + 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75, + 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75, + 0x76,0x5f,0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33, + 0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20, + 0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x69,0x65,0x77, + 0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b, + 0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x33,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b, + 0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a, + 0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30, + 0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30, + 0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69, + 0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x67,0x62, + 0x75,0x66,0x66,0x65,0x72,0x5f,0x62,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x5f, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x34,0x20,0x5b, + 0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a, + 0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75, + 0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x6f,0x66,0x66, + 0x73,0x65,0x74,0x20,0x2d,0x20,0x5f,0x32,0x34,0x2e,0x63,0x61,0x6d,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x38,0x38,0x20,0x3d, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x5f,0x32,0x34,0x2e,0x6f,0x66,0x66, + 0x73,0x65,0x74,0x20,0x2b,0x20,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72, + 0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x66,0x6c,0x6f, + 0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x29,0x2c,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c, + 0x69,0x7a,0x65,0x28,0x5f,0x35,0x33,0x29,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x69, + 0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30, + 0x2e,0x35,0x29,0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x73,0x69,0x7a,0x65,0x2e,0x78, + 0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28, + 0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20, + 0x5f,0x32,0x34,0x2e,0x73,0x69,0x7a,0x65,0x2e,0x79,0x29,0x29,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x34,0x2e,0x6d,0x76, + 0x70,0x20,0x2a,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20, + 0x3d,0x20,0x28,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72, + 0x69,0x78,0x20,0x2a,0x20,0x5f,0x38,0x38,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63, + 0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x33,0x78,0x33,0x28,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74, + 0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x32,0x34,0x2e, + 0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78, + 0x79,0x7a,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74, + 0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x66,0x6c, + 0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x5f, + 0x69,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x5f,0x32,0x34,0x2e, + 0x75,0x76,0x73,0x2e,0x78,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73, + 0x2e,0x7a,0x29,0x2c,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x79,0x20,0x2b, + 0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20, + 0x2a,0x20,0x5f,0x32,0x34,0x2e,0x75,0x76,0x73,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, +]; +/* + #include + #include + + using namespace metal; + + struct main0_out + { + float4 out_position [[color(0)]]; + float4 out_normal [[color(1)]]; + }; + + struct main0_in + { + float2 uv_in [[user(locn0)]]; + float3 view_space_pos [[user(locn1)]]; + float3 view_space_normal [[user(locn2)]]; + }; + + fragment main0_out main0(main0_in in [[stage_in]], texture2d gsprite [[texture(0)]], sampler gspritesmp [[sampler(0)]]) + { + main0_out out = {}; + if (gsprite.sample(gspritesmp, in.uv_in).w < 0.00999999977648258209228515625) + { + discard_fragment(); + } + out.out_position = float4(in.view_space_pos, 1.0); + out.out_normal = float4(fast::normalize(in.view_space_normal), 1.0); + return out; + } + +*/ +fs_gbuffer_billboard_source_metal_macos := u8.[ + 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f, + 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65, + 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a, + 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20, + 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f, + 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x31, + 0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20, + 0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73, + 0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61, + 0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f, + 0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f, + 0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e, + 0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65, + 0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b, + 0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78, + 0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x67,0x73, + 0x70,0x72,0x69,0x74,0x65,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x67,0x73, + 0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c, + 0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d, + 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b, + 0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x67,0x73,0x70,0x72,0x69, + 0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x67,0x73,0x70,0x72,0x69,0x74, + 0x65,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x29,0x2e, + 0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37, + 0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35, + 0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d, + 0x65,0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, + 0x20,0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x69, + 0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f, + 0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28, + 0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28, + 0x69,0x6e,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f, + 0x72,0x6d,0x61,0x6c,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, +]; +gbuffer_billboard_shader_desc :: (backend: sg_backend) -> sg_shader_desc { + desc: sg_shader_desc; + desc.label = "gbuffer_billboard_shader"; + if backend == { + case .GLCORE; + desc.vertex_func.source = xx *vs_gbuffer_billboard_source_glsl430; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_gbuffer_billboard_source_glsl430; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 192; + desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 12; + desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_billboard_vs_params"; + desc.images[0].stage = .FRAGMENT; + desc.images[0].multisampled = false; + desc.images[0].image_type = ._2D; + desc.images[0].sample_type = .FLOAT; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 0; + desc.image_sampler_pairs[0].sampler_slot = 0; + desc.image_sampler_pairs[0].glsl_name = "gsprite_gspritesmp"; + case .GLES3; + desc.vertex_func.source = xx *vs_gbuffer_billboard_source_glsl300es; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_gbuffer_billboard_source_glsl300es; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 192; + desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 12; + desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_billboard_vs_params"; + desc.images[0].stage = .FRAGMENT; + desc.images[0].multisampled = false; + desc.images[0].image_type = ._2D; + desc.images[0].sample_type = .FLOAT; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 0; + desc.image_sampler_pairs[0].sampler_slot = 0; + desc.image_sampler_pairs[0].glsl_name = "gsprite_gspritesmp"; + case .METAL_MACOS; + desc.vertex_func.source = xx *vs_gbuffer_billboard_source_metal_macos; + desc.vertex_func.entry = "main0"; + desc.fragment_func.source = xx *fs_gbuffer_billboard_source_metal_macos; + desc.fragment_func.entry = "main0"; + desc.attrs[0].base_type = .FLOAT; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 192; + desc.uniform_blocks[0].msl_buffer_n = 0; + desc.images[0].stage = .FRAGMENT; + desc.images[0].multisampled = false; + desc.images[0].image_type = ._2D; + desc.images[0].sample_type = .FLOAT; + desc.images[0].msl_texture_n = 0; + desc.samplers[0].stage = .FRAGMENT; + desc.samplers[0].sampler_type = .FILTERING; + desc.samplers[0].msl_sampler_n = 0; + desc.image_sampler_pairs[0].stage = .FRAGMENT; + desc.image_sampler_pairs[0].image_slot = 0; + desc.image_sampler_pairs[0].sampler_slot = 0; + } + return desc; +} diff --git a/src/shaders/shader_gbuffer_billboard.glsl b/src/shaders/shader_gbuffer_billboard.glsl new file mode 100644 index 0000000..0db1f98 --- /dev/null +++ b/src/shaders/shader_gbuffer_billboard.glsl @@ -0,0 +1,59 @@ +@vs vs_gbuffer_billboard + +in vec3 position; + +layout(binding=0) uniform gbuffer_billboard_vs_params { + mat4 mvp; + vec4 uvs; + vec3 offset; + vec2 size; + vec3 cam; + mat4 view_matrix; +}; + +out vec2 uv_in; +out vec3 view_space_pos; +out vec3 view_space_normal; + +void main() { + vec3 local_pos = vec3((position.x - 0.5) * size.x, (position.y) * size.y, position.z); + vec3 world_up = vec3(0.0, 1.0, 0.0); + vec3 look_dir = offset - cam; + look_dir.y = 0.0; + look_dir = normalize(look_dir); + vec3 world_right = normalize(cross(world_up, look_dir)); + vec3 world_pos = offset + (world_right * local_pos.x) + (world_up * local_pos.y); + gl_Position = mvp * vec4(world_pos, 1.0); + vec4 view_pos_4 = view_matrix * vec4(world_pos, 1.0); + view_space_pos = view_pos_4.xyz; + view_space_normal = mat3(view_matrix) * vec3(0,1,0); + uv_in = vec2(uvs.x + position.x * uvs.z, uvs.y + position.y * uvs.w); +} +@end + +@fs fs_gbuffer_billboard + +in vec2 uv_in; +in vec3 view_space_pos; +in vec3 view_space_normal; + +layout(binding = 0) uniform texture2D gsprite; +layout(binding = 0) uniform sampler gspritesmp; + +layout(location=0) out vec4 out_position; +layout(location=1) out vec4 out_normal; + +void main() { + vec2 uv = uv_in; + #if SOKOL_GLSL + uv.y = 1.0 - uv.y; + #endif + vec4 sampled = texture(sampler2D(gsprite, gspritesmp), uv); + if(sampled.a < 0.01) discard; + out_position = vec4(view_space_pos, 1.0); + out_normal = vec4(normalize(view_space_normal), 1.0); +} + +@end + +@program gbuffer_billboard vs_gbuffer_billboard fs_gbuffer_billboard