implement depth of field
This commit is contained in:
parent
8489b84660
commit
78014fcb6f
@ -19,10 +19,11 @@ game_ui :: () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
game_tick :: () {
|
game_tick :: () {
|
||||||
if input_button_states[#char "W"] & .START then char_pos += Vector3.{1.0, 0.0, 0.0};
|
speed := 0.1;
|
||||||
if input_button_states[#char "S"] & .START then char_pos += Vector3.{-1.0, 0.0, 0.0};
|
if input_button_states[#char "W"] & .DOWN then char_pos += speed * Vector3.{-1.0, 0.0, 0.0};
|
||||||
if input_button_states[#char "A"] & .START then char_pos += Vector3.{0.0, 0.0, 1.0};
|
if input_button_states[#char "S"] & .DOWN then char_pos += speed * Vector3.{1.0, 0.0, 0.0};
|
||||||
if input_button_states[#char "D"] & .START then char_pos += Vector3.{0.0, 0.0, -1.0};
|
if input_button_states[#char "A"] & .DOWN then char_pos += speed * Vector3.{0.0, 0.0, 1.0};
|
||||||
|
if input_button_states[#char "D"] & .DOWN then char_pos += speed * Vector3.{0.0, 0.0, -1.0};
|
||||||
cam.target = char_pos;
|
cam.target = char_pos;
|
||||||
cam.position = char_pos + .{10,5,0};
|
cam.position = char_pos + .{10,5,0};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
{
|
{
|
||||||
"exposure": 0.057475,
|
"exposure": -0.239281,
|
||||||
"contrast": 1.075945,
|
"contrast": 1.821381,
|
||||||
"saturation": 1.202777,
|
"saturation": 0.988528,
|
||||||
"gamma": 1.019477,
|
"gamma": 2.194679,
|
||||||
"tonemap": 1,
|
"tonemap": 1,
|
||||||
"ssao": 2.603531
|
"ssao": 0.864454,
|
||||||
|
"dilate_separation": 1.318038,
|
||||||
|
"dilate_size": 7,
|
||||||
|
"dilate_min": 0.142381,
|
||||||
|
"dilate_max": 0.242047,
|
||||||
|
"dof_blur_size": 2,
|
||||||
|
"dof_min": 2.750411,
|
||||||
|
"dof_max": 15.987307,
|
||||||
|
"dof_point": 14.644861
|
||||||
}
|
}
|
||||||
@ -214,16 +214,17 @@
|
|||||||
},{
|
},{
|
||||||
"trileName": "pillar_top",
|
"trileName": "pillar_top",
|
||||||
"positions": [
|
"positions": [
|
||||||
0,2,2,1,0,1,-1,1,-3,2,-1,1,-3,3,2,1
|
0,2,2,1,0,1,-1,1,-3,2,-1,1,-3,3,2,1,-46,3,-13,1,-46,4,-15,1,-48,4,-15,1,-48,4,-13,1
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
"trileName": "test",
|
"trileName": "test",
|
||||||
"positions": [
|
"positions": [
|
||||||
-3,1,-1,1,0,1,2,1,-3,1,2,1,0,0,2,1,-3,0,2,1,-3,0,-1,1,0,0,-1,1,-3,2,2,1
|
-3,1,-1,1,0,1,2,1,-3,1,2,1,0,0,2,1,-3,0,2,1,-3,0,-1,1,0,0,-1,1,-3,2,2,1,-46,0,-15,1,-46,0,-13,1,-48,0,-13,1,-48,0,-15,1,-46,1,-15,1,-46,1,-13,1,-48,1,-13,1,-48,1,-15,1,-46,2,-15,1,-46,2,-13,1,-48,2,-13,1,-48,2,-15,1,-48,3,-13,1,-48,3,-15,1,-46,3,-15,1
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
"trileName": "plat",
|
"trileName": "plat",
|
||||||
"positions": [
|
"positions": [
|
||||||
|
-47,3,-15,1,-47,3,-14,1,-48,3,-14,1,-46,3,-14,1,-47,3,-13,1
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
"trileName": "deck",
|
"trileName": "deck",
|
||||||
|
|||||||
@ -35,6 +35,7 @@ V_MINOR :: 5;
|
|||||||
|
|
||||||
state: struct {
|
state: struct {
|
||||||
pass_action_clear : sg_pass_action;
|
pass_action_clear : sg_pass_action;
|
||||||
|
pass_action_clear_gbuf : sg_pass_action;
|
||||||
pass_action : sg_pass_action;
|
pass_action : sg_pass_action;
|
||||||
dpi_scale : float;
|
dpi_scale : float;
|
||||||
fons : *FONScontext;
|
fons : *FONScontext;
|
||||||
@ -88,6 +89,7 @@ init :: () {
|
|||||||
create_pipelines();
|
create_pipelines();
|
||||||
|
|
||||||
state.pass_action_clear.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 0, a = 0 } };
|
state.pass_action_clear.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 0, a = 0 } };
|
||||||
|
state.pass_action_clear_gbuf.colors[0] = .{ load_action = .CLEAR, clear_value = .{ r = 0, g = 0, b = 1000, a = 0 } };
|
||||||
state.pass_action.colors[0] = .{ load_action = .LOAD };
|
state.pass_action.colors[0] = .{ load_action = .LOAD };
|
||||||
|
|
||||||
init_asset_pack_load();
|
init_asset_pack_load();
|
||||||
|
|||||||
@ -30,7 +30,11 @@ backend_handle_command :: (cmd: *Render_Command) {
|
|||||||
update_image_from_ground(gen_command.world, *gPipelines.plane.bind.images[1]);
|
update_image_from_ground(gen_command.world, *gPipelines.plane.bind.images[1]);
|
||||||
case .DRAW_GROUND;
|
case .DRAW_GROUND;
|
||||||
ground_command := cast(*Render_Command_Draw_Ground)cmd;
|
ground_command := cast(*Render_Command_Draw_Ground)cmd;
|
||||||
|
if in_gbuffer_pass {
|
||||||
|
backend_draw_ground_gbuf(ground_command.worldConfig);
|
||||||
|
} else {
|
||||||
backend_draw_ground(ground_command.worldConfig);
|
backend_draw_ground(ground_command.worldConfig);
|
||||||
|
}
|
||||||
case .UPDATE_TRIXELS;
|
case .UPDATE_TRIXELS;
|
||||||
trixel_update_command := cast(*Render_Command_Update_Trixels)cmd;
|
trixel_update_command := cast(*Render_Command_Update_Trixels)cmd;
|
||||||
backend_update_trixels(trixel_update_command);
|
backend_update_trixels(trixel_update_command);
|
||||||
@ -218,6 +222,27 @@ backend_draw_ground :: (wc: *World_Config) {
|
|||||||
sg_draw(0, 6, 2);
|
sg_draw(0, 6, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backend_draw_ground_gbuf :: (wc: *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;
|
||||||
|
vs_params.isGround = 1;
|
||||||
|
vs_params.planeHeight = wc.planeHeight;
|
||||||
|
sg_apply_pipeline(gPipelines.gbuffer.pipeline);
|
||||||
|
|
||||||
|
bindings : sg_bindings;
|
||||||
|
bindings.vertex_buffers[0] = g_plane_gbuffer_vertex_buffer;
|
||||||
|
bindings.vertex_buffers[1] = g_plane_gbuffer_normal_buffer;
|
||||||
|
bindings.vertex_buffers[2] = g_plane_gbuffer_center_buffer;
|
||||||
|
bindings.vertex_buffers[3] = g_plane_gbuffer_instance_buffer;
|
||||||
|
|
||||||
|
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, 6, 1);
|
||||||
|
}
|
||||||
|
|
||||||
backend_process_command_buckets :: () {
|
backend_process_command_buckets :: () {
|
||||||
// 1. Set up textures and buffers.
|
// 1. Set up textures and buffers.
|
||||||
for render_command_buckets.setup {
|
for render_command_buckets.setup {
|
||||||
@ -248,7 +273,7 @@ backend_process_command_buckets :: () {
|
|||||||
|
|
||||||
// 4. G-Buffer pass
|
// 4. G-Buffer pass
|
||||||
in_gbuffer_pass = true;
|
in_gbuffer_pass = true;
|
||||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_gbuf_attachments}));
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear_gbuf, attachments = g_gbuf_attachments}));
|
||||||
for render_command_buckets.gbuffer {
|
for render_command_buckets.gbuffer {
|
||||||
backend_handle_command(it);
|
backend_handle_command(it);
|
||||||
}
|
}
|
||||||
@ -271,9 +296,15 @@ backend_process_command_buckets :: () {
|
|||||||
sg_draw(0, 6, 1);
|
sg_draw(0, 6, 1);
|
||||||
sg_end_pass();
|
sg_end_pass();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments }));
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_ssao_attachments }));
|
||||||
sg_apply_pipeline(gPipelines.op.pipeline);
|
sg_apply_pipeline(gPipelines.op.pipeline);
|
||||||
|
op_uniform : Op_Fs_Params;
|
||||||
|
op_uniform.blur_size = 1;
|
||||||
|
op_uniform.op = 0;
|
||||||
gPipelines.op.bind.images[0] = g_postprocess_a;
|
gPipelines.op.bind.images[0] = g_postprocess_a;
|
||||||
|
sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform, size = size_of(type_of(op_uniform)) }));
|
||||||
sg_apply_bindings(*gPipelines.op.bind);
|
sg_apply_bindings(*gPipelines.op.bind);
|
||||||
sg_draw(0, 6, 1);
|
sg_draw(0, 6, 1);
|
||||||
sg_end_pass();
|
sg_end_pass();
|
||||||
@ -286,13 +317,14 @@ backend_process_command_buckets :: () {
|
|||||||
sg_end_pass();
|
sg_end_pass();
|
||||||
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
||||||
|
|
||||||
|
dof_process();
|
||||||
|
|
||||||
// Begin drawing to swapchain
|
// Begin drawing to swapchain
|
||||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, swapchain = cast,force(sg_swapchain) sglue_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:
|
// Draw the render texture and do post processing:
|
||||||
sg_apply_pipeline(gPipelines.postprocess.pipeline);
|
sg_apply_pipeline(gPipelines.postprocess.pipeline);
|
||||||
gPipelines.postprocess.bind.images[0] = g_rendertex;
|
gPipelines.postprocess.bind.images[0] = g_postprocess_a;
|
||||||
sg_apply_bindings(*gPipelines.postprocess.bind);
|
sg_apply_bindings(*gPipelines.postprocess.bind);
|
||||||
post_process_config_uniform : Post_Process_Config;
|
post_process_config_uniform : Post_Process_Config;
|
||||||
fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process);
|
fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process);
|
||||||
|
|||||||
42
src/rendering/backend_sokol_helpers.jai
Normal file
42
src/rendering/backend_sokol_helpers.jai
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
dof_process :: () {
|
||||||
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a }));
|
||||||
|
sg_apply_pipeline(gPipelines.op.pipeline);
|
||||||
|
op_uniform_dilate : Op_Fs_Params;
|
||||||
|
op_uniform_dilate.blur_size = current_post_process.dof_blur_size;
|
||||||
|
op_uniform_dilate.op=2;
|
||||||
|
gPipelines.op.bind.images[0] = g_rendertex;
|
||||||
|
sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform_dilate, size = size_of(type_of(op_uniform_dilate)) }));
|
||||||
|
sg_apply_bindings(*gPipelines.op.bind);
|
||||||
|
sg_draw(0, 6, 1);
|
||||||
|
sg_end_pass();
|
||||||
|
|
||||||
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_b }));
|
||||||
|
sg_apply_pipeline(gPipelines.op.pipeline);
|
||||||
|
op_uniform_dof_blur : Op_Fs_Params;
|
||||||
|
op_uniform_dof_blur.blur_size = current_post_process.dilate_size;
|
||||||
|
op_uniform_dof_blur.separation = current_post_process.dilate_separation;
|
||||||
|
op_uniform_dof_blur.dilate_min = current_post_process.dilate_min;
|
||||||
|
op_uniform_dof_blur.dilate_max = current_post_process.dilate_max;
|
||||||
|
op_uniform_dof_blur.op=1;
|
||||||
|
gPipelines.op.bind.images[0] = g_postprocess_a;
|
||||||
|
sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *op_uniform_dof_blur, size = size_of(type_of(op_uniform_dof_blur)) }));
|
||||||
|
sg_apply_bindings(*gPipelines.op.bind);
|
||||||
|
sg_draw(0, 6, 1);
|
||||||
|
sg_end_pass();
|
||||||
|
|
||||||
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_postprocess_attach_a }));
|
||||||
|
sg_apply_pipeline(gPipelines.mix.pipeline);
|
||||||
|
mix_uniform : Mix_Fs_Params;
|
||||||
|
mix_uniform.op = 0;
|
||||||
|
mix_uniform.dof_min = current_post_process.dof_min;
|
||||||
|
mix_uniform.dof_max = current_post_process.dof_max;
|
||||||
|
mix_uniform.dof_point = current_post_process.dof_point;
|
||||||
|
gPipelines.mix.bind.images[0] = g_postprocess_b;
|
||||||
|
gPipelines.mix.bind.images[1] = g_rendertex;
|
||||||
|
gPipelines.mix.bind.images[2] = g_gbuf_position;
|
||||||
|
sg_apply_uniforms(UB_op_fs_params, *(sg_range.{ ptr = *mix_uniform, size = size_of(type_of(mix_uniform)) }));
|
||||||
|
sg_apply_bindings(*gPipelines.mix.bind);
|
||||||
|
sg_draw(0, 6, 1);
|
||||||
|
sg_end_pass();
|
||||||
|
}
|
||||||
|
|
||||||
@ -62,6 +62,8 @@ gPipelines : struct {
|
|||||||
|
|
||||||
op : Pipeline_Binding;
|
op : Pipeline_Binding;
|
||||||
|
|
||||||
|
mix : Pipeline_Binding;
|
||||||
|
|
||||||
// Renders the SSAO texture using things from the gbuffer pass.
|
// Renders the SSAO texture using things from the gbuffer pass.
|
||||||
ssao: Pipeline_Binding;
|
ssao: Pipeline_Binding;
|
||||||
}
|
}
|
||||||
@ -136,10 +138,12 @@ create_pipelines :: () {
|
|||||||
create_postprocess_pipeline();
|
create_postprocess_pipeline();
|
||||||
create_ssao_pipeline();
|
create_ssao_pipeline();
|
||||||
create_op_pipeline();
|
create_op_pipeline();
|
||||||
|
create_mix_pipeline();
|
||||||
|
|
||||||
create_shadowmap_image();
|
create_shadowmap_image();
|
||||||
create_final_image();
|
create_final_image();
|
||||||
create_ssao_images();
|
create_ssao_images();
|
||||||
|
create_gbuffer_impostors();
|
||||||
}
|
}
|
||||||
|
|
||||||
create_gbuffer_images :: () {
|
create_gbuffer_images :: () {
|
||||||
@ -469,7 +473,6 @@ create_sky_pipeline :: () {
|
|||||||
gPipelines.sky.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
gPipelines.sky.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ToDo: This needs to be redone when the window is resized;
|
|
||||||
create_plane_pipeline_reflection_images :: () {
|
create_plane_pipeline_reflection_images :: () {
|
||||||
binding := *gPipelines.plane.bind;
|
binding := *gPipelines.plane.bind;
|
||||||
if binding.images[4].id != INVALID_ID then sg_destroy_image(binding.images[4]);
|
if binding.images[4].id != INVALID_ID then sg_destroy_image(binding.images[4]);
|
||||||
@ -689,6 +692,7 @@ create_postprocess_pipeline :: () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Takes in a texture, manipulates it and outputs it.
|
||||||
create_op_pipeline :: () {
|
create_op_pipeline :: () {
|
||||||
platconf := get_plat_conf();
|
platconf := get_plat_conf();
|
||||||
pipeline: sg_pipeline_desc;
|
pipeline: sg_pipeline_desc;
|
||||||
@ -749,6 +753,67 @@ create_op_pipeline :: () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Takes in 2-3 textures, and mixes them.
|
||||||
|
create_mix_pipeline :: () {
|
||||||
|
platconf := get_plat_conf();
|
||||||
|
pipeline: sg_pipeline_desc;
|
||||||
|
shader_desc := mix_shader_desc(sg_query_backend());
|
||||||
|
pipeline.shader = sg_make_shader(*shader_desc);
|
||||||
|
|
||||||
|
pipeline.layout.attrs[ATTR_mix_position] = .{ format = .FLOAT2 };
|
||||||
|
pipeline.layout.attrs[ATTR_mix_uv] = .{ format = .FLOAT2 };
|
||||||
|
pipeline.index_type = .UINT16;
|
||||||
|
|
||||||
|
color_state := sg_color_target_state.{
|
||||||
|
blend = .{
|
||||||
|
enabled = true,
|
||||||
|
src_factor_rgb = .SRC_ALPHA,
|
||||||
|
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
|
||||||
|
}
|
||||||
|
};
|
||||||
|
pipeline.depth = .{
|
||||||
|
write_enabled = true,
|
||||||
|
compare = .LESS_EQUAL,
|
||||||
|
pixel_format = .DEPTH
|
||||||
|
};
|
||||||
|
|
||||||
|
pipeline.color_count = 1;
|
||||||
|
pipeline.colors[0] = color_state;
|
||||||
|
|
||||||
|
gPipelines.mix.pipeline = sg_make_pipeline(*pipeline);
|
||||||
|
|
||||||
|
quad_vertices : [16]float = .[
|
||||||
|
-1.0, 1.0, 0.0, flip_if_plat(1.0), // top-let
|
||||||
|
-1.0, -1.0, 0.0, flip_if_plat(0.0), // bottom-let
|
||||||
|
1.0, -1.0, 1.0, flip_if_plat(0.0), // bottom-right
|
||||||
|
1.0, 1.0, 1.0, flip_if_plat(1.0), // top-right
|
||||||
|
];
|
||||||
|
quad_indices : [6]u16 = .[
|
||||||
|
0, 1, 2, 0, 2, 3
|
||||||
|
];
|
||||||
|
|
||||||
|
vbuffer := sg_buffer_desc.{ size = size_of(float) * 16, data = .{
|
||||||
|
ptr = quad_vertices.data,
|
||||||
|
size = 16 * 4
|
||||||
|
}};
|
||||||
|
ibuffer := sg_buffer_desc.{ size = size_of(u16) * 6, data = .{
|
||||||
|
ptr = quad_indices.data,
|
||||||
|
size = 6 * 2
|
||||||
|
},
|
||||||
|
type = .INDEXBUFFER,
|
||||||
|
};
|
||||||
|
|
||||||
|
gPipelines.mix.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||||
|
gPipelines.mix.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||||
|
gPipelines.mix.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,
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
create_ssao_images :: () {
|
create_ssao_images :: () {
|
||||||
if g_ssaobuf.id != INVALID_ID then sg_destroy_image(g_ssaobuf);
|
if g_ssaobuf.id != INVALID_ID then sg_destroy_image(g_ssaobuf);
|
||||||
if g_ssaobuf_depth.id != INVALID_ID then sg_destroy_image(g_ssaobuf_depth);
|
if g_ssaobuf_depth.id != INVALID_ID then sg_destroy_image(g_ssaobuf_depth);
|
||||||
@ -874,3 +939,56 @@ create_ssao_pipeline :: () {
|
|||||||
init_plane_textures :: () {
|
init_plane_textures :: () {
|
||||||
gPipelines.plane.bind.images[3] = create_texture_from_pack("./resources/utiltex/water.png");
|
gPipelines.plane.bind.images[3] = create_texture_from_pack("./resources/utiltex/water.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_plane_gbuffer_vertex_buffer : sg_buffer;
|
||||||
|
g_plane_gbuffer_normal_buffer : sg_buffer;
|
||||||
|
g_plane_gbuffer_center_buffer : sg_buffer;
|
||||||
|
g_plane_gbuffer_instance_buffer : sg_buffer;
|
||||||
|
|
||||||
|
create_gbuffer_impostors :: () {
|
||||||
|
plane_vertices: [6]Vector3 = .[
|
||||||
|
.{-1.0, 0.0, -1.0},
|
||||||
|
.{ 1.0, 0.0, -1.0},
|
||||||
|
.{ 1.0, 0.0, 1.0},
|
||||||
|
.{-1.0, 0.0, -1.0},
|
||||||
|
.{ 1.0, 0.0, 1.0},
|
||||||
|
.{-1.0, 0.0, 1.0},
|
||||||
|
];
|
||||||
|
vbuffer := sg_buffer_desc.{ size = size_of(float) * 18, data = .{
|
||||||
|
ptr = plane_vertices.data,
|
||||||
|
size = 6 * 3 * 4
|
||||||
|
}};
|
||||||
|
g_plane_gbuffer_vertex_buffer = sg_make_buffer(*vbuffer);
|
||||||
|
|
||||||
|
plane_normals: [6]Vector3 = .[
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
];
|
||||||
|
nbuffer := sg_buffer_desc.{ size = size_of(float) * 18, data = .{
|
||||||
|
ptr = plane_normals.data,
|
||||||
|
size = 6 * 3 * 4
|
||||||
|
}};
|
||||||
|
g_plane_gbuffer_normal_buffer = sg_make_buffer(*nbuffer);
|
||||||
|
|
||||||
|
plane_centers: [2]Vector3 = .[ // these are useless, just to fill the pipeline requirement.
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
.{0.0, 1.0, 0.0},
|
||||||
|
];
|
||||||
|
cbuffer := sg_buffer_desc.{ size = size_of(float) * 6, data = .{
|
||||||
|
ptr = plane_centers.data,
|
||||||
|
size = 3 * 2 * 4
|
||||||
|
}};
|
||||||
|
g_plane_gbuffer_center_buffer = sg_make_buffer(*cbuffer);
|
||||||
|
|
||||||
|
instances: [1]Vector4 = .[.{0,0,0,0}];
|
||||||
|
instance_buffer := sg_buffer_desc.{size = 4 * 4, data = .{
|
||||||
|
ptr = instances.data,
|
||||||
|
size = 4*4,
|
||||||
|
}};
|
||||||
|
g_plane_gbuffer_instance_buffer = sg_make_buffer(*instance_buffer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -5,6 +5,14 @@ Post_Process :: struct {
|
|||||||
gamma : float = 1.0; @Slider,0.3,3.0,0.1;
|
gamma : float = 1.0; @Slider,0.3,3.0,0.1;
|
||||||
tonemap : float = 1.0; @Slider,0,1,1;
|
tonemap : float = 1.0; @Slider,0,1,1;
|
||||||
ssao : float = 1.0; @Slider,0,5,0.1;
|
ssao : float = 1.0; @Slider,0,5,0.1;
|
||||||
|
dilate_separation : float = 1.0; @Slider,0,6,0.1;
|
||||||
|
dilate_size : s32 = 2; @Slider,0,10,1;
|
||||||
|
dilate_min : float = 0.1; @Slider,0,1,0.1;
|
||||||
|
dilate_max : float = 0.3; @Slider,0,1,0.1;
|
||||||
|
dof_blur_size : s32 = 2; @Slider,0,10,1;
|
||||||
|
dof_min : float = 1.0; @Slider,0,10,1;
|
||||||
|
dof_max : float = 3.0; @Slider,0,20,1;
|
||||||
|
dof_point : float = 5.0; @Slider,0,30,1;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_post_process : Post_Process;
|
current_post_process : Post_Process;
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#load "helpers.jai";
|
#load "helpers.jai";
|
||||||
#load "pipelines.jai";
|
#load "pipelines.jai";
|
||||||
#load "post_processing.jai";
|
#load "post_processing.jai";
|
||||||
|
#load "backend_sokol_helpers.jai";
|
||||||
|
|
||||||
#scope_file
|
#scope_file
|
||||||
|
|
||||||
|
|||||||
@ -115,8 +115,8 @@ tasks_to_commands :: () {
|
|||||||
commandDrawGround.worldConfig = *(cast(*Rendering_Task_Ground)it).world.conf;
|
commandDrawGround.worldConfig = *(cast(*Rendering_Task_Ground)it).world.conf;
|
||||||
commandGenGround := New(Render_Command_Generate_Ground_Texture,, temp);
|
commandGenGround := New(Render_Command_Generate_Ground_Texture,, temp);
|
||||||
commandGenGround.world = (cast(*Rendering_Task_Ground)it).world;
|
commandGenGround.world = (cast(*Rendering_Task_Ground)it).world;
|
||||||
array_add(*render_command_buckets.setup, commandGenGround);
|
|
||||||
array_add(*render_command_buckets.main, commandDrawGround);
|
array_add(*render_command_buckets.main, commandDrawGround);
|
||||||
|
array_add(*render_command_buckets.gbuffer, commandDrawGround);
|
||||||
case .SET_CAMERA;
|
case .SET_CAMERA;
|
||||||
task := (cast(*Rendering_Task_Set_Camera)it);
|
task := (cast(*Rendering_Task_Set_Camera)it);
|
||||||
command := New(Render_Command_Set_Camera,, temp);
|
command := New(Render_Command_Set_Camera,, temp);
|
||||||
|
|||||||
@ -30,74 +30,116 @@ UB_gbuffer_vs_params :: 0;
|
|||||||
Gbuffer_Vs_Params :: struct {
|
Gbuffer_Vs_Params :: struct {
|
||||||
mvp: [16]float;
|
mvp: [16]float;
|
||||||
view_matrix: [16]float;
|
view_matrix: [16]float;
|
||||||
|
isGround: s32;
|
||||||
|
planeHeight: float;
|
||||||
|
_: [8]u8;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform vec4 gbuffer_vs_params[8];
|
struct gbuffer_vs_params
|
||||||
|
{
|
||||||
|
mat4 mvp;
|
||||||
|
mat4 view_matrix;
|
||||||
|
int isGround;
|
||||||
|
float planeHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform gbuffer_vs_params _12;
|
||||||
|
|
||||||
layout(location = 0) in vec4 position;
|
layout(location = 0) in vec4 position;
|
||||||
layout(location = 3) in vec4 instance;
|
|
||||||
layout(location = 0) out vec3 view_space_pos;
|
layout(location = 0) out vec3 view_space_pos;
|
||||||
layout(location = 1) out vec3 view_space_normal;
|
layout(location = 1) out vec3 view_space_normal;
|
||||||
layout(location = 1) in vec4 normal;
|
layout(location = 1) in vec4 normal;
|
||||||
|
layout(location = 3) in vec4 instance;
|
||||||
layout(location = 2) in vec4 centre;
|
layout(location = 2) in vec4 centre;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 _23 = vec4(position.xyz + instance.xyz, 1.0);
|
if (_12.isGround == 1)
|
||||||
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;
|
vec4 _42 = vec4(position.x * 100.0, _12.planeHeight, position.z * 100.0, 1.0);
|
||||||
view_space_pos = (_33 * _23).xyz;
|
gl_Position = _12.mvp * _42;
|
||||||
view_space_normal = mat3(_33[0].xyz, _33[1].xyz, _33[2].xyz) * normal.xyz;
|
view_space_pos = (_12.view_matrix * _42).xyz;
|
||||||
|
view_space_normal = mat3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * normal.xyz;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vec4 _92 = vec4(position.xyz + instance.xyz, 1.0);
|
||||||
|
gl_Position = _12.mvp * _92;
|
||||||
|
view_space_pos = (_12.view_matrix * _92).xyz;
|
||||||
|
view_space_normal = mat3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * normal.xyz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
vs_g_source_glsl430 := u8.[
|
vs_g_source_glsl430 := u8.[
|
||||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
|
||||||
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x67,0x62,0x75,0x66,0x66,
|
0x72,0x75,0x63,0x74,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,
|
||||||
0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,
|
0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,
|
||||||
|
0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,
|
||||||
|
0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x3b,0x0a,0x20,0x20,0x20,
|
||||||
|
0x20,0x69,0x6e,0x74,0x20,0x69,0x73,0x47,0x72,0x6f,0x75,0x6e,0x64,0x3b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,
|
||||||
|
0x69,0x67,0x68,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,
|
||||||
|
0x6d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||||
|
0x61,0x6d,0x73,0x20,0x5f,0x31,0x32,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,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,
|
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,
|
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,
|
||||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,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,
|
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,
|
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,
|
0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,
|
||||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||||
0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,
|
0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,
|
||||||
0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,
|
0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
|
||||||
0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,
|
0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||||
0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,
|
||||||
0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,
|
||||||
0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||||
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
|
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x32,0x2e,0x69,0x73,0x47,0x72,
|
||||||
0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,
|
0x6f,0x75,0x6e,0x64,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||||
0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,
|
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x34,
|
||||||
0x63,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
0x32,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,
|
0x6e,0x2e,0x78,0x20,0x2a,0x20,0x31,0x30,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x31,0x32,
|
||||||
0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
0x2e,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x2c,0x20,0x70,0x6f,
|
||||||
0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x2e,0x30,
|
||||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x67,0x62,
|
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,
|
||||||
0x36,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,
|
0x32,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x34,0x32,0x3b,0x0a,0x20,0x20,0x20,
|
||||||
0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
0x20,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,
|
||||||
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,
|
0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,
|
||||||
0x34,0x28,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
|
0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x34,0x32,0x29,0x2e,0x78,0x79,
|
||||||
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
|
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,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,
|
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,
|
0x61,0x74,0x33,0x28,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,
|
||||||
0x5f,0x33,0x33,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,
|
0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,
|
||||||
0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78,
|
||||||
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,
|
||||||
|
0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,0x6f,
|
||||||
|
0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x39,0x32,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,0x20,0x20,
|
||||||
|
0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||||
|
0x5f,0x31,0x32,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,
|
||||||
|
0x65,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,
|
||||||
|
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x39,0x32,0x29,0x2e,
|
||||||
|
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,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,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,
|
||||||
|
0x61,0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,
|
||||||
|
0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,
|
||||||
|
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,
|
||||||
|
0x61,0x74,0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,
|
||||||
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#version 430
|
#version 430
|
||||||
@ -139,68 +181,106 @@ fs_g_source_glsl430 := u8.[
|
|||||||
/*
|
/*
|
||||||
#version 300 es
|
#version 300 es
|
||||||
|
|
||||||
uniform vec4 gbuffer_vs_params[8];
|
struct gbuffer_vs_params
|
||||||
|
{
|
||||||
|
mat4 mvp;
|
||||||
|
mat4 view_matrix;
|
||||||
|
int isGround;
|
||||||
|
float planeHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform gbuffer_vs_params _12;
|
||||||
|
|
||||||
layout(location = 0) in vec4 position;
|
layout(location = 0) in vec4 position;
|
||||||
layout(location = 3) in vec4 instance;
|
|
||||||
out vec3 view_space_pos;
|
out vec3 view_space_pos;
|
||||||
out vec3 view_space_normal;
|
out vec3 view_space_normal;
|
||||||
layout(location = 1) in vec4 normal;
|
layout(location = 1) in vec4 normal;
|
||||||
|
layout(location = 3) in vec4 instance;
|
||||||
layout(location = 2) in vec4 centre;
|
layout(location = 2) in vec4 centre;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 _23 = vec4(position.xyz + instance.xyz, 1.0);
|
if (_12.isGround == 1)
|
||||||
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;
|
vec4 _42 = vec4(position.x * 100.0, _12.planeHeight, position.z * 100.0, 1.0);
|
||||||
view_space_pos = (_33 * _23).xyz;
|
gl_Position = _12.mvp * _42;
|
||||||
view_space_normal = mat3(_33[0].xyz, _33[1].xyz, _33[2].xyz) * normal.xyz;
|
view_space_pos = (_12.view_matrix * _42).xyz;
|
||||||
|
view_space_normal = mat3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * normal.xyz;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vec4 _92 = vec4(position.xyz + instance.xyz, 1.0);
|
||||||
|
gl_Position = _12.mvp * _92;
|
||||||
|
view_space_pos = (_12.view_matrix * _92).xyz;
|
||||||
|
view_space_normal = mat3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * normal.xyz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
vs_g_source_glsl300es := u8.[
|
vs_g_source_glsl300es := u8.[
|
||||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
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,
|
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
|
||||||
0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
|
0x6d,0x61,0x74,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,
|
||||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
|
0x74,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x3b,0x0a,
|
||||||
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x69,0x73,0x47,0x72,0x6f,0x75,0x6e,0x64,
|
||||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,
|
||||||
0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
|
0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,
|
||||||
0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,
|
0x66,0x6f,0x72,0x6d,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,
|
||||||
0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,
|
0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x32,0x3b,0x0a,0x0a,0x6c,0x61,0x79,
|
||||||
0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,
|
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,
|
||||||
0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
|
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||||
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,
|
0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,
|
||||||
0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6f,0x75,0x74,
|
||||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,
|
0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,
|
||||||
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,
|
0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,
|
||||||
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x76,
|
0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,
|
||||||
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,
|
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||||
0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,0x79,0x7a,0x2c,
|
0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,
|
||||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,
|
0x6e,0x63,0x65,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||||
0x5f,0x33,0x33,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,
|
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
|
||||||
0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,
|
0x34,0x20,0x63,0x65,0x6e,0x74,0x72,0x65,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
|
||||||
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
|
||||||
0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,
|
0x28,0x5f,0x31,0x32,0x2e,0x69,0x73,0x47,0x72,0x6f,0x75,0x6e,0x64,0x20,0x3d,0x3d,
|
||||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x67,0x62,0x75,
|
0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||||
0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,
|
0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x34,0x32,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||||
0x5d,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x31,
|
||||||
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x67,0x62,0x75,0x66,0x66,
|
0x30,0x30,0x2e,0x30,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x70,0x6c,0x61,0x6e,0x65,0x48,
|
||||||
0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
|
0x65,0x69,0x67,0x68,0x74,0x2c,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,
|
||||||
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
|
||||||
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,
|
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
|
||||||
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x67,0x62,0x75,
|
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x32,0x2e,0x6d,0x76,0x70,0x20,0x2a,
|
||||||
0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
|
0x20,0x5f,0x34,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x69,
|
||||||
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,
|
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,
|
0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,
|
||||||
|
0x2a,0x20,0x5f,0x34,0x32,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
0x20,0x20,0x20,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,
|
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,
|
0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x6d,0x61,0x74,0x33,0x28,0x5f,0x31,0x32,
|
||||||
0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,0x31,0x5d,0x2e,
|
0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,
|
||||||
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x33,0x33,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,
|
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,
|
||||||
0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x7d,
|
0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,
|
||||||
0x0a,0x0a,0x00,
|
0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,
|
||||||
|
0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,
|
||||||
|
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,
|
||||||
|
0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||||
|
0x76,0x65,0x63,0x34,0x20,0x5f,0x39,0x32,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,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||||
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x32,0x2e,0x6d,0x76,0x70,
|
||||||
|
0x20,0x2a,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||||
|
0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x3d,
|
||||||
|
0x20,0x28,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,
|
||||||
|
0x78,0x20,0x2a,0x20,0x5f,0x39,0x32,0x29,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,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,
|
||||||
|
0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,
|
||||||
|
0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,
|
||||||
|
0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,
|
||||||
|
0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x32,
|
||||||
|
0x5d,0x2e,0x78,0x79,0x7a,0x29,0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,
|
||||||
|
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#version 300 es
|
#version 300 es
|
||||||
@ -253,6 +333,8 @@ fs_g_source_glsl300es := u8.[
|
|||||||
{
|
{
|
||||||
float4x4 mvp;
|
float4x4 mvp;
|
||||||
float4x4 view_matrix;
|
float4x4 view_matrix;
|
||||||
|
int isGround;
|
||||||
|
float planeHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct main0_out
|
struct main0_out
|
||||||
@ -269,13 +351,23 @@ fs_g_source_glsl300es := u8.[
|
|||||||
float4 instance [[attribute(3)]];
|
float4 instance [[attribute(3)]];
|
||||||
};
|
};
|
||||||
|
|
||||||
vertex main0_out main0(main0_in in [[stage_in]], constant gbuffer_vs_params& _28 [[buffer(0)]])
|
vertex main0_out main0(main0_in in [[stage_in]], constant gbuffer_vs_params& _12 [[buffer(0)]])
|
||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
float4 _23 = float4(in.position.xyz + in.instance.xyz, 1.0);
|
if (_12.isGround == 1)
|
||||||
out.gl_Position = _28.mvp * _23;
|
{
|
||||||
out.view_space_pos = (_28.view_matrix * _23).xyz;
|
float4 _42 = float4(in.position.x * 100.0, _12.planeHeight, in.position.z * 100.0, 1.0);
|
||||||
out.view_space_normal = float3x3(_28.view_matrix[0].xyz, _28.view_matrix[1].xyz, _28.view_matrix[2].xyz) * in.normal.xyz;
|
out.gl_Position = _12.mvp * _42;
|
||||||
|
out.view_space_pos = (_12.view_matrix * _42).xyz;
|
||||||
|
out.view_space_normal = float3x3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * in.normal.xyz;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float4 _92 = float4(in.position.xyz + in.instance.xyz, 1.0);
|
||||||
|
out.gl_Position = _12.mvp * _92;
|
||||||
|
out.view_space_pos = (_12.view_matrix * _92).xyz;
|
||||||
|
out.view_space_normal = float3x3(_12.view_matrix[0].xyz, _12.view_matrix[1].xyz, _12.view_matrix[2].xyz) * in.normal.xyz;
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,52 +381,80 @@ vs_g_source_metal_macos := u8.[
|
|||||||
0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
|
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,
|
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,
|
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,
|
0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x3b,0x0a,0x20,
|
||||||
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x69,0x73,0x47,0x72,0x6f,0x75,0x6e,0x64,0x3b,
|
||||||
0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
|
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,
|
||||||
0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,
|
0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
|
||||||
0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,
|
0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,
|
||||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x69,0x65,0x77,
|
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,
|
||||||
0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,
|
0x70,0x61,0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
|
||||||
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
|
0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
|
0x6f,0x61,0x74,0x33,0x20,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,
|
||||||
0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,
|
||||||
0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||||
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
|
||||||
0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,
|
0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
|
||||||
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
|
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,
|
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,
|
||||||
0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
|
||||||
0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,
|
0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||||
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,
|
0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,
|
||||||
0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,
|
0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,
|
||||||
0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,
|
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
|
||||||
0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,
|
0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,
|
||||||
0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,
|
0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,
|
||||||
0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,
|
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,
|
||||||
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x38,0x20,0x5b,
|
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,
|
||||||
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,
|
0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
|
||||||
0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,
|
0x20,0x67,0x62,0x75,0x66,0x66,0x65,0x72,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||||
0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
0x6d,0x73,0x26,0x20,0x5f,0x31,0x32,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,
|
||||||
0x74,0x34,0x20,0x5f,0x32,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
|
0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
|
||||||
0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,
|
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
|
||||||
0x2b,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x2e,0x78,0x79,
|
0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x32,0x2e,0x69,0x73,0x47,
|
||||||
0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
0x72,0x6f,0x75,0x6e,0x64,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,
|
||||||
0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,
|
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||||
0x32,0x38,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x32,0x33,0x3b,0x0a,0x20,0x20,
|
0x20,0x5f,0x34,0x32,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,
|
||||||
0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,
|
0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x31,0x30,
|
||||||
0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,0x77,
|
0x30,0x2e,0x30,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,
|
||||||
0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x32,0x33,0x29,0x2e,0x78,
|
0x69,0x67,0x68,0x74,0x2c,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x69,0x65,0x77,
|
0x6e,0x2e,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||||
0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,
|
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,
|
||||||
0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,
|
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x32,
|
||||||
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x7a,0x2c,
|
0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x34,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
0x20,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,
|
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,
|
||||||
0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x32,0x38,0x2e,0x76,0x69,0x65,
|
0x63,0x65,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x28,0x5f,0x31,0x32,0x2e,0x76,0x69,
|
||||||
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x32,0x5d,0x2e,0x78,0x79,0x7a,0x29,
|
0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x34,0x32,0x29,
|
||||||
0x20,0x2a,0x20,0x69,0x6e,0x2e,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,
|
0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
|
0x74,0x2e,0x76,0x69,0x65,0x77,0x5f,0x73,0x70,0x61,0x63,0x65,0x5f,0x6e,0x6f,0x72,
|
||||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x6d,0x61,0x6c,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x78,0x33,0x28,0x5f,
|
||||||
|
0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,
|
||||||
|
0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,
|
||||||
|
0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,
|
||||||
|
0x31,0x32,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,0x7d,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x39,0x32,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,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,
|
||||||
|
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x32,0x2e,
|
||||||
|
0x6d,0x76,0x70,0x20,0x2a,0x20,0x5f,0x39,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,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,0x31,0x32,0x2e,0x76,0x69,0x65,
|
||||||
|
0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x20,0x2a,0x20,0x5f,0x39,0x32,0x29,0x2e,
|
||||||
|
0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,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,0x31,
|
||||||
|
0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,0x61,0x74,0x72,0x69,0x78,0x5b,0x30,0x5d,
|
||||||
|
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x6d,
|
||||||
|
0x61,0x74,0x72,0x69,0x78,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x31,
|
||||||
|
0x32,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,0x7d,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 <metal_stdlib>
|
||||||
@ -416,10 +536,19 @@ gbuffer_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
|||||||
desc.attrs[3].glsl_name = "instance";
|
desc.attrs[3].glsl_name = "instance";
|
||||||
desc.uniform_blocks[0].stage = .VERTEX;
|
desc.uniform_blocks[0].stage = .VERTEX;
|
||||||
desc.uniform_blocks[0].layout = .STD140;
|
desc.uniform_blocks[0].layout = .STD140;
|
||||||
desc.uniform_blocks[0].size = 128;
|
desc.uniform_blocks[0].size = 144;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
desc.uniform_blocks[0].glsl_uniforms[0].type = .MAT4;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
|
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 0;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_vs_params";
|
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "_12.mvp";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].type = .MAT4;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].glsl_name = "_12.view_matrix";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].type = .INT;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].glsl_name = "_12.isGround";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].glsl_name = "_12.planeHeight";
|
||||||
case .GLES3;
|
case .GLES3;
|
||||||
desc.vertex_func.source = xx *vs_g_source_glsl300es;
|
desc.vertex_func.source = xx *vs_g_source_glsl300es;
|
||||||
desc.vertex_func.entry = "main";
|
desc.vertex_func.entry = "main";
|
||||||
@ -435,10 +564,19 @@ gbuffer_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
|||||||
desc.attrs[3].glsl_name = "instance";
|
desc.attrs[3].glsl_name = "instance";
|
||||||
desc.uniform_blocks[0].stage = .VERTEX;
|
desc.uniform_blocks[0].stage = .VERTEX;
|
||||||
desc.uniform_blocks[0].layout = .STD140;
|
desc.uniform_blocks[0].layout = .STD140;
|
||||||
desc.uniform_blocks[0].size = 128;
|
desc.uniform_blocks[0].size = 144;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
desc.uniform_blocks[0].glsl_uniforms[0].type = .MAT4;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
|
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 0;
|
||||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "gbuffer_vs_params";
|
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "_12.mvp";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].type = .MAT4;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[1].glsl_name = "_12.view_matrix";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].type = .INT;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[2].glsl_name = "_12.isGround";
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].array_count = 0;
|
||||||
|
desc.uniform_blocks[0].glsl_uniforms[3].glsl_name = "_12.planeHeight";
|
||||||
case .METAL_MACOS;
|
case .METAL_MACOS;
|
||||||
desc.vertex_func.source = xx *vs_g_source_metal_macos;
|
desc.vertex_func.source = xx *vs_g_source_metal_macos;
|
||||||
desc.vertex_func.entry = "main0";
|
desc.vertex_func.entry = "main0";
|
||||||
@ -450,7 +588,7 @@ gbuffer_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
|||||||
desc.attrs[3].base_type = .FLOAT;
|
desc.attrs[3].base_type = .FLOAT;
|
||||||
desc.uniform_blocks[0].stage = .VERTEX;
|
desc.uniform_blocks[0].stage = .VERTEX;
|
||||||
desc.uniform_blocks[0].layout = .STD140;
|
desc.uniform_blocks[0].layout = .STD140;
|
||||||
desc.uniform_blocks[0].size = 128;
|
desc.uniform_blocks[0].size = 144;
|
||||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
|
|||||||
574
src/shaders/jai/shader_mix.jai
Normal file
574
src/shaders/jai/shader_mix.jai
Normal file
@ -0,0 +1,574 @@
|
|||||||
|
/*
|
||||||
|
#version:1# (machine generated, don't edit!)
|
||||||
|
|
||||||
|
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||||
|
|
||||||
|
Cmdline:
|
||||||
|
sokol-shdc -i shader_mix.glsl -o ./jai/shader_mix.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||||
|
|
||||||
|
Overview:
|
||||||
|
=========
|
||||||
|
Shader program: 'mix':
|
||||||
|
Get shader desc: mix_shader_desc(sg_query_backend())
|
||||||
|
Vertex Shader: vs_mix
|
||||||
|
Fragment Shader: fs_mix
|
||||||
|
Attributes:
|
||||||
|
ATTR_mix_position => 0
|
||||||
|
ATTR_mix_uv => 1
|
||||||
|
Bindings:
|
||||||
|
Uniform block 'mix_fs_params':
|
||||||
|
Jai struct: Mix_Fs_Params
|
||||||
|
Bind slot: UB_mix_fs_params => 1
|
||||||
|
Image 'mixtex_a':
|
||||||
|
Image type: ._2D
|
||||||
|
Sample type: .FLOAT
|
||||||
|
Multisampled: false
|
||||||
|
Bind slot: IMG_mixtex_a => 0
|
||||||
|
Image 'mixtex_b':
|
||||||
|
Image type: ._2D
|
||||||
|
Sample type: .FLOAT
|
||||||
|
Multisampled: false
|
||||||
|
Bind slot: IMG_mixtex_b => 1
|
||||||
|
Image 'mixtex_c':
|
||||||
|
Image type: ._2D
|
||||||
|
Sample type: .FLOAT
|
||||||
|
Multisampled: false
|
||||||
|
Bind slot: IMG_mixtex_c => 2
|
||||||
|
Sampler 'mixsmp':
|
||||||
|
Type: .FILTERING
|
||||||
|
Bind slot: SMP_mixsmp => 0
|
||||||
|
*/
|
||||||
|
ATTR_mix_position :: 0;
|
||||||
|
ATTR_mix_uv :: 1;
|
||||||
|
UB_mix_fs_params :: 1;
|
||||||
|
IMG_mixtex_a :: 0;
|
||||||
|
IMG_mixtex_b :: 1;
|
||||||
|
IMG_mixtex_c :: 2;
|
||||||
|
SMP_mixsmp :: 0;
|
||||||
|
Mix_Fs_Params :: struct {
|
||||||
|
op: s32;
|
||||||
|
dof_min: float;
|
||||||
|
dof_max: float;
|
||||||
|
dof_point: float;
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
#version 430
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 position;
|
||||||
|
layout(location = 0) out vec2 texcoord;
|
||||||
|
layout(location = 1) in vec2 uv;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(position, 0.5, 1.0);
|
||||||
|
texcoord = uv;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
vs_mix_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,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,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,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
||||||
|
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||||
|
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||||
|
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
||||||
|
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
||||||
|
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
||||||
|
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
|
||||||
|
];
|
||||||
|
/*
|
||||||
|
#version 430
|
||||||
|
|
||||||
|
struct mix_fs_params
|
||||||
|
{
|
||||||
|
int op;
|
||||||
|
float dof_min;
|
||||||
|
float dof_max;
|
||||||
|
float dof_point;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform mix_fs_params _10;
|
||||||
|
|
||||||
|
layout(binding = 16) uniform sampler2D mixtex_b_mixsmp;
|
||||||
|
layout(binding = 17) uniform sampler2D mixtex_a_mixsmp;
|
||||||
|
layout(binding = 18) uniform sampler2D mixtex_c_mixsmp;
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 texcoord;
|
||||||
|
layout(location = 0) out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (_10.op == 0)
|
||||||
|
{
|
||||||
|
frag_color = vec4(mix(texture(mixtex_b_mixsmp, texcoord).xyz, texture(mixtex_a_mixsmp, texcoord).xyz, vec3(smoothstep(_10.dof_min, _10.dof_max, abs(texture(mixtex_c_mixsmp, texcoord).z + _10.dof_point)))), 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frag_color = vec4(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
fs_mix_source_glsl430 := u8.[
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
|
||||||
|
0x72,0x75,0x63,0x74,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,
|
||||||
|
0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,0x3b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,
|
||||||
|
0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,
|
||||||
|
0x66,0x5f,0x6d,0x61,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||||
|
0x20,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
|
||||||
|
0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,
|
||||||
|
0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x30,0x3b,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,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,0x69,0x78,0x73,
|
||||||
|
0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,
|
||||||
|
0x6e,0x67,0x20,0x3d,0x20,0x31,0x37,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,
|
||||||
|
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,
|
||||||
|
0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||||
|
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,0x38,0x29,
|
||||||
|
0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,
|
||||||
|
0x32,0x44,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,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,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||||
|
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,
|
||||||
|
0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6d,0x69,0x78,0x28,0x74,0x65,
|
||||||
|
0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,
|
||||||
|
0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,
|
||||||
|
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,
|
||||||
|
0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
||||||
|
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,
|
||||||
|
0x63,0x33,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,
|
||||||
|
0x30,0x2e,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,
|
||||||
|
0x6f,0x66,0x5f,0x6d,0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x74,0x65,0x78,0x74,
|
||||||
|
0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,
|
||||||
|
0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,
|
||||||
|
0x20,0x2b,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,
|
||||||
|
0x29,0x29,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
|
||||||
|
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x29,0x3b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
];
|
||||||
|
/*
|
||||||
|
#version 300 es
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 position;
|
||||||
|
out vec2 texcoord;
|
||||||
|
layout(location = 1) in vec2 uv;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(position, 0.5, 1.0);
|
||||||
|
texcoord = uv;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
vs_mix_source_glsl300es := u8.[
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,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,0x70,0x6f,
|
||||||
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
||||||
|
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||||
|
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
||||||
|
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
||||||
|
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
||||||
|
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||||
|
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
];
|
||||||
|
/*
|
||||||
|
#version 300 es
|
||||||
|
precision mediump float;
|
||||||
|
precision highp int;
|
||||||
|
|
||||||
|
struct mix_fs_params
|
||||||
|
{
|
||||||
|
int op;
|
||||||
|
highp float dof_min;
|
||||||
|
highp float dof_max;
|
||||||
|
highp float dof_point;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform mix_fs_params _10;
|
||||||
|
|
||||||
|
uniform highp sampler2D mixtex_b_mixsmp;
|
||||||
|
uniform highp sampler2D mixtex_a_mixsmp;
|
||||||
|
uniform highp sampler2D mixtex_c_mixsmp;
|
||||||
|
|
||||||
|
in highp vec2 texcoord;
|
||||||
|
layout(location = 0) out highp vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (_10.op == 0)
|
||||||
|
{
|
||||||
|
frag_color = vec4(mix(texture(mixtex_b_mixsmp, texcoord).xyz, texture(mixtex_a_mixsmp, texcoord).xyz, vec3(smoothstep(_10.dof_min, _10.dof_max, abs(texture(mixtex_c_mixsmp, texcoord).z + _10.dof_point)))), 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frag_color = vec4(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
fs_mix_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,0x73,
|
||||||
|
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,
|
||||||
|
0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,
|
||||||
|
0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,
|
||||||
|
0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,
|
||||||
|
0x61,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,
|
||||||
|
0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x3b,0x0a,0x7d,
|
||||||
|
0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x6d,0x69,0x78,0x5f,0x66,
|
||||||
|
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,0x31,0x30,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,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,
|
||||||
|
0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,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,
|
||||||
|
0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,
|
||||||
|
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,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,
|
||||||
|
0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,
|
||||||
|
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||||
|
0x64,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,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
|
||||||
|
0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x30,0x2e,0x6f,0x70,
|
||||||
|
0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||||
|
0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x6d,0x69,0x78,0x28,0x74,0x65,0x78,0x74,0x75,
|
||||||
|
0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x5f,0x6d,0x69,0x78,0x73,
|
||||||
|
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,
|
||||||
|
0x7a,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6d,0x69,0x78,0x74,0x65,
|
||||||
|
0x78,0x5f,0x61,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,
|
||||||
|
0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||||
|
0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x30,0x2e,0x64,
|
||||||
|
0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,
|
||||||
|
0x6d,0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||||
|
0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x5f,0x6d,0x69,0x78,0x73,0x6d,0x70,
|
||||||
|
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,0x20,0x2b,0x20,
|
||||||
|
0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x29,0x29,0x29,
|
||||||
|
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
];
|
||||||
|
/*
|
||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float2 texcoord [[user(locn0)]];
|
||||||
|
float4 gl_Position [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct main0_in
|
||||||
|
{
|
||||||
|
float2 position [[attribute(0)]];
|
||||||
|
float2 uv [[attribute(1)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
vertex main0_out main0(main0_in in [[stage_in]])
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.gl_Position = float4(in.position, 0.5, 1.0);
|
||||||
|
out.texcoord = in.uv;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
vs_mix_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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,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,0x32,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,0x32,0x20,0x75,0x76,0x20,0x5b,
|
||||||
|
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,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,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,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||||
|
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
||||||
|
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
||||||
|
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
||||||
|
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,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 mix_fs_params
|
||||||
|
{
|
||||||
|
int op;
|
||||||
|
float dof_min;
|
||||||
|
float dof_max;
|
||||||
|
float dof_point;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float4 frag_color [[color(0)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct main0_in
|
||||||
|
{
|
||||||
|
float2 texcoord [[user(locn0)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
fragment main0_out main0(main0_in in [[stage_in]], constant mix_fs_params& _10 [[buffer(0)]], texture2d<float> mixtex_a [[texture(0)]], texture2d<float> mixtex_b [[texture(1)]], texture2d<float> mixtex_c [[texture(2)]], sampler mixsmp [[sampler(0)]])
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
if (_10.op == 0)
|
||||||
|
{
|
||||||
|
out.frag_color = float4(mix(mixtex_b.sample(mixsmp, in.texcoord).xyz, mixtex_a.sample(mixsmp, in.texcoord).xyz, float3(smoothstep(_10.dof_min, _10.dof_max, abs(mixtex_c.sample(mixsmp, in.texcoord).z + _10.dof_point)))), 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out.frag_color = float4(1.0);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
fs_mix_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,
|
||||||
|
0x69,0x78,0x5f,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
|
0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x69,0x6e,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x6d,0x61,0x78,0x3b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x64,0x6f,0x66,0x5f,0x70,
|
||||||
|
0x6f,0x69,0x6e,0x74,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,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,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,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,
|
||||||
|
0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,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,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x6d,0x69,0x78,0x5f,
|
||||||
|
0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x30,0x20,0x5b,
|
||||||
|
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,
|
||||||
|
0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x6d,
|
||||||
|
0x69,0x78,0x74,0x65,0x78,0x5f,0x61,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||||
|
0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,
|
||||||
|
0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,
|
||||||
|
0x62,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x31,0x29,0x5d,0x5d,
|
||||||
|
0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,
|
||||||
|
0x74,0x3e,0x20,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,0x20,0x5b,0x5b,0x74,0x65,
|
||||||
|
0x78,0x74,0x75,0x72,0x65,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,
|
||||||
|
0x6c,0x65,0x72,0x20,0x6d,0x69,0x78,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,0x5f,0x31,0x30,
|
||||||
|
0x2e,0x6f,0x70,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,
|
||||||
|
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
|
||||||
|
0x6d,0x69,0x78,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x62,0x2e,0x73,0x61,0x6d,
|
||||||
|
0x70,0x6c,0x65,0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,
|
||||||
|
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x6d,0x69,
|
||||||
|
0x78,0x74,0x65,0x78,0x5f,0x61,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d,0x69,
|
||||||
|
0x78,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||||
|
0x64,0x29,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x73,
|
||||||
|
0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x30,0x2e,0x64,0x6f,
|
||||||
|
0x66,0x5f,0x6d,0x69,0x6e,0x2c,0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x6d,
|
||||||
|
0x61,0x78,0x2c,0x20,0x61,0x62,0x73,0x28,0x6d,0x69,0x78,0x74,0x65,0x78,0x5f,0x63,
|
||||||
|
0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x6d,0x69,0x78,0x73,0x6d,0x70,0x2c,0x20,
|
||||||
|
0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x2e,0x7a,0x20,0x2b,
|
||||||
|
0x20,0x5f,0x31,0x30,0x2e,0x64,0x6f,0x66,0x5f,0x70,0x6f,0x69,0x6e,0x74,0x29,0x29,
|
||||||
|
0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x31,
|
||||||
|
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,
|
||||||
|
0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
];
|
||||||
|
mix_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||||
|
desc: sg_shader_desc;
|
||||||
|
desc.label = "mix_shader";
|
||||||
|
if backend == {
|
||||||
|
case .GLCORE;
|
||||||
|
desc.vertex_func.source = xx *vs_mix_source_glsl430;
|
||||||
|
desc.vertex_func.entry = "main";
|
||||||
|
desc.fragment_func.source = xx *fs_mix_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 = "uv";
|
||||||
|
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||||
|
desc.uniform_blocks[1].layout = .STD140;
|
||||||
|
desc.uniform_blocks[1].size = 16;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].type = .INT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.op";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.dof_min";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.dof_max";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_10.dof_point";
|
||||||
|
desc.images[0].stage = .FRAGMENT;
|
||||||
|
desc.images[0].multisampled = false;
|
||||||
|
desc.images[0].image_type = ._2D;
|
||||||
|
desc.images[0].sample_type = .FLOAT;
|
||||||
|
desc.images[1].stage = .FRAGMENT;
|
||||||
|
desc.images[1].multisampled = false;
|
||||||
|
desc.images[1].image_type = ._2D;
|
||||||
|
desc.images[1].sample_type = .FLOAT;
|
||||||
|
desc.images[2].stage = .FRAGMENT;
|
||||||
|
desc.images[2].multisampled = false;
|
||||||
|
desc.images[2].image_type = ._2D;
|
||||||
|
desc.images[2].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 = 1;
|
||||||
|
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[0].glsl_name = "mixtex_b_mixsmp";
|
||||||
|
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[1].image_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].glsl_name = "mixtex_a_mixsmp";
|
||||||
|
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[2].image_slot = 2;
|
||||||
|
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[2].glsl_name = "mixtex_c_mixsmp";
|
||||||
|
case .GLES3;
|
||||||
|
desc.vertex_func.source = xx *vs_mix_source_glsl300es;
|
||||||
|
desc.vertex_func.entry = "main";
|
||||||
|
desc.fragment_func.source = xx *fs_mix_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 = "uv";
|
||||||
|
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||||
|
desc.uniform_blocks[1].layout = .STD140;
|
||||||
|
desc.uniform_blocks[1].size = 16;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].type = .INT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_10.op";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_10.dof_min";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_10.dof_max";
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0;
|
||||||
|
desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_10.dof_point";
|
||||||
|
desc.images[0].stage = .FRAGMENT;
|
||||||
|
desc.images[0].multisampled = false;
|
||||||
|
desc.images[0].image_type = ._2D;
|
||||||
|
desc.images[0].sample_type = .FLOAT;
|
||||||
|
desc.images[1].stage = .FRAGMENT;
|
||||||
|
desc.images[1].multisampled = false;
|
||||||
|
desc.images[1].image_type = ._2D;
|
||||||
|
desc.images[1].sample_type = .FLOAT;
|
||||||
|
desc.images[2].stage = .FRAGMENT;
|
||||||
|
desc.images[2].multisampled = false;
|
||||||
|
desc.images[2].image_type = ._2D;
|
||||||
|
desc.images[2].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 = 1;
|
||||||
|
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[0].glsl_name = "mixtex_b_mixsmp";
|
||||||
|
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[1].image_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].glsl_name = "mixtex_a_mixsmp";
|
||||||
|
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[2].image_slot = 2;
|
||||||
|
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[2].glsl_name = "mixtex_c_mixsmp";
|
||||||
|
case .METAL_MACOS;
|
||||||
|
desc.vertex_func.source = xx *vs_mix_source_metal_macos;
|
||||||
|
desc.vertex_func.entry = "main0";
|
||||||
|
desc.fragment_func.source = xx *fs_mix_source_metal_macos;
|
||||||
|
desc.fragment_func.entry = "main0";
|
||||||
|
desc.attrs[0].base_type = .FLOAT;
|
||||||
|
desc.attrs[1].base_type = .FLOAT;
|
||||||
|
desc.uniform_blocks[1].stage = .FRAGMENT;
|
||||||
|
desc.uniform_blocks[1].layout = .STD140;
|
||||||
|
desc.uniform_blocks[1].size = 16;
|
||||||
|
desc.uniform_blocks[1].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.images[1].stage = .FRAGMENT;
|
||||||
|
desc.images[1].multisampled = false;
|
||||||
|
desc.images[1].image_type = ._2D;
|
||||||
|
desc.images[1].sample_type = .FLOAT;
|
||||||
|
desc.images[1].msl_texture_n = 1;
|
||||||
|
desc.images[2].stage = .FRAGMENT;
|
||||||
|
desc.images[2].multisampled = false;
|
||||||
|
desc.images[2].image_type = ._2D;
|
||||||
|
desc.images[2].sample_type = .FLOAT;
|
||||||
|
desc.images[2].msl_texture_n = 2;
|
||||||
|
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 = 1;
|
||||||
|
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[1].image_slot = 0;
|
||||||
|
desc.image_sampler_pairs[1].sampler_slot = 0;
|
||||||
|
desc.image_sampler_pairs[2].stage = .FRAGMENT;
|
||||||
|
desc.image_sampler_pairs[2].image_slot = 2;
|
||||||
|
desc.image_sampler_pairs[2].sampler_slot = 0;
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,8 @@
|
|||||||
layout(binding=0) uniform gbuffer_vs_params {
|
layout(binding=0) uniform gbuffer_vs_params {
|
||||||
mat4 mvp;
|
mat4 mvp;
|
||||||
mat4 view_matrix;
|
mat4 view_matrix;
|
||||||
|
int isGround;
|
||||||
|
float planeHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
in vec4 position;
|
in vec4 position;
|
||||||
@ -13,12 +15,20 @@ out vec3 view_space_pos;
|
|||||||
out vec3 view_space_normal;
|
out vec3 view_space_normal;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 world_pos = vec4(position.xyz + instance.xyz, 1.0);
|
if (isGround == 1) {
|
||||||
|
vec4 world_pos = vec4(position.x * 100.0, planeHeight, position.z * 100.0, 1.0);
|
||||||
vec4 view_pos_4 = view_matrix * world_pos;
|
vec4 view_pos_4 = view_matrix * world_pos;
|
||||||
|
|
||||||
gl_Position = mvp * world_pos;
|
gl_Position = mvp * world_pos;
|
||||||
view_space_pos = view_pos_4.xyz;
|
view_space_pos = view_pos_4.xyz;
|
||||||
view_space_normal = mat3(view_matrix) * normal.xyz;
|
view_space_normal = mat3(view_matrix) * normal.xyz;
|
||||||
|
} else {
|
||||||
|
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
|
@end
|
||||||
|
|
||||||
|
|||||||
49
src/shaders/shader_mix.glsl
Normal file
49
src/shaders/shader_mix.glsl
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
@vs vs_mix
|
||||||
|
in vec2 position;
|
||||||
|
in vec2 uv;
|
||||||
|
|
||||||
|
out vec2 texcoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(position, 0.5, 1.0);
|
||||||
|
texcoord = uv;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@fs fs_mix
|
||||||
|
in vec2 texcoord;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
layout(binding=1) uniform mix_fs_params {
|
||||||
|
int op;
|
||||||
|
float dof_min;
|
||||||
|
float dof_max;
|
||||||
|
float dof_point;
|
||||||
|
/*
|
||||||
|
List of mixs:
|
||||||
|
0. blur for ssao
|
||||||
|
1. dilate.
|
||||||
|
2. normal blur
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(binding = 0) uniform texture2D mixtex_a;
|
||||||
|
layout(binding = 1) uniform texture2D mixtex_b;
|
||||||
|
layout(binding = 2) uniform texture2D mixtex_c;
|
||||||
|
layout(binding = 0) uniform sampler mixsmp;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
if(op == 0) {
|
||||||
|
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(mixtex_a, mixsmp), 0));
|
||||||
|
vec3 in_focus = texture(sampler2D(mixtex_b, mixsmp), texcoord).rgb;
|
||||||
|
vec3 out_focus = texture(sampler2D(mixtex_a, mixsmp), texcoord).rgb;
|
||||||
|
vec4 position = texture(sampler2D(mixtex_c, mixsmp), texcoord);
|
||||||
|
float blur = smoothstep(dof_min, dof_max, abs(position.z + dof_point));
|
||||||
|
frag_color = vec4(mix(in_focus, out_focus, blur), 1.0);
|
||||||
|
} else {
|
||||||
|
frag_color = vec4(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@program mix vs_mix fs_mix
|
||||||
@ -14,21 +14,69 @@ void main() {
|
|||||||
in vec2 texcoord;
|
in vec2 texcoord;
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
layout(binding=1) uniform op_fs_params {
|
||||||
|
int blur_size;
|
||||||
|
int op;
|
||||||
|
float separation;
|
||||||
|
float dilate_min;
|
||||||
|
float dilate_max;
|
||||||
|
/*
|
||||||
|
List of ops:
|
||||||
|
0. blur for ssao
|
||||||
|
1. dilate.
|
||||||
|
2. normal blur
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
layout(binding = 0) uniform texture2D optex;
|
layout(binding = 0) uniform texture2D optex;
|
||||||
layout(binding = 0) uniform sampler opsmp;
|
layout(binding = 0) uniform sampler opsmp;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
if(op == 2) {
|
||||||
|
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
|
||||||
|
vec3 result = vec3(0.0);
|
||||||
|
for (int x = -blur_size; x < blur_size; ++x)
|
||||||
|
{
|
||||||
|
for (int y = -blur_size; y < blur_size; ++y)
|
||||||
|
{
|
||||||
|
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
||||||
|
result += texture(sampler2D(optex, opsmp), texcoord + offset).xyz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frag_color = vec4((result / (blur_size*2 * blur_size*2)), 1.0);
|
||||||
|
}
|
||||||
|
else if(op == 1) {
|
||||||
|
float minThreshold = dilate_min;
|
||||||
|
float maxThreshold = dilate_max;
|
||||||
|
vec2 texSize = textureSize(sampler2D(optex, opsmp), 0).xy;
|
||||||
|
vec2 fragCoord = gl_FragCoord.xy;
|
||||||
|
frag_color = texture(sampler2D(optex, opsmp), fragCoord / texSize);
|
||||||
|
if (blur_size <= 0) { return; }
|
||||||
|
float mx = 0.0;
|
||||||
|
vec4 cmx = frag_color;
|
||||||
|
for (int i = -blur_size; i <= blur_size; ++i) {
|
||||||
|
for (int j = -blur_size; j <= blur_size; ++j) {
|
||||||
|
if (!(distance(vec2(i, j), vec2(0, 0)) <= blur_size)) { continue; }
|
||||||
|
vec4 c = texture(sampler2D(optex,opsmp),(gl_FragCoord.xy + (vec2(i, j) * separation)) / texSize);
|
||||||
|
float mxt = dot(c.rgb, vec3(0.3, 0.59, 0.11));
|
||||||
|
if (mxt > mx) {
|
||||||
|
mx = mxt;
|
||||||
|
cmx = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frag_color.rgb = mix(frag_color.rgb, cmx.rgb, smoothstep(minThreshold, maxThreshold, mx));
|
||||||
|
} else {
|
||||||
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
|
vec2 texelSize = 1.0 / vec2(textureSize(sampler2D(optex, opsmp), 0));
|
||||||
float result = 0.0;
|
float result = 0.0;
|
||||||
for (int x = -2; x < 2; ++x)
|
for (int x = -blur_size; x < blur_size; ++x) {
|
||||||
{
|
for (int y = -blur_size; y < blur_size; ++y) {
|
||||||
for (int y = -2; y < 2; ++y)
|
|
||||||
{
|
|
||||||
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
||||||
result += texture(sampler2D(optex, opsmp), texcoord + offset).r;
|
result += texture(sampler2D(optex, opsmp), texcoord + offset).r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frag_color = vec4(vec3(result / (4.0 * 4.0)), 1.0);
|
frag_color = vec4(vec3(result / (blur_size*2 * blur_size*2)), 1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user