Skip to content

Instantly share code, notes, and snippets.

@pythonesque
Created May 12, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pythonesque/ff444b682c3e5e357dc311aff48f4878 to your computer and use it in GitHub Desktop.
Save pythonesque/ff444b682c3e5e357dc311aff48f4878 to your computer and use it in GitHub Desktop.
Outputs
[INFO] Entry point EntryPoint { name: "main", execution_model: Vertex, work_group_size: WorkGroupSize { x: 0, y: 0, z: 0 } }
[DEBUG] SPIRV-Cross generated shader:
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct u_locals
{
packed_float3 model_offs;
float load_time;
};
struct u_globals
{
float4x4 view_mat;
float4x4 proj_mat;
float4x4 all_mat;
float4 cam_pos;
float4 focus_pos;
float4 view_distance;
float4 time_of_day;
float4 tick;
float4 screen_res;
uint4 light_shadow_count;
uint4 medium;
int4 select_pos;
float4 gamma;
};
struct main0_out
{
float3 f_pos [[user(locn0)]];
uint f_pos_norm [[user(locn1)]];
float3 f_col [[user(locn2)]];
float f_light [[user(locn3)]];
float4 gl_Position [[position]];
};
struct main0_in
{
uint v_pos_norm [[attribute(0)]];
uint v_col_light [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant u_globals& _43 [[buffer(0)]], constant u_locals& _28 [[buffer(3)]])
{
main0_out out = {};
out.f_pos = float3((uint3(in.v_pos_norm) >> uint3(0u, 8u, 16u)) & uint3(255u, 255u, 8191u)) + float3(_28.model_offs);
out.f_pos.z *= fast::min(1.00010001659393310546875 - (0.0199999995529651641845703125 / pow(_43.tick.x - _28.load_time, 10.0)), 1.0);
out.f_pos.z -= (25.0 * pow(distance(_43.focus_pos.xy, out.f_pos.xy) / _43.view_distance.x, 20.0));
out.f_col = float3((uint3(in.v_col_light) >> uint3(8u, 16u, 24u)) & uint3(255u)) / float3(255.0);
out.f_light = float(in.v_col_light & 255u) / 255.0;
out.f_pos_norm = in.v_pos_norm;
out.gl_Position = _43.all_mat * float4(out.f_pos, 1.0);
return out;
}
[INFO] Entry point EntryPoint { name: "main", execution_model: Fragment, work_group_size: WorkGroupSize { x: 0, y: 0, z: 0 } }
[DEBUG] SPIRV-Cross generated shader:
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}
device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}
constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}
threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};
struct u_globals
{
float4x4 view_mat;
float4x4 proj_mat;
float4x4 all_mat;
float4 cam_pos;
float4 focus_pos;
float4 view_distance;
float4 time_of_day;
float4 tick;
float4 screen_res;
uint4 light_shadow_count;
uint4 medium;
int4 select_pos;
float4 gamma;
};
struct Light
{
float4 light_pos;
float4 light_col;
};
struct Light_1
{
float4 light_pos;
float4 light_col;
};
struct u_lights
{
Light_1 lights[32];
};
struct Shadow
{
float4 shadow_pos_radius;
};
struct Shadow_1
{
float4 shadow_pos_radius;
};
struct u_shadows
{
Shadow_1 shadows[24];
};
struct u_locals
{
float3 model_offs;
float load_time;
};
constant spvUnsafeArray<float3, 6> _867 = spvUnsafeArray<float3, 6>({ float3(-1.0, 0.0, 0.0), float3(1.0, 0.0, 0.0), float3(0.0, -1.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, -1.0), float3(0.0, 0.0, 1.0) });
struct main0_out
{
float4 tgt_color [[color(0)]];
};
struct main0_in
{
float3 f_pos [[user(locn0)]];
uint f_pos_norm [[user(locn1)]];
float3 f_col [[user(locn2)]];
float f_light [[user(locn3)]];
};
static inline __attribute__((always_inline))
float3 get_sun_dir(thread const float& time_of_day)
{
float sun_angle_rad = time_of_day * 7.2722039476502686738967895507812e-05;
return float3(sin(sun_angle_rad), 0.0, cos(sun_angle_rad));
}
static inline __attribute__((always_inline))
float3 get_moon_dir(thread const float& time_of_day)
{
float moon_angle_rad = time_of_day * 7.2722039476502686738967895507812e-05;
return normalize(-float3(sin(moon_angle_rad), 0.0, cos(moon_angle_rad) - 0.5));
}
static inline __attribute__((always_inline))
float get_sun_brightness(thread const float3& sun_dir)
{
return fast::max((-sun_dir.z) + 0.60000002384185791015625, 0.0) * 0.89999997615814208984375;
}
static inline __attribute__((always_inline))
float get_moon_brightness(thread const float3& moon_dir)
{
return fast::max((-moon_dir.z) + 0.60000002384185791015625, 0.0) * 0.070000000298023223876953125;
}
static inline __attribute__((always_inline))
float3 get_sun_color(thread const float3& sun_dir)
{
return mix(mix(float3(3.0, 1.5, 0.300000011920928955078125), float3(0.00200000009499490261077880859375, 0.00999999977648258209228515625, 0.02999999932944774627685546875), float3(fast::max(sun_dir.z, 0.0))), float3(1.2000000476837158203125, 1.0, 1.0), float3(fast::max(-sun_dir.z, 0.0)));
}
static inline __attribute__((always_inline))
float3 get_moon_color(thread const float3& moon_dir)
{
return float3(0.0500000007450580596923828125, 0.0500000007450580596923828125, 0.60000002384185791015625);
}
static inline __attribute__((always_inline))
void get_sun_diffuse(thread const float3& norm, thread const float& time_of_day, thread float3& light, thread float3& diffuse_light, thread float3& ambient_light, thread const float& diffusion)
{
float param = time_of_day;
float3 sun_dir = get_sun_dir(param);
float param_1 = time_of_day;
float3 moon_dir = get_moon_dir(param_1);
float3 param_2 = sun_dir;
float sun_light = get_sun_brightness(param_2);
float3 param_3 = moon_dir;
float moon_light = get_moon_brightness(param_3);
float3 param_4 = sun_dir;
float3 sun_color = get_sun_color(param_4);
float3 param_5 = moon_dir;
float3 moon_color = get_moon_color(param_5);
float3 sun_chroma = sun_color * sun_light;
float3 moon_chroma = moon_color * moon_light;
light = (sun_chroma + moon_chroma) + float3(0.100000001490116119384765625);
diffuse_light = ((sun_chroma * mix(1.0, fast::max((dot(-norm, sun_dir) * 0.5) + 0.5, 0.0), diffusion)) + (moon_chroma * mix(1.0, pow(dot(-norm, moon_dir) * 2.0, 2.0), diffusion))) + float3(0.100000001490116119384765625);
ambient_light = float3((0.100000001490116119384765625 * sun_light) + moon_light);
}
static inline __attribute__((always_inline))
float shadow_at(thread const float3& wpos, thread const float3& wnorm, constant u_globals& v_577, constant u_shadows& v_789)
{
float shadow = 1.0;
Shadow S;
for (uint i = 0u; i < v_577.light_shadow_count.y; i++)
{
S.shadow_pos_radius = v_789.shadows[i].shadow_pos_radius;
float3 shadow_pos = S.shadow_pos_radius.xyz;
float radius = S.shadow_pos_radius.w;
float3 diff = shadow_pos - wpos;
if (diff.z >= 0.0)
{
diff.z = ((-sign(diff.z)) * diff.z) * 0.100000001490116119384765625;
}
float shade = fast::max(pow(((diff.x * diff.x) + (diff.y * diff.y)) + (diff.z * diff.z), 0.25) / pow((radius * radius) * 0.5, 0.25), 0.5);
shadow = fast::min(shadow, shade);
}
return fast::min(shadow, 1.0);
}
static inline __attribute__((always_inline))
float attenuation_strength(thread const float3& rpos)
{
return 1.0 / (((rpos.x * rpos.x) + (rpos.y * rpos.y)) + (rpos.z * rpos.z));
}
static inline __attribute__((always_inline))
float3 srgb_to_linear(thread const float3& srgb)
{
bool3 cutoff = srgb < float3(0.040449999272823333740234375);
float3 higher = pow((srgb + float3(0.054999999701976776123046875)) / float3(1.05499994754791259765625), float3(2.400000095367431640625));
float3 lower = srgb / float3(12.9200000762939453125);
return select(higher, lower, cutoff);
}
static inline __attribute__((always_inline))
float3 light_at(thread const float3& wpos, thread const float3& wnorm, constant u_globals& v_577, constant u_lights& v_718)
{
float3 light = float3(0.0);
Light L;
for (uint i = 0u; i < v_577.light_shadow_count.x; i++)
{
L.light_pos = v_718.lights[i].light_pos;
L.light_col = v_718.lights[i].light_col;
float3 light_pos = L.light_pos.xyz;
float3 difference = light_pos - wpos;
float3 param = difference;
float strength = pow(attenuation_strength(param), 0.60000002384185791015625);
float3 param_1 = L.light_col.xyz;
float3 color = srgb_to_linear(param_1) * (strength * L.light_col.w);
light += (color * (fast::max(0.0, fast::max(dot(normalize(difference), wnorm), 0.1500000059604644775390625)) + 0.02500000037252902984619140625));
}
return light;
}
static inline __attribute__((always_inline))
float3 illuminate(thread const float3& color, thread const float3& light, thread const float3& diffuse, thread const float3& ambience)
{
float avg_col = ((color.x + color.y) + color.z) / 3.0;
return (((color - float3(avg_col)) * light) + ((diffuse + ambience) * avg_col)) * (diffuse + ambience);
}
static inline __attribute__((always_inline))
float fog(thread const float3& f_pos, thread const float3& focus_pos, thread const uint& medium, constant u_globals& v_577)
{
float fog_radius = v_577.view_distance.x;
float mist_radius = 10000000.0;
float min_fog = 0.5;
float max_fog = 1.0;
if (medium == 1u)
{
mist_radius = 96.0;
min_fog = 0.0;
}
float fog_1 = distance(f_pos.xy, focus_pos.xy) / fog_radius;
float mist = distance(f_pos, focus_pos) / mist_radius;
return pow(fast::clamp((fast::max(fog_1, mist) - min_fog) / (max_fog - min_fog), 0.0, 1.0), 1.7000000476837158203125);
}
static inline __attribute__((always_inline))
float3 rand_perm_3(thread const float3& pos)
{
return sin(pos * float3((1473.699951171875 * pos.z) + 472.29998779296875, (8891.099609375 * pos.x) + 723.0999755859375, (3813.300048828125 * pos.y) + 982.5));
}
static inline __attribute__((always_inline))
float is_star_at(thread const float3& dir)
{
float star_scale = 80.0;
float3 pos = (floor(dir * star_scale) - float3(0.5)) / float3(star_scale);
float3 param = pos;
pos += (rand_perm_3(param) * (3.0 / star_scale));
float dist = length(normalize(pos) - dir);
if (dist < 0.00150000001303851604461669921875)
{
return 1.0;
}
return 0.0;
}
static inline __attribute__((always_inline))
float4 get_cloud_color(thread const float3& dir, thread const float3& origin, thread const float& time_of_day, thread const float& max_dist, thread const float& quality)
{
return float4(0.0);
}
static inline __attribute__((always_inline))
float3 get_sky_color(thread const float3& dir, thread const float& time_of_day, thread const float3& origin, thread const float3& f_pos, thread const float& quality, thread const bool& with_stars, thread float4& clouds)
{
float param = time_of_day;
float3 sun_dir = get_sun_dir(param);
float param_1 = time_of_day;
float3 moon_dir = get_moon_dir(param_1);
float star = 0.0;
if (with_stars)
{
float3 star_dir = normalize(((sun_dir * dir.z) + (cross(sun_dir, float3(0.0, 1.0, 0.0)) * dir.x)) + (float3(0.0, 1.0, 0.0) * dir.y));
float3 param_2 = star_dir;
star = is_star_at(param_2);
}
float3 sun_halo_color = mix(float3(1.2000000476837158203125, 0.1500000059604644775390625, 0.0), float3(0.3499999940395355224609375, 0.3499999940395355224609375, 0.0), float3(fast::max(-sun_dir.z, 0.0)));
float3 sun_halo = sun_halo_color * pow(fast::max(dot(dir, -sun_dir) + 0.100000001490116119384765625, 0.0), 8.0);
float3 sun_surf = float3(300.0, 180.0, 70.0) * pow(fast::max(dot(dir, -sun_dir) - 0.001000000047497451305389404296875, 0.0), 3000.0);
float3 sun_light = (sun_halo + sun_surf) * fast::clamp(dir.z * 10.0, 0.0, 1.0);
float3 moon_halo = float3(0.014999999664723873138427734375, 0.014999999664723873138427734375, 0.0500000007450580596923828125) * pow(fast::max(dot(dir, -moon_dir) + 0.100000001490116119384765625, 0.0), 8.0);
float3 moon_surf = float3(350.0, 500.0, 750.0) * pow(fast::max(dot(dir, -moon_dir) - 0.001000000047497451305389404296875, 0.0), 3000.0);
float3 moon_light = fast::clamp(moon_halo + moon_surf, float3(0.0), float3(fast::max(dir.z * 3.0, 0.0)));
float3 sky_top = mix(mix(float3(0.0599999986588954925537109375, 0.100000001490116119384765625, 0.20000000298023223876953125) + (float3(star) / (float3(1.0) + (moon_surf * 100.0))), float3(0.001000000047497451305389404296875, 0.001000000047497451305389404296875, 0.0024999999441206455230712890625) + (float3(star) / (float3(1.0) + (moon_surf * 100.0))), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.100000001490116119384765625, 0.20000000298023223876953125, 0.89999997615814208984375), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_mid = mix(mix(float3(0.3499999940395355224609375, 0.100000001490116119384765625, 0.1500000059604644775390625), float3(0.001000000047497451305389404296875, 0.004999999888241291046142578125, 0.0199999995529651641845703125), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.0199999995529651641845703125, 0.07999999821186065673828125, 0.800000011920928955078125), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_bot = mix(mix(float3(0.0, 0.100000001490116119384765625, 0.23000000417232513427734375), float3(0.00200000009499490261077880859375, 0.0040000001899898052215576171875, 0.0040000001899898052215576171875), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.100000001490116119384765625, 0.20000000298023223876953125, 0.300000011920928955078125), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_color = mix(mix(sky_mid, sky_bot, float3(pow(fast::max(-dir.z, 0.0), 0.4000000059604644775390625))), sky_top, float3(fast::max(dir.z, 0.0)));
float f_dist = distance(origin, f_pos);
float3 param_3 = dir;
float3 param_4 = origin;
float param_5 = time_of_day;
float param_6 = f_dist;
float param_7 = quality;
clouds = get_cloud_color(param_3, param_4, param_5, param_6, param_7);
float3 param_8 = sun_dir;
float3 param_9 = sun_dir;
float3 param_10 = moon_dir;
float3 param_11 = moon_dir;
float3 _547 = clouds.xyz * ((((sun_halo * 1.5) + get_sun_color(param_9)) * get_sun_brightness(param_8)) + (((moon_halo * 80.0) + get_moon_color(param_11)) * get_moon_brightness(param_10)));
clouds = float4(_547.x, _547.y, _547.z, clouds.w);
if (f_dist > 5000.0)
{
sky_color += (sun_light + moon_light);
}
return mix(sky_color, clouds.xyz, float3(clouds.w));
}
fragment main0_out main0(main0_in in [[stage_in]], constant u_globals& v_577 [[buffer(0)]], constant u_lights& v_718 [[buffer(1)]], constant u_shadows& v_789 [[buffer(2)]])
{
main0_out out = {};
float3 f_norm = _867[(in.f_pos_norm >> uint(29)) & 7u];
float3 param = f_norm;
float param_1 = v_577.time_of_day.x;
float param_5 = 1.0;
float3 param_2;
float3 param_3;
float3 param_4;
get_sun_diffuse(param, param_1, param_2, param_3, param_4, param_5);
float3 light = param_2;
float3 diffuse_light = param_3;
float3 ambient_light = param_4;
float3 param_6 = in.f_pos;
float3 param_7 = f_norm;
float point_shadow = shadow_at(param_6, param_7, v_577, v_789);
diffuse_light *= (in.f_light * point_shadow);
ambient_light *= (in.f_light * point_shadow);
float3 param_8 = in.f_pos;
float3 param_9 = f_norm;
float3 point_light = light_at(param_8, param_9, v_577, v_718);
light += point_light;
diffuse_light += point_light;
float3 param_10 = in.f_col;
float3 param_11 = srgb_to_linear(param_10);
float3 param_12 = light;
float3 param_13 = diffuse_light;
float3 param_14 = ambient_light;
float3 surf_color = illuminate(param_11, param_12, param_13, param_14);
float3 param_15 = in.f_pos;
float3 param_16 = v_577.focus_pos.xyz;
uint param_17 = v_577.medium.x;
float fog_level = fog(param_15, param_16, param_17, v_577);
float3 param_18 = normalize(in.f_pos - v_577.cam_pos.xyz);
float param_19 = v_577.time_of_day.x;
float3 param_20 = v_577.cam_pos.xyz;
float3 param_21 = in.f_pos;
float param_22 = 1.0;
bool param_23 = true;
float4 param_24;
float3 _977 = get_sky_color(param_18, param_19, param_20, param_21, param_22, param_23, param_24);
float4 clouds = param_24;
float3 fog_color = _977;
float3 color = mix(mix(surf_color, fog_color, float3(fog_level)), clouds.xyz, float3(clouds.w));
out.tgt_color = float4(color, 1.0);
return out;
}
[DEBUG] create_graphics_pipeline GraphicsPipelineDesc {
shaders: GraphicsShaderSet {
vertex: EntryPoint {
entry: "main",
module: ShaderModule::Raw(length = 1036),
specialization: Specialization {
constants: [],
data: [],
},
},
hull: None,
domain: None,
geometry: None,
fragment: Some(
EntryPoint {
entry: "main",
module: ShaderModule::Raw(length = 6587),
specialization: Specialization {
constants: [],
data: [],
},
},
),
},
rasterizer: Rasterizer {
polygon_mode: Fill,
cull_face: NONE,
front_face: CounterClockwise,
depth_clamping: false,
depth_bias: None,
conservative: false,
line_width: Static(
1.0,
),
},
vertex_buffers: [
VertexBufferDesc {
binding: 0,
stride: 8,
rate: Vertex,
},
],
attributes: [
AttributeDesc {
location: 0,
binding: 0,
element: Element {
format: R32Uint,
offset: 0,
},
},
AttributeDesc {
location: 1,
binding: 0,
element: Element {
format: R32Uint,
offset: 4,
},
},
],
input_assembler: InputAssemblerDesc {
primitive: TriangleList,
with_adjacency: false,
restart_index: None,
},
blender: BlendDesc {
logic_op: None,
targets: [
ColorBlendDesc {
mask: RED | GREEN | BLUE | ALPHA | COLOR | ALL,
blend: Some(
BlendState {
color: Add {
src: SrcAlpha,
dst: OneMinusSrcAlpha,
},
alpha: Add {
src: One,
dst: One,
},
},
),
},
],
},
depth_stencil: DepthStencilDesc {
depth: Some(
DepthTest {
fun: LessEqual,
write: false,
},
),
depth_bounds: false,
stencil: None,
},
multisampling: None,
baked_states: BakedStates {
viewport: None,
scissor: None,
blend_color: None,
depth_bounds: None,
},
layout: PipelineLayout {
shader_compiler_options: CompilerOptions {
platform: macOS,
version: V2_0,
vertex: CompilerVertexOptions {
invert_y: false,
transform_clip_space: false,
},
swizzle_buffer_index: 30,
indirect_params_buffer_index: 29,
output_buffer_index: 28,
patch_output_buffer_index: 27,
tessellation_factor_buffer_index: 26,
buffer_size_buffer_index: 25,
enable_point_size_builtin: false,
enable_rasterization: true,
capture_output_to_buffer: false,
swizzle_texture_samples: false,
tessellation_domain_origin_lower_left: false,
enable_argument_buffers: false,
pad_fragment_output_components: false,
resource_binding_overrides: {
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
},
vertex_attribute_overrides: {},
const_samplers: {},
},
shader_compiler_options_point: CompilerOptions {
platform: macOS,
version: V2_0,
vertex: CompilerVertexOptions {
invert_y: false,
transform_clip_space: false,
},
swizzle_buffer_index: 30,
indirect_params_buffer_index: 29,
output_buffer_index: 28,
patch_output_buffer_index: 27,
tessellation_factor_buffer_index: 26,
buffer_size_buffer_index: 25,
enable_point_size_builtin: true,
enable_rasterization: true,
capture_output_to_buffer: false,
swizzle_texture_samples: false,
tessellation_domain_origin_lower_left: false,
enable_argument_buffers: false,
pad_fragment_output_components: false,
resource_binding_overrides: {
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
},
vertex_attribute_overrides: {},
const_samplers: {},
},
infos: [
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
ps: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 1,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 1,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 2,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 2,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 3,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 3,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 4,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 4,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
],
total: MultiStageData {
vs: ResourceData {
buffers: 4,
textures: 2,
samplers: 2,
},
ps: ResourceData {
buffers: 4,
textures: 2,
samplers: 2,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
push_constants: MultiStageData {
vs: None,
ps: None,
cs: None,
},
total_push_constants: 0,
},
subpass: Subpass {
index: 0,
main_pass: RenderPass {
attachments: [
Attachment {
format: Some(
Bgra8Srgb,
),
samples: 1,
ops: AttachmentOps {
load: Load,
store: Store,
},
stencil_ops: AttachmentOps {
load: DontCare,
store: DontCare,
},
layouts: General..General,
},
Attachment {
format: Some(
D32SfloatS8Uint,
),
samples: 1,
ops: AttachmentOps {
load: Load,
store: Store,
},
stencil_ops: AttachmentOps {
load: Load,
store: Store,
},
layouts: General..General,
},
],
subpasses: [
Subpass {
colors: [
(
0,
STORE,
None,
),
],
depth_stencil: Some(
(
1,
STORE,
),
),
inputs: [],
target_formats: SubpassFormats {
colors: [
(
BGRA8Unorm_sRGB,
Float,
),
],
depth_stencil: Some(
Depth32Float_Stencil8,
),
},
},
],
name: "",
},
},
flags: (empty),
parent: None,
}
[INFO] Entry point EntryPoint { name: "main", execution_model: Vertex, work_group_size: WorkGroupSize { x: 0, y: 0, z: 0 } }
[DEBUG] SPIRV-Cross generated shader:
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct u_locals
{
packed_float3 model_offs;
float load_time;
};
struct u_globals
{
float4x4 view_mat;
float4x4 proj_mat;
float4x4 all_mat;
float4 cam_pos;
float4 focus_pos;
float4 view_distance;
float4 time_of_day;
float4 tick;
float4 screen_res;
uint4 light_shadow_count;
uint4 medium;
int4 select_pos;
float4 gamma;
};
struct main0_out
{
float3 f_pos [[user(locn0)]];
uint f_pos_norm [[user(locn1)]];
float3 f_col [[user(locn2)]];
float f_light [[user(locn3)]];
float4 gl_Position [[position]];
};
struct main0_in
{
uint v_pos_norm [[attribute(0)]];
uint v_col_light [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant u_globals& _43 [[buffer(0)]], constant u_locals& _28 [[buffer(3)]])
{
main0_out out = {};
out.f_pos = float3((uint3(in.v_pos_norm) >> uint3(0u, 8u, 16u)) & uint3(255u, 255u, 8191u)) + float3(_28.model_offs);
out.f_pos.z *= fast::min(1.00010001659393310546875 - (0.0199999995529651641845703125 / pow(_43.tick.x - _28.load_time, 10.0)), 1.0);
out.f_pos.z -= (25.0 * pow(distance(_43.focus_pos.xy, out.f_pos.xy) / _43.view_distance.x, 20.0));
out.f_col = float3((uint3(in.v_col_light) >> uint3(8u, 16u, 24u)) & uint3(255u)) / float3(255.0);
out.f_light = float(in.v_col_light & 255u) / 255.0;
out.f_pos_norm = in.v_pos_norm;
out.gl_Position = _43.all_mat * float4(out.f_pos, 1.0);
return out;
}
[INFO] Entry point EntryPoint { name: "main", execution_model: Fragment, work_group_size: WorkGroupSize { x: 0, y: 0, z: 0 } }
[DEBUG] SPIRV-Cross generated shader:
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}
device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}
constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}
threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};
struct u_globals
{
float4x4 view_mat;
float4x4 proj_mat;
float4x4 all_mat;
float4 cam_pos;
float4 focus_pos;
float4 view_distance;
float4 time_of_day;
float4 tick;
float4 screen_res;
uint4 light_shadow_count;
uint4 medium;
int4 select_pos;
float4 gamma;
};
struct Light
{
float4 light_pos;
float4 light_col;
};
struct Light_1
{
float4 light_pos;
float4 light_col;
};
struct u_lights
{
Light_1 lights[32];
};
struct Shadow
{
float4 shadow_pos_radius;
};
struct Shadow_1
{
float4 shadow_pos_radius;
};
struct u_shadows
{
Shadow_1 shadows[24];
};
struct u_locals
{
float3 model_offs;
float load_time;
};
constant spvUnsafeArray<float3, 6> _867 = spvUnsafeArray<float3, 6>({ float3(-1.0, 0.0, 0.0), float3(1.0, 0.0, 0.0), float3(0.0, -1.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, -1.0), float3(0.0, 0.0, 1.0) });
struct main0_out
{
float4 tgt_color [[color(0)]];
};
struct main0_in
{
float3 f_pos [[user(locn0)]];
uint f_pos_norm [[user(locn1)]];
float3 f_col [[user(locn2)]];
float f_light [[user(locn3)]];
};
static inline __attribute__((always_inline))
float3 get_sun_dir(thread const float& time_of_day)
{
float sun_angle_rad = time_of_day * 7.2722039476502686738967895507812e-05;
return float3(sin(sun_angle_rad), 0.0, cos(sun_angle_rad));
}
static inline __attribute__((always_inline))
float3 get_moon_dir(thread const float& time_of_day)
{
float moon_angle_rad = time_of_day * 7.2722039476502686738967895507812e-05;
return normalize(-float3(sin(moon_angle_rad), 0.0, cos(moon_angle_rad) - 0.5));
}
static inline __attribute__((always_inline))
float get_sun_brightness(thread const float3& sun_dir)
{
return fast::max((-sun_dir.z) + 0.60000002384185791015625, 0.0) * 0.89999997615814208984375;
}
static inline __attribute__((always_inline))
float get_moon_brightness(thread const float3& moon_dir)
{
return fast::max((-moon_dir.z) + 0.60000002384185791015625, 0.0) * 0.070000000298023223876953125;
}
static inline __attribute__((always_inline))
float3 get_sun_color(thread const float3& sun_dir)
{
return mix(mix(float3(3.0, 1.5, 0.300000011920928955078125), float3(0.00200000009499490261077880859375, 0.00999999977648258209228515625, 0.02999999932944774627685546875), float3(fast::max(sun_dir.z, 0.0))), float3(1.2000000476837158203125, 1.0, 1.0), float3(fast::max(-sun_dir.z, 0.0)));
}
static inline __attribute__((always_inline))
float3 get_moon_color(thread const float3& moon_dir)
{
return float3(0.0500000007450580596923828125, 0.0500000007450580596923828125, 0.60000002384185791015625);
}
static inline __attribute__((always_inline))
void get_sun_diffuse(thread const float3& norm, thread const float& time_of_day, thread float3& light, thread float3& diffuse_light, thread float3& ambient_light, thread const float& diffusion)
{
float param = time_of_day;
float3 sun_dir = get_sun_dir(param);
float param_1 = time_of_day;
float3 moon_dir = get_moon_dir(param_1);
float3 param_2 = sun_dir;
float sun_light = get_sun_brightness(param_2);
float3 param_3 = moon_dir;
float moon_light = get_moon_brightness(param_3);
float3 param_4 = sun_dir;
float3 sun_color = get_sun_color(param_4);
float3 param_5 = moon_dir;
float3 moon_color = get_moon_color(param_5);
float3 sun_chroma = sun_color * sun_light;
float3 moon_chroma = moon_color * moon_light;
light = (sun_chroma + moon_chroma) + float3(0.100000001490116119384765625);
diffuse_light = ((sun_chroma * mix(1.0, fast::max((dot(-norm, sun_dir) * 0.5) + 0.5, 0.0), diffusion)) + (moon_chroma * mix(1.0, pow(dot(-norm, moon_dir) * 2.0, 2.0), diffusion))) + float3(0.100000001490116119384765625);
ambient_light = float3((0.100000001490116119384765625 * sun_light) + moon_light);
}
static inline __attribute__((always_inline))
float shadow_at(thread const float3& wpos, thread const float3& wnorm, constant u_globals& v_577, constant u_shadows& v_789)
{
float shadow = 1.0;
Shadow S;
for (uint i = 0u; i < v_577.light_shadow_count.y; i++)
{
S.shadow_pos_radius = v_789.shadows[i].shadow_pos_radius;
float3 shadow_pos = S.shadow_pos_radius.xyz;
float radius = S.shadow_pos_radius.w;
float3 diff = shadow_pos - wpos;
if (diff.z >= 0.0)
{
diff.z = ((-sign(diff.z)) * diff.z) * 0.100000001490116119384765625;
}
float shade = fast::max(pow(((diff.x * diff.x) + (diff.y * diff.y)) + (diff.z * diff.z), 0.25) / pow((radius * radius) * 0.5, 0.25), 0.5);
shadow = fast::min(shadow, shade);
}
return fast::min(shadow, 1.0);
}
static inline __attribute__((always_inline))
float attenuation_strength(thread const float3& rpos)
{
return 1.0 / (((rpos.x * rpos.x) + (rpos.y * rpos.y)) + (rpos.z * rpos.z));
}
static inline __attribute__((always_inline))
float3 srgb_to_linear(thread const float3& srgb)
{
bool3 cutoff = srgb < float3(0.040449999272823333740234375);
float3 higher = pow((srgb + float3(0.054999999701976776123046875)) / float3(1.05499994754791259765625), float3(2.400000095367431640625));
float3 lower = srgb / float3(12.9200000762939453125);
return select(higher, lower, cutoff);
}
static inline __attribute__((always_inline))
float3 light_at(thread const float3& wpos, thread const float3& wnorm, constant u_globals& v_577, constant u_lights& v_718)
{
float3 light = float3(0.0);
Light L;
for (uint i = 0u; i < v_577.light_shadow_count.x; i++)
{
L.light_pos = v_718.lights[i].light_pos;
L.light_col = v_718.lights[i].light_col;
float3 light_pos = L.light_pos.xyz;
float3 difference = light_pos - wpos;
float3 param = difference;
float strength = pow(attenuation_strength(param), 0.60000002384185791015625);
float3 param_1 = L.light_col.xyz;
float3 color = srgb_to_linear(param_1) * (strength * L.light_col.w);
light += (color * (fast::max(0.0, fast::max(dot(normalize(difference), wnorm), 0.1500000059604644775390625)) + 0.02500000037252902984619140625));
}
return light;
}
static inline __attribute__((always_inline))
float3 illuminate(thread const float3& color, thread const float3& light, thread const float3& diffuse, thread const float3& ambience)
{
float avg_col = ((color.x + color.y) + color.z) / 3.0;
return (((color - float3(avg_col)) * light) + ((diffuse + ambience) * avg_col)) * (diffuse + ambience);
}
static inline __attribute__((always_inline))
float fog(thread const float3& f_pos, thread const float3& focus_pos, thread const uint& medium, constant u_globals& v_577)
{
float fog_radius = v_577.view_distance.x;
float mist_radius = 10000000.0;
float min_fog = 0.5;
float max_fog = 1.0;
if (medium == 1u)
{
mist_radius = 96.0;
min_fog = 0.0;
}
float fog_1 = distance(f_pos.xy, focus_pos.xy) / fog_radius;
float mist = distance(f_pos, focus_pos) / mist_radius;
return pow(fast::clamp((fast::max(fog_1, mist) - min_fog) / (max_fog - min_fog), 0.0, 1.0), 1.7000000476837158203125);
}
static inline __attribute__((always_inline))
float3 rand_perm_3(thread const float3& pos)
{
return sin(pos * float3((1473.699951171875 * pos.z) + 472.29998779296875, (8891.099609375 * pos.x) + 723.0999755859375, (3813.300048828125 * pos.y) + 982.5));
}
static inline __attribute__((always_inline))
float is_star_at(thread const float3& dir)
{
float star_scale = 80.0;
float3 pos = (floor(dir * star_scale) - float3(0.5)) / float3(star_scale);
float3 param = pos;
pos += (rand_perm_3(param) * (3.0 / star_scale));
float dist = length(normalize(pos) - dir);
if (dist < 0.00150000001303851604461669921875)
{
return 1.0;
}
return 0.0;
}
static inline __attribute__((always_inline))
float4 get_cloud_color(thread const float3& dir, thread const float3& origin, thread const float& time_of_day, thread const float& max_dist, thread const float& quality)
{
return float4(0.0);
}
static inline __attribute__((always_inline))
float3 get_sky_color(thread const float3& dir, thread const float& time_of_day, thread const float3& origin, thread const float3& f_pos, thread const float& quality, thread const bool& with_stars, thread float4& clouds)
{
float param = time_of_day;
float3 sun_dir = get_sun_dir(param);
float param_1 = time_of_day;
float3 moon_dir = get_moon_dir(param_1);
float star = 0.0;
if (with_stars)
{
float3 star_dir = normalize(((sun_dir * dir.z) + (cross(sun_dir, float3(0.0, 1.0, 0.0)) * dir.x)) + (float3(0.0, 1.0, 0.0) * dir.y));
float3 param_2 = star_dir;
star = is_star_at(param_2);
}
float3 sun_halo_color = mix(float3(1.2000000476837158203125, 0.1500000059604644775390625, 0.0), float3(0.3499999940395355224609375, 0.3499999940395355224609375, 0.0), float3(fast::max(-sun_dir.z, 0.0)));
float3 sun_halo = sun_halo_color * pow(fast::max(dot(dir, -sun_dir) + 0.100000001490116119384765625, 0.0), 8.0);
float3 sun_surf = float3(300.0, 180.0, 70.0) * pow(fast::max(dot(dir, -sun_dir) - 0.001000000047497451305389404296875, 0.0), 3000.0);
float3 sun_light = (sun_halo + sun_surf) * fast::clamp(dir.z * 10.0, 0.0, 1.0);
float3 moon_halo = float3(0.014999999664723873138427734375, 0.014999999664723873138427734375, 0.0500000007450580596923828125) * pow(fast::max(dot(dir, -moon_dir) + 0.100000001490116119384765625, 0.0), 8.0);
float3 moon_surf = float3(350.0, 500.0, 750.0) * pow(fast::max(dot(dir, -moon_dir) - 0.001000000047497451305389404296875, 0.0), 3000.0);
float3 moon_light = fast::clamp(moon_halo + moon_surf, float3(0.0), float3(fast::max(dir.z * 3.0, 0.0)));
float3 sky_top = mix(mix(float3(0.0599999986588954925537109375, 0.100000001490116119384765625, 0.20000000298023223876953125) + (float3(star) / (float3(1.0) + (moon_surf * 100.0))), float3(0.001000000047497451305389404296875, 0.001000000047497451305389404296875, 0.0024999999441206455230712890625) + (float3(star) / (float3(1.0) + (moon_surf * 100.0))), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.100000001490116119384765625, 0.20000000298023223876953125, 0.89999997615814208984375), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_mid = mix(mix(float3(0.3499999940395355224609375, 0.100000001490116119384765625, 0.1500000059604644775390625), float3(0.001000000047497451305389404296875, 0.004999999888241291046142578125, 0.0199999995529651641845703125), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.0199999995529651641845703125, 0.07999999821186065673828125, 0.800000011920928955078125), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_bot = mix(mix(float3(0.0, 0.100000001490116119384765625, 0.23000000417232513427734375), float3(0.00200000009499490261077880859375, 0.0040000001899898052215576171875, 0.0040000001899898052215576171875), float3(fast::max(pow(sun_dir.z, 0.20000000298023223876953125), 0.0))), float3(0.100000001490116119384765625, 0.20000000298023223876953125, 0.300000011920928955078125), float3(fast::max(-sun_dir.z, 0.0)));
float3 sky_color = mix(mix(sky_mid, sky_bot, float3(pow(fast::max(-dir.z, 0.0), 0.4000000059604644775390625))), sky_top, float3(fast::max(dir.z, 0.0)));
float f_dist = distance(origin, f_pos);
float3 param_3 = dir;
float3 param_4 = origin;
float param_5 = time_of_day;
float param_6 = f_dist;
float param_7 = quality;
clouds = get_cloud_color(param_3, param_4, param_5, param_6, param_7);
float3 param_8 = sun_dir;
float3 param_9 = sun_dir;
float3 param_10 = moon_dir;
float3 param_11 = moon_dir;
float3 _547 = clouds.xyz * ((((sun_halo * 1.5) + get_sun_color(param_9)) * get_sun_brightness(param_8)) + (((moon_halo * 80.0) + get_moon_color(param_11)) * get_moon_brightness(param_10)));
clouds = float4(_547.x, _547.y, _547.z, clouds.w);
if (f_dist > 5000.0)
{
sky_color += (sun_light + moon_light);
}
return mix(sky_color, clouds.xyz, float3(clouds.w));
}
fragment main0_out main0(main0_in in [[stage_in]], constant u_globals& v_577 [[buffer(0)]], constant u_lights& v_718 [[buffer(1)]], constant u_shadows& v_789 [[buffer(2)]])
{
main0_out out = {};
uint norm_axis = (in.f_pos_norm >> uint(30)) & 3u;
float3 f_norm = _867[(in.f_pos_norm >> uint(29)) & 7u];
float3 param = f_norm;
float param_1 = v_577.time_of_day.x;
float param_5 = 1.0;
float3 param_2;
float3 param_3;
float3 param_4;
get_sun_diffuse(param, param_1, param_2, param_3, param_4, param_5);
float3 light = param_2;
float3 diffuse_light = param_3;
float3 ambient_light = param_4;
float3 param_6 = in.f_pos;
float3 param_7 = f_norm;
float point_shadow = shadow_at(param_6, param_7, v_577, v_789);
diffuse_light *= (in.f_light * point_shadow);
ambient_light *= (in.f_light * point_shadow);
float3 param_8 = in.f_pos;
float3 param_9 = f_norm;
float3 point_light = light_at(param_8, param_9, v_577, v_718);
light += point_light;
diffuse_light += point_light;
float3 param_10 = in.f_col;
float3 param_11 = srgb_to_linear(param_10);
float3 param_12 = light;
float3 param_13 = diffuse_light;
float3 param_14 = ambient_light;
float3 surf_color = illuminate(param_11, param_12, param_13, param_14);
float3 param_15 = in.f_pos;
float3 param_16 = v_577.focus_pos.xyz;
uint param_17 = v_577.medium.x;
float fog_level = fog(param_15, param_16, param_17, v_577);
float3 param_18 = normalize(in.f_pos - v_577.cam_pos.xyz);
float param_19 = v_577.time_of_day.x;
float3 param_20 = v_577.cam_pos.xyz;
float3 param_21 = in.f_pos;
float param_22 = 1.0;
bool param_23 = true;
float4 param_24;
float3 _982 = get_sky_color(param_18, param_19, param_20, param_21, param_22, param_23, param_24);
float4 clouds = param_24;
float3 fog_color = _982;
float3 color = mix(mix(surf_color, fog_color, float3(fog_level)), clouds.xyz, float3(clouds.w));
out.tgt_color = float4(color, 1.0);
return out;
}
[WARN] Shader warnings: Compilation succeeded with:
program_source:332:10: warning: unused variable 'norm_axis'
uint norm_axis = (in.f_pos_norm >> uint(30)) & 3u;
^
[DEBUG] create_graphics_pipeline GraphicsPipelineDesc {
shaders: GraphicsShaderSet {
vertex: EntryPoint {
entry: "main",
module: ShaderModule::Raw(length = 1036),
specialization: Specialization {
constants: [],
data: [],
},
},
hull: None,
domain: None,
geometry: None,
fragment: Some(
EntryPoint {
entry: "main",
module: ShaderModule::Raw(length = 6587),
specialization: Specialization {
constants: [],
data: [],
},
},
),
},
rasterizer: Rasterizer {
polygon_mode: Fill,
cull_face: NONE,
front_face: CounterClockwise,
depth_clamping: false,
depth_bias: None,
conservative: false,
line_width: Static(
1.0,
),
},
vertex_buffers: [
VertexBufferDesc {
binding: 0,
stride: 8,
rate: Vertex,
},
],
attributes: [
AttributeDesc {
location: 0,
binding: 0,
element: Element {
format: R32Uint,
offset: 0,
},
},
AttributeDesc {
location: 1,
binding: 0,
element: Element {
format: R32Uint,
offset: 4,
},
},
],
input_assembler: InputAssemblerDesc {
primitive: TriangleList,
with_adjacency: false,
restart_index: None,
},
blender: BlendDesc {
logic_op: None,
targets: [
ColorBlendDesc {
mask: RED | GREEN | BLUE | ALPHA | COLOR | ALL,
blend: Some(
BlendState {
color: Add {
src: SrcAlpha,
dst: OneMinusSrcAlpha,
},
alpha: Add {
src: One,
dst: One,
},
},
),
},
],
},
depth_stencil: DepthStencilDesc {
depth: Some(
DepthTest {
fun: LessEqual,
write: false,
},
),
depth_bounds: false,
stencil: None,
},
multisampling: None,
baked_states: BakedStates {
viewport: None,
scissor: None,
blend_color: None,
depth_bounds: None,
},
layout: PipelineLayout {
shader_compiler_options: CompilerOptions {
platform: macOS,
version: V2_0,
vertex: CompilerVertexOptions {
invert_y: false,
transform_clip_space: false,
},
swizzle_buffer_index: 30,
indirect_params_buffer_index: 29,
output_buffer_index: 28,
patch_output_buffer_index: 27,
tessellation_factor_buffer_index: 26,
buffer_size_buffer_index: 25,
enable_point_size_builtin: false,
enable_rasterization: true,
capture_output_to_buffer: false,
swizzle_texture_samples: false,
tessellation_domain_origin_lower_left: false,
enable_argument_buffers: false,
pad_fragment_output_components: false,
resource_binding_overrides: {
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
},
vertex_attribute_overrides: {},
const_samplers: {},
},
shader_compiler_options_point: CompilerOptions {
platform: macOS,
version: V2_0,
vertex: CompilerVertexOptions {
invert_y: false,
transform_clip_space: false,
},
swizzle_buffer_index: 30,
indirect_params_buffer_index: 29,
output_buffer_index: 28,
patch_output_buffer_index: 27,
tessellation_factor_buffer_index: 26,
buffer_size_buffer_index: 25,
enable_point_size_builtin: true,
enable_rasterization: true,
capture_output_to_buffer: false,
swizzle_texture_samples: false,
tessellation_domain_origin_lower_left: false,
enable_argument_buffers: false,
pad_fragment_output_components: false,
resource_binding_overrides: {
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Vertex,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 0,
}: ResourceBinding {
buffer_id: 0,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 0,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 0,
binding: 2,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 0,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 1,
binding: 0,
}: ResourceBinding {
buffer_id: 1,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 2,
binding: 0,
}: ResourceBinding {
buffer_id: 2,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 3,
binding: 0,
}: ResourceBinding {
buffer_id: 3,
texture_id: 4294967295,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 0,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 1,
sampler_id: 4294967295,
},
ResourceBindingLocation {
stage: Fragment,
desc_set: 4,
binding: 1,
}: ResourceBinding {
buffer_id: 4294967295,
texture_id: 4294967295,
sampler_id: 1,
},
},
vertex_attribute_overrides: {},
const_samplers: {},
},
infos: [
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
ps: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 1,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 1,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 2,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 2,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 3,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 3,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
DescriptorSetInfo {
offsets: MultiStageData {
vs: ResourceData {
buffers: 4,
textures: 1,
samplers: 1,
},
ps: ResourceData {
buffers: 4,
textures: 1,
samplers: 1,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
dynamic_buffers: [],
},
],
total: MultiStageData {
vs: ResourceData {
buffers: 4,
textures: 2,
samplers: 2,
},
ps: ResourceData {
buffers: 4,
textures: 2,
samplers: 2,
},
cs: ResourceData {
buffers: 0,
textures: 0,
samplers: 0,
},
},
push_constants: MultiStageData {
vs: None,
ps: None,
cs: None,
},
total_push_constants: 0,
},
subpass: Subpass {
index: 0,
main_pass: RenderPass {
attachments: [
Attachment {
format: Some(
Bgra8Srgb,
),
samples: 1,
ops: AttachmentOps {
load: Load,
store: Store,
},
stencil_ops: AttachmentOps {
load: DontCare,
store: DontCare,
},
layouts: General..General,
},
Attachment {
format: Some(
D32SfloatS8Uint,
),
samples: 1,
ops: AttachmentOps {
load: Load,
store: Store,
},
stencil_ops: AttachmentOps {
load: Load,
store: Store,
},
layouts: General..General,
},
],
subpasses: [
Subpass {
colors: [
(
0,
STORE,
None,
),
],
depth_stencil: Some(
(
1,
STORE,
),
),
inputs: [],
target_formats: SubpassFormats {
colors: [
(
BGRA8Unorm_sRGB,
Float,
),
],
depth_stencil: Some(
Depth32Float_Stencil8,
),
},
},
],
name: "",
},
},
flags: (empty),
parent: None,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment