Compare commits

...

2 Commits

Author SHA1 Message Date
c30381aa72 small improvements 2025-10-19 22:51:46 +03:00
546067fda7 work on geometry pass for SSAO 2025-10-19 21:35:31 +03:00
9 changed files with 653 additions and 12 deletions

View File

@ -7,7 +7,7 @@ theme_ptr : GR.Overall_Theme;
current_pipeline : s32 = 0;
current_slot : s32 = 0;
pipeline_names : []string = .["shadowmap", "reflection", "main"];
pipeline_names : []string = .["shadowmap", "reflection", "main", "position", "normal"];
draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *void) {
r2 := r;
@ -27,6 +27,8 @@ draw_subwindow_texture_debug :: (state: *GR.Subwindow_State, r: GR.Rect, data: *
case 0; image = g_shadowmap_img;
case 1; image = gPipelines.plane.bind.images[0];
case 2; image = g_rendertex;
case 3; image = g_gbuf_position;
case 4; image = g_gbuf_normal;
}
uiTex.tex = image;

View File

@ -5,6 +5,7 @@ Render_Command_Buckets :: struct {
shadow : [..]*Render_Command;
reflection : [..]*Render_Command;
main : [..]*Render_Command;
gbuffer : [..]*Render_Command;
ui : [..]*Render_Command;
}

View File

@ -8,6 +8,7 @@ current_trile_offset_index : s32 = 0;
current_world_config : *World_Config = null;
in_shadowmap_pass : bool = false;
in_reflection_pass : bool = false;
in_gbuffer_pass : bool = false;
shadow_mvp : Matrix4;
backend_handle_command :: (cmd: *Render_Command) {
@ -98,6 +99,42 @@ backend_add_trile_positions :: (positions : []Vector4) {
}
backend_draw_trile_positions :: (trile : string, amount : s32, worldConf: *World_Config) {
if in_gbuffer_pass {
backend_draw_trile_positions_gbuffer(trile, amount, worldConf);
} else {
backend_draw_trile_positions_main(trile, amount, worldConf);
}
}
backend_draw_trile_positions_gbuffer :: (trile : string, amount : s32, worldConf: *World_Config) {
mvp := create_viewproj(*camera);
view := create_lookat(*camera);
vs_params : Gbuffer_Vs_Params;
vs_params.mvp = mvp.floats;
vs_params.view_matrix = view.floats;
sg_apply_pipeline(gPipelines.gbuffer.pipeline);
world_conf : Trile_World_Config;
world_config_to_shader_type(worldConf, *world_conf);
offset := trile_offsets[current_trile_offset_index];
current_trile_offset_index += 1;
trilegfx := get_trile_gfx(trile);
bindings : sg_bindings;
bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
bindings.vertex_buffers[1] = trilegfx.normal_buffer;
bindings.vertex_buffers[2] = trilegfx.centre_buffer;
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
bindings.vertex_buffer_offsets[3] = offset;
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
bindings.images[0] = trilegfx.trixel_colors;
sg_apply_bindings(*bindings);
sg_apply_uniforms(UB_gbuffer_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
sg_draw(0, cast(s32) trilegfx.vertex_count, amount);
}
backend_draw_trile_positions_main :: (trile : string, amount : s32, worldConf: *World_Config) {
mvp : Matrix4;
if !in_shadowmap_pass {
mvp = create_viewproj(*camera);
@ -128,15 +165,12 @@ backend_draw_trile_positions :: (trile : string, amount : s32, worldConf: *World
fs_params : Trile_Fs_Params;
fs_params.mvp_shadow = shadow_mvp.floats;
fs_params.is_reflection = ifx in_reflection_pass then cast(s32)1 else cast(s32)0;
sg_apply_bindings(*bindings);
sg_apply_uniforms(UB_trile_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
sg_apply_uniforms(UB_trile_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
sg_draw(0, cast(s32) trilegfx.vertex_count, amount);
}
backend_draw_sky :: (wc: *World_Config) {
mvp := create_viewproj(*camera);
vs_params : Sky_Vs_Params;
@ -201,7 +235,7 @@ backend_process_command_buckets :: () {
}
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
// 2. Reflection pass
// 3. Reflection pass
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = gPipelines.plane.attachments}));
in_reflection_pass = true;
for render_command_buckets.reflection {
@ -211,7 +245,19 @@ backend_process_command_buckets :: () {
sg_end_pass();
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
// 3. Main pass
// 4. G-Buffer pass
in_gbuffer_pass = true;
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, 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.
// --- TODO: Do SSAO pass here:
// 5. Main pass
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_rendertex_attachments}));
for render_command_buckets.main {
backend_handle_command(it);
@ -219,7 +265,8 @@ backend_process_command_buckets :: () {
sg_end_pass();
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
// Begin main pass
// Begin drawing to swapchain
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, swapchain = cast,force(sg_swapchain) sglue_swapchain() }));
// Draw the render texture and do post processing:
@ -236,8 +283,6 @@ backend_process_command_buckets :: () {
sgl_ortho(0.0, sapp_widthf(), sapp_heightf(), 0.0, -1.0, +1.0);
arb_tri_flush();
// End the main pass
sg_end_pass();
sg_commit();
@ -246,6 +291,7 @@ backend_process_command_buckets :: () {
array_reset_keeping_memory(*render_command_buckets.shadow);
array_reset_keeping_memory(*render_command_buckets.reflection);
array_reset_keeping_memory(*render_command_buckets.main);
array_reset_keeping_memory(*render_command_buckets.gbuffer);
array_reset_keeping_memory(*render_command_buckets.ui);
array_reset_keeping_memory(*trile_offsets);
current_world_config = null;

View File

@ -18,7 +18,16 @@ g_rendertex : sg_image;
g_rendertex_depth : sg_image;
g_rendertex_attachments : sg_attachments;
g_gbuf_position : sg_image;
g_gbuf_normal : sg_image;
g_gbuf_depth : sg_image;
g_gbuf_attachments : sg_attachments;
g_ssaobuf : sg_image;
gPipelines : struct {
// G-Buffer generation for SSAO and other effects
gbuffer: Pipeline_Binding;
// Arbitrary triangle rendering for rendering 2D things on the screen.
// Used for UI rendering.
@ -100,6 +109,8 @@ create_shadowmap_image :: () {
}
create_pipelines :: () {
create_gbuffer_images();
create_gbuffer_pipeline();
create_arbtri_pipeline();
create_trixel_pipeline();
create_trile_pipeline();
@ -111,6 +122,40 @@ create_pipelines :: () {
create_final_image();
}
create_gbuffer_images :: () {
w,h := get_render_size();
if g_gbuf_position.id != INVALID_ID then sg_destroy_image(g_gbuf_position);
if g_gbuf_normal.id != INVALID_ID then sg_destroy_image(g_gbuf_normal);
if g_gbuf_depth.id != INVALID_ID then sg_destroy_image(g_gbuf_depth);
img_desc := sg_image_desc.{
width = w,
height = h,
pixel_format = .RGBA16F,
render_target = true,
};
depth_desc := sg_image_desc.{
width = w,
height = h,
pixel_format = .DEPTH,
render_target = true,
};
g_gbuf_position = sg_make_image(*img_desc);
g_gbuf_normal = sg_make_image(*img_desc);
g_gbuf_depth = sg_make_image(*depth_desc);
attachmentsDesc : sg_attachments_desc;
attachmentsDesc = .{
colors[0].image = g_gbuf_position,
colors[1].image = g_gbuf_normal,
depth_stencil.image = g_gbuf_depth,
};
sg_destroy_attachments(g_gbuf_attachments);
g_gbuf_attachments = sg_make_attachments(*attachmentsDesc);
}
TRIXEL_SIZE_HALF : float : 1.0/32.0;
TRIXEL_SIZE : float : 1.0/16.0;
@ -237,6 +282,49 @@ create_trixel_pipeline :: () {
gPipelines.trixel.bind.vertex_buffers[2] = sg_make_buffer(*instance_buffer);
}
create_gbuffer_pipeline :: () {
pipeline: sg_pipeline_desc;
shader_desc := gbuffer_shader_desc(sg_query_backend());
pipeline.shader = sg_make_shader(*shader_desc);
pipeline.layout.buffers[0].stride = 4*3;
pipeline.layout.buffers[1].stride = 4*3;
pipeline.layout.buffers[3].step_func = .PER_INSTANCE;
instance_buffer := sg_buffer_desc.{ usage = .STREAM, size = 16 * 4096 * 4 * 4};
pipeline.layout.attrs[ATTR_trile_position] = .{ format = .FLOAT3, buffer_index = 0 };
pipeline.layout.attrs[ATTR_trile_normal] = .{ format = .FLOAT3, buffer_index = 1 };
pipeline.layout.attrs[ATTR_trile_centre] = .{ format = .FLOAT3, buffer_index = 2 };
pipeline.layout.attrs[ATTR_trile_instance] = .{ format = .FLOAT4, buffer_index = 3 };
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;
gPipelines.gbuffer.pipeline = sg_make_pipeline(*pipeline);
gPipelines.gbuffer.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,
}));
gPipelines.gbuffer.bind.vertex_buffers[3] = sg_make_buffer(*instance_buffer);
}
create_trile_pipeline :: () {
pipeline: sg_pipeline_desc;
shader_desc := trile_shader_desc(sg_query_backend());

View File

@ -103,6 +103,7 @@ tasks_to_commands :: () {
drawPositionsCmd.conf = trileTask.worldConf;
array_add(*render_command_buckets.reflection, drawPositionsCmd);
array_add(*render_command_buckets.main, drawPositionsCmd);
array_add(*render_command_buckets.gbuffer, drawPositionsCmd);
array_add(*render_command_buckets.shadow, drawPositionsCmd);
case .SKY;
command := New(Render_Command_Sky,, temp);
@ -121,6 +122,7 @@ tasks_to_commands :: () {
command := New(Render_Command_Set_Camera,, temp);
command.camera = task.camera;
array_add(*render_command_buckets.main, command);
array_add(*render_command_buckets.gbuffer, command);
commandReflected := New(Render_Command_Set_Camera,, temp);
commandReflected.camera = task.camera;
commandReflected.camera.target *= Vector3.{1, -1, 1};

View File

@ -0,0 +1,457 @@
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shader_gbuffer.glsl -o ./jai/shader_gbuffer.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
Shader program: 'gbuffer':
Get shader desc: gbuffer_shader_desc(sg_query_backend())
Vertex Shader: vs_g
Fragment Shader: fs_g
Attributes:
ATTR_gbuffer_position => 0
ATTR_gbuffer_normal => 1
ATTR_gbuffer_centre => 2
ATTR_gbuffer_instance => 3
Bindings:
Uniform block 'gbuffer_vs_params':
Jai struct: Gbuffer_Vs_Params
Bind slot: UB_gbuffer_vs_params => 0
*/
ATTR_gbuffer_position :: 0;
ATTR_gbuffer_normal :: 1;
ATTR_gbuffer_centre :: 2;
ATTR_gbuffer_instance :: 3;
UB_gbuffer_vs_params :: 0;
Gbuffer_Vs_Params :: struct {
mvp: [16]float;
view_matrix: [16]float;
};
/*
#version 430
uniform vec4 gbuffer_vs_params[8];
layout(location = 0) in vec4 position;
layout(location = 3) in vec4 instance;
layout(location = 0) out vec3 view_space_pos;
layout(location = 1) out vec3 view_space_normal;
layout(location = 1) in vec4 normal;
layout(location = 2) in vec4 centre;
void main()
{
vec4 _23 = vec4(position.xyz + instance.xyz, 1.0);
mat4 _33 = mat4(gbuffer_vs_params[4], gbuffer_vs_params[5], gbuffer_vs_params[6], gbuffer_vs_params[7]);
gl_Position = mat4(gbuffer_vs_params[0], gbuffer_vs_params[1], gbuffer_vs_params[2], gbuffer_vs_params[3]) * _23;
view_space_pos = (_33 * _23).xyz;
view_space_normal = mat3(_33[0].xyz, _33[1].xyz, _33[2].xyz) * normal.xyz;
}
*/
vs_g_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,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,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,0x34,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,0x33,0x29,0x20,0x69,0x6e,0x20,
0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,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,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,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,
0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,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,0x34,0x20,
0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,
0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x67,0x62,
0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x36,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,
0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,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,0x76,0x73,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,0x62,
0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,
0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x32,0x33,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,0x33,0x33,0x20,0x2a,0x20,0x5f,0x32,0x33,
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,0x33,0x33,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,
0x5f,0x33,0x33,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,
0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 430
layout(location = 0) out vec4 out_position;
layout(location = 0) in vec3 view_space_pos;
layout(location = 1) out vec4 out_normal;
layout(location = 1) in vec3 view_space_normal;
void main()
{
out_position = vec4(view_space_pos, 1.0);
out_normal = vec4(normalize(view_space_normal), 1.0);
}
*/
fs_g_source_glsl430 := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,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,0x30,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,0x31,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,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_vs_params[8];
layout(location = 0) in vec4 position;
layout(location = 3) in vec4 instance;
out vec3 view_space_pos;
out vec3 view_space_normal;
layout(location = 1) in vec4 normal;
layout(location = 2) in vec4 centre;
void main()
{
vec4 _23 = vec4(position.xyz + instance.xyz, 1.0);
mat4 _33 = mat4(gbuffer_vs_params[4], gbuffer_vs_params[5], gbuffer_vs_params[6], gbuffer_vs_params[7]);
gl_Position = mat4(gbuffer_vs_params[0], gbuffer_vs_params[1], gbuffer_vs_params[2], gbuffer_vs_params[3]) * _23;
view_space_pos = (_33 * _23).xyz;
view_space_normal = mat3(_33[0].xyz, _33[1].xyz, _33[2].xyz) * normal.xyz;
}
*/
vs_g_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,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
0x38,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,0x34,
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,0x33,0x29,0x20,
0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
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,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,0x34,0x20,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,0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,
0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,0x79,0x7a,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,
0x5f,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,
0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x67,0x62,0x75,
0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,
0x5d,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,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,
0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
0x5d,0x29,0x20,0x2a,0x20,0x5f,0x32,0x33,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,0x33,0x33,0x20,0x2a,0x20,0x5f,0x32,0x33,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,0x33,0x33,
0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,0x31,0x5d,0x2e,
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,
0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
];
/*
#version 300 es
precision mediump float;
precision highp int;
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()
{
out_position = vec4(view_space_pos, 1.0);
out_normal = vec4(normalize(view_space_normal), 1.0);
}
*/
fs_g_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,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,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 <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct gbuffer_vs_params
{
float4x4 mvp;
float4x4 view_matrix;
};
struct main0_out
{
float3 view_space_pos [[user(locn0)]];
float3 view_space_normal [[user(locn1)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float4 position [[attribute(0)]];
float4 normal [[attribute(1)]];
float4 instance [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant gbuffer_vs_params& _28 [[buffer(0)]])
{
main0_out out = {};
float4 _23 = float4(in.position.xyz + in.instance.xyz, 1.0);
out.gl_Position = _28.mvp * _23;
out.view_space_pos = (_28.view_matrix * _23).xyz;
out.view_space_normal = float3x3(_28.view_matrix[0].xyz, _28.view_matrix[1].xyz, _28.view_matrix[2].xyz) * in.normal.xyz;
return out;
}
*/
vs_g_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,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,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,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,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,0x6e,0x6f,0x72,0x6d,0x61,0x6c,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,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,0x34,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,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,
0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,
0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,
0x75,0x74,0x65,0x28,0x33,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,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x38,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,0x34,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,
0x2b,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,0x79,
0x7a,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,0x38,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x32,0x33,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,0x38,0x2e,0x76,0x69,0x65,0x77,
0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x32,0x33,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,0x38,0x2e,0x76,0x69,0x65,
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,
0x20,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,
0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,
0x20,0x2a,0x20,0x69,0x6e,0x2e,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_position [[color(0)]];
float4 out_normal [[color(1)]];
};
struct main0_in
{
float3 view_space_pos [[user(locn0)]];
float3 view_space_normal [[user(locn1)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
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_g_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,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,
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,0x6e,0x6f,0x72,0x6d,
0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,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,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,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_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
desc.label = "gbuffer_shader";
if backend == {
case .GLCORE;
desc.vertex_func.source = xx *vs_g_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_g_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "normal";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "centre";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "instance";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_vs_params";
case .GLES3;
desc.vertex_func.source = xx *vs_g_source_glsl300es;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_g_source_glsl300es;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "normal";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "centre";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "instance";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_vs_params";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_g_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = xx *fs_g_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[1].base_type = .FLOAT;
desc.attrs[2].base_type = .FLOAT;
desc.attrs[3].base_type = .FLOAT;
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].msl_buffer_n = 0;
}
return desc;
}

View File

@ -0,0 +1,39 @@
@vs vs_g
layout(binding=0) uniform gbuffer_vs_params {
mat4 mvp;
mat4 view_matrix;
};
in vec4 position;
in vec4 normal;
in vec4 centre;
in vec4 instance;
out vec3 view_space_pos;
out vec3 view_space_normal;
void main() {
vec4 world_pos = vec4(position.xyz + instance.xyz, 1.0);
vec4 view_pos_4 = view_matrix * world_pos;
gl_Position = mvp * world_pos;
view_space_pos = view_pos_4.xyz;
view_space_normal = mat3(view_matrix) * normal.xyz;
}
@end
@fs fs_g
in vec3 view_space_pos;
in vec3 view_space_normal;
layout(location=0) out vec4 out_position;
layout(location=1) out vec4 out_normal;
void main() {
out_position = vec4(view_space_pos, 1.0);
out_normal = vec4(normalize(view_space_normal), 1.0);
}
@end
@program gbuffer vs_g fs_g

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1640"
version = "1.7">
version = "2.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
@ -35,11 +35,17 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "/Users/tuomas.katajisto/trueno"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
Location = "home"
FilePath = "../../Users/tuomas.katajisto/trueno/first">
</PathRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"