diff --git a/game/game.jai b/game/game.jai index 280f208..38b8c99 100644 --- a/game/game.jai +++ b/game/game.jai @@ -14,4 +14,5 @@ game_tick :: () { game_draw :: () { draw_sky(*cam); + draw_ground_plane(*cam); } diff --git a/src/editor/level_editor.jai b/src/editor/level_editor.jai index e492a2b..e064a29 100644 --- a/src/editor/level_editor.jai +++ b/src/editor/level_editor.jai @@ -263,6 +263,7 @@ tick_level_editor :: () { draw_level_editor :: () { draw_sky(*get_level_editor_camera(), *world.conf); + draw_ground_plane(*get_level_editor_camera(), *world.conf); cam := get_level_editor_camera(); mvp := create_viewproj(*cam); diff --git a/src/pipelines.jai b/src/pipelines.jai index d73eb93..0c2dfe4 100644 --- a/src/pipelines.jai +++ b/src/pipelines.jai @@ -18,8 +18,12 @@ gPipelines : struct { // Sky rendering. sky : Pipeline_Binding; + // Renders sets of triles trile : Pipeline_Binding; + // Renders the ground plane. + plane : Pipeline_Binding; + } create_pipelines :: () { @@ -27,6 +31,7 @@ create_pipelines :: () { create_trixel_pipeline(); create_trile_pipeline(); create_sky_pipeline(); + create_plane_pipeline(); } TRIXEL_SIZE_HALF : float : 1.0/32.0; @@ -276,6 +281,52 @@ create_sky_pipeline :: () { gPipelines.sky.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer); } +create_plane_pipeline :: () { + pipeline: sg_pipeline_desc; + shader_desc := plane_shader_desc(sg_query_backend()); + pipeline.shader = sg_make_shader(*shader_desc); + pipeline.layout.buffers[0].stride = 4*3; + + pipeline.layout.attrs[ATTR_plane_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: [4]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}, + ]; + + indices: [6]u16 = .[ + 0, 1, 2, + 0, 2, 3, + ]; + + pipeline.color_count = 1; + pipeline.colors[0] = color_state; + + gPipelines.plane.pipeline = sg_make_pipeline(*pipeline); + + ibuffer := sg_buffer_desc.{ type = .INDEXBUFFER, data = .{ ptr = indices.data, size = 6 * 2 } }; + vbuffer := sg_buffer_desc.{ data = .{ ptr = vertices.data, size = 4 * 3 * 4 } }; + + gPipelines.plane.bind.index_buffer = sg_make_buffer(*ibuffer); + gPipelines.plane.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer); +} + create_arbtri_pipeline :: () { pipeline: sg_pipeline_desc; shader_desc := triangle_shader_desc(sg_query_backend()); diff --git a/src/rendering/groundplane.jai b/src/rendering/groundplane.jai new file mode 100644 index 0000000..82a8395 --- /dev/null +++ b/src/rendering/groundplane.jai @@ -0,0 +1,17 @@ +draw_ground_plane :: (cam: *Camera, worldConfig: *World_Config = null) { + mvp := create_viewproj(cam); + vs_params : Plane_Vs_Params; + + world_conf : Plane_World_Config; + + wc : *World_Config = ifx worldConfig == null then *(World_Config.{}) else worldConfig; + + world_config_to_shader_type(wc, *world_conf); + + vs_params.mvp = mvp.floats; + sg_apply_pipeline(gPipelines.plane.pipeline); + 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))})); + sg_draw(0, 6, 10); +} diff --git a/src/rendering/rendering.jai b/src/rendering/rendering.jai index 8d2daa4..09fc7e1 100644 --- a/src/rendering/rendering.jai +++ b/src/rendering/rendering.jai @@ -1 +1,2 @@ +#load "groundplane.jai"; #load "sky.jai"; diff --git a/src/shaders/jai/shader_plane.jai b/src/shaders/jai/shader_plane.jai new file mode 100644 index 0000000..d449d13 --- /dev/null +++ b/src/shaders/jai/shader_plane.jai @@ -0,0 +1,781 @@ +/* + #version:1# (machine generated, don't edit!) + + Generated by sokol-shdc (https://github.com/floooh/sokol-tools) + + Cmdline: + sokol-shdc -i shader_plane.glsl -o ./jai/shader_plane.jai -l glsl430:glsl300es:metal_macos -f sokol_jai + + Overview: + ========= + Shader program: 'plane': + Get shader desc: plane_shader_desc(sg_query_backend()) + Vertex Shader: vs_plane + Fragment Shader: fs_plane + Attributes: + ATTR_plane_position => 0 + Bindings: + Uniform block 'plane_vs_params': + Jai struct: Plane_Vs_Params + Bind slot: UB_plane_vs_params => 0 + Uniform block 'plane_world_config': + Jai struct: Plane_World_Config + Bind slot: UB_plane_world_config => 1 +*/ +ATTR_plane_position :: 0; +UB_plane_vs_params :: 0; +UB_plane_world_config :: 1; +Plane_Vs_Params :: struct { + mvp: [16]float; +}; +Plane_World_Config :: struct { + skyBase: [3]float; + _: [4]u8; + skyTop: [3]float; + _: [4]u8; + sunDisk: [3]float; + _: [4]u8; + horizonHalo: [3]float; + _: [4]u8; + sunHalo: [3]float; + _: [4]u8; + sunLightColor: [3]float; + _: [4]u8; + sunPosition: [3]float; + sunIntensity: float; + skyIntensity: float; + hasClouds: s32; + hasPlane: s32; + planeHeight: float; + planeType: s32; + time: float; + _: [8]u8; +}; +/* + #version 430 + + uniform vec4 plane_vs_params[4]; + layout(location = 0) in vec4 position; + layout(location = 0) out vec4 pos; + layout(location = 1) flat out int idx; + + void main() + { + vec3 _16 = position.xyz * 1000.0; + gl_Position = mat4(plane_vs_params[0], plane_vs_params[1], plane_vs_params[2], plane_vs_params[3]) * vec4(_16.x, (_16.y + 0.100000001490116119384765625) + (float(gl_InstanceID) * 0.004999999888241291046142578125), _16.z, 1.0); + pos = position; + idx = gl_InstanceID; + } + +*/ +vs_plane_source_glsl430 := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e, + 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6c,0x61,0x6e,0x65, + 0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c, + 0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d, + 0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, + 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76, + 0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x66,0x6c, + 0x61,0x74,0x20,0x6f,0x75,0x74,0x20,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x3b,0x0a, + 0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x31,0x36,0x20,0x3d,0x20,0x70,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30, + 0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x70,0x6c,0x61,0x6e, + 0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20, + 0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72, + 0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, + 0x63,0x34,0x28,0x5f,0x31,0x36,0x2e,0x78,0x2c,0x20,0x28,0x5f,0x31,0x36,0x2e,0x79, + 0x20,0x2b,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39, + 0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35, + 0x29,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e, + 0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x29,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30, + 0x34,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x38,0x32,0x34,0x31,0x32,0x39,0x31, + 0x30,0x34,0x36,0x31,0x34,0x32,0x35,0x37,0x38,0x31,0x32,0x35,0x29,0x2c,0x20,0x5f, + 0x31,0x36,0x2e,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x70,0x6f,0x73,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x69,0x64,0x78,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73, + 0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 430 + + struct plane_world_config + { + vec3 skyBase; + vec3 skyTop; + vec3 sunDisk; + vec3 horizonHalo; + vec3 sunHalo; + vec3 sunLightColor; + vec3 sunPosition; + float sunIntensity; + float skyIntensity; + int hasClouds; + int hasPlane; + float planeHeight; + int planeType; + float time; + }; + + uniform plane_world_config _28; + + layout(location = 0) out vec4 frag_color; + layout(location = 0) in vec4 pos; + layout(location = 1) flat in int idx; + + float random(vec2 st) + { + return fract(sin(dot(st, vec2(12.98980045318603515625, 767.23297119140625))) * 43758.546875); + } + + void main() + { + if (_28.planeType == 1) + { + frag_color = vec4(0.0, 0.0, 1.0, 1.0); + } + else + { + vec2 _63 = vec2(float(int(pos.x * 50000.0)), float(int(pos.z * 50000.0))); + vec2 param = _63; + if (random(param) < (float(idx) * 0.100000001490116119384765625)) + { + discard; + } + vec2 param_1 = _63; + frag_color = vec4(0.0, random(param_1) + 0.100000001490116119384765625, 0.0, 1.0); + } + } + +*/ +fs_plane_source_glsl430 := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74, + 0x72,0x75,0x63,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f,0x72,0x6c,0x64, + 0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65, + 0x63,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48, + 0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75, + 0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20, + 0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73, + 0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73, + 0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73, + 0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20, + 0x68,0x61,0x73,0x50,0x6c,0x61,0x6e,0x65,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,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79, + 0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x74,0x69, + 0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20, + 0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66, + 0x69,0x67,0x20,0x5f,0x32,0x38,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28, + 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75, + 0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20, + 0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x69, + 0x6e,0x20,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x3b,0x0a,0x0a,0x66,0x6c,0x6f,0x61, + 0x74,0x20,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x76,0x65,0x63,0x32,0x20,0x73,0x74, + 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66, + 0x72,0x61,0x63,0x74,0x28,0x73,0x69,0x6e,0x28,0x64,0x6f,0x74,0x28,0x73,0x74,0x2c, + 0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x32,0x2e,0x39,0x38,0x39,0x38,0x30,0x30,0x34, + 0x35,0x33,0x31,0x38,0x36,0x30,0x33,0x35,0x31,0x35,0x36,0x32,0x35,0x2c,0x20,0x37, + 0x36,0x37,0x2e,0x32,0x33,0x32,0x39,0x37,0x31,0x31,0x39,0x31,0x34,0x30,0x36,0x32, + 0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x34,0x33,0x37,0x35,0x38,0x2e,0x35,0x34,0x36, + 0x38,0x37,0x35,0x29,0x3b,0x0a,0x7d,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, + 0x32,0x38,0x2e,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20, + 0x31,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,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, + 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,0x76,0x65,0x63,0x32,0x20,0x5f,0x36,0x33,0x20,0x3d,0x20, + 0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x6e,0x74,0x28,0x70, + 0x6f,0x73,0x2e,0x78,0x20,0x2a,0x20,0x35,0x30,0x30,0x30,0x30,0x2e,0x30,0x29,0x29, + 0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x6e,0x74,0x28,0x70,0x6f,0x73,0x2e, + 0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x30,0x30,0x2e,0x30,0x29,0x29,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x20,0x3d,0x20,0x5f,0x36,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x69,0x66,0x20,0x28,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x70,0x61,0x72, + 0x61,0x6d,0x29,0x20,0x3c,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x64,0x78, + 0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34, + 0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32, + 0x35,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72, + 0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f, + 0x31,0x20,0x3d,0x20,0x5f,0x36,0x33,0x3b,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,0x30,0x2e,0x30,0x2c,0x20,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x70, + 0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x20,0x2b,0x20,0x30,0x2e,0x31,0x30,0x30,0x30, + 0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38, + 0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 300 es + + uniform vec4 plane_vs_params[4]; + layout(location = 0) in vec4 position; + out vec4 pos; + flat out int idx; + + void main() + { + vec3 _16 = position.xyz * 1000.0; + gl_Position = mat4(plane_vs_params[0], plane_vs_params[1], plane_vs_params[2], plane_vs_params[3]) * vec4(_16.x, (_16.y + 0.100000001490116119384765625) + (float(gl_InstanceID) * 0.004999999888241291046142578125), _16.z, 1.0); + pos = position; + idx = gl_InstanceID; + } + +*/ +vs_plane_source_glsl300es := u8.[ + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6c, + 0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f, + 0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63, + 0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x66,0x6c,0x61,0x74,0x20,0x6f,0x75,0x74,0x20, + 0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d, + 0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33, + 0x20,0x5f,0x31,0x36,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e, + 0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30,0x30,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, + 0x6d,0x61,0x74,0x34,0x28,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61, + 0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x70,0x6c,0x61, + 0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c, + 0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73, + 0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x36,0x2e, + 0x78,0x2c,0x20,0x28,0x5f,0x31,0x36,0x2e,0x79,0x20,0x2b,0x20,0x30,0x2e,0x31,0x30, + 0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39, + 0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x20,0x2b,0x20,0x28,0x66,0x6c, + 0x6f,0x61,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49, + 0x44,0x29,0x20,0x2a,0x20,0x30,0x2e,0x30,0x30,0x34,0x39,0x39,0x39,0x39,0x39,0x39, + 0x38,0x38,0x38,0x32,0x34,0x31,0x32,0x39,0x31,0x30,0x34,0x36,0x31,0x34,0x32,0x35, + 0x37,0x38,0x31,0x32,0x35,0x29,0x2c,0x20,0x5f,0x31,0x36,0x2e,0x7a,0x2c,0x20,0x31, + 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x64,0x78, + 0x20,0x3d,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44, + 0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +]; +/* + #version 300 es + precision mediump float; + precision highp int; + + struct plane_world_config + { + highp vec3 skyBase; + highp vec3 skyTop; + highp vec3 sunDisk; + highp vec3 horizonHalo; + highp vec3 sunHalo; + highp vec3 sunLightColor; + highp vec3 sunPosition; + highp float sunIntensity; + highp float skyIntensity; + int hasClouds; + int hasPlane; + highp float planeHeight; + int planeType; + highp float time; + }; + + uniform plane_world_config _28; + + layout(location = 0) out highp vec4 frag_color; + in highp vec4 pos; + flat in int idx; + + highp float random(highp vec2 st) + { + return fract(sin(dot(st, vec2(12.98980045318603515625, 767.23297119140625))) * 43758.546875); + } + + void main() + { + if (_28.planeType == 1) + { + frag_color = vec4(0.0, 0.0, 1.0, 1.0); + } + else + { + highp vec2 _63 = vec2(float(int(pos.x * 50000.0)), float(int(pos.z * 50000.0))); + highp vec2 param = _63; + if (random(param) < (float(idx) * 0.100000001490116119384765625)) + { + discard; + } + highp vec2 param_1 = _63; + frag_color = vec4(0.0, random(param_1) + 0.100000001490116119384765625, 0.0, 1.0); + } + } + +*/ +fs_plane_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,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f,0x72,0x6c, + 0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73, + 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, + 0x33,0x20,0x73,0x6b,0x79,0x54,0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69, + 0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x44,0x69,0x73,0x6b, + 0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33, + 0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e, + 0x48,0x61,0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20, + 0x76,0x65,0x63,0x33,0x20,0x73,0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x33,0x20,0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20, + 0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x6b, + 0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a,0x20, + 0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x50,0x6c,0x61,0x6e,0x65,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x6c,0x61,0x6e,0x65,0x48,0x65,0x69,0x67,0x68,0x74,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x69,0x6e,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x74,0x69,0x6d,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f, + 0x72,0x6d,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x63, + 0x6f,0x6e,0x66,0x69,0x67,0x20,0x5f,0x32,0x38,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20, + 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,0x70,0x6f,0x73,0x3b,0x0a,0x66, + 0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x3b,0x0a, + 0x0a,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x61,0x6e, + 0x64,0x6f,0x6d,0x28,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x73, + 0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20, + 0x66,0x72,0x61,0x63,0x74,0x28,0x73,0x69,0x6e,0x28,0x64,0x6f,0x74,0x28,0x73,0x74, + 0x2c,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x32,0x2e,0x39,0x38,0x39,0x38,0x30,0x30, + 0x34,0x35,0x33,0x31,0x38,0x36,0x30,0x33,0x35,0x31,0x35,0x36,0x32,0x35,0x2c,0x20, + 0x37,0x36,0x37,0x2e,0x32,0x33,0x32,0x39,0x37,0x31,0x31,0x39,0x31,0x34,0x30,0x36, + 0x32,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x34,0x33,0x37,0x35,0x38,0x2e,0x35,0x34, + 0x36,0x38,0x37,0x35,0x29,0x3b,0x0a,0x7d,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,0x32,0x38,0x2e,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d, + 0x20,0x31,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,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,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,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32, + 0x20,0x5f,0x36,0x33,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61, + 0x74,0x28,0x69,0x6e,0x74,0x28,0x70,0x6f,0x73,0x2e,0x78,0x20,0x2a,0x20,0x35,0x30, + 0x30,0x30,0x30,0x2e,0x30,0x29,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69, + 0x6e,0x74,0x28,0x70,0x6f,0x73,0x2e,0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x30,0x30, + 0x2e,0x30,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68, + 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x61,0x72,0x61,0x6d,0x20, + 0x3d,0x20,0x5f,0x36,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69, + 0x66,0x20,0x28,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x29, + 0x20,0x3c,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69,0x64,0x78,0x29,0x20,0x2a, + 0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31, + 0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x29, + 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x61,0x72, + 0x61,0x6d,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x36,0x33,0x3b,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,0x30,0x2e,0x30,0x2c,0x20,0x72,0x61,0x6e,0x64,0x6f, + 0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x20,0x2b,0x20,0x30,0x2e,0x31, + 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31, + 0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x30,0x2e,0x30,0x2c, + 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a, + 0x00, +]; +/* + #include + #include + + using namespace metal; + + struct plane_vs_params + { + float4x4 mvp; + }; + + struct main0_out + { + float4 pos [[user(locn0)]]; + int idx [[user(locn1)]]; + float4 gl_Position [[position]]; + }; + + struct main0_in + { + float4 position [[attribute(0)]]; + }; + + vertex main0_out main0(main0_in in [[stage_in]], constant plane_vs_params& _28 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]]) + { + main0_out out = {}; + float3 _16 = in.position.xyz * 1000.0; + out.gl_Position = _28.mvp * float4(_16.x, (_16.y + 0.100000001490116119384765625) + (float(int(gl_InstanceIndex)) * 0.004999999888241291046142578125), _16.z, 1.0); + out.pos = in.position; + out.idx = int(gl_InstanceIndex); + return out; + } + +*/ +vs_plane_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,0x70, + 0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76, + 0x70,0x3b,0x0a,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,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, + 0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e, + 0x74,0x20,0x69,0x64,0x78,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63, + 0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b, + 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a, + 0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a, + 0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73, + 0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, + 0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74, + 0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69, + 0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b, + 0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e, + 0x73,0x74,0x61,0x6e,0x74,0x20,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x76,0x73,0x5f,0x70, + 0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x38,0x20,0x5b,0x5b,0x62,0x75,0x66, + 0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67, + 0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20, + 0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74, + 0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,0x36,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x31,0x30, + 0x30,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c, + 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x32,0x38,0x2e, + 0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x31,0x36, + 0x2e,0x78,0x2c,0x20,0x28,0x5f,0x31,0x36,0x2e,0x79,0x20,0x2b,0x20,0x30,0x2e,0x31, + 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31, + 0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x20,0x2b,0x20,0x28,0x66, + 0x6c,0x6f,0x61,0x74,0x28,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74, + 0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e, + 0x30,0x30,0x34,0x39,0x39,0x39,0x39,0x39,0x39,0x38,0x38,0x38,0x32,0x34,0x31,0x32, + 0x39,0x31,0x30,0x34,0x36,0x31,0x34,0x32,0x35,0x37,0x38,0x31,0x32,0x35,0x29,0x2c, + 0x20,0x5f,0x31,0x36,0x2e,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x6f,0x75,0x74,0x2e,0x70,0x6f,0x73,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70, + 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x2e,0x69,0x64,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e, + 0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, +]; +/* + #pragma clang diagnostic ignored "-Wmissing-prototypes" + + #include + #include + + using namespace metal; + + struct plane_world_config + { + float3 skyBase; + float3 skyTop; + float3 sunDisk; + float3 horizonHalo; + float3 sunHalo; + float3 sunLightColor; + packed_float3 sunPosition; + float sunIntensity; + float skyIntensity; + int hasClouds; + int hasPlane; + float planeHeight; + int planeType; + float time; + }; + + struct main0_out + { + float4 frag_color [[color(0)]]; + }; + + struct main0_in + { + float4 pos [[user(locn0)]]; + int idx [[user(locn1)]]; + }; + + static inline __attribute__((always_inline)) + float random(thread const float2& st) + { + return fract(sin(dot(st, float2(12.98980045318603515625, 767.23297119140625))) * 43758.546875); + } + + fragment main0_out main0(main0_in in [[stage_in]], constant plane_world_config& _28 [[buffer(0)]]) + { + main0_out out = {}; + if (_28.planeType == 1) + { + out.frag_color = float4(0.0, 0.0, 1.0, 1.0); + } + else + { + float2 _63 = float2(float(int(in.pos.x * 50000.0)), float(int(in.pos.z * 50000.0))); + float2 param = _63; + if (random(param) < (float(in.idx) * 0.100000001490116119384765625)) + { + discard_fragment(); + } + float2 param_1 = _63; + out.frag_color = float4(0.0, random(param_1) + 0.100000001490116119384765625, 0.0, 1.0); + } + return out; + } + +*/ +fs_plane_source_metal_macos := u8.[ + 0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x63,0x6c,0x61,0x6e,0x67,0x20,0x64,0x69, + 0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x20,0x69,0x67,0x6e,0x6f,0x72,0x65,0x64, + 0x20,0x22,0x2d,0x57,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x2d,0x70,0x72,0x6f,0x74, + 0x6f,0x74,0x79,0x70,0x65,0x73,0x22,0x0a,0x0a,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,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f, + 0x72,0x6c,0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x0a,0x7b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79,0x42,0x61,0x73,0x65,0x3b, + 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x6b,0x79,0x54, + 0x6f,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73, + 0x75,0x6e,0x44,0x69,0x73,0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61, + 0x74,0x33,0x20,0x68,0x6f,0x72,0x69,0x7a,0x6f,0x6e,0x48,0x61,0x6c,0x6f,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73,0x75,0x6e,0x48,0x61, + 0x6c,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x73, + 0x75,0x6e,0x4c,0x69,0x67,0x68,0x74,0x43,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20, + 0x20,0x20,0x70,0x61,0x63,0x6b,0x65,0x64,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20, + 0x73,0x75,0x6e,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73,0x75,0x6e,0x49,0x6e,0x74,0x65,0x6e,0x73, + 0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x73, + 0x6b,0x79,0x49,0x6e,0x74,0x65,0x6e,0x73,0x69,0x74,0x79,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x43,0x6c,0x6f,0x75,0x64,0x73,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x68,0x61,0x73,0x50,0x6c,0x61,0x6e,0x65, + 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,0x20,0x20,0x20,0x20,0x69,0x6e,0x74, + 0x20,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x20,0x74,0x69,0x6d,0x65,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,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x75,0x73, + 0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20, + 0x20,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28, + 0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74, + 0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x5f,0x5f,0x61,0x74, + 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x61,0x6c,0x77,0x61,0x79, + 0x73,0x5f,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x29,0x29,0x0a,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x74,0x68,0x72,0x65,0x61,0x64,0x20,0x63, + 0x6f,0x6e,0x73,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x26,0x20,0x73,0x74,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x66,0x72, + 0x61,0x63,0x74,0x28,0x73,0x69,0x6e,0x28,0x64,0x6f,0x74,0x28,0x73,0x74,0x2c,0x20, + 0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x31,0x32,0x2e,0x39,0x38,0x39,0x38,0x30,0x30, + 0x34,0x35,0x33,0x31,0x38,0x36,0x30,0x33,0x35,0x31,0x35,0x36,0x32,0x35,0x2c,0x20, + 0x37,0x36,0x37,0x2e,0x32,0x33,0x32,0x39,0x37,0x31,0x31,0x39,0x31,0x34,0x30,0x36, + 0x32,0x35,0x29,0x29,0x29,0x20,0x2a,0x20,0x34,0x33,0x37,0x35,0x38,0x2e,0x35,0x34, + 0x36,0x38,0x37,0x35,0x29,0x3b,0x0a,0x7d,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,0x70,0x6c,0x61,0x6e,0x65,0x5f,0x77,0x6f,0x72,0x6c, + 0x64,0x5f,0x63,0x6f,0x6e,0x66,0x69,0x67,0x26,0x20,0x5f,0x32,0x38,0x20,0x5b,0x5b, + 0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20, + 0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74, + 0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f, + 0x32,0x38,0x2e,0x70,0x6c,0x61,0x6e,0x65,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20, + 0x31,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,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,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,0x6c,0x6f,0x61,0x74, + 0x32,0x20,0x5f,0x36,0x33,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x66, + 0x6c,0x6f,0x61,0x74,0x28,0x69,0x6e,0x74,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e, + 0x78,0x20,0x2a,0x20,0x35,0x30,0x30,0x30,0x30,0x2e,0x30,0x29,0x29,0x2c,0x20,0x66, + 0x6c,0x6f,0x61,0x74,0x28,0x69,0x6e,0x74,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x2e, + 0x7a,0x20,0x2a,0x20,0x35,0x30,0x30,0x30,0x30,0x2e,0x30,0x29,0x29,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70, + 0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x5f,0x36,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x70, + 0x61,0x72,0x61,0x6d,0x29,0x20,0x3c,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x69, + 0x6e,0x2e,0x69,0x64,0x78,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30, + 0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34, + 0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20, + 0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64, + 0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x28, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x61,0x72,0x61, + 0x6d,0x5f,0x31,0x20,0x3d,0x20,0x5f,0x36,0x33,0x3b,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,0x30,0x2e,0x30,0x2c,0x20, + 0x72,0x61,0x6e,0x64,0x6f,0x6d,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x20, + 0x2b,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30, + 0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x2c, + 0x20,0x30,0x2e,0x30,0x2c,0x20,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, +]; +plane_shader_desc :: (backend: sg_backend) -> sg_shader_desc { + desc: sg_shader_desc; + desc.label = "plane_shader"; + if backend == { + case .GLCORE; + desc.vertex_func.source = xx *vs_plane_source_glsl430; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_plane_source_glsl430; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4; + desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "plane_vs_params"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_28.skyBase"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_28.skyTop"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_28.sunDisk"; + desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_28.horizonHalo"; + desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_28.sunHalo"; + desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_28.sunLightColor"; + desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_28.sunPosition"; + desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_28.sunIntensity"; + desc.uniform_blocks[1].glsl_uniforms[8].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_28.skyIntensity"; + desc.uniform_blocks[1].glsl_uniforms[9].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_28.hasClouds"; + desc.uniform_blocks[1].glsl_uniforms[10].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_28.hasPlane"; + desc.uniform_blocks[1].glsl_uniforms[11].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_28.planeHeight"; + desc.uniform_blocks[1].glsl_uniforms[12].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_28.planeType"; + desc.uniform_blocks[1].glsl_uniforms[13].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[13].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_28.time"; + case .GLES3; + desc.vertex_func.source = xx *vs_plane_source_glsl300es; + desc.vertex_func.entry = "main"; + desc.fragment_func.source = xx *fs_plane_source_glsl300es; + desc.fragment_func.entry = "main"; + desc.attrs[0].base_type = .FLOAT; + desc.attrs[0].glsl_name = "position"; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4; + desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4; + desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "plane_vs_params"; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].glsl_uniforms[0].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[0].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "_28.skyBase"; + desc.uniform_blocks[1].glsl_uniforms[1].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[1].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[1].glsl_name = "_28.skyTop"; + desc.uniform_blocks[1].glsl_uniforms[2].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[2].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[2].glsl_name = "_28.sunDisk"; + desc.uniform_blocks[1].glsl_uniforms[3].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[3].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[3].glsl_name = "_28.horizonHalo"; + desc.uniform_blocks[1].glsl_uniforms[4].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[4].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[4].glsl_name = "_28.sunHalo"; + desc.uniform_blocks[1].glsl_uniforms[5].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[5].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[5].glsl_name = "_28.sunLightColor"; + desc.uniform_blocks[1].glsl_uniforms[6].type = .FLOAT3; + desc.uniform_blocks[1].glsl_uniforms[6].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[6].glsl_name = "_28.sunPosition"; + desc.uniform_blocks[1].glsl_uniforms[7].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[7].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[7].glsl_name = "_28.sunIntensity"; + desc.uniform_blocks[1].glsl_uniforms[8].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[8].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[8].glsl_name = "_28.skyIntensity"; + desc.uniform_blocks[1].glsl_uniforms[9].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[9].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[9].glsl_name = "_28.hasClouds"; + desc.uniform_blocks[1].glsl_uniforms[10].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[10].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[10].glsl_name = "_28.hasPlane"; + desc.uniform_blocks[1].glsl_uniforms[11].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[11].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[11].glsl_name = "_28.planeHeight"; + desc.uniform_blocks[1].glsl_uniforms[12].type = .INT; + desc.uniform_blocks[1].glsl_uniforms[12].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[12].glsl_name = "_28.planeType"; + desc.uniform_blocks[1].glsl_uniforms[13].type = .FLOAT; + desc.uniform_blocks[1].glsl_uniforms[13].array_count = 0; + desc.uniform_blocks[1].glsl_uniforms[13].glsl_name = "_28.time"; + case .METAL_MACOS; + desc.vertex_func.source = xx *vs_plane_source_metal_macos; + desc.vertex_func.entry = "main0"; + desc.fragment_func.source = xx *fs_plane_source_metal_macos; + desc.fragment_func.entry = "main0"; + desc.attrs[0].base_type = .FLOAT; + desc.uniform_blocks[0].stage = .VERTEX; + desc.uniform_blocks[0].layout = .STD140; + desc.uniform_blocks[0].size = 64; + desc.uniform_blocks[0].msl_buffer_n = 0; + desc.uniform_blocks[1].stage = .FRAGMENT; + desc.uniform_blocks[1].layout = .STD140; + desc.uniform_blocks[1].size = 144; + desc.uniform_blocks[1].msl_buffer_n = 0; + } + return desc; +} diff --git a/src/shaders/jai/shader_triangle.jai b/src/shaders/jai/shader_triangle.jai index b4742e0..48e4ae0 100644 --- a/src/shaders/jai/shader_triangle.jai +++ b/src/shaders/jai/shader_triangle.jai @@ -43,6 +43,7 @@ SMP_smp :: 0; void main() { gl_Position = position; + gl_Position.y += (float(gl_InstanceID) * 0.100000001490116119384765625); color = color0; texcoord = uv; } @@ -64,9 +65,14 @@ vs_source_glsl430 := u8.[ 0x65,0x63,0x34,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,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, - 0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63, - 0x6f,0x6c,0x6f,0x72,0x30,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, + 0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69, + 0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x67, + 0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x29,0x20,0x2a,0x20, + 0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31, + 0x36,0x31,0x31,0x39,0x33,0x38,0x34,0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,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 @@ -168,6 +174,7 @@ fs_source_glsl430 := u8.[ void main() { gl_Position = position; + gl_Position.y += (float(gl_InstanceID) * 0.100000001490116119384765625); color = color0; texcoord = uv; } @@ -187,9 +194,14 @@ vs_source_glsl300es := u8.[ 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,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,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, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d, + 0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61, + 0x6e,0x63,0x65,0x49,0x44,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30, + 0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34, + 0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,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 @@ -304,10 +316,11 @@ fs_source_glsl300es := u8.[ float4 uv [[attribute(2)]]; }; - vertex main0_out main0(main0_in in [[stage_in]]) + vertex main0_out main0(main0_in in [[stage_in]], uint gl_InstanceIndex [[instance_id]]) { main0_out out = {}; out.gl_Position = in.position; + out.gl_Position.y += (float(int(gl_InstanceIndex)) * 0.100000001490116119384765625); out.color = in.color0; out.texcoord = in.uv; return out; @@ -338,11 +351,19 @@ vs_source_metal_macos := u8.[ 0x28,0x32,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,0x69,0x6e,0x2e,0x70, - 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, + 0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74, + 0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65, + 0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,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,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74, + 0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2b,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28, + 0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49, + 0x6e,0x64,0x65,0x78,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x31,0x30,0x30,0x30,0x30, + 0x30,0x30,0x30,0x31,0x34,0x39,0x30,0x31,0x31,0x36,0x31,0x31,0x39,0x33,0x38,0x34, + 0x37,0x36,0x35,0x36,0x32,0x35,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74, 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f, 0x72,0x30,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, diff --git a/src/shaders/shader_plane.glsl b/src/shaders/shader_plane.glsl new file mode 100644 index 0000000..8f5d685 --- /dev/null +++ b/src/shaders/shader_plane.glsl @@ -0,0 +1,65 @@ +@vs vs_plane + +in vec4 position; + +layout(binding=0) uniform plane_vs_params { + mat4 mvp; +}; + +out vec4 pos; +out flat int idx; + + +void main() { + vec3 multisize = vec3(position.xyz * 1000.0); + gl_Position = mvp * (vec4(multisize.x, multisize.y + 0.1 + float(gl_InstanceIndex) * 0.005, multisize.z, 1.0)); + pos = position; + idx = gl_InstanceIndex; +} +@end + +@fs fs_plane + +in vec4 pos; +in flat int idx; +out vec4 frag_color; + +float random (vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898,767.233)))* 43758.5453123); +} + +layout(binding=1) uniform plane_world_config { + vec3 skyBase; + vec3 skyTop; + vec3 sunDisk; + vec3 horizonHalo; + vec3 sunHalo; + vec3 sunLightColor; + vec3 sunPosition; + float sunIntensity; + float skyIntensity; + + int hasClouds; + + int hasPlane; + float planeHeight; + int planeType; + + float time; +}; + +void main() { + if(planeType == 1) { + frag_color = vec4(0.0, 0.0, 1.0, 1.0); + } else { + vec2 approxPos = vec2(int(pos.x * 50000.0), int(pos.z * 50000.0)); + float height = random(approxPos); + if(height < float(idx) * 0.1) { + discard; + } + frag_color = vec4(0.0, random(approxPos) + 0.1, 0.0, 1.0); + } +} +@end + +@program plane vs_plane fs_plane diff --git a/src/shaders/shader_triangle.glsl b/src/shaders/shader_triangle.glsl index 9ce101f..9478c73 100644 --- a/src/shaders/shader_triangle.glsl +++ b/src/shaders/shader_triangle.glsl @@ -8,6 +8,7 @@ out vec4 texcoord; void main() { gl_Position = position; + gl_Position.y += float(gl_InstanceIndex) * 0.1; color = color0; texcoord = uv; }