work on post processing pipeline, still some bugs
This commit is contained in:
parent
f86026b588
commit
966513a64d
@ -38,7 +38,7 @@ sapp_init :: () {
|
||||
window_title = wi.title,
|
||||
// icon = .{ sokol_default = true },
|
||||
logger = .{ func = slog_func },
|
||||
sample_count = platconf.sample_count,
|
||||
sample_count = 1, // I think I'll end up pixelifying the whole thing, so I don't think we need MSAA.
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ backend_draw_ground :: (wc: *World_Config) {
|
||||
vs_params : Plane_Vs_Params;
|
||||
world_conf : Plane_World_Config;
|
||||
plane_data : Plane_Data;
|
||||
w, h := get_window_size();
|
||||
w, h := get_render_size();
|
||||
plane_data.screen_w = w;
|
||||
plane_data.screen_h = h;
|
||||
|
||||
@ -147,6 +147,8 @@ backend_draw_ground :: (wc: *World_Config) {
|
||||
|
||||
vs_params.mvp = mvp.floats;
|
||||
sg_apply_pipeline(gPipelines.plane.pipeline);
|
||||
gPipelines.plane.bind.samplers[2] = g_shadowmap_sampler;
|
||||
gPipelines.plane.bind.images[2] = g_shadowmap;
|
||||
sg_apply_bindings(*gPipelines.plane.bind);
|
||||
sg_apply_uniforms(UB_plane_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_apply_uniforms(UB_plane_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||
@ -177,22 +179,30 @@ backend_process_command_buckets :: () {
|
||||
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
||||
|
||||
// 3. Main pass
|
||||
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, attachments = g_rendertex_attachments}));
|
||||
for render_command_buckets.main {
|
||||
backend_handle_command(it);
|
||||
}
|
||||
sg_end_pass();
|
||||
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
||||
// 3.2 Draw the UI. @ToDo: This should probably happen after post processing once we have that.
|
||||
// Also, it's kind of stupid that this has it's own command system. It should be moved to using the
|
||||
// same backend commands we are using for other rendering.
|
||||
|
||||
// Begin main pass
|
||||
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:
|
||||
sg_apply_pipeline(gPipelines.postprocess.pipeline);
|
||||
gPipelines.postprocess.bind.images[0] = g_rendertex;
|
||||
sg_apply_bindings(*gPipelines.postprocess.bind);
|
||||
sg_draw(0, 6, 1);
|
||||
|
||||
sgl_defaults();
|
||||
sgl_matrix_mode_projection();
|
||||
sgl_ortho(0.0, sapp_widthf(), sapp_heightf(), 0.0, -1.0, +1.0);
|
||||
arb_tri_flush();
|
||||
|
||||
// End the main pass
|
||||
sg_end_pass();
|
||||
|
||||
sg_end_pass();
|
||||
|
||||
sg_commit();
|
||||
|
||||
|
||||
@ -30,3 +30,27 @@ create_set_cam_rendering_task :: (cam: Camera) {
|
||||
camtask := Rendering_Task_Set_Camera.{type = .SET_CAMERA, camera = cam};
|
||||
add_rendering_task(camtask);
|
||||
}
|
||||
|
||||
get_low_res :: (width: s32, height: s32, max_dimension: s32 = 720) -> (s32, s32) {
|
||||
if width == 0 || height == 0 {
|
||||
return 0, 0;
|
||||
}
|
||||
aspect_ratio := cast(float)width / cast(float)height;
|
||||
w: s32;
|
||||
h: s32;
|
||||
if width > height {
|
||||
w = max_dimension;
|
||||
h = cast(s32)floor(cast(float)w / aspect_ratio);
|
||||
} else {
|
||||
h = max_dimension;
|
||||
w = cast(s32)floor(cast(float)h * aspect_ratio);
|
||||
}
|
||||
|
||||
return w, h;
|
||||
}
|
||||
|
||||
get_render_size :: () -> (s32, s32) {
|
||||
w,h := get_window_size();
|
||||
wl, hl := get_low_res(w,h, 360);
|
||||
return wl, hl;
|
||||
}
|
||||
|
||||
@ -8,9 +8,15 @@ Pipeline_Binding :: struct {
|
||||
}
|
||||
|
||||
g_specular_lut : sg_image;
|
||||
|
||||
g_shadowmap : sg_image;
|
||||
g_shadowmap_img : sg_image; // Apparently we are requried to have one of these, sigh... we don't use this.
|
||||
g_shadowmap_img : sg_image;
|
||||
g_shadowmap_attachments : sg_attachments;
|
||||
g_shadowmap_sampler : sg_sampler;
|
||||
|
||||
g_rendertex : sg_image;
|
||||
g_rendertex_depth : sg_image;
|
||||
g_rendertex_attachments : sg_attachments;
|
||||
|
||||
gPipelines : struct {
|
||||
|
||||
@ -31,6 +37,37 @@ gPipelines : struct {
|
||||
// Renders the ground plane.
|
||||
plane : Pipeline_Binding;
|
||||
|
||||
postprocess : Pipeline_Binding;
|
||||
}
|
||||
|
||||
create_final_image :: () {
|
||||
// @ToDo: Some smarter logic for this.
|
||||
w,h := get_render_size();
|
||||
|
||||
if g_rendertex.id != INVALID_ID then sg_destroy_image(g_rendertex);
|
||||
if g_rendertex_depth.id != INVALID_ID then sg_destroy_image(g_rendertex);
|
||||
|
||||
img_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .RGBA32F,
|
||||
render_target = true,
|
||||
};
|
||||
depth_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .DEPTH,
|
||||
render_target = true,
|
||||
};
|
||||
g_rendertex = sg_make_image(*img_desc);
|
||||
g_rendertex_depth = sg_make_image(*depth_desc);
|
||||
attachmentsDesc : sg_attachments_desc;
|
||||
attachmentsDesc = .{
|
||||
colors[0].image = g_rendertex,
|
||||
depth_stencil.image = g_rendertex_depth,
|
||||
};
|
||||
// sg_destroy_attachments(g_rendertex_attachments);
|
||||
g_rendertex_attachments = sg_make_attachments(*attachmentsDesc);
|
||||
}
|
||||
|
||||
create_shadowmap_image :: () {
|
||||
@ -42,13 +79,13 @@ create_shadowmap_image :: () {
|
||||
depth_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .DEPTH_STENCIL,
|
||||
pixel_format = .DEPTH,
|
||||
render_target = true,
|
||||
};
|
||||
img_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
render_target = true,
|
||||
};
|
||||
g_shadowmap = sg_make_image(*depth_desc);
|
||||
@ -68,7 +105,10 @@ create_pipelines :: () {
|
||||
create_trile_pipeline();
|
||||
create_sky_pipeline();
|
||||
create_plane_pipeline();
|
||||
create_postprocess_pipeline();
|
||||
|
||||
create_shadowmap_image();
|
||||
create_final_image();
|
||||
}
|
||||
|
||||
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
||||
@ -82,8 +122,6 @@ Position_Color :: struct {
|
||||
}
|
||||
|
||||
create_trixel_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := trixel_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
@ -99,20 +137,19 @@ create_trixel_pipeline :: () {
|
||||
pipeline.depth = .{
|
||||
write_enabled = true,
|
||||
compare = .LESS_EQUAL,
|
||||
pixel_format = .DEPTH,
|
||||
};
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
pipeline.sample_count = platconf.sample_count;
|
||||
|
||||
|
||||
vertices : [24]Vector3 = .[
|
||||
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||
@ -201,7 +238,6 @@ create_trixel_pipeline :: () {
|
||||
}
|
||||
|
||||
create_trile_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := trile_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
@ -219,11 +255,11 @@ create_trile_pipeline :: () {
|
||||
pipeline.depth = .{
|
||||
write_enabled = true,
|
||||
compare = .LESS_EQUAL,
|
||||
pixel_format = .DEPTH,
|
||||
};
|
||||
pipeline.sample_count = platconf.sample_count;
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
@ -246,22 +282,21 @@ create_trile_pipeline :: () {
|
||||
}
|
||||
|
||||
create_sky_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := sky_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
pipeline.layout.buffers[0].stride = 4*3;
|
||||
pipeline.sample_count = platconf.sample_count;
|
||||
|
||||
pipeline.layout.attrs[ATTR_sky_position] = .{ format = .FLOAT3, buffer_index = 0 };
|
||||
pipeline.index_type = .UINT16;
|
||||
pipeline.depth = .{
|
||||
write_enabled = true,
|
||||
compare = .LESS_EQUAL,
|
||||
pixel_format = .DEPTH,
|
||||
};
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
@ -328,49 +363,40 @@ create_sky_pipeline :: () {
|
||||
|
||||
// @ToDo: This needs to be redone when the window is resized;
|
||||
create_plane_pipeline_reflection_images :: () {
|
||||
platconf := get_plat_conf();
|
||||
binding := *gPipelines.plane.bind;
|
||||
if binding.images[4].id != INVALID_ID then sg_destroy_image(binding.images[4]);
|
||||
if binding.images[5].id != INVALID_ID then sg_destroy_image(binding.images[5]);
|
||||
if binding.images[0].id != INVALID_ID then sg_destroy_image(binding.images[0]);
|
||||
|
||||
w, h := get_window_size();
|
||||
w, h := get_render_size();
|
||||
img_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
render_target = true,
|
||||
};
|
||||
depth_desc := sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = .DEPTH_STENCIL,
|
||||
pixel_format = .DEPTH,
|
||||
render_target = true,
|
||||
};
|
||||
binding.images[4] = sg_make_image(*img_desc);
|
||||
img_desc.sample_count = 1;
|
||||
binding.images[0] = sg_make_image(*img_desc);
|
||||
binding.images[5] = sg_make_image(*depth_desc);
|
||||
|
||||
attachmentsDesc : sg_attachments_desc;
|
||||
if platconf.sample_count > 1 {
|
||||
attachmentsDesc = .{
|
||||
colors[0].image = gPipelines.plane.bind.images[4],
|
||||
resolves[0].image = gPipelines.plane.bind.images[0],
|
||||
depth_stencil.image = gPipelines.plane.bind.images[5],
|
||||
};
|
||||
} else {
|
||||
attachmentsDesc = .{
|
||||
colors[0].image = gPipelines.plane.bind.images[0],
|
||||
depth_stencil.image = gPipelines.plane.bind.images[5],
|
||||
};
|
||||
}
|
||||
|
||||
sg_destroy_attachments(gPipelines.plane.attachments);
|
||||
gPipelines.plane.attachments = sg_make_attachments(*attachmentsDesc);
|
||||
}
|
||||
|
||||
create_plane_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := plane_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
@ -382,11 +408,11 @@ create_plane_pipeline :: () {
|
||||
pipeline.depth = .{
|
||||
write_enabled = true,
|
||||
compare = .LESS_EQUAL,
|
||||
pixel_format = .DEPTH_STENCIL
|
||||
pixel_format = .DEPTH
|
||||
};
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
pixel_format = .RGBA32F,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
@ -406,7 +432,6 @@ create_plane_pipeline :: () {
|
||||
0, 2, 3,
|
||||
];
|
||||
|
||||
pipeline.sample_count = platconf.sample_count;
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = color_state;
|
||||
@ -433,6 +458,14 @@ create_plane_pipeline :: () {
|
||||
mag_filter = .NEAREST,
|
||||
}));
|
||||
|
||||
g_shadowmap_sampler = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .LINEAR,
|
||||
mag_filter = .LINEAR,
|
||||
compare = .LESS,
|
||||
}));
|
||||
|
||||
gPipelines.plane.bind.samplers[1] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
@ -462,7 +495,6 @@ create_arbtri_pipeline :: () {
|
||||
pipeline.layout.attrs[ATTR_triangle_position] = .{ format = .FLOAT3 };
|
||||
pipeline.layout.attrs[ATTR_triangle_color0] = .{ format = .FLOAT4 };
|
||||
pipeline.layout.attrs[ATTR_triangle_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.sample_count = platconf.sample_count;
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
@ -488,3 +520,59 @@ create_arbtri_pipeline :: () {
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
create_postprocess_pipeline :: () {
|
||||
platconf := get_plat_conf();
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := postprocess_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
|
||||
pipeline.layout.attrs[ATTR_postprocess_position] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_postprocess_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.index_type = .UINT16;
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
|
||||
}
|
||||
};
|
||||
|
||||
pipeline.color_count = 1;
|
||||
pipeline.colors[0] = color_state;
|
||||
|
||||
gPipelines.postprocess.pipeline = sg_make_pipeline(*pipeline);
|
||||
|
||||
quad_vertices : [16]float = .[
|
||||
-1.0, 1.0, 0.0, 1.0, // top-let
|
||||
-1.0, -1.0, 0.0, 0.0, // bottom-let
|
||||
1.0, -1.0, 1.0, 0.0, // bottom-right
|
||||
1.0, 1.0, 1.0, 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.postprocess.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
gPipelines.postprocess.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.postprocess.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,
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
Rendering_Task_Type :: enum {
|
||||
INVALID;
|
||||
GROUND;
|
||||
GROUND; // We need to add an ability to invalidate buffer here too.
|
||||
SKY;
|
||||
SET_CAMERA;
|
||||
TRILE; // not implemented yet
|
||||
TRILE; // We need to add an ability to invalidate buffer instead of updating it constantly. Also probably have a buffer for static world triles and one for moving ones.
|
||||
TRIXELS;
|
||||
SPRITE; // not implemented yet
|
||||
PARTICLES; // not implemented yet
|
||||
SPRITE;
|
||||
PARTICLES;
|
||||
};
|
||||
|
||||
Rendering_Task :: struct {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
325
src/shaders/jai/shader_post_process_main.jai
Normal file
325
src/shaders/jai/shader_post_process_main.jai
Normal file
@ -0,0 +1,325 @@
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i shader_post_process_main.glsl -o ./jai/shader_post_process_main.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'postprocess':
|
||||
Get shader desc: postprocess_shader_desc(sg_query_backend())
|
||||
Vertex Shader: vs_pp
|
||||
Fragment Shader: fs_pp
|
||||
Attributes:
|
||||
ATTR_postprocess_position => 0
|
||||
ATTR_postprocess_uv => 1
|
||||
Bindings:
|
||||
Image 'pptex':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_pptex => 0
|
||||
Sampler 'ppsmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_ppsmp => 0
|
||||
*/
|
||||
ATTR_postprocess_position :: 0;
|
||||
ATTR_postprocess_uv :: 1;
|
||||
IMG_pptex :: 0;
|
||||
SMP_ppsmp :: 0;
|
||||
/*
|
||||
#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_pp_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
|
||||
|
||||
layout(binding = 16) uniform sampler2D pptex_ppsmp;
|
||||
|
||||
layout(location = 0) in vec2 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(pptex_ppsmp, texcoord);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_pp_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x70,0x70,0x74,0x65,0x78,0x5f,0x70,0x70,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,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x70,0x70,0x74,0x65,
|
||||
0x78,0x5f,0x70,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x29,0x3b,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_pp_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;
|
||||
|
||||
uniform highp sampler2D pptex_ppsmp;
|
||||
|
||||
in highp vec2 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(pptex_ppsmp, texcoord);
|
||||
}
|
||||
|
||||
*/
|
||||
fs_pp_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x70,0x70,0x74,0x65,0x78,0x5f,0x70,0x70,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,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,
|
||||
0x74,0x75,0x72,0x65,0x28,0x70,0x70,0x74,0x65,0x78,0x5f,0x70,0x70,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x29,0x3b,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_pp_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 main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 texcoord [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> pptex [[texture(0)]], sampler ppsmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = pptex.sample(ppsmp, in.texcoord);
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
fs_pp_source_metal_macos := u8.[
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,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,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x3e,0x20,0x70,0x70,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,
|
||||
0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,
|
||||
0x70,0x70,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,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x70,0x70,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x28,0x70,0x70,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
postprocess_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
desc.label = "postprocess_shader";
|
||||
if backend == {
|
||||
case .GLCORE;
|
||||
desc.vertex_func.source = xx *vs_pp_source_glsl430;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_pp_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.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "pptex_ppsmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_pp_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
desc.fragment_func.source = xx *fs_pp_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.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "pptex_ppsmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_pp_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
desc.fragment_func.source = xx *fs_pp_source_metal_macos;
|
||||
desc.fragment_func.entry = "main0";
|
||||
desc.attrs[0].base_type = .FLOAT;
|
||||
desc.attrs[1].base_type = .FLOAT;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
@ -69,8 +69,10 @@ layout(binding=2) uniform plane_data {
|
||||
|
||||
layout(binding = 0) uniform texture2D reftex;
|
||||
layout(binding = 1) uniform texture2D groundtex;
|
||||
layout(binding = 2) uniform texture2D shadow;
|
||||
layout(binding = 0) uniform sampler refsmp;
|
||||
layout(binding = 1) uniform sampler groundsmp;
|
||||
layout(binding = 2) uniform sampler shadowsmp;
|
||||
|
||||
float random (vec2 st) {
|
||||
return fract(sin(dot(st.xy,
|
||||
@ -139,6 +141,7 @@ void main() {
|
||||
vec3 c1 = get_ground_sample(npos, sign2(toCenter.x), 0.0);
|
||||
vec3 c2 = get_ground_sample(npos, 0.0, sign2(toCenter.y));
|
||||
vec3 c3 = get_ground_sample(npos, sign2(toCenter.x), sign2(toCenter.y));
|
||||
float shadowp = texture(sampler2DShadow(shadow, shadowsmp), vec3(0,0,0));
|
||||
|
||||
// @ToDo: Consider using cool Inigo Quilez trick here to make it even smoother.
|
||||
vec3 b01 = mix(c0, c1, u);
|
||||
@ -148,7 +151,7 @@ void main() {
|
||||
if(planeType == 1) {
|
||||
frag_color = vec4(bf, 1.0);
|
||||
} else {
|
||||
frag_color = vec4(b23, 1.0);
|
||||
frag_color = vec4(vec3(shadowp), 1.0);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
26
src/shaders/shader_post_process_main.glsl
Normal file
26
src/shaders/shader_post_process_main.glsl
Normal file
@ -0,0 +1,26 @@
|
||||
@vs vs_pp
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
out vec2 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs_pp
|
||||
in vec2 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D pptex;
|
||||
layout(binding = 0) uniform sampler ppsmp;
|
||||
|
||||
void main() {
|
||||
vec4 sampled = texture(sampler2D(pptex, ppsmp), texcoord.xy);
|
||||
frag_color = sampled;
|
||||
}
|
||||
@end
|
||||
|
||||
@program postprocess vs_pp fs_pp
|
||||
@ -145,10 +145,6 @@ texture_load_from_memory :: (texture: *Ui_Texture, memory: []u8, srgb: bool, bui
|
||||
gScissor : Ui_Rect;
|
||||
gScissorActive : bool = false;
|
||||
|
||||
get_render_size :: () -> (s32, s32) {
|
||||
return 700, 700;
|
||||
}
|
||||
|
||||
set_scissor :: (x0: s32, y0: s32, x1: s32, y1: s32) {
|
||||
arb_tri_command_add(.{ type = .SET_SCISSOR, scissor = .{x0, y0, x1 - x0, y1 - y0}});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user