lighting model for trile editor
This commit is contained in:
parent
5729577126
commit
a7c1b0794c
@ -173,6 +173,24 @@ draw_material_tab :: (theme: *GR.Overall_Theme, area: GR.Rect) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw_sky :: () {
|
||||||
|
cam := get_trile_editor_camera();
|
||||||
|
|
||||||
|
mvp := create_viewproj(*cam);
|
||||||
|
vs_params : Sky_Vs_Params;
|
||||||
|
vs_params.mvp = mvp.floats;
|
||||||
|
sg_apply_pipeline(gPipelines.sky.pipeline);
|
||||||
|
sg_apply_bindings(*gPipelines.sky.bind);
|
||||||
|
sg_apply_uniforms(UB_sky_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||||
|
sg_draw(0, 36, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
draw_trile_editor :: () {
|
||||||
|
draw_sky();
|
||||||
|
draw_trile();
|
||||||
|
}
|
||||||
|
|
||||||
draw_trile :: () {
|
draw_trile :: () {
|
||||||
cam := get_trile_editor_camera();
|
cam := get_trile_editor_camera();
|
||||||
|
|
||||||
@ -232,7 +250,7 @@ draw_trile :: () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[1], *(sg_range.{
|
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[2], *(sg_range.{
|
||||||
ptr = trixels.data,
|
ptr = trixels.data,
|
||||||
size = size_of(type_of(trixels)),
|
size = size_of(type_of(trixels)),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -112,8 +112,8 @@ frame :: () {
|
|||||||
|
|
||||||
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() }));
|
||||||
tick_ui();
|
tick_ui();
|
||||||
|
draw_trile_editor();
|
||||||
ui_pass();
|
ui_pass();
|
||||||
draw_trile();
|
|
||||||
sg_end_pass();
|
sg_end_pass();
|
||||||
sg_commit();
|
sg_commit();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#load "./shaders/jai/shader_triangle.jai";
|
#load "./shaders/jai/shader_triangle.jai";
|
||||||
#load "./shaders/jai/shader_trixel.jai";
|
#load "./shaders/jai/shader_trixel.jai";
|
||||||
|
#load "./shaders/jai/shader_sky.jai";
|
||||||
|
|
||||||
Pipeline_Binding :: struct {
|
Pipeline_Binding :: struct {
|
||||||
pipeline : sg_pipeline;
|
pipeline : sg_pipeline;
|
||||||
@ -16,11 +17,15 @@ gPipelines : struct {
|
|||||||
// generated meshes.
|
// generated meshes.
|
||||||
trixel : Pipeline_Binding;
|
trixel : Pipeline_Binding;
|
||||||
|
|
||||||
|
// Sky rendering.
|
||||||
|
sky : Pipeline_Binding;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create_pipelines :: () {
|
create_pipelines :: () {
|
||||||
create_arbtri_pipeline();
|
create_arbtri_pipeline();
|
||||||
create_trixel_pipeline();
|
create_trixel_pipeline();
|
||||||
|
create_sky_pipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
||||||
@ -148,6 +153,85 @@ create_trixel_pipeline :: () {
|
|||||||
gPipelines.trixel.bind.vertex_buffers[2] = sg_make_buffer(*instance_buffer);
|
gPipelines.trixel.bind.vertex_buffers[2] = sg_make_buffer(*instance_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_sky_pipeline :: () {
|
||||||
|
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.layout.attrs[ATTR_sky_position] = .{ format = .FLOAT3, buffer_index = 0 };
|
||||||
|
pipeline.index_type = .UINT16;
|
||||||
|
pipeline.depth = .{
|
||||||
|
write_enabled = true,
|
||||||
|
compare = .LESS_EQUAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
color_state := sg_color_target_state.{
|
||||||
|
pixel_format = .RGBA8,
|
||||||
|
blend = .{
|
||||||
|
enabled = true,
|
||||||
|
src_factor_rgb = .SRC_ALPHA,
|
||||||
|
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
vertices : [24]Vector3 = .[
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, -TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, -TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, TRIXEL_SIZE/2},
|
||||||
|
.{-TRIXEL_SIZE/2, TRIXEL_SIZE/2, -TRIXEL_SIZE/2}
|
||||||
|
];
|
||||||
|
|
||||||
|
k : u16 = 0;
|
||||||
|
i : u16 = 0;
|
||||||
|
|
||||||
|
indices : [36]u16;
|
||||||
|
|
||||||
|
while i < 36 {
|
||||||
|
indices[i] = 4*k;
|
||||||
|
indices[i + 1] = 4*k + 1;
|
||||||
|
indices[i + 2] = 4*k + 2;
|
||||||
|
indices[i + 3] = 4*k;
|
||||||
|
indices[i + 4] = 4*k + 2;
|
||||||
|
indices[i + 5] = 4*k + 3;
|
||||||
|
k += 1;
|
||||||
|
i += 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pipeline.color_count = 1;
|
||||||
|
pipeline.colors[0] = color_state;
|
||||||
|
|
||||||
|
gPipelines.sky.pipeline = sg_make_pipeline(*pipeline);
|
||||||
|
|
||||||
|
ibuffer := sg_buffer_desc.{ type = .INDEXBUFFER, data = .{ ptr = indices.data, size = 36 * 2 } };
|
||||||
|
vbuffer := sg_buffer_desc.{ data = .{ ptr = vertices.data, size = 24 * 3 * 4 } };
|
||||||
|
|
||||||
|
gPipelines.sky.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||||
|
gPipelines.sky.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||||
|
}
|
||||||
|
|
||||||
create_arbtri_pipeline :: () {
|
create_arbtri_pipeline :: () {
|
||||||
pipeline: sg_pipeline_desc;
|
pipeline: sg_pipeline_desc;
|
||||||
shader_desc := triangle_shader_desc(sg_query_backend());
|
shader_desc := triangle_shader_desc(sg_query_backend());
|
||||||
|
|||||||
1193
src/shaders/jai/shader_sky.jai
Normal file
1193
src/shaders/jai/shader_sky.jai
Normal file
File diff suppressed because it is too large
Load Diff
@ -36,14 +36,18 @@ Vs_Params :: struct {
|
|||||||
uniform vec4 vs_params[4];
|
uniform vec4 vs_params[4];
|
||||||
layout(location = 2) in vec4 inst;
|
layout(location = 2) in vec4 inst;
|
||||||
layout(location = 0) in vec4 position;
|
layout(location = 0) in vec4 position;
|
||||||
|
layout(location = 1) out vec4 fnormal;
|
||||||
|
layout(location = 1) in vec4 normal;
|
||||||
layout(location = 0) out vec4 color;
|
layout(location = 0) out vec4 color;
|
||||||
layout(location = 3) in vec4 inst_col;
|
layout(location = 3) in vec4 inst_col;
|
||||||
layout(location = 1) in vec4 normal;
|
layout(location = 2) out vec4 pos;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + inst.xyz, 1.0);
|
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + inst.xyz, 1.0);
|
||||||
|
fnormal = normal;
|
||||||
color = inst_col;
|
color = inst_col;
|
||||||
|
pos = gl_Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -56,46 +60,80 @@ vs_trixel_source_glsl430 := u8.[
|
|||||||
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
|
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,
|
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,
|
0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||||
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
|
0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
|
||||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,
|
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
||||||
0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,
|
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,
|
||||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||||
0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,
|
0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
|
||||||
0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
|
0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
|
||||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
|
||||||
0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,
|
0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||||
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,
|
||||||
0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x0a,0x76,
|
||||||
0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,
|
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||||
0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,
|
||||||
0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,
|
0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,
|
||||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
|
0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,
|
||||||
0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x7d,0x0a,
|
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,
|
||||||
0x0a,0x00,
|
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,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,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,
|
||||||
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||||
|
0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
layout(location = 0) out vec4 frag_color;
|
|
||||||
layout(location = 0) in vec4 color;
|
layout(location = 0) in vec4 color;
|
||||||
|
layout(location = 2) in vec4 pos;
|
||||||
|
layout(location = 1) in vec4 fnormal;
|
||||||
|
layout(location = 0) out vec4 frag_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
frag_color = color;
|
frag_color = vec4(((color.xyz * 0.300000011920928955078125) + ((color.xyz * max(0.0, dot(normalize(vec3(5.0, 5.0, 2.0) - pos.xyz), fnormal.xyz))) * 0.5)) + (((color.xyz * max(0.0, dot(normalize(vec3(-5.0, -2.0, -2.0) - pos.xyz), fnormal.xyz))) * 0.300000011920928955078125) * vec3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
fs_trixel_source_glsl430 := u8.[
|
fs_trixel_source_glsl430 := u8.[
|
||||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
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,
|
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,
|
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,
|
||||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
|
||||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
|
||||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||||
0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
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,0x76,0x65,0x63,0x34,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||||
|
0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,
|
||||||
|
0x35,0x29,0x20,0x2b,0x20,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,
|
||||||
|
0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,
|
||||||
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x35,
|
||||||
|
0x2e,0x30,0x2c,0x20,0x35,0x2e,0x30,0x2c,0x20,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,
|
||||||
|
0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,
|
||||||
|
0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29,
|
||||||
|
0x20,0x2b,0x20,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,
|
||||||
|
0x2a,0x20,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,
|
||||||
|
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x2d,0x35,
|
||||||
|
0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20,
|
||||||
|
0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,
|
||||||
|
0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,
|
||||||
|
0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,
|
||||||
|
0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,
|
||||||
|
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,
|
||||||
|
0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x2c,
|
||||||
|
0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,
|
||||||
|
0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c,0x20,0x31,
|
||||||
|
0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#version 300 es
|
#version 300 es
|
||||||
@ -103,14 +141,18 @@ fs_trixel_source_glsl430 := u8.[
|
|||||||
uniform vec4 vs_params[4];
|
uniform vec4 vs_params[4];
|
||||||
layout(location = 2) in vec4 inst;
|
layout(location = 2) in vec4 inst;
|
||||||
layout(location = 0) in vec4 position;
|
layout(location = 0) in vec4 position;
|
||||||
|
out vec4 fnormal;
|
||||||
|
layout(location = 1) in vec4 normal;
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
layout(location = 3) in vec4 inst_col;
|
layout(location = 3) in vec4 inst_col;
|
||||||
layout(location = 1) in vec4 normal;
|
out vec4 pos;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + inst.xyz, 1.0);
|
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + inst.xyz, 1.0);
|
||||||
|
fnormal = normal;
|
||||||
color = inst_col;
|
color = inst_col;
|
||||||
|
pos = gl_Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -122,12 +164,14 @@ vs_trixel_source_glsl300es := u8.[
|
|||||||
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x3b,0x0a,0x6c,
|
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,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,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,
|
0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,
|
||||||
0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,
|
0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
|
||||||
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
|
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,
|
||||||
0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x6c,0x61,0x79,
|
0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6f,0x75,0x74,
|
||||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,
|
||||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,
|
||||||
|
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,
|
||||||
|
0x6f,0x6c,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,
|
||||||
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
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,
|
0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||||
@ -136,21 +180,25 @@ vs_trixel_source_glsl300es := u8.[
|
|||||||
0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,
|
0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,
|
||||||
0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,
|
0x2a,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,0x2e,0x78,0x79,0x7a,0x2c,0x20,
|
0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20,
|
||||||
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,
|
||||||
0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x6c,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,
|
||||||
|
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#version 300 es
|
#version 300 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
precision highp int;
|
precision highp int;
|
||||||
|
|
||||||
layout(location = 0) out highp vec4 frag_color;
|
|
||||||
in highp vec4 color;
|
in highp vec4 color;
|
||||||
|
in highp vec4 pos;
|
||||||
|
in highp vec4 fnormal;
|
||||||
|
layout(location = 0) out highp vec4 frag_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
frag_color = color;
|
frag_color = vec4(((color.xyz * 0.300000011920928955078125) + ((color.xyz * max(0.0, dot(normalize(vec3(5.0, 5.0, 2.0) - pos.xyz), fnormal.xyz))) * 0.5)) + (((color.xyz * max(0.0, dot(normalize(vec3(-5.0, -2.0, -2.0) - pos.xyz), fnormal.xyz))) * 0.300000011920928955078125) * vec3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -158,14 +206,38 @@ fs_trixel_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,
|
||||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
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,
|
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x6c,
|
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x69,
|
||||||
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,0x69,
|
|
||||||
0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
|
0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
|
||||||
0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
|
0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||||
0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x6c,0x61,
|
||||||
|
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||||
|
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,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,0x76,0x65,
|
||||||
|
0x63,0x34,0x28,0x28,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,
|
||||||
|
0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,
|
||||||
|
0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x28,
|
||||||
|
0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x61,0x78,
|
||||||
|
0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||||
|
0x69,0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x35,0x2e,0x30,0x2c,0x20,0x35,0x2e,
|
||||||
|
0x30,0x2c,0x20,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,0x78,0x79,
|
||||||
|
0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,
|
||||||
|
0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x6d,0x61,0x78,0x28,
|
||||||
|
0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
|
||||||
|
0x7a,0x65,0x28,0x76,0x65,0x63,0x33,0x28,0x2d,0x35,0x2e,0x30,0x2c,0x20,0x2d,0x32,
|
||||||
|
0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x70,0x6f,0x73,0x2e,
|
||||||
|
0x78,0x79,0x7a,0x29,0x2c,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,
|
||||||
|
0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||||
|
0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,0x31,0x32,
|
||||||
|
0x35,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,
|
||||||
|
0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,
|
||||||
|
0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,
|
||||||
|
0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,
|
||||||
|
0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,
|
||||||
|
0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
@ -181,12 +253,15 @@ fs_trixel_source_glsl300es := u8.[
|
|||||||
struct main0_out
|
struct main0_out
|
||||||
{
|
{
|
||||||
float4 color [[user(locn0)]];
|
float4 color [[user(locn0)]];
|
||||||
|
float4 fnormal [[user(locn1)]];
|
||||||
|
float4 pos [[user(locn2)]];
|
||||||
float4 gl_Position [[position]];
|
float4 gl_Position [[position]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct main0_in
|
struct main0_in
|
||||||
{
|
{
|
||||||
float4 position [[attribute(0)]];
|
float4 position [[attribute(0)]];
|
||||||
|
float4 normal [[attribute(1)]];
|
||||||
float4 inst [[attribute(2)]];
|
float4 inst [[attribute(2)]];
|
||||||
float4 inst_col [[attribute(3)]];
|
float4 inst_col [[attribute(3)]];
|
||||||
};
|
};
|
||||||
@ -195,7 +270,9 @@ fs_trixel_source_glsl300es := u8.[
|
|||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.gl_Position = _26.mvp * float4(in.position.xyz + in.inst.xyz, 1.0);
|
out.gl_Position = _26.mvp * float4(in.position.xyz + in.inst.xyz, 1.0);
|
||||||
|
out.fnormal = in.normal;
|
||||||
out.color = in.inst_col;
|
out.color = in.inst_col;
|
||||||
|
out.pos = out.gl_Position;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,32 +289,42 @@ vs_trixel_source_metal_macos := u8.[
|
|||||||
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
|
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
|
||||||
0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
|
0x6f,0x6c,0x6f,0x72,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,
|
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,
|
0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
|
||||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
|
0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||||
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,
|
0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
|
||||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x69,
|
0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||||
0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
|
0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,
|
||||||
0x34,0x20,0x69,0x6e,0x73,0x74,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
|
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||||
0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||||
0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x20,0x5b,0x5b,0x61,
|
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,
|
||||||
0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
|
0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x61,
|
||||||
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
|
||||||
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
|
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x20,0x5b,
|
||||||
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,
|
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,
|
||||||
0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x36,0x20,0x5b,0x5b,0x62,0x75,
|
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,
|
||||||
0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
0x5f,0x63,0x6f,0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
|
||||||
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
|
0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,
|
||||||
0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,
|
0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
|
||||||
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x36,0x2e,0x6d,
|
0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,
|
||||||
0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x70,
|
0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,
|
||||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x69,0x6e,
|
0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,
|
||||||
0x2e,0x69,0x6e,0x73,0x74,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
|
0x5f,0x32,0x36,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,
|
||||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||||
0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x3b,0x0a,0x20,0x20,
|
0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,
|
||||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
0x0a,0x00,
|
0x20,0x3d,0x20,0x5f,0x32,0x36,0x2e,0x6d,0x76,0x70,0x20,0x2a,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,0x2e,0x78,0x79,
|
||||||
|
0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
||||||
|
0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x6e,0x6f,
|
||||||
|
0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,
|
||||||
|
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,
|
||||||
|
0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x70,0x6f,0x73,0x20,0x3d,
|
||||||
|
0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
|
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 <metal_stdlib>
|
||||||
@ -253,12 +340,14 @@ vs_trixel_source_metal_macos := u8.[
|
|||||||
struct main0_in
|
struct main0_in
|
||||||
{
|
{
|
||||||
float4 color [[user(locn0)]];
|
float4 color [[user(locn0)]];
|
||||||
|
float4 fnormal [[user(locn1)]];
|
||||||
|
float4 pos [[user(locn2)]];
|
||||||
};
|
};
|
||||||
|
|
||||||
fragment main0_out main0(main0_in in [[stage_in]])
|
fragment main0_out main0(main0_in in [[stage_in]])
|
||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.frag_color = in.color;
|
out.frag_color = float4(((in.color.xyz * 0.300000011920928955078125) + ((in.color.xyz * fast::max(0.0, dot(fast::normalize(float3(5.0, 5.0, 2.0) - in.pos.xyz), in.fnormal.xyz))) * 0.5)) + (((in.color.xyz * fast::max(0.0, dot(fast::normalize(float3(-5.0, -2.0, -2.0) - in.pos.xyz), in.fnormal.xyz))) * 0.300000011920928955078125) * float3(1.0, 0.699999988079071044921875, 0.699999988079071044921875)), 1.0);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,14 +364,42 @@ fs_trixel_source_metal_macos := u8.[
|
|||||||
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||||
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
|
0x63,0x6f,0x6c,0x6f,0x72,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,
|
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||||
0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,
|
0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
|
||||||
0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,
|
0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,
|
0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
|
||||||
0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,
|
0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,
|
||||||
0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
|
0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
|
||||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,
|
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
|
||||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
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,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||||
|
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x28,0x69,0x6e,0x2e,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x33,0x30,0x30,0x30,0x30,
|
||||||
|
0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,0x35,0x30,0x37,0x38,
|
||||||
|
0x31,0x32,0x35,0x29,0x20,0x2b,0x20,0x28,0x28,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6d,0x61,
|
||||||
|
0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,0x28,0x66,0x61,0x73,0x74,0x3a,
|
||||||
|
0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,
|
||||||
|
0x33,0x28,0x35,0x2e,0x30,0x2c,0x20,0x35,0x2e,0x30,0x2c,0x20,0x32,0x2e,0x30,0x29,
|
||||||
|
0x20,0x2d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,
|
||||||
|
0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,
|
||||||
|
0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x29,0x20,0x2b,0x20,0x28,0x28,0x28,0x69,
|
||||||
|
0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x66,0x61,
|
||||||
|
0x73,0x74,0x3a,0x3a,0x6d,0x61,0x78,0x28,0x30,0x2e,0x30,0x2c,0x20,0x64,0x6f,0x74,
|
||||||
|
0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,
|
||||||
|
0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x2d,0x35,0x2e,0x30,0x2c,0x20,0x2d,0x32,
|
||||||
|
0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x20,0x2d,0x20,0x69,0x6e,0x2e,0x70,
|
||||||
|
0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x2c,0x20,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,
|
||||||
|
0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x29,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x33,
|
||||||
|
0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x31,0x39,0x32,0x30,0x39,0x32,0x38,0x39,0x35,
|
||||||
|
0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x29,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||||
|
0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,
|
||||||
|
0x38,0x38,0x30,0x37,0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,
|
||||||
|
0x35,0x2c,0x20,0x30,0x2e,0x36,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x30,0x37,
|
||||||
|
0x39,0x30,0x37,0x31,0x30,0x34,0x34,0x39,0x32,0x31,0x38,0x37,0x35,0x29,0x29,0x2c,
|
||||||
|
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||||
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
];
|
];
|
||||||
trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||||
|
|||||||
117
src/shaders/shader_sky.glsl
Normal file
117
src/shaders/shader_sky.glsl
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
@vs vs_sky
|
||||||
|
|
||||||
|
in vec4 position;
|
||||||
|
|
||||||
|
layout(binding=0) uniform sky_vs_params {
|
||||||
|
mat4 mvp;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
out vec4 pos;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = mvp * (vec4(position.xyz * 500.0, 1.0));
|
||||||
|
pos = position;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@fs fs_sky
|
||||||
|
in vec4 pos;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
const float time = 0.0;
|
||||||
|
const float cirrus = 0.5;
|
||||||
|
const float cumulus = 0.6;
|
||||||
|
|
||||||
|
// ----- SKY SHADER -------
|
||||||
|
|
||||||
|
float hash(float n)
|
||||||
|
{
|
||||||
|
return fract(sin(n) * 43758.5453123);
|
||||||
|
}
|
||||||
|
|
||||||
|
float noise(vec3 x)
|
||||||
|
{
|
||||||
|
vec3 f = fract(x);
|
||||||
|
float n = dot(floor(x), vec3(1.0, 157.0, 113.0));
|
||||||
|
return mix(mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),
|
||||||
|
mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),
|
||||||
|
mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),
|
||||||
|
mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mat3 m = mat3(0.0, 1.60, 1.20, -1.6, 0.72, -0.96, -1.2, -0.96, 1.28);
|
||||||
|
float fbm(vec3 p)
|
||||||
|
{
|
||||||
|
float f = 0.0;
|
||||||
|
f += noise(p) / 2.0; p = m * p * 1.1;
|
||||||
|
f += noise(p) / 4.0; p = m * p * 1.2;
|
||||||
|
f += noise(p) / 6.0; p = m * p * 1.3;
|
||||||
|
f += noise(p) / 12.0; p = m * p * 1.4;
|
||||||
|
f += noise(p) / 24.0;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 filmic_aces(vec3 v)
|
||||||
|
{
|
||||||
|
v = v * mat3(
|
||||||
|
0.59719f, 0.35458f, 0.04823f,
|
||||||
|
0.07600f, 0.90834f, 0.01566f,
|
||||||
|
0.02840f, 0.13383f, 0.83777f
|
||||||
|
);
|
||||||
|
return (v * (v + 0.0245786f) - 9.0537e-5f) /
|
||||||
|
(v * (0.983729f * v + 0.4329510f) + 0.238081f) * mat3(
|
||||||
|
1.60475f, -0.53108f, -0.07367f,
|
||||||
|
-0.10208f, 1.10813f, -0.00605f,
|
||||||
|
-0.00327f, -0.07276f, 1.07602f
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 sky(vec3 skypos, vec3 sunpos) {
|
||||||
|
vec3 skyBase = vec3(0.3843, 0.8117, 0.9568);
|
||||||
|
vec3 skyTop = vec3(0.17, 0.4, 0.95);
|
||||||
|
vec3 sunDisk = vec3(1.0, 1.0, 1.0);
|
||||||
|
vec3 horizonHalo = vec3(1.0, 1.0, 1.0);
|
||||||
|
vec3 sunHalo = vec3(1.0, 1.0, 1.0);
|
||||||
|
|
||||||
|
vec3 sunCol = sunDisk.xyz;
|
||||||
|
vec3 baseSky = skyBase.xyz;
|
||||||
|
vec3 topSky = skyTop.xyz;
|
||||||
|
|
||||||
|
float sDist = dot(normalize(skypos), normalize(sunpos));
|
||||||
|
|
||||||
|
vec3 npos = normalize(skypos);
|
||||||
|
|
||||||
|
|
||||||
|
vec3 skyGradient = mix(baseSky, topSky, clamp(skypos.y * 2.0, 0.0, 0.7));
|
||||||
|
|
||||||
|
vec3 final = skyGradient;
|
||||||
|
final += sunHalo.xyz * clamp((sDist - 0.95) * 10.0, 0.0, 0.8) * 0.2;
|
||||||
|
|
||||||
|
// Sun disk
|
||||||
|
if(sDist > 0.9999) {
|
||||||
|
final = sunDisk.xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Horizon halo
|
||||||
|
final += mix(horizonHalo.xyz, vec3(0.0,0.0,0.0), clamp(abs(npos.y) * 80.0, 0.0, 1.0)) * 0.1;
|
||||||
|
|
||||||
|
final = vec3(final);
|
||||||
|
|
||||||
|
// Cirrus Clouds
|
||||||
|
float density = smoothstep(1.0 - cirrus, 1.0, fbm(npos.xyz / npos.y * 2.0 + time * 0.05)) * 0.3;
|
||||||
|
final.rgb = mix(final.rgb, vec3(1.0, 1.0, 1.0), max(0.0, npos.y) * density * 2.0);
|
||||||
|
|
||||||
|
return final;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- END SKY ----
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 dir = normalize(pos.xyz);
|
||||||
|
vec3 color = sky(dir, normalize(vec3(0.6,0.9,0.6)));
|
||||||
|
frag_color = vec4(color, 1.0);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@program sky vs_sky fs_sky
|
||||||
@ -12,23 +12,38 @@ layout(binding=0) uniform vs_params {
|
|||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
out vec4 fnormal;
|
out vec4 fnormal;
|
||||||
|
out vec4 pos;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 instancepos = inst.xyz;
|
vec3 instancepos = inst.xyz;
|
||||||
gl_Position = mvp * (vec4(position.xyz + instancepos, 1.0));
|
gl_Position = mvp * (vec4(position.xyz + instancepos, 1.0));
|
||||||
fnormal = normal;
|
fnormal = normal;
|
||||||
color = inst_col;
|
color = inst_col;
|
||||||
|
pos = gl_Position;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@fs fs_trixel
|
@fs fs_trixel
|
||||||
in vec4 color;
|
in vec4 color;
|
||||||
in vec4 fnormal;
|
in vec4 fnormal;
|
||||||
|
in vec4 pos;
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
frag_color = color * 0.1 + fnormal;
|
|
||||||
|
// 2 lights.
|
||||||
|
vec3 light1 = vec3(5.0, 5.0, 2.0);
|
||||||
|
vec3 light2 = vec3(-5.0, -2.0, -2.0);
|
||||||
|
|
||||||
|
vec3 albedo = color.xyz;
|
||||||
|
vec3 light = 0.3 * albedo;
|
||||||
|
|
||||||
|
vec3 light1dir = normalize(light1 - pos.xyz);
|
||||||
|
vec3 light2dir = normalize(light2 - pos.xyz);
|
||||||
|
light += max(0.0, dot(light1dir, fnormal.xyz)) * albedo * 0.5;
|
||||||
|
light += max(0.0, dot(light2dir, fnormal.xyz)) * albedo * 0.3 * vec3(1.0, 0.7, 0.7);
|
||||||
|
frag_color = vec4(light, 1.0);
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user