pub const GPU_DEVICE_FALLBACK: &str = "euv-software-fallback";
pub const GPU_DEVICE_WEB: &str = "Browser WebGL2 / WebGPU";
pub const GPU_DEVICE_D3D12: &str = "Windows Direct3D 12";
pub const GPU_DEVICE_VULKAN: &str = "Vulkan Physical GPU";
pub const GPU_DRIVER_RING_SLOTS: usize = 3;
pub const MOBILE_MAX_MULTI_UPLOAD_RECTS: usize = 12;
pub const MOBILE_UPLOAD_PER_RECT_OVERHEAD_BYTES: usize = 16_384;
pub const MOBILE_UPLOAD_FULL_FRAME_COVERAGE_THRESHOLD: f32 = 0.70;
pub const MOBILE_UPLOAD_COALESCE_PAD_PX: u32 = 4;
pub const GLSL_ES3_BACKDROP_BLUR_VERTEX_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
out highp vec2 v_uv;\n\
void main() {\n\
vec2 p = vec2((gl_VertexID == 1) ? 3.0 : -1.0, (gl_VertexID == 2) ? 3.0 : -1.0);\n\
gl_Position = vec4(p, 0.0, 1.0);\n\
v_uv = vec2(p.x * 0.5 + 0.5, p.y * 0.5 + 0.5);\n\
}\n";
pub const MOBILE_TIMING_UNOBSERVABLE_REASON_SIMULATOR: &str = "simulator_compositor_unobservable";
pub const MOBILE_TIMING_UNOBSERVABLE_REASON_UNSUPPORTED: &str = "presentation_time_unsupported";
pub const WEB_GL2_BLIT_VERT_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
void main() {\n\
vec2 pos = vec2((gl_VertexID == 1) ? 3.0 : -1.0, (gl_VertexID == 2) ? 3.0 : -1.0);\n\
gl_Position = vec4(pos, 0.0, 1.0);\n\
}\n";
pub const WEB_GL2_BLIT_FRAG_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
precision highp sampler2D;\n\
uniform highp sampler2D u_tex;\n\
uniform highp vec2 u_view;\n\
out highp vec4 out_color;\n\
void main() {\n\
ivec2 tex_size = textureSize(u_tex, 0);\n\
highp vec2 view = max(u_view, vec2(1.0));\n\
ivec2 view_size = ivec2(view + vec2(0.5));\n\
if (tex_size == view_size) {\n\
ivec2 texel = ivec2(int(gl_FragCoord.x), tex_size.y - 1 - int(gl_FragCoord.y));\n\
out_color = texelFetch(u_tex, clamp(texel, ivec2(0), tex_size - ivec2(1)), 0);\n\
} else {\n\
highp vec2 uv = vec2(gl_FragCoord.x, view.y - gl_FragCoord.y) / view;\n\
out_color = texture(u_tex, uv);\n\
}\n\
}\n";
pub const WGSL_FLUID_OCEAN_SHADER: &str = r#"struct OceanUniforms {
viewport_time_agitation: vec4<f32>,
sun_dir_horizon: vec4<f32>,
roll_cos_sin_pad: vec4<f32>,
};
@group(0) @binding(0) var<uniform> u_ocean: OceanUniforms;
struct OceanVertOut {
@builtin(position) pos: vec4<f32>,
@location(0) uv: vec2<f32>,
};
@vertex
fn euv_ocean_vertex(@builtin(vertex_index) vid: u32) -> OceanVertOut {
let px = select(-1.0, 3.0, vid == 1u);
let py = select(-1.0, 3.0, vid == 2u);
var out: OceanVertOut;
out.pos = vec4<f32>(px, py, 0.0, 1.0);
out.uv = vec2<f32>(px * 0.5 + 0.5, 0.5 - py * 0.5);
return out;
}
fn euv_ocean_aces(hdr: vec3<f32>) -> vec3<f32> {
let num = hdr * (2.51 * hdr + 0.03);
let den = hdr * (2.43 * hdr + 0.59) + 0.14;
return clamp(num / max(den, vec3<f32>(0.0001)), vec3<f32>(0.0), vec3<f32>(1.0));
}
@fragment
fn euv_ocean_fragment(in: OceanVertOut) -> @location(0) vec4<f32> {
let sim_time = u_ocean.viewport_time_agitation.z;
let agitation = max(u_ocean.viewport_time_agitation.w, 1.0);
let sun_dir = normalize(u_ocean.sun_dir_horizon.xyz);
let horizon_v = u_ocean.sun_dir_horizon.w;
let ray = normalize(vec3<f32>((in.uv.x - 0.5) * 2.0, (horizon_v - in.uv.y) * 2.0, 1.62));
var col = vec3<f32>(0.0);
if (ray.y >= 0.0) {
let sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
let glow = pow(sdot, 16.0);
let disk = smoothstep(0.9992, 0.9997, sdot);
let sky_t = smoothstep(0.0, 0.55, ray.y);
let horiz = vec3<f32>(0.16, 0.17, 0.19) + vec3<f32>(0.68, 0.48, 0.22) * glow;
col = mix(horiz, vec3<f32>(0.01, 0.015, 0.024), sky_t) + vec3<f32>(3.2, 2.7, 2.0) * disk;
} else {
let dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
let wp = ray.xz * dist;
let w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
let w1 = sin(-wp.x * 0.19 + wp.y * 1.06 + sim_time * 1.18) * 0.15 * agitation;
let norm = normalize(vec3<f32>(-(w0 * 0.12 - w1 * 0.20), 1.0, -(w0 * 0.62 + w1 * 1.06)));
let vdir = -ray;
let ndv = clamp(dot(norm, vdir), 0.002, 1.0);
let fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
let hvec = normalize(vdir + sun_dir);
let ndh = max(dot(norm, hvec), 0.0);
let den = ndh * ndh * (0.00018 - 1.0) + 1.0;
let ggx = min(0.00018 / (3.14159265 * den * den), 24.0);
let body = vec3<f32>(0.0004, 0.052, 0.086) + vec3<f32>(0.002, 0.34, 0.43) * clamp(w0 + w1 + 0.12, 0.0, 1.0) * exp(-dist * 0.05);
col = mix(body, vec3<f32>(0.02, 0.09, 0.16), fresnel * 0.58) + vec3<f32>(1.16, 1.02, 0.82) * ggx * 0.55;
}
return vec4<f32>(pow(euv_ocean_aces(col), vec3<f32>(1.0 / 2.2)), 1.0);
}
"#;
pub const MSL_FLUID_OCEAN_SHADER: &str = r#"#include <metal_stdlib>
using namespace metal;
struct OceanUniforms {
float4 viewport_time_agitation;
float4 sun_dir_horizon;
float4 roll_cos_sin_pad;
};
struct OceanVertOut {
float4 pos [[position]];
float2 uv;
};
vertex OceanVertOut euv_ocean_vertex(uint vid [[vertex_id]]) {
float2 pos = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
OceanVertOut out;
out.pos = float4(pos, 0.0, 1.0);
out.uv = float2(pos.x * 0.5 + 0.5, 0.5 - pos.y * 0.5);
return out;
}
static inline float3 euv_ocean_aces(float3 hdr) {
float3 num = hdr * (2.51 * hdr + 0.03);
float3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
return clamp(num / max(den, float3(0.0001)), float3(0.0), float3(1.0));
}
fragment float4 euv_ocean_fragment(
OceanVertOut in [[stage_in]],
constant OceanUniforms& u [[buffer(0)]]
) {
float sim_time = u.viewport_time_agitation.z;
float agitation = max(u.viewport_time_agitation.w, 1.0);
float3 sun_dir = normalize(u.sun_dir_horizon.xyz);
float horizon_v = u.sun_dir_horizon.w;
float2 centered = float2((in.uv.x - 0.5) * 2.0, (horizon_v - in.uv.y) * 2.0);
float3 ray = normalize(float3(centered.x, centered.y, 1.62));
float3 color;
if (ray.y >= 0.0) {
float sun_dot = clamp(dot(ray, sun_dir), 0.0, 1.0);
float glow = pow(sun_dot, 16.0);
float disk = smoothstep(0.9992, 0.9997, sun_dot);
float sky_t = smoothstep(0.0, 0.55, ray.y);
float3 horiz = float3(0.16, 0.17, 0.19) + float3(0.68, 0.48, 0.22) * glow;
float3 zenith = float3(0.01, 0.015, 0.024);
color = mix(horiz, zenith, sky_t) + float3(3.2, 2.7, 2.0) * disk;
} else {
float dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
float2 wp = ray.xz * dist;
float w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
float w1 = sin(-wp.x * 0.19 + wp.y * 1.06 + sim_time * 1.18) * 0.15 * agitation;
float3 norm = normalize(float3(-(w0 * 0.12 - w1 * 0.20), 1.0, -(w0 * 0.62 + w1 * 1.06)));
float3 view_dir = -ray;
float ndv = clamp(dot(norm, view_dir), 0.002, 1.0);
float fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
float3 half_vec = normalize(view_dir + sun_dir);
float ndh = max(dot(norm, half_vec), 0.0);
float denom = ndh * ndh * (0.00018 - 1.0) + 1.0;
float ggx = min(0.00018 / (3.14159265 * denom * denom), 24.0);
float3 body = float3(0.0004, 0.052, 0.086) + float3(0.002, 0.34, 0.43) * clamp(w0 + w1 + 0.12, 0.0, 1.0) * exp(-dist * 0.05);
float3 sky_refl = float3(0.02, 0.09, 0.16);
color = mix(body, sky_refl, fresnel * 0.58) + float3(1.16, 1.02, 0.82) * ggx * 0.55;
}
float3 ldr = pow(euv_ocean_aces(color), float3(1.0 / 2.2));
return float4(ldr, 1.0);
}
"#;
pub const GLSL_ES3_FLUID_OCEAN_FRAGMENT_SHADER: &str = r#"#version 300 es
precision highp float;
in highp vec2 v_uv;
uniform highp vec4 u_viewport_time_agitation;
uniform highp vec4 u_sun_dir_horizon;
out vec4 out_color;
vec3 euv_ocean_aces(vec3 hdr) {
vec3 num = hdr * (2.51 * hdr + 0.03);
vec3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
return clamp(num / max(den, vec3(0.0001)), vec3(0.0), vec3(1.0));
}
void main() {
float sim_time = u_viewport_time_agitation.z;
float agitation = max(u_viewport_time_agitation.w, 1.0);
vec3 sun_dir = normalize(u_sun_dir_horizon.xyz);
vec3 ray = normalize(vec3((v_uv.x - 0.5) * 2.0, (u_sun_dir_horizon.w - v_uv.y) * 2.0, 1.62));
vec3 color;
if (ray.y >= 0.0) {
float sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
color = mix(vec3(0.16, 0.17, 0.19) + vec3(0.68, 0.48, 0.22) * pow(sdot, 16.0), vec3(0.01, 0.015, 0.024), smoothstep(0.0, 0.55, ray.y));
} else {
float dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
vec2 wp = ray.xz * dist;
float w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
vec3 norm = normalize(vec3(-w0 * 0.12, 1.0, -w0 * 0.62));
float ndv = clamp(dot(norm, -ray), 0.002, 1.0);
float fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
color = mix(vec3(0.0004, 0.052, 0.086), vec3(0.02, 0.09, 0.16), fresnel * 0.58);
}
out_color = vec4(pow(euv_ocean_aces(color), vec3(1.0 / 2.2)), 1.0);
}
"#;
pub const HLSL_FLUID_OCEAN_SHADER: &str = r#"cbuffer OceanUniforms : register(b0) {
float4 viewport_time_agitation;
float4 sun_dir_horizon;
float4 roll_cos_sin_pad;
};
struct OceanVertOut {
float4 pos : SV_Position;
float2 uv : TEXCOORD0;
};
OceanVertOut euv_ocean_vertex(uint vid : SV_VertexID) {
float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
OceanVertOut o;
o.pos = float4(p, 0.0, 1.0);
o.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
return o;
}
float3 euv_ocean_aces(float3 hdr) {
float3 num = hdr * (2.51 * hdr + 0.03);
float3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
return saturate(num / max(den, float3(0.0001, 0.0001, 0.0001)));
}
float4 euv_ocean_fragment(OceanVertOut i) : SV_Target {
float3 sun_dir = normalize(sun_dir_horizon.xyz);
float3 ray = normalize(float3((i.uv.x - 0.5) * 2.0, (sun_dir_horizon.w - i.uv.y) * 2.0, 1.62));
float3 col = (ray.y >= 0.0) ? lerp(float3(0.16, 0.17, 0.19), float3(0.01, 0.015, 0.024), smoothstep(0.0, 0.55, ray.y)) : float3(0.002, 0.08, 0.12);
return float4(pow(euv_ocean_aces(col), 1.0 / 2.2), 1.0);
}
"#;
pub const MSL_GPU_SCENE_SHADER: &str = r#"#include <metal_stdlib>
using namespace metal;
struct GpuOceanUniform {
float4 time_agit_hor_aspect;
float4 roll_boat_uv;
float4 sun_dir_wake;
float4 view_dims;
};
struct GpuOceanOut {
float4 pos [[position]];
float2 uv;
};
struct GpuBoatVert {
float4 pos_ndc;
float4 color;
};
struct GpuBoatOut {
float4 pos [[position]];
float4 color;
};
struct GpuWorld3dUniform {
float4x4 view_proj;
float4 camera_pos;
float4 sun_dir_fog;
float4 sun_color_ambient;
float4 sky_horizon_tod;
float4 sky_zenith_aspect;
};
struct GpuWorld3dVert {
float4 position;
float4 normal;
float4 color_submat;
};
struct GpuWorld3dInst {
float4x4 model;
float4 albedo_metallic;
float4 emissive_roughness;
};
struct GpuWorld3dOut {
float4 pos [[position]];
float3 world_pos;
float3 world_normal;
float4 base_metallic;
float4 emissive_rough;
float submat_mode;
float detail_mode;
};
static inline float3 euv_scene_aces(float3 hdr) {
float3 x = max(hdr, float3(0.0));
float3 num = x * (2.51 * x + 0.03);
float3 den = x * (2.43 * x + 0.59) + 0.14;
return pow(clamp(num / max(den, float3(0.0001)), float3(0.0), float3(1.0)), float3(1.0 / 2.2));
}
static inline float euv_scene_hash(float2 cell) {
float2 p = fract(cell * float2(0.1031, 0.1030));
p += dot(p, p.yx + 33.33);
return fract((p.x + p.y) * p.x);
}
static inline float euv_scene_noise(float2 p) {
float2 i = floor(p);
float2 f = fract(p);
float2 u = f * f * (3.0 - 2.0 * f);
float a = euv_scene_hash(i);
float b = euv_scene_hash(i + float2(1.0, 0.0));
float c = euv_scene_hash(i + float2(0.0, 1.0));
float d = euv_scene_hash(i + float2(1.0, 1.0));
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
static inline float euv_cloud_fbm(float2 p, int octs) {
float val = 0.0;
float amp = 0.52;
float2 q = p;
for (int i = 0; i < octs; ++i) {
val += euv_scene_noise(q) * amp;
q = float2(q.x * 1.92 - q.y * 0.58 + 3.1, q.x * 0.58 + q.y * 1.92 - 1.7);
amp *= 0.50;
}
return clamp(val, 0.0, 1.0);
}
static inline float3 euv_ocean_sky(float3 ray, float3 sun_dir, float sim_time, bool high_detail) {
float ry = max(ray.y, 0.0);
float sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
float sp2 = sdot * sdot;
float sp4 = sp2 * sp2;
float sp16 = sp4 * sp4 * sp4 * sp4;
float sp64 = sp16 * sp16 * sp16 * sp16;
float sun_az_glow = pow(clamp(dot(normalize(float2(ray.x, ray.z)), normalize(float2(sun_dir.x, sun_dir.z))), 0.0, 1.0), 4.0);
float disk = smoothstep(0.9990, 0.99965, sdot);
float sky_t = smoothstep(0.0, 0.55, ry);
float3 horiz = float3(0.22, 0.17, 0.20) + float3(0.95, 0.52, 0.22) * sp16 + float3(1.5, 1.08, 0.62) * sp64;
float3 zenith = float3(0.012, 0.024, 0.050);
float3 base_sky = mix(horiz, zenith, sky_t);
float strat_y = pow(ry, 0.62) * 3.95;
float2 base_c = float2(ray.x * (1.68 + 0.42 * (1.0 - min(ry, 1.0))) + sim_time * 0.015, strat_y * 2.28 + sim_time * 0.007);
float warp_a = euv_scene_noise(base_c * float2(0.62, 0.72) + float2(3.1, -1.4));
float warp_b = high_detail ? euv_scene_noise(base_c * float2(1.60, 1.85) + float2(-2.3, 5.7)) : 0.5;
float2 c_uv = base_c + float2((warp_a - 0.5) * 1.15 + (warp_b - 0.5) * 0.42, (warp_a - 0.5) * 0.66 - (warp_b - 0.5) * 0.24);
float cloud_raw = euv_cloud_fbm(c_uv, high_detail ? 5 : 2);
float billow = 0.0;
float wisp_ridge = 0.0;
if (high_detail) {
float g1 = euv_scene_noise(c_uv * float2(3.10, 4.40) + float2(8.4, -3.9));
float g2 = euv_scene_noise(c_uv * float2(7.80, 10.60) + float2(-4.2, 9.1));
float r_raw = 1.0 - abs(euv_scene_noise(c_uv * float2(5.2, 8.4) + float2(1.9, -2.6)) * 2.0 - 1.0);
billow = g1 * 0.14 + g2 * 0.09;
wisp_ridge = r_raw * r_raw * 0.11;
}
float cloud_field = clamp(cloud_raw * 0.77 + billow + wisp_ridge, 0.0, 1.0);
float overhead = smoothstep(0.035, 0.24, ry);
float clearing = sun_az_glow * exp(-ry * 7.2) * 0.58;
float cloud_cov = smoothstep(0.24, 0.66, cloud_field + overhead * 0.36 - clearing);
float cloud_dark = (0.54 + 0.42 * overhead) * cloud_cov;
float rim_sample = high_detail ? euv_cloud_fbm(c_uv + float2(sun_dir.x * 0.32, 0.18), 3) : (cloud_field * 0.90);
float edge_lacy = 1.0 - abs(cloud_cov * 2.0 - 1.0);
float sun_lit_edge = (clamp((cloud_field - rim_sample) * 3.5 + 0.14, 0.0, 1.0) + edge_lacy * edge_lacy * 0.42) * (0.16 + 0.84 * sun_az_glow) * (1.0 - overhead * 0.60);
float wisp_tex = high_detail ? ((cloud_field - 0.5) * 0.058 + wisp_ridge * 0.18) : 0.0;
float3 cloud_col = high_detail
? max(float3(0.005, 0.009, 0.016), float3(0.010, 0.016, 0.026) + float3(0.042, 0.052, 0.072) * (1.0 - cloud_dark) + float3(0.90, 1.06, 1.24) * wisp_tex + float3(0.86 + 0.58 * sp4, 0.60 + 0.38 * sp4, 0.32 + 0.16 * sp4) * sun_lit_edge)
: (float3(0.003, 0.018, 0.036) + float3(0.015, 0.056, 0.094) * (1.0 - cloud_dark) + float3(0.40 + 0.28 * sp4, 0.34 + 0.22 * sp4, 0.26 + 0.15 * sp4) * sun_lit_edge);
float cloud_alpha = clamp(cloud_cov * (0.74 + 0.24 * overhead), 0.0, 0.98);
float3 sky = mix(base_sky, cloud_col, cloud_alpha);
if (high_detail) {
sky += float3(4.5, 3.6, 2.5) * disk;
} else if (sdot > 0.988) {
sky += float3(1.20, 0.98, 0.66) * (sp64 * sp64 * 1.25);
}
return sky;
}
vertex GpuOceanOut euv_scene_ocean_vert(uint vid [[vertex_id]]) {
float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
GpuOceanOut out;
out.pos = float4(p, 0.0, 1.0);
out.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
return out;
}
fragment float4 euv_scene_ocean_frag(
GpuOceanOut in [[stage_in]],
constant GpuOceanUniform& u [[buffer(0)]],
texture2d<float> wake_tex [[texture(0)]]
) {
constexpr sampler s_lin(address::clamp_to_edge, filter::linear);
float sim_time = u.time_agit_hor_aspect.x;
float agitation = max(u.time_agit_hor_aspect.y, 1.0);
float horizon_v = u.time_agit_hor_aspect.z;
float aspect = max(u.time_agit_hor_aspect.w, 0.25);
float roll_cos = u.roll_boat_uv.x;
float roll_sin = u.roll_boat_uv.y;
float2 boat_uv = u.roll_boat_uv.zw;
float3 sun_dir = normalize(u.sun_dir_wake.xyz);
float wake_active = u.sun_dir_wake.w;
float raw_dx = (in.uv.x - 0.5) * 2.0 * aspect;
float raw_dy = (horizon_v - in.uv.y) * 2.0;
float rx_u = raw_dx * roll_cos + raw_dy * roll_sin;
float ry_u = -raw_dx * roll_sin + raw_dy * roll_cos;
float3 ray = normalize(float3(rx_u, ry_u, 1.62));
float neg_ry_raw = max(-ray.y, 0.0024);
float2 wp_grad_ref = ray.xz * clamp(1.42 / neg_ry_raw, 0.6, 240.0);
float pixel_foot_fw = clamp(length(fwidth(wp_grad_ref)) * 0.68, 0.0, 8.0);
float3 hdr;
if (ray.y >= 0.0) {
hdr = euv_ocean_sky(ray, sun_dir, sim_time, true);
} else {
float neg_ry = neg_ry_raw;
float dist = clamp(1.42 / neg_ry, 0.6, 240.0);
float2 wp0 = ray.xz * dist;
if (dist < 16.0) {
float ph0 = dot(wp0, float2(0.18, 0.984)) * 0.62 + sim_time * 0.88;
float h_p = 0.230 * agitation * (exp(-(1.0 - sin(ph0))) - 0.40);
dist = clamp((1.42 - h_p) / neg_ry, 0.6, 240.0);
wp0 = ray.xz * dist;
}
float pixel_foot = max(pixel_foot_fw, dist * 0.0012);
const float4 waves[8] = {
float4(0.18, 0.984, 0.62, 0.230),
float4(-0.36, 0.933, 1.08, 0.160),
float4(0.52, 0.854, 1.88, 0.098),
float4(-0.60, 0.800, 3.10, 0.062),
float4(0.46, 0.888, 5.15, 0.038),
float4(-0.68, 0.733, 8.40, 0.024),
float4(0.74, 0.673, 13.80, 0.015),
float4(-0.76, 0.650, 22.40, 0.009)
};
const float speeds[8] = { 0.88, 1.18, 1.62, 2.08, 2.62, 3.18, 3.85, 4.65 };
float2 wp = wp0;
float h = 0.0;
float2 grad = float2(0.0);
float crest_acc = 0.0;
for (int wi = 0; wi < 8; ++wi) {
float freq = waves[wi].z;
float aa_arg = pixel_foot * freq * 0.62;
if (aa_arg > 3.6) {
break;
}
float aa_w = 1.0 / (1.0 + aa_arg * aa_arg);
float amp = waves[wi].w * agitation;
float ph = dot(wp, waves[wi].xy) * freq + sim_time * speeds[wi];
float sp = sin(ph);
float cp = cos(ph);
float sharp_e = exp(-(1.0 - sp));
h += amp * (sharp_e - 0.40) * aa_w;
float slope = amp * freq * sharp_e * cp * aa_w;
grad += waves[wi].xy * slope;
crest_acc += sharp_e * amp;
wp += waves[wi].xy * (cp * amp * 0.92 * aa_w);
}
float near_steep = 1.0 + 0.48 * exp(-dist * 0.082);
grad = float2(grad.x * near_steep, grad.y * near_steep * 1.14);
if (pixel_foot < 0.28) {
float cap_aa = 1.0 / (1.0 + (pixel_foot * 15.0) * (pixel_foot * 15.0));
float c1 = cos(wp0.x * 16.5 + wp0.y * 26.0 + sim_time * 3.8) * 0.068 * cap_aa * agitation;
float c2 = cos(-wp0.x * 22.0 + wp0.y * 31.0 + sim_time * 4.7) * 0.052 * cap_aa * agitation;
grad += float2(c1 * 0.56 - c2 * 0.62, c1 * 0.82 + c2 * 0.78);
}
float wake_foam = 0.0;
if (wake_active > 0.5) {
float4 wk = wake_tex.sample(s_lin, in.uv);
float2 flow = clamp((wk.rg - float2(0.5)) * 4.0 * 0.22, float2(-0.20), float2(0.20));
grad += flow;
wake_foam = wk.b;
}
float2 raw_bd = float2((in.uv.x - boat_uv.x) * aspect, in.uv.y - boat_uv.y);
float2 rot_bd = float2(raw_bd.x * roll_cos - raw_bd.y * roll_sin, raw_bd.x * roll_sin + raw_bd.y * roll_cos);
float2 boat_local = float2(rot_bd.x / 0.145, rot_bd.y / 0.036);
float boat_ring_d2 = dot(boat_local, boat_local);
if (boat_ring_d2 > 0.30 && boat_ring_d2 < 12.8) {
float r_hull = sqrt(boat_ring_d2);
float rip_env = exp(-max(r_hull - 0.85, 0.0) * 1.08) * smoothstep(0.55, 0.92, r_hull);
float rip_wave = cos(r_hull * 16.5 - sim_time * 4.2) * 0.36 * rip_env;
float inv_rh = 1.0 / max(r_hull, 0.1);
grad += float2(boat_local.x * inv_rh * rip_wave, boat_local.y * inv_rh * rip_wave * 1.38);
}
float3 norm = normalize(float3(-grad.x, 1.0, -grad.y));
float3 view_dir = -ray;
float ndv = clamp(dot(norm, view_dir), 0.002, 1.0);
float fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
float3 refl_dir = reflect(ray, norm);
refl_dir.y = max(refl_dir.y, 0.006);
float3 sky_refl = euv_ocean_sky(normalize(refl_dir), sun_dir, sim_time, false);
float3 half_vec = normalize(view_dir + sun_dir);
float ndh = max(dot(norm, half_vec), 0.0);
float d1 = ndh * ndh * (0.00018 - 1.0) + 1.0;
float ggx_tight = min(0.00018 / (3.14159265 * d1 * d1), 28.0);
float d2 = ndh * ndh * (0.00036 - 1.0) + 1.0;
float ggx_mid = min(0.00036 / (3.14159265 * d2 * d2), 5.2);
float glint = smoothstep(0.982, 0.9985, ndh);
float sparkle_boost = 0.86 + 0.52 * smoothstep(2.5, 24.0, dist);
float3 spec = float3(1.18, 1.02, 0.80) * ((ggx_tight * 0.52 + ggx_mid * 0.10 + glint * 0.48) * sparkle_boost);
float sss = clamp(h * 1.45 + 0.16, 0.0, 1.0) * exp(-dist * 0.048) * (0.35 + 0.65 * pow(clamp(dot(-view_dir, sun_dir), 0.0, 1.0), 3.0));
float3 deep_body = float3(0.002, 0.046, 0.078) + float3(0.008, 0.34, 0.39) * sss;
float refl_weight = clamp(fresnel * 0.58 + 0.022, 0.022, 0.70);
hdr = mix(deep_body, sky_refl, refl_weight) + spec;
if (rot_bd.y > -0.01 && rot_bd.y < 0.24 && abs(rot_bd.x) < 0.22) {
float ripple = sin(rot_bd.y * 95.0 - sim_time * 4.5 + grad.x * 6.0) * 0.012;
float rx_b = abs(rot_bd.x + ripple);
float tri_mask = smoothstep(0.14, 0.02, rx_b + max(rot_bd.y, 0.0) * 0.55) * (1.0 - max(rot_bd.y, 0.0) / 0.24);
hdr = mix(hdr, float3(0.55, 0.52, 0.48), tri_mask * 0.34);
}
float crest_norm = crest_acc / max(agitation, 1.0);
float steep_foam = smoothstep(0.44, 0.62, crest_norm) * clamp(agitation - 1.02, 0.0, 1.0);
float total_foam = clamp(steep_foam * 0.45 + wake_foam * 0.28, 0.0, 0.54);
hdr = mix(hdr, float3(0.78, 0.90, 0.96), total_foam);
if (boat_ring_d2 < 4.5) {
if (boat_ring_d2 < 1.12) {
float contact_ao = (1.0 - smoothstep(0.18, 1.06, boat_ring_d2)) * 0.44;
hdr *= float3(1.0 - contact_ao, 1.0 - contact_ao * 0.82, 1.0 - contact_ao * 0.72);
}
float foam_ny = boat_local.y - 0.16;
float foam_d2 = boat_local.x * boat_local.x * 1.16 + foam_ny * foam_ny * 1.08;
float rim_band = smoothstep(0.42, 0.82, foam_d2) * (1.0 - smoothstep(0.88, 1.54, foam_d2)) * smoothstep(-0.45, 0.24, boat_local.y);
float aft_wake = smoothstep(0.22, 0.82, boat_local.x) * (1.0 - smoothstep(0.88, 1.62, boat_local.x)) * (1.0 - smoothstep(0.18, 1.20, abs(boat_local.y - 0.26))) * 0.46;
float collar_mask = clamp(rim_band + aft_wake, 0.0, 1.0);
if (collar_mask > 0.02) {
float lacy_a = euv_scene_noise(wp0 * 8.2 + float2(2.3, -1.7));
float lacy_b = euv_scene_noise(wp0 * 21.0 + float2(-sim_time * 0.85, 4.1));
float flecks = euv_scene_noise(wp0 * 42.0 + float2(7.1, -sim_time * 1.35));
float foam_pat = smoothstep(0.46, 0.78, lacy_a * 0.42 + lacy_b * 0.36 + flecks * 0.22);
float spray_dots = smoothstep(0.74, 0.88, flecks) * rim_band * 0.72;
float hull_foam = clamp(collar_mask * foam_pat * 0.78 + spray_dots, 0.0, 0.86);
hdr = mix(hdr, float3(0.92, 0.97, 1.0), hull_foam);
}
}
float horiz_fog = exp(-neg_ry * 38.0);
float3 fog_col = euv_ocean_sky(normalize(float3(ray.x, 0.01, ray.z)), sun_dir, sim_time, false);
hdr = mix(hdr, fog_col, clamp(horiz_fog * 0.82, 0.0, 0.88));
}
return float4(euv_scene_aces(hdr), 1.0);
}
vertex GpuBoatOut euv_scene_boat_vert(
uint vid [[vertex_id]],
device const GpuBoatVert* verts [[buffer(0)]]
) {
GpuBoatVert v = verts[vid];
GpuBoatOut out;
out.pos = float4(v.pos_ndc.xy, 0.0, 1.0);
out.color = v.color;
return out;
}
fragment float4 euv_scene_boat_frag(GpuBoatOut in [[stage_in]]) {
return in.color;
}
vertex GpuOceanOut euv_scene_3d_sky_vert(uint vid [[vertex_id]]) {
float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
GpuOceanOut out;
out.pos = float4(p, 0.9999, 1.0);
out.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
return out;
}
fragment float4 euv_scene_3d_sky_frag(
GpuOceanOut in [[stage_in]],
constant GpuWorld3dUniform& u [[buffer(0)]]
) {
float sky_t = clamp(1.0 - in.uv.y * 1.15, 0.0, 1.0);
float3 col = mix(u.sky_horizon_tod.rgb, u.sky_zenith_aspect.rgb, smoothstep(0.0, 0.85, sky_t));
float sun_glow = pow(clamp(1.0 - abs(in.uv.x - 0.55) * 1.6, 0.0, 1.0) * clamp(1.0 - abs(in.uv.y - 0.34) * 2.2, 0.0, 1.0), 3.0);
col += u.sun_color_ambient.rgb * sun_glow * 0.45;
return float4(euv_scene_aces(col * u.camera_pos.w), 1.0);
}
vertex GpuWorld3dOut euv_scene_3d_mesh_vert(
uint vid [[vertex_id]],
uint iid [[instance_id]],
constant GpuWorld3dUniform& u [[buffer(0)]],
device const GpuWorld3dVert* verts [[buffer(1)]],
device const GpuWorld3dInst* insts [[buffer(2)]]
) {
GpuWorld3dVert v = verts[vid];
GpuWorld3dInst inst = insts[iid];
float detail_mode = inst.model[3].w;
float4x4 m = inst.model;
m[3].w = 1.0;
float4 world_p = m * float4(v.position.xyz, 1.0);
float4 clip_p = u.view_proj * world_p;
clip_p.z = clip_p.z * 0.5 + clip_p.w * 0.5;
float3 c0 = m[0].xyz;
float3 c1 = m[1].xyz;
float3 c2 = m[2].xyz;
float3x3 cof = float3x3(cross(c1, c2), cross(c2, c0), cross(c0, c1));
float3 wn = normalize(cof * v.normal.xyz);
GpuWorld3dOut out;
out.pos = clip_p;
out.world_pos = world_p.xyz;
out.world_normal = wn;
if (v.color_submat.w > 0.5) {
out.base_metallic = float4(v.color_submat.rgb, inst.albedo_metallic.w);
} else {
out.base_metallic = float4(inst.albedo_metallic.rgb * v.color_submat.rgb, inst.albedo_metallic.w);
}
out.emissive_rough = inst.emissive_roughness;
out.submat_mode = v.color_submat.w;
out.detail_mode = detail_mode;
return out;
}
fragment float4 euv_scene_3d_mesh_frag(
GpuWorld3dOut in [[stage_in]],
constant GpuWorld3dUniform& u [[buffer(0)]]
) {
float3 norm = normalize(in.world_normal);
float3 view_dir = normalize(u.camera_pos.xyz - in.world_pos);
float3 sun_dir = normalize(u.sun_dir_fog.xyz);
float dist = length(u.camera_pos.xyz - in.world_pos);
float fw_pos = length(fwidth(in.world_pos));
float fw_xz = length(fwidth(in.world_pos.xz));
float3 base_col = in.base_metallic.rgb;
float metallic = clamp(in.base_metallic.w, 0.0, 1.0);
float roughness = clamp(in.emissive_rough.w, 0.05, 1.0);
float3 emissive = (in.submat_mode > 1.5) ? base_col * 1.15 : in.emissive_rough.rgb;
float env_boost = 0.85;
if (in.detail_mode > 0.5 && in.detail_mode < 1.5 && norm.y > 0.82) {
float wpx = in.world_pos.x;
float wpz = in.world_pos.z;
float abs_x = abs(wpx);
float edge_aa = clamp(fw_xz * 0.9, 0.035, 0.36);
float curb_w = smoothstep(9.9 - edge_aa, 9.9 + edge_aa, abs_x);
float walk_w = smoothstep(10.6 - edge_aa, 10.6 + edge_aa, abs_x);
float micro_fade = 1.0 - smoothstep(22.0, 70.0, dist);
float grain_n = euv_scene_hash(floor(float2(wpx * 4.3, wpz * 4.3))) - 0.5;
float om_curb = 1.0 - curb_w;
float inner_lin = 1.0 - clamp(abs(abs_x - 3.65) * 0.85, 0.0, 1.0);
float outer_lin = 1.0 - clamp(abs(abs_x - 6.85) * 0.95, 0.0, 1.0);
float tire_wear = clamp(inner_lin * inner_lin + outer_lin * outer_lin, 0.0, 1.0) * om_curb;
float gutter_band = (1.0 - clamp(abs(abs_x - 9.75) * 2.8, 0.0, 1.0)) * om_curb;
float puddle_fade = 1.0 - smoothstep(48.0, 120.0, dist);
float p_coarse = euv_scene_noise(float2(wpx * 0.14 + 3.1, wpz * 0.08 - 1.7));
float p_fine = euv_scene_noise(float2(wpx * 0.38 - 5.4, wpz * 0.24 + 2.9));
float center_crown = (1.0 - clamp(abs_x * 0.65, 0.0, 1.0)) * om_curb;
float puddle_raw = p_coarse * 0.66 + p_fine * 0.34 + tire_wear * 0.14 + gutter_band * 0.16 - center_crown * 0.24;
float puddle = smoothstep(0.44, 0.90, puddle_raw) * om_curb * puddle_fade;
float tarmac_scale = (1.0 + grain_n * 0.24 * micro_fade * (1.0 - puddle)) * (1.0 - 0.14 * tire_wear) * (1.0 - 0.38 * puddle) * (1.0 - 0.30 * gutter_band);
float3 road_col = base_col * tarmac_scale;
float yellow_w = (1.0 - smoothstep(0.085 - edge_aa, 0.085 + edge_aa, abs(abs_x - 0.22))) * om_curb;
if (yellow_w > 0.01) {
float pv = (1.0 - 0.14 * puddle) * (0.92 + grain_n * 0.14 * micro_fade);
road_col = mix(road_col, float3(0.88, 0.62, 0.10) * pv, yellow_w * 0.94);
}
float dash_on = (fract(wpz * 0.125) < 0.42) ? 1.0 : 0.0;
float lane_w = (1.0 - smoothstep(0.085 - edge_aa, 0.085 + edge_aa, abs(abs_x - 4.65))) * dash_on * om_curb;
float shoulder_w = (1.0 - smoothstep(0.10 - edge_aa, 0.10 + edge_aa, abs(abs_x - 8.95))) * om_curb;
float cross_cell = (wpz + 18.0) - 40.0 * floor((wpz + 18.0) / 40.0) - 20.0;
float cross_w = (abs(cross_cell) < 1.80 && abs_x < 8.40 && abs_x > 0.55 && fract(wpx * 0.85) < 0.50) ? (0.85 * om_curb) : 0.0;
float white_w = max(max(shoulder_w, lane_w), cross_w);
if (white_w > 0.01) {
float pv = (1.0 - 0.16 * puddle) * (0.90 + grain_n * 0.12 * micro_fade);
road_col = mix(road_col, float3(0.78, 0.81, 0.86) * pv, white_w * 0.90);
}
float3 curb_col = float3(0.36, 0.38, 0.42) * (1.0 + grain_n * 0.10 * micro_fade);
float tile_seam = (fract(wpx * 0.45) < 0.045 || fract(wpz * 0.45) < 0.045) ? 0.72 : 1.0;
float3 walk_col = float3(0.24, 0.26, 0.30) * tile_seam * (1.0 + grain_n * 0.10 * micro_fade);
base_col = mix(mix(road_col, curb_col, curb_w), walk_col, walk_w);
roughness = mix(mix(roughness, 0.06, puddle), 0.78, walk_w);
env_boost = mix(0.85, 1.85, puddle);
} else if (in.detail_mode > 1.5 && in.detail_mode < 2.5 && abs(norm.y) < 0.35 && in.submat_mode < 0.5) {
float u_coord = (abs(norm.x) > abs(norm.z)) ? in.world_pos.z : in.world_pos.x;
float world_y = in.world_pos.y;
float dist_fade = 1.0 - smoothstep(130.0, 320.0, dist);
float px_sz = max(fw_pos * 0.75, dist * 0.0022);
if (world_y < 3.45) {
float su_s = u_coord * 0.26;
float fx_s = fract(su_s);
float fy_s = clamp(world_y / 3.45, 0.0, 1.0);
float pane_w = smoothstep(0.08, 0.14, fx_s) * (1.0 - smoothstep(0.86, 0.92, fx_s)) * smoothstep(0.14, 0.22, fy_s) * (1.0 - smoothstep(0.86, 0.92, fy_s)) * dist_fade;
float sh = euv_scene_hash(float2(floor(su_s), 7.0));
float3 shop_glow = (sh < 0.40) ? float3(1.18, 0.78, 0.36) : ((sh < 0.62) ? float3(0.28, 0.88, 1.18) : ((sh < 0.80) ? float3(1.12, 0.32, 0.68) : float3(0.0)));
base_col = mix(base_col * 0.64, base_col * 0.40, pane_w);
emissive += shop_glow * (pane_w * (0.55 + 0.55 * (1.0 - fy_s)) * 0.92);
roughness = mix(roughness, 0.12, pane_w);
} else {
float su = u_coord * 0.48;
float sy = world_y * 0.33;
float fx_win = fract(su);
float fy_win = fract(sy);
float aa_u = clamp(px_sz * 0.48, 0.018, 0.32);
float aa_v = clamp(px_sz * 0.33, 0.018, 0.32);
float pane_u = smoothstep(0.14 - aa_u, 0.14 + aa_u, fx_win) * (1.0 - smoothstep(0.86 - aa_u, 0.86 + aa_u, fx_win));
float pane_v = smoothstep(0.18 - aa_v, 0.18 + aa_v, fy_win) * (1.0 - smoothstep(0.84 - aa_v, 0.84 + aa_v, fy_win));
float pane_w = clamp(pane_u * pane_v * dist_fade, 0.0, 1.0);
float spandrel = (fy_win < 0.14 || fy_win > 0.88) ? 0.70 : 0.84;
float3 wall_base = base_col * spandrel;
float ch = euv_scene_hash(float2(floor(su), floor(sy)));
float room_lvl = 0.68 + fract(ch * 17.3) * 0.45;
float blind_grad = clamp(0.48 + 0.66 * (1.0 - fy_win), 0.38, 1.14);
float r_scale = pane_w * room_lvl * blind_grad;
if (ch < 0.22) {
base_col = mix(wall_base, base_col * 0.86, pane_w);
emissive += float3(1.24, 0.86, 0.42) * r_scale;
} else if (ch < 0.33) {
base_col = mix(wall_base, base_col * 0.84, pane_w);
emissive += float3(0.28, 0.86, 1.24) * r_scale;
} else if (ch < 0.42) {
base_col = mix(wall_base, base_col * 0.88, pane_w);
emissive += float3(0.96, 0.94, 0.88) * (r_scale * 0.82);
} else if (ch < 0.50) {
base_col = mix(wall_base, base_col * 0.84, pane_w);
emissive += float3(1.06, 0.34, 0.72) * (r_scale * 0.86);
} else {
float dark_g = clamp(0.36 + 0.22 * fy_win, 0.32, 0.62);
base_col = mix(wall_base, base_col * dark_g, pane_w);
}
roughness = mix(roughness, 0.10, pane_w);
env_boost = mix(0.85, 1.45, pane_w);
}
} else if (in.detail_mode > 2.5 && norm.y > 0.80) {
float2 wp = in.world_pos.xz;
float aa_w = 1.0 / (1.0 + fw_xz * 0.85);
float w_a = cos(wp.x * 0.42 + wp.y * 0.64 + u.sky_horizon_tod.w * 2.4) * 0.08 * aa_w;
float w_b = cos(-wp.x * 0.78 + wp.y * 0.52 + u.sky_horizon_tod.w * 3.1) * 0.06 * aa_w;
norm = normalize(float3(w_a - w_b, 1.0, w_a + w_b));
base_col = float3(0.015, 0.095, 0.145);
roughness = 0.08;
metallic = 0.02;
env_boost = 1.65;
}
float3 half_vec = normalize(view_dir + sun_dir);
float ndl = max(dot(norm, sun_dir), 0.0);
float ndv = max(dot(norm, view_dir), 0.002);
float ndh = max(dot(norm, half_vec), 0.0);
float hdv = max(dot(half_vec, view_dir), 0.0);
float a2 = roughness * roughness * roughness * roughness;
float d_den = ndh * ndh * (a2 - 1.0) + 1.0;
float ndf = a2 / max(3.14159265 * d_den * d_den, 0.0001);
float3 f0 = mix(float3(0.04), base_col, metallic);
float3 fresnel = f0 + (float3(1.0) - f0) * pow(1.0 - hdv, 5.0);
float k_g = (roughness + 1.0);
k_g = (k_g * k_g) * 0.125;
float g_v = ndv / (ndv * (1.0 - k_g) + k_g);
float g_l = ndl / (ndl * (1.0 - k_g) + k_g);
float3 spec = (ndf * g_v * g_l * fresnel) / max(4.0 * ndv * ndl, 0.001);
float3 kd = (float3(1.0) - fresnel) * (1.0 - metallic);
float3 direct = (kd * base_col / 3.14159265 + spec) * u.sun_color_ambient.rgb * ndl * 1.45;
float sky_w = norm.y * 0.5 + 0.5;
float3 hemi = mix(u.sky_horizon_tod.rgb * 0.42, u.sky_zenith_aspect.rgb * 0.9 + u.sky_horizon_tod.rgb * 0.35, sky_w);
float3 env_refl = mix(u.sky_horizon_tod.rgb, u.sky_zenith_aspect.rgb, clamp(reflect(-view_dir, norm).y * 0.5 + 0.5, 0.0, 1.0));
float3 f_env = f0 + (max(float3(1.0 - roughness), f0) - f0) * pow(1.0 - ndv, 5.0);
float3 ambient = (base_col * (1.0 - metallic * 0.65) * hemi + env_refl * f_env * env_boost) * (0.45 + u.sun_color_ambient.w);
float3 hdr = direct + ambient + emissive;
float fog_t = 1.0 - exp(-dist * u.sun_dir_fog.w);
hdr = mix(hdr, u.sky_horizon_tod.rgb, clamp(fog_t, 0.0, 0.86));
return float4(euv_scene_aces(hdr * u.camera_pos.w), 1.0);
}
"#;
pub(crate) const MTL_SIMULATOR_TOKEN: &str = "simulator";
pub(crate) const MTL_VIRTUAL_TOKEN: &str = "virtual";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_STRING: &str = "NSString\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_URL: &str = "NSURL\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_ARRAY: &str = "NSArray\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_PIPELINE_DESC: &str = "MTLRenderPipelineDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_PASS_DESC: &str = "MTLRenderPassDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_TEX_DESC: &str = "MTLTextureDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_BINARY_ARCHIVE_DESC: &str = "MTLBinaryArchiveDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ALLOC: &str = "alloc\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_INIT: &str = "init\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RETAIN: &str = "retain\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_STRING_UTF8: &str = "stringWithUTF8String:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_FILE_URL_WITH_PATH: &str = "fileURLWithPath:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ARRAY_WITH_OBJECT: &str = "arrayWithObject:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_UTF8_STRING: &str = "UTF8String\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NAME: &str = "name\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_CMD_QUEUE: &str = "newCommandQueue\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_LIBRARY: &str = "newLibraryWithSource:options:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_FUNCTION: &str = "newFunctionWithName:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_PIPELINE_STATE: &str = "newRenderPipelineStateWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BINARY_ARCHIVE: &str = "newBinaryArchiveWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ADD_PIPELINE_TO_ARCHIVE: &str =
"addRenderPipelineFunctionsWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SERIALIZE_TO_URL: &str = "serializeToURL:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_URL: &str = "setUrl:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BINARY_ARCHIVES: &str = "setBinaryArchives:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_FUNCTION: &str = "setVertexFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_FUNCTION: &str = "setFragmentFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_COLOR_ATTACHMENTS: &str = "colorAttachments\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_OBJECT_AT_INDEX: &str = "objectAtIndexedSubscript:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_PIXEL_FORMAT: &str = "setPixelFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BLENDING_ENABLED: &str = "setBlendingEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_RGB_BLEND_OP: &str = "setRgbBlendOperation:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_ALPHA_BLEND_OP: &str = "setAlphaBlendOperation:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SRC_RGB_BLEND: &str = "setSourceRGBBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DST_RGB_BLEND: &str = "setDestinationRGBBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SRC_ALPHA_BLEND: &str = "setSourceAlphaBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DST_ALPHA_BLEND: &str = "setDestinationAlphaBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_TEX_2D_DESC: &str =
"texture2DDescriptorWithPixelFormat:width:height:mipmapped:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_USAGE: &str = "setUsage:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_TEXTURE: &str = "newTextureWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_REPLACE_REGION: &str =
"replaceRegion:mipmapLevel:withBytes:bytesPerRow:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BUFFER: &str = "newBufferWithBytes:length:options:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BUFFER_LENGTH: &str = "newBufferWithLength:options:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_CONTENTS: &str = "contents\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_CMD_BUFFER: &str = "commandBuffer\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RENDER_ENCODER: &str = "renderCommandEncoderWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_PIPELINE_STATE: &str = "setRenderPipelineState:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_BUFFER: &str = "setVertexBuffer:offset:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_BYTES: &str = "setVertexBytes:length:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_TEXTURE: &str = "setFragmentTexture:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SCISSOR_RECT: &str = "setScissorRect:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DRAW_PRIMITIVES_INSTANCED: &str =
"drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_END_ENCODING: &str = "endEncoding\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_PRESENT_DRAWABLE: &str = "presentDrawable:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ADD_PRESENTED_HANDLER: &str = "addPresentedHandler:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ADD_COMPLETED_HANDLER: &str = "addCompletedHandler:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_PRESENTED_TIME: &str = "presentedTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_STATUS: &str = "status\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_WAIT_UNTIL_COMPLETED: &str = "waitUntilCompleted\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_GPU_START_TIME: &str = "GPUStartTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_GPU_END_TIME: &str = "GPUEndTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEXT_DRAWABLE: &str = "nextDrawable\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_TEXTURE: &str = "texture\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_WIDTH: &str = "width\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_HEIGHT: &str = "height\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RENDER_PASS_DESC: &str = "renderPassDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_TEXTURE: &str = "setTexture:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_LOAD_ACTION: &str = "setLoadAction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STORE_ACTION: &str = "setStoreAction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_CLEAR_COLOR: &str = "setClearColor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEVICE: &str = "setDevice:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAMEBUFFER_ONLY: &str = "setFramebufferOnly:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_MAX_DRAWABLE_COUNT: &str = "setMaximumDrawableCount:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DISPLAY_SYNC: &str = "setDisplaySyncEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DRAWABLE_SIZE: &str = "drawableSize\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DRAWABLE_SIZE: &str = "setDrawableSize:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RESPONDS_TO_SEL: &str = "respondsToSelector:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_BYTES: &str = "setFragmentBytes:length:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VIEWPORT: &str = "setViewport:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_COMMIT: &str = "commit\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RELEASE: &str = "release\0";
pub(crate) const SHADER_STATE_LABEL_VALIDATED_FALLBACK: &str = "LUT + Hash Warm";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_VERTEX: &str = "euv_ui_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_FRAGMENT: &str = "euv_ui_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_VERTEX: &str = "euv_blur_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_DOWN: &str = "euv_blur_downsample";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_UP: &str = "euv_blur_upsample";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_3D_VERTEX: &str = "euv_3d_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_3D_FRAGMENT: &str = "euv_3d_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_OCEAN_VERTEX: &str = "euv_ocean_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_OCEAN_FRAGMENT: &str = "euv_ocean_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_OCEAN_VERT: &str = "euv_scene_ocean_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_OCEAN_FRAG: &str = "euv_scene_ocean_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_BOAT_VERT: &str = "euv_scene_boat_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_BOAT_FRAG: &str = "euv_scene_boat_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_SKY_VERT: &str = "euv_scene_3d_sky_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_SKY_FRAG: &str = "euv_scene_3d_sky_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_MESH_VERT: &str = "euv_scene_3d_mesh_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_MESH_FRAG: &str = "euv_scene_3d_mesh_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_DEPTH_STENCIL_DESC: &str = "MTLDepthStencilDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_COMPARE_FN: &str = "setDepthCompareFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_WRITE_ENABLED: &str = "setDepthWriteEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_DEPTH_STENCIL_STATE: &str = "newDepthStencilStateWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_STENCIL_STATE: &str = "setDepthStencilState:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_ATTACHMENT_PIXEL_FORMAT: &str =
"setDepthAttachmentPixelFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DEPTH_ATTACHMENT: &str = "depthAttachment\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_CLEAR_DEPTH: &str = "setClearDepth:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_DEPTH32_FLOAT: usize = 252;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_COMPARE_FUNC_LESS: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORE_ACTION_DONT_CARE: usize = 0;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STORAGE_MODE_GPU: &str = "setStorageMode:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORAGE_MODE_PRIVATE_GPU: usize = 2;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_TEX_USAGE_RENDER_TARGET_GPU: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_VERTEX_DESC: &str = "MTLVertexDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ATTRIBUTES: &str = "attributes\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_LAYOUTS: &str = "layouts\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FORMAT: &str = "setFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_OFFSET: &str = "setOffset:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BUFFER_INDEX: &str = "setBufferIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STRIDE: &str = "setStride:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STEP_FUNCTION: &str = "setStepFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STEP_RATE: &str = "setStepRate:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_DESC: &str = "setVertexDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_VERTEX_FORMAT_FLOAT3: usize = 30;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_VERTEX_STEP_PER_VERTEX: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const GPU_DEVICE_APPLE_METAL: &str = "Apple Metal GPU";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ARCHIVE_FILE_PREFIX: &str = "euv-mtl-pipeline-";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ARCHIVE_FILE_SUFFIX: &str = ".metallib.archive";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_R8_UNORM: usize = 10;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_RGBA8_UNORM: usize = 70;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_BGRA8_UNORM: usize = 80;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_LOAD_ACTION_LOAD: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_LOAD_ACTION_CLEAR: usize = 2;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORE_ACTION_STORE: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PRIMITIVE_TYPE_TRIANGLE: usize = 3;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CMD_BUFFER_STATUS_COMPLETED: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_ONE: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_SRC_ALPHA: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: usize = 5;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const OBJC_BLOCK_IS_GLOBAL: i32 = 1 << 28;
#[cfg(target_os = "windows")]
pub(crate) const DLL_D3D12: &[u8] = b"d3d12.dll\0";
#[cfg(target_os = "windows")]
pub(crate) const DLL_D3DCOMPILER: &[u8] = b"d3dcompiler_47.dll\0";
#[cfg(target_os = "windows")]
pub(crate) const SYM_D3D12_CREATE_DEVICE: &[u8] = b"D3D12CreateDevice\0";
#[cfg(target_os = "windows")]
pub(crate) const SYM_D3D_COMPILE: &[u8] = b"D3DCompile\0";
#[cfg(target_os = "linux")]
pub(crate) const LIB_VULKAN_SONAME: &str = "libvulkan.so.1";
#[cfg(target_os = "android")]
pub(crate) const LIB_VULKAN_SONAME: &str = "libvulkan.so";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const SYM_VK_CREATE_INSTANCE: &str = "vkCreateInstance";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const SYM_VK_ENUM_DEVICES: &str = "vkEnumeratePhysicalDevices";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const RTLD_LAZY_GPU: i32 = 1;