New sample renderer and UI (#10)

No changes to simulation
This commit is contained in:
Erin Catto 2026-06-06 10:06:05 -07:00 • committed by GitHub
commit 9e02b7f3b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
196 changed files with 116992 additions and 29969 deletions

0
samples/shaders/.gitkeep Normal file
View file

286
samples/shaders/CLAUDE.md Normal file
View file

@ -0,0 +1,286 @@
# Shaders
This directory contains all GPU shader code for the renderer. Authored in
GLSL, cross-compiled to per-backend variants (HLSL for D3D11, MSL for Metal,
GLSL 410 for desktop GL) by **sokol-shdc**.
Read this file before writing or editing any `.glsl` file. The root
`CLAUDE.md` covers project-wide conventions; this file covers shader-specific
rules that don't apply elsewhere.
## Toolchain
- Author in **GLSL 4.30 core** dialect, with sokol-shdc directives.
- sokol-shdc generates a single C header per shader file, containing the
bytecode/source for every enabled backend plus pipeline reflection.
- Generated headers live in `shaders/generated/` and **are committed**, so a
fresh clone builds without sokol-shdc. `BOX3D_BUILD_SHADERS` (default ON)
recompiles them in place via a CMake custom command; build with it OFF to
use the committed headers and fetch no tooling.
- Shader edits trigger the custom command automatically; run
`cmake --build build --target shaders` to force a rebuild.
Backends configured in `cmake/Shaders.cmake`:
- `hlsl5` for D3D11 (Windows)
- `metal_macos` for Metal (macOS)
- `glsl430` for GL 4.3 core (Linux). 4.3 is the floor sokol_gfx requires
for storage buffers; we use storage buffers for per-instance data.
If sokol-shdc rejects a shader, it's a hard build break - there is no
fallback path. Fix the shader, don't disable a backend.
## File layout
One shader program per `.glsl` file. The filename is the program name.
```
shaders/
CLAUDE.md this file
sky.glsl procedural Preetham sky
common/ shared @include fragments
pbr.glsl PBR helpers (BRDF, IBL evaluation)
preetham.glsl Preetham sky radiance function
xe_gtao_common.glsl XeGTAO helper block (PrefilterDepth,
MainPass, Denoise primitives)
shapes/
cube.glsl instanced cube
sphere.glsl ray-cast sphere impostor
capsule.glsl ray-cast capsule impostor
geom.glsl hulls + meshes + heightfields
edge.glsl per-shape edge overlay
shadow_caster_cube.glsl depth-only shadow caster,
shadow_caster_sphere.glsl per-shape, one per primitive class
shadow_caster_capsule.glsl
shadow_caster_geom.glsl
ibl/ one-time cubemap / LUT builders
sky_to_cube.glsl rasterize sky into a cubemap face
prefilter.glsl GGX prefilter the IBL cubemap
brdf_lut.glsl split-sum integration LUT
post/
depth_only_cube.glsl GTAO/shadow prepass per primitive
depth_only_sphere.glsl class - outputs linear view-Z
depth_only_capsule.glsl
depth_only_geom.glsl
gtao_prefilter_depth.glsl XeGTAO compute
gtao_main_pass.glsl
gtao_denoise.glsl
mask_sphere.glsl hover/select highlight mask,
mask_capsule.glsl uint output, GREATER depth test
mask_hull.glsl
highlight_outline.glsl edge-detect + premult-alpha composite
tonemap.glsl AgX
overlays/
line.glsl shader-expanded lines
point.glsl shader-expanded points
```
Each shader currently inlines its own UBO declarations (`ub_frame`,
`ub_pass`, `ub_draw`) - there is no shared `frame_ubo.glsl` /
`pass_ubo.glsl` block to `@include`. The three shared blocks that do
exist are `common/pbr.glsl`, `common/preetham.glsl`, and
`common/xe_gtao_common.glsl`; the lit shape shaders `@include` PBR and
the sky shaders include Preetham. Shadow-cascade sampling is inlined
per shape shader (`sampleShadowPCF` / `sampleCascade` /
`sampleShadowCascaded` in each of cube/sphere/capsule/geom) - keep
those four implementations in sync if you change the algorithm.
A shader file has, in order:
1. `@ctype` directives mapping GLSL types to C types (mat4 -> Mat4,
vec4 -> Vec4, vec3 -> b3Vec3, vec2 -> b3Vec2).
2. `@include` of any common blocks needed.
3. `@vs` block - vertex stage.
4. `@fs` block - fragment stage.
5. `@program <name> <vs> <fs>` declaration.
Don't put multiple programs in one file. Don't share `@vs` or `@fs` blocks
across programs except via `@include`.
## Naming inside shaders
- Uniform blocks: `ub_frame`, `ub_pass`, `ub_draw`. Lowercase, prefixed `ub_`.
- Samplers: `smp_<purpose>` (e.g. `smp_shadow`, `smp_blue_noise`).
- Textures: `tex_<purpose>` (e.g. `tex_depth`, `tex_normal`, `tex_shadow`).
- Vertex inputs: `in_<name>` (e.g. `in_pos`, `in_normal`, `in_inst_xform0`).
- Varyings (vs->fs): `v_<name>` (e.g. `v_view_pos`, `v_world_normal`).
- Fragment outputs: `out_<name>` (e.g. `out_color`, `out_normal`, `out_id`).
- Locals: `snake_case`. Constants: `SCREAMING_SNAKE_CASE`.
## Uniform organization
Three UBO frequencies, **never** mixed:
```glsl
// ub_frame - updated once per frame, bound at slot 0
layout(binding=0) uniform ub_frame {
mat4 view;
mat4 proj;
mat4 view_proj;
mat4 inv_view_proj;
vec4 camera_pos; // .xyz = pos, .w = time
vec4 viewport; // .xy = size px, .zw = 1/size
vec4 sun_dir; // .xyz = world-space dir TO sun, .w = unused
vec4 sun_color; // .rgb = color * intensity, .a = ambient strength
};
// ub_pass - updated once per render pass, bound at slot 1
layout(binding=1) uniform ub_pass {
// per-pass data: shadow matrices, post-process knobs, etc.
};
// ub_draw - updated per draw call, bound at slot 2
layout(binding=2) uniform ub_draw {
// small per-draw data; instance arrays go in storage buffers, not UBOs
};
```
Per-instance data lives in **storage buffers**, indexed by `gl_InstanceIndex`.
Don't pack instance data into UBOs - they're size-limited and the wrong tool.
A UBO declared at `binding=N` is **stage-specific** in sokol-shdc - declaring
the same UBO in both `@vs` and `@fs` collides. Place each UBO in the stage
that reads it; if a value is needed in both stages, either replicate it at
a different binding, precompute on the C side and split into VS/FS-only
UBOs, or pass via a varying. The three-tier scheme above describes update
frequencies, not a guarantee that every shader exposes all three to both
stages.
## Coordinate spaces
Be explicit about which space a value lives in. Suffix variable names:
`*_world`, `*_view`, `*_clip`, `*_ndc`, `*_screen`. Mixing spaces silently
is the single most common shader bug.
- **Reverse-Z**: clip-space Z is 1 at near, 0 at far. Depth comparison is
`GREATER`. Far-plane clears to 0, not 1.
- **View space**: right-handed, Y-up, Z out of screen (camera looks down -Z).
- **NDC**: `[-1, 1]` for X and Y; Z is `[0, 1]` (reverse-Z).
- **UV**: `[0, 1]`, top-left origin in sampling. sokol-shdc handles the
GL/D3D/Metal Y-flip difference automatically when sampling render targets;
don't flip manually.
When reconstructing world position from depth, sample reverse-Z and
transform through `inv_view_proj` (declared in the per-shader UBO that
needs it - see `sky.glsl`, `overlays/line.glsl`, the lit shape
shaders). There is no shared math helper for this - it's inlined where
needed.
## Flat shading
Compute view-space normal from `dFdx`/`dFdy` of view-space position:
```glsl
vec3 dx = dFdx(v_view_pos);
vec3 dy = dFdy(v_view_pos);
vec3 n_view = normalize(cross(dx, dy));
```
This works for any triangle mesh and gives free flat shading without
duplicating vertices. Impostors compute their analytic normal directly
and skip this.
Do **not** pass per-vertex normals as varyings unless the shape needs
smooth shading (which, in this renderer, none of them do).
## Impostor shaders
Sphere and capsule impostors all follow the same structure:
1. Vertex shader emits a bounding proxy (cube for spheres, OBB for capsules).
2. Fragment shader reconstructs the view ray from `gl_FragCoord` and
`inv_view_proj`.
3. Ray-cast against the analytic primitive in **world space** (not view
space - keeps the math simpler when transforming ray origins).
4. On miss: `discard`.
5. On hit: write `gl_FragDepth` from the hit point in clip space, output
the analytic surface normal in view space.
Reference math: Inigo Quilez, https://iquilezles.org/articles/intersectors/.
`gl_FragDepth` writes disable early-Z. That's fine for impostors but it
means the impostor pipelines don't get the hi-Z optimization. Don't write
`gl_FragDepth` from triangle-mesh shaders - let the rasterizer do it.
When writing `gl_FragDepth`, write the **reverse-Z** value (1 at near,
0 at far). The impostor shaders show the pattern: compute clip-space Z
from a world-space hit point via the view-proj matrix, then
`gl_FragDepth = clip.z / clip.w`.
## Shadow sampling
The four lit shape shaders (`cube.glsl`, `sphere.glsl`, `capsule.glsl`,
`geom.glsl`) each inline their own `sampleShadowPCF` /
`sampleCascade` / `sampleShadowCascaded` functions. They read
`cascade_matrices[3]`, `cascade_far_view_z`, and the shadow-atlas
sampler from the per-shape UBO + per-pass binding. The four
implementations are intentionally identical - if you change the
algorithm (kernel, bias formula, cascade-blend logic), update all four
at once. A future cleanup would lift them into a shared
`common/shadow.glsl` block; until then, treat the four copies as one
unit.
Don't sample shadow maps from any other shader without going through
the same helper trio - non-standard sample patterns (PCSS,
contact-hardening) belong inside `sampleShadowPCF` behind a flag, not
forked into new call sites.
## Things to NOT do
- Don't use `#ifdef <BACKEND>` to branch on backend. sokol-shdc handles
cross-compilation; backend-specific shader code means we've lost.
- Don't sample a depth target with a regular sampler when you need raw
depth values. Use the depth-specific sampler binding declared in the
pass - drivers compare-sample by default on depth textures otherwise.
- Don't use derivatives (`dFdx`/`dFdy`/`fwidth`) in non-uniform control
flow. They produce undefined results inside `if`/`discard` branches.
Compute derivatives at top level, then branch.
- Don't write to `gl_FragDepth` conditionally (some pixels write, others
don't). Either every pixel writes it or none do - otherwise the early-Z
decision is per-draw, not per-pixel, and you get the worst of both.
- Don't use `texture()` without an explicit LOD in fragment shaders that
contain `discard` or `gl_FragDepth` writes after the sample. The
derivative for mipmap selection becomes undefined. Use `textureLod()`
with LOD 0 if mipmapping isn't needed.
- Don't pack different update frequencies into one UBO. Use the three-tier
scheme above.
- Don't store full 4x4 instance transforms. 3x4 affine; the bottom row is
always `(0, 0, 0, 1)` and we don't need perspective from instance data.
- Don't encode normals as `vec3` in storage buffers if you're tight on
bandwidth - octahedral encoding to two `f16`s saves the byte. There's
no shared helper yet; if a second use case comes up, lift it into
`common/`. Don't do this preemptively; profile first.
- Don't write debug colors (red for "this branch ran") and leave them in.
Use the debug view-mode mechanism instead - it's a uniform switch, not
edited shader code.
- Don't add new uniform blocks without updating the C-side reflection.
sokol-shdc generates `_uniformblock_size()` and `_uniformblock_slot()`
helpers; use them, don't hardcode sizes or slot indices.
## Debugging shaders
- The **debug view-modes** machinery is controlled by
`fi.debug_view_mode` and runtime keys 0-6. A single uniform selects:
lit, view-space distance, CSM cascade index, view-space normal, raw
GTAO AO. This is faster than RenderDoc for 90% of issues.
- Use **RenderDoc** on Linux/Windows or **Xcode GPU frame capture** on
macOS for the other 10%. Both work with sokol's backends.
- When a shader looks wrong, check coordinate spaces first, depth
reverse-Z second, derivatives in branches third. In that order.
- sokol's validation layer catches most binding mistakes. If something
renders black, check the validation log before reading shader code.
## When adding a new shader
1. Decide which file it belongs in (or create a new one if it's a new
pipeline). One program per file.
2. Add `@ctype` directives matching the C-side struct layouts.
3. Pick the right UBO tier for each uniform - frame, pass, or draw.
4. Author the shader; build with `cmake --build build --target shaders`
and watch sokol-shdc output for warnings (it's strict, that's good).
5. Make sure at least one scene in `main.cpp`'s `k_sceneTable` exercises
the new pipeline - the smoke test cycles every scene, so a scene
that touches the shader is render3d's regression net for sokol
validation errors. If no existing scene covers it, add a new
`src/app/*_scene.{cpp,h}` (mirror the `pbr_scene` / `gtao_scene`
pattern) and wire it through `SceneKind`.
6. Update this file if the shader introduces a new convention worth
documenting.

View file

@ -0,0 +1,140 @@
# Shader compilation via sokol-shdc.
# Each .glsl file in shaders/ becomes a single C header in
# generated/<name>.glsl.h that holds source/bytecode for every enabled backend
# (D3D11, Metal, GL 4.5 core). The generated headers are committed so a fresh
# clone builds without sokol-shdc. BOX3D_BUILD_SHADERS (default ON) recompiles
# them in place when a .glsl changes; off builds straight from the committed
# headers and fetches no tooling.
set(SHADER_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated"
CACHE INTERNAL "Directory holding generated shader headers")
if(BOX3D_BUILD_SHADERS)
if(NOT SOKOL_SHDC_EXECUTABLE OR NOT EXISTS "${SOKOL_SHDC_EXECUTABLE}")
message(FATAL_ERROR
"SOKOL_SHDC_EXECUTABLE is not set or does not exist: "
"${SOKOL_SHDC_EXECUTABLE}")
endif()
file(MAKE_DIRECTORY "${SHADER_OUTPUT_DIR}")
# Shared @include fragments - sokol-shdc's @include resolves relative to
# the input file, so shaders include these via "../common/<name>.glsl".
# Tracked as DEPENDS on every shader so an edit to a shared file triggers
# a rebuild of everything that might include it, and listed in the shaders
# target's SOURCES so they show up in IDE project trees - sokol-shdc never
# sees them as direct inputs, so they would be invisible otherwise.
# CONFIGURE_DEPENDS re-globs when a new common file appears, at the cost of
# a configure-step stat each build.
file(GLOB SHADER_COMMON_INCLUDES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/common/*.glsl")
endif()
# Reset the accumulators on every configure so stale entries from a prior
# `cmake --fresh`-skipped run don't carry over.
set_property(GLOBAL PROPERTY SHADER_OUTPUTS "")
set_property(GLOBAL PROPERTY SHADER_INPUTS "")
# Backends: hlsl5 (D3D11), metal_macos (Metal), glsl430 (GL 4.5).
set(SHADER_LANGUAGES "hlsl5:metal_macos:glsl430")
# Registers a custom_command per .glsl input so only changed shaders re-run
# sokol-shdc on incremental builds. Skipped when BOX3D_BUILD_SHADERS is off -
# the committed header stands in for the input then. Either way the output
# path is recorded for the include dir and the IDE source list. After every
# shader is declared the trailing block produces the `shaders` target (the
# build entry point) and the `shaders` INTERFACE library consumers link to.
function(add_shader name input)
if(NOT IS_ABSOLUTE "${input}")
set(input "${CMAKE_CURRENT_SOURCE_DIR}/${input}")
endif()
set(output "${SHADER_OUTPUT_DIR}/${name}.glsl.h")
if(BOX3D_BUILD_SHADERS)
add_custom_command(
OUTPUT "${output}"
COMMAND "${SOKOL_SHDC_EXECUTABLE}"
--input "${input}"
--output "${output}"
--slang "${SHADER_LANGUAGES}"
# --reflection
DEPENDS "${input}" ${SHADER_COMMON_INCLUDES}
COMMENT "sokol-shdc ${name}.glsl"
VERBATIM
)
set_source_files_properties("${output}" PROPERTIES GENERATED TRUE)
endif()
set_property(GLOBAL APPEND PROPERTY SHADER_OUTPUTS "${output}")
set_property(GLOBAL APPEND PROPERTY SHADER_INPUTS "${input}")
endfunction()
# shapes
add_shader(cube "shapes/cube.glsl")
add_shader(sphere "shapes/sphere.glsl")
add_shader(capsule "shapes/capsule.glsl")
add_shader(geom "shapes/geom.glsl")
add_shader(edge "shapes/edge.glsl")
add_shader(shadow_caster_cube "shapes/shadow_caster_cube.glsl")
add_shader(shadow_caster_geom "shapes/shadow_caster_geom.glsl")
add_shader(shadow_caster_sphere "shapes/shadow_caster_sphere.glsl")
add_shader(shadow_caster_capsule "shapes/shadow_caster_capsule.glsl")
# ibl
add_shader(sky "ibl/sky.glsl")
add_shader(brdf_lut "ibl/brdf_lut.glsl")
add_shader(sky_to_cube "ibl/sky_to_cube.glsl")
add_shader(prefilter "ibl/prefilter.glsl")
# post
add_shader(depth_only_cube "post/depth_only_cube.glsl")
add_shader(depth_only_sphere "post/depth_only_sphere.glsl")
add_shader(depth_only_capsule "post/depth_only_capsule.glsl")
add_shader(depth_only_geom "post/depth_only_geom.glsl")
add_shader(gtao_prefilter_depth "post/gtao_prefilter_depth.glsl")
add_shader(gtao_main_pass "post/gtao_main_pass.glsl")
add_shader(gtao_denoise "post/gtao_denoise.glsl")
add_shader(tonemap "post/tonemap.glsl")
add_shader(mask_sphere "post/mask_sphere.glsl")
add_shader(mask_capsule "post/mask_capsule.glsl")
add_shader(mask_hull "post/mask_hull.glsl")
add_shader(highlight_outline "post/highlight_outline.glsl")
# overlay
add_shader(overlay_line "overlays/line.glsl")
add_shader(overlay_point "overlays/point.glsl")
get_property(_outputs GLOBAL PROPERTY SHADER_OUTPUTS)
get_property(_inputs GLOBAL PROPERTY SHADER_INPUTS)
if(BOX3D_BUILD_SHADERS)
# DEPENDS drives the build (run sokol-shdc when the .glsl inputs change).
# SOURCES is purely an IDE hint - Visual Studio and Xcode show listed files
# in the project tree even though nothing here is compiled. We list the leaf
# .glsl shaders, the common/ @include fragments, and the generated .glsl.h.
add_custom_target(shaders
DEPENDS ${_outputs}
SOURCES ${_inputs} ${SHADER_COMMON_INCLUDES} ${_outputs}
)
# IDE grouping. TREE mirrors the on-disk shaders layout.
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}"
FILES ${_inputs} ${SHADER_COMMON_INCLUDES})
source_group("Generated" FILES ${_outputs})
# The Visual Studio generator emits a build-stamp file named
# CMakeFiles/<target> for each custom target. Left ungrouped it floats at
# the project root as a stray "shaders" node with a can't-find-file icon -
# file it under the build-rule machinery.
source_group("CMake Rules" FILES "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/shaders")
else()
# No codegen: the samples build straight from the committed headers.
add_custom_target(shaders SOURCES ${_inputs} ${_outputs})
endif()
# shader_gen is the INTERFACE library consumers link to. It forwards the include
# path for the generated headers (SYSTEM so /WX doesn't trip on shdc output) and
# pulls in the shaders target so any link forces the headers to exist first.
add_library(shader_gen INTERFACE)
add_dependencies(shader_gen shaders)
target_include_directories(shader_gen SYSTEM INTERFACE "${SHADER_OUTPUT_DIR}")

View file

@ -0,0 +1,238 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Shared PBR helpers, included via `@include../common/pbr.glsl` by each
// lit shape shader (cube, sphere, capsule, geom).
//
// brdf_evaluate: a subset of Disney/Principled. GGX (Trowbridge-Reitz)
// NDF, Smith correlated geometry, Schlick Fresnel, Lambert diffuse. No
// subsurface, transmission, clearcoat, sheen, anisotropy. References:
// Walter et al. 2007, Karis 2013 (UE4), Heitz 2014.
//
// proceduralGrid: fwidth-antialiased two-tier grid pattern over world-space
// XZ. Used by the geom pipeline when v_material.z selects the ground
// material. Designed to feed straight into brdf_evaluate as baseColor.
//
// Callers pick the coordinate space. N, V, L must all be in the same
// space. n.l, n.v, n.h are rotation-invariant. The cube shader uses view
// space (its dFdx/dFdy normal can't safely cross to world on D3D11, see
// cube.glsl), every other lit shader uses world space.
const float PBR_PI = 3.14159265358979323846;
float pbrDistributionGGX(float n_dot_h, float alpha)
{
float a2 = alpha * alpha;
float d = (n_dot_h * n_dot_h) * (a2 - 1.0) + 1.0;
return a2 / (PBR_PI * d * d);
}
// Smith correlated G, Heitz 2014.
float pbrVisibilitySmithCorrelated(float n_dot_v, float n_dot_l, float alpha)
{
float a2 = alpha * alpha;
float vv = n_dot_l * sqrt(n_dot_v * n_dot_v * (1.0 - a2) + a2);
float vl = n_dot_v * sqrt(n_dot_l * n_dot_l * (1.0 - a2) + a2);
return 0.5 / (vv + vl + 1e-5);
}
vec3 pbrFresnelSchlick(float v_dot_h, vec3 f0)
{
float t = 1.0 - v_dot_h;
float t2 = t * t;
return f0 + (vec3(1.0) - f0) * (t2 * t2 * t);
}
// Direct sun lighting only. sun_radiance is sun_color.rgb premultiplied
// by the shadow factor so the caller's existing shadow path is unchanged.
// Ambient is split out into pbrEvaluateIbl below, callers compose
// direct + ibl_ambient.
vec3 brdf_evaluate(vec3 N, vec3 V, vec3 L, vec3 sun_radiance,
vec3 base_color, float metallic, float roughness)
{
float n_dot_l = max(dot(N, L), 0.0);
float n_dot_v = max(dot(N, V), 1e-4);
vec3 H = normalize(V + L);
float n_dot_h = max(dot(N, H), 0.0);
float v_dot_h = max(dot(V, H), 0.0);
// Perceptual roughness -> roughness alpha (Karis). The 0.045 floor
// keeps the specular highlight from collapsing to a singular point
// at roughness 0, which causes hot-pixel sparkle under MSAA.
float perc = max(roughness, 0.045);
float alpha = perc * perc;
vec3 f0 = mix(vec3(0.04), base_color, metallic);
float D = pbrDistributionGGX(n_dot_h, alpha);
float Vis = pbrVisibilitySmithCorrelated(n_dot_v, n_dot_l, alpha);
vec3 F = pbrFresnelSchlick(v_dot_h, f0);
vec3 specular = D * Vis * F;
vec3 diffuse = (vec3(1.0) - F) * (1.0 - metallic) * base_color / PBR_PI;
return (diffuse + specular) * sun_radiance * n_dot_l;
}
// Evaluate band-0..2 SH at world-space direction N. The stored
// coefficients (sh[0..8].xyz) are already pre-multiplied with the
// Funk-Hecke / Ramamoorthi diffuse convolution weights, so this returns
// irradiance E(N) directly. Pre-multiply convention is fixed C-side in
// projectSkyToSh, the shader just dots against the SH basis.
//
// Index order matches Sloan / Ramamoorthi:
// 0 = (l=0,m= 0)
// 1 = (l=1,m=-1) 2 = (l=1,m= 0) 3 = (l=1,m=+1)
// 4 = (l=2,m=-2) 5 = (l=2,m=-1) 6 = (l=2,m= 0) 7 = (l=2,m=+1) 8 = (l=2,m=+2).
vec3 pbrEvaluateShIrradiance(vec3 N, vec4 sh[9])
{
const float Y00 = 0.282094791773878;
const float Y1n1 = 0.488602511902919;
const float Y10 = 0.488602511902919;
const float Y1p1 = 0.488602511902919;
const float Y2n2 = 1.092548430592079;
const float Y2n1 = 1.092548430592079;
const float Y20 = 0.315391565252520;
const float Y2p1 = 1.092548430592079;
const float Y2p2 = 0.546274215296039;
float b0 = Y00;
float b1 = -Y1n1 * N.y;
float b2 = Y10 * N.z;
float b3 = -Y1p1 * N.x;
float b4 = Y2n2 * N.x * N.y;
float b5 = -Y2n1 * N.y * N.z;
float b6 = Y20 * (3.0 * N.z * N.z - 1.0);
float b7 = -Y2p1 * N.x * N.z;
float b8 = Y2p2 * (N.x * N.x - N.y * N.y);
return sh[0].xyz * b0
+ sh[1].xyz * b1 + sh[2].xyz * b2 + sh[3].xyz * b3
+ sh[4].xyz * b4 + sh[5].xyz * b5 + sh[6].xyz * b6
+ sh[7].xyz * b7 + sh[8].xyz * b8;
}
// IBL ambient: SH diffuse + GGX prefilter specular via Karis split-sum.
// Returns the ambient RGB to add to the direct lighting term. N_world
// and V_world must be in world space (the cube shader transforms its
// view-space normal here before calling).
//
// Fresnel-roughness compensates the diffuse fraction at grazing angles
// for rough surfaces, Lagarde 2014. F0_max = max(1-roughness, F0) lets
// dielectrics stay bright even when roughness is high.
vec3 pbrEvaluateIbl(vec3 N_world, vec3 V_world, vec3 base_color, float metallic,
float roughness, vec4 sh[9],
textureCube tex_spec_cube, sampler smp_spec_cube,
texture2D tex_brdf_lut, sampler smp_brdf_lut,
float max_lod)
{
// Clamp upper bound too: impostor n_world (sphere/capsule) comes from
// (hit - center) / radius and isn't explicitly normalized, so float
// drift can push |n_world| slightly above 1 and n_dot_v above 1. Then
// 1.0 - n_dot_v < 0 and pow(negative, 5.0) is undefined per GLSL spec
// (NVIDIA returns NaN), which propagates through F and renders as
// isolated black pixels on the surface.
float n_dot_v = clamp(dot(N_world, V_world), 1e-4, 1.0);
vec3 R = reflect(-V_world, N_world);
vec3 F0 = mix(vec3(0.04), base_color, metallic);
vec3 F0m = max(vec3(1.0 - roughness), F0);
// max(0, ...) is a no-op given the n_dot_v clamp above, but the HLSL
// cross-compile loses the range info and warns about pow(negative, n)
// (X3571) without it.
vec3 F = F0 + (F0m - F0) * pow(max(0.0, 1.0 - n_dot_v), 5.0);
vec3 kS = F;
vec3 kD = (vec3(1.0) - kS) * (1.0 - metallic);
vec3 irradiance = max(pbrEvaluateShIrradiance(N_world, sh), vec3(0.0));
vec3 diffuse = kD * base_color * irradiance / PBR_PI;
float lod = roughness * max_lod;
vec3 prefiltered = textureLod(samplerCube(tex_spec_cube, smp_spec_cube), R, lod).rgb;
vec2 brdf = texture(sampler2D(tex_brdf_lut, smp_brdf_lut),
vec2(n_dot_v, roughness)).rg;
vec3 specular = prefiltered * (F0 * brdf.x + brdf.y);
return diffuse + specular;
}
// Ambient selector. iblEnabled chooses between the image-based ambient
// (pbrEvaluateIbl above) and the legacy flat ambient, base_color *
// flat_strength, that the renderer used. The renderer drives
// iblEnabled from a Render Settings panel toggle so the IBL contribution
// can be A/B'd against the flat term.
//
// The branch is on a uniform: every fragment of every lit draw sees the
// same iblEnabled, so this is uniform control flow and the implicit-LOD
// BRDF-LUT fetch inside pbrEvaluateIbl stays well-defined. Callers pass the
// same N_world/V_world/base_color they would have passed to pbrEvaluateIbl.
vec3 pbrEvaluateAmbient(bool iblEnabled,
vec3 N_world, vec3 V_world,
vec3 base_color, float metallic, float roughness,
float flat_strength,
vec4 sh[9],
textureCube tex_spec_cube, sampler smp_spec_cube,
texture2D tex_brdf_lut, sampler smp_brdf_lut,
float max_lod)
{
// Single result, pre-seeded with the flat-ambient fallback. The early-
// return form `if (iblEnabled) return...; return flat;` cross-
// compiles through SPIRV-Cross into a returned-flag pattern whose return
// temp fxc can't prove definitely-assigned (warning X4000). Seeding the
// result and overwriting it in the one branch sidesteps that. The IBL
// path is still evaluated only when enabled, and the value is bit-
// identical to a direct pbrEvaluateIbl call.
vec3 result = base_color * flat_strength;
if (iblEnabled) {
result = pbrEvaluateIbl(N_world, V_world,
base_color, metallic, roughness,
sh,
tex_spec_cube, smp_spec_cube,
tex_brdf_lut, smp_brdf_lut,
max_lod);
}
return result;
}
// Two-tier antialiased grid:
// * minor lines at `cell_size` cadence, slight darkening
// * major lines every 10 cells, stronger darkening
// `fwidth` of the cell coordinate keeps the line width near 1 screen pixel
// at any distance / viewing angle. Caller passes a flat per-instance
// `cell_size`, the result is suitable as `base_color` for brdf_evaluate.
//
// Derivatives are valid here only because the geom shader calls this
// from a branch on a flat per-instance varying (every fragment in a
// quad of a single draw shares the same materialMode).
vec3 proceduralGrid(vec2 world_xz, vec3 base_color, float cell_size)
{
vec2 coord_minor = world_xz / cell_size;
vec2 d_minor = max(fwidth(coord_minor), vec2(1.0e-6));
vec2 g_minor = abs(fract(coord_minor - 0.5) - 0.5) / d_minor;
float line_minor = 1.0 - clamp(min(g_minor.x, g_minor.y), 0.0, 1.0);
vec2 coord_major = world_xz / (cell_size * 10.0);
vec2 d_major = max(fwidth(coord_major), vec2(1.0e-6));
vec2 g_major = abs(fract(coord_major - 0.5) - 0.5) / d_major;
float line_major = 1.0 - clamp(min(g_major.x, g_major.y), 0.0, 1.0);
vec3 minor_color = base_color * 0.70;
vec3 major_color = base_color * 0.35;
vec3 result = mix(base_color, minor_color, line_minor);
result = mix(result, major_color, line_major);
// Colored axes: red along +X, blue along +Z. Pixel-wide like the grid
// lines, gated to the positive half so the origin reads as a corner.
// Saturated primaries are identical in linear and sRGB, so they need no
// encoding fixup before the BRDF.
vec2 d_axis = max(fwidth(world_xz), vec2(1.0e-6));
float axis_x = (1.0 - clamp(abs(world_xz.y) / d_axis.y, 0.0, 1.0)) * step(0.0, world_xz.x);
float axis_z = (1.0 - clamp(abs(world_xz.x) / d_axis.x, 0.0, 1.0)) * step(0.0, world_xz.y);
result = mix(result, vec3(1.0, 0.0, 0.0), axis_x);
result = mix(result, vec3(0.0, 0.0, 1.0), axis_z);
return result;
}

View file

@ -0,0 +1,146 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Preetham/Shirley/Smits 1999 analytic daylight sky.
//
// preethamSky(view_dir, sun_dir, turbidity) returns linear-sRGB radiance
// for an unoccluded sky direction. Both directions must be unit-length,
// Y is up. Output is unmultiplied, callers apply the luminance scale
// and below-horizon fade themselves, or call preethamSkyScaled which
// does both.
//
// Preetham diverges at and below the horizon. The helper clamps the
// view direction to slightly above the horizon and clamps sun.y to the
// upper hemisphere so the Perez/zenith math stays finite when the sun
// is below the horizon, the caller is responsible for fading output to
// zero in that case.
const float PREETHAM_PI = 3.14159265358979323846;
// Empirical luminance scale, chosen to land near the target ~10:1
// sun:sky ratio under the renderer's sun_color premultiplied-by-pi
// convention. Shared between the sky backdrop (sky.glsl) and the IBL
// sky cubemap (sky_to_cube.glsl) so both consumers see the same sky.
const float PREETHAM_LUMINANCE_SCALE = 0.06;
// Perez luminance distribution:
// F(theta, gamma) = (1 + A * exp(B / cos(theta)))
// * (1 + C * exp(D * gamma) + E * cos^2(gamma))
// theta = view angle from zenith, gamma = view angle from sun direction.
// cos_theta is clamped >= 0.01 to avoid the exp(B / 0) singularity at
// the horizon (Preetham is invalid there anyway).
float preethamPerez(float cos_theta, float cos_gamma, float gamma,
float A, float B, float C, float D, float E)
{
float term1 = 1.0 + A * exp(B / max(cos_theta, 0.01));
float term2 = 1.0 + C * exp(D * gamma) + E * cos_gamma * cos_gamma;
return term1 * term2;
}
// CIE xyY -> XYZ.
vec3 preethamXyY_to_XYZ(float x, float y, float Y)
{
float yy = max(y, 1.0e-5);
return vec3(Y * x / yy, Y, Y * (1.0 - x - y) / yy);
}
// CIE XYZ (D65) -> linear sRGB.
vec3 preethamXYZ_to_linear_srgb(vec3 c)
{
return vec3(
dot(c, vec3(3.2404542, - 1.5371385, - 0.4985314)),
dot(c, vec3(-0.9692660, 1.8760108, 0.0415560)),
dot(c, vec3(0.0556434, - 0.2040259, 1.0572252))
);
}
vec3 preethamSky(vec3 view_dir, vec3 sun_dir, float turbidity)
{
// Clamp sun's elevation to the upper hemisphere so the Perez/zenith
// math stays finite below the horizon. The horizontal components
// sun_dir are intentionally kept unmodified, cos_gamma reads the
// original direction so the sun's azimuth is preserved.
float sun_y = clamp(sun_dir.y, 0.0, 1.0);
// Pin the look-up direction to slightly above the horizon when the
// view points downward. Preetham diverges below the horizon, and
// this gives the sky a sensible colour where the ground would
// otherwise occlude it (e.g. scenes with no ground in the lower
// portion of frame).
vec3 view_clamped = normalize(vec3(view_dir.x, max(view_dir.y, 0.0) + 0.01, view_dir.z));
float cos_theta = max(view_clamped.y, 0.0); // zenith angle of view
float cos_gamma = clamp(dot(sun_dir, view_clamped), - 1.0, 1.0); // sun-to-view angle
float gamma = acos(cos_gamma);
float sun_theta = acos(sun_y);
// Perez coefficients as functions of turbidity T (Preetham table 2)
float T = max(turbidity, 1.0);
float T2 = T * T;
// Y (luminance):
float A_Y = 0.1787 * T - 1.4630;
float B_Y = -0.3554 * T + 0.4275;
float C_Y = -0.0227 * T + 5.3251;
float D_Y = 0.1206 * T - 2.5771;
float E_Y = -0.0670 * T + 0.3703;
// x (chromaticity):
float A_x = -0.0193 * T - 0.2592;
float B_x = -0.0665 * T + 0.0008;
float C_x = -0.0004 * T + 0.2125;
float D_x = -0.0641 * T - 0.8989;
float E_x = -0.0033 * T + 0.0452;
// y (chromaticity):
float A_y = -0.0167 * T - 0.2608;
float B_y = -0.0950 * T + 0.0092;
float C_y = -0.0079 * T + 0.2102;
float D_y = -0.0441 * T - 1.6537;
float E_y = -0.0109 * T + 0.0529;
// Zenith chromaticities (Preetham Eq. A.3, polynomial in T and sun_theta).
float ts = sun_theta;
float ts2 = ts * ts;
float ts3 = ts2 * ts;
float x_z =
(0.00166 * ts3 - 0.00375 * ts2 + 0.00209 * ts) * T2 +
(-0.02903 * ts3 + 0.06377 * ts2 - 0.03202 * ts + 0.00394) * T +
(0.11693 * ts3 - 0.21196 * ts2 + 0.06052 * ts + 0.25886);
float y_z =
(0.00275 * ts3 - 0.00610 * ts2 + 0.00317 * ts) * T2 +
(-0.04214 * ts3 + 0.08970 * ts2 - 0.04153 * ts + 0.00516) * T +
(0.15346 * ts3 - 0.26756 * ts2 + 0.06670 * ts + 0.26688);
// Zenith luminance (Preetham Eq. A.2). Result in kcd/m^2.
float chi = (4.0 / 9.0 - T / 120.0) * (PREETHAM_PI - 2.0 * sun_theta);
float Y_z = (4.0453 * T - 4.9710) * tan(chi) - 0.2155 * T + 2.4192;
// Normalize: F(theta=0, gamma=sun_theta) at zenith equals zenith
// values, so divide by perez(zenith) and multiply by perez(view).
float cos_zen_gamma = sun_y; // dot(zenith, sun_dir) = sun_dir.y
float pY_v = preethamPerez(cos_theta, cos_gamma, gamma, A_Y, B_Y, C_Y, D_Y, E_Y);
float px_v = preethamPerez(cos_theta, cos_gamma, gamma, A_x, B_x, C_x, D_x, E_x);
float py_v = preethamPerez(cos_theta, cos_gamma, gamma, A_y, B_y, C_y, D_y, E_y);
float pY_z = preethamPerez(1.0, cos_zen_gamma, sun_theta, A_Y, B_Y, C_Y, D_Y, E_Y);
float px_z = preethamPerez(1.0, cos_zen_gamma, sun_theta, A_x, B_x, C_x, D_x, E_x);
float py_z = preethamPerez(1.0, cos_zen_gamma, sun_theta, A_y, B_y, C_y, D_y, E_y);
float Y = max(Y_z * pY_v / max(pY_z, 1.0e-5), 0.0);
float x = x_z * px_v / max(px_z, 1.0e-5);
float y = y_z * py_v / max(py_z, 1.0e-5);
vec3 XYZ = preethamXyY_to_XYZ(x, y, Y);
vec3 rgb = preethamXYZ_to_linear_srgb(XYZ);
return max(rgb, vec3(0.0));
}
// Convenience wrapper: raw Preetham scaled by the empirical luminance
// factor and the caller's below-horizon fade weight (1 above horizon,
// 0 below). The sky backdrop shader and the IBL sky cubemap both call
// this so they're guaranteed to agree pixel-for-pixel.
vec3 preethamSkyScaled(vec3 view_dir, vec3 sun_dir, float turbidity, float fade)
{
return preethamSky(view_dir, sun_dir, turbidity) * PREETHAM_LUMINANCE_SCALE * fade;
}

View file

@ -0,0 +1,192 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// XeGTAO helper functions shared between the GTAO compute shaders
// (MainPass, Denoise). Ported from Esoterica HLSL with the following
// GLSL adaptations:
//
// * lpfloat collapses to float (XE_GTAO_USE_HALF_FLOAT_PRECISION=0,
// XE_GTAO_FP32_DEPTHS=1, matches Esoterica's config).
// * HLSL `out` parameters become inout where needed.
// * `mul(matrix, vec)` is rewritten as `matrix * vec` and column-major
// conventions are preserved.
// * Functions that took a `Texture2D<float>` / `SamplerState` /
// `RWTexture2D<float>` parameter in HLSL cannot be cleanly expressed
// in cross-compiled GLSL. Those functions (XeGTAO_MainPass,
// XeGTAO_ComputeViewspaceNormal, XeGTAO_OutputWorkingTerm,
// XeGTAO_Denoise) are inlined into the consuming shader and reference
// its texture/image bindings directly. This file holds only the pure
// helpers.
// * GTAOConsts is a plain struct populated once per dispatch from the
// ub_gtao UBO. Each consumer constructs a GTAOConsts in main and
// passes it down to the helpers below. The struct is a strict subset
// of Esoterica's `GTAOConstants`, only the fields the helpers
// actually read are carried, so each consuming shader's ub_gtao only
// needs to declare those (plus whatever else its own main reads
// directly).
//
// Include via `@include xe_gtao_common.glsl` inside the consumer's @cs
// block. The consumer is responsible for declaring the ub_gtao UBO with
// the fields its main reads.
const float XE_GTAO_PI = 3.1415926535897932384626433832795;
const float XE_GTAO_PI_HALF = 1.5707963267948966192313216916398;
// Esoterica's XE_GTAO_OCCLUSION_TERM_SCALE, applied by
// XeGTAO_OutputWorkingTerm (divides) and the denoise finalApply
// (multiplies). Keeps the noisy occlusion-term in [0,1] for storage,
// rescaled to ~[0,1.5] for the final lit lookup.
const float XE_GTAO_OCCLUSION_TERM_SCALE = 1.5;
// XE_GTAO_DEPTH_MIP_LEVELS = 5, the prefiltered depth chain has 5 mips
// (mip 0..4). MainPass clamps the computed sample mip to [0, 5).
const float XE_GTAO_DEPTH_MIP_LEVELS = 5.0;
// HilbertIndex parameters, XE_HILBERT_LEVEL = 6U, width 64.
const uint XE_HILBERT_WIDTH = 64u;
struct GTAOConsts
{
vec2 ViewportPixelSize;
vec2 NDCToViewMul;
vec2 NDCToViewAdd;
vec2 NDCToViewMul_x_PixelSize;
float EffectRadius;
float EffectFalloffRange;
float RadiusMultiplier;
float FinalValuePower;
float SampleDistributionPower;
float ThinOccluderCompensation;
float DepthMIPSamplingOffset;
float SliceCount;
float StepsPerSlice;
};
// http://h14s.p5r.org/2012/09/0x5f3759df.html via XeGTAO.esh:184-187.
// Bit-cast through floatBitsToInt / intBitsToFloat for the GLSL idiom.
float XeGTAO_FastSqrt(float x)
{
return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(x) >> 1));
}
// Lagarde 2014 approximation, input [-1, 1], output [0, PI]. XeGTAO.esh:189.
float XeGTAO_FastACos(float inX)
{
float x = abs(inX);
float res = -0.156583 * x + XE_GTAO_PI_HALF;
res *= XeGTAO_FastSqrt(1.0 - x);
return (inX >= 0.0) ? res : (XE_GTAO_PI - res);
}
// Clamp depth into fp32-finite range. XeGTAO.esh:648-655.
float XeGTAO_ClampDepth(float depth)
{
return clamp(depth, 0.0, 3.402823466e+38);
}
// Pass-through: our input depth is already positive linear view-Z, so the
// "screen-space -> view-space" linearize step is the identity. Kept for
// signature parity with XeGTAO.esh:117-123 so ports of MainPass and
// ComputeViewspaceNormal stay verbatim.
float XeGTAO_ScreenSpaceToViewSpaceDepth(float screenDepth, GTAOConsts consts)
{
return screenDepth;
}
// XeGTAO.esh:104-115 with the Esoterica reverse-Z patch (negate Z so it
// points OUT of the screen in view space). render3d's view space is
// also right-handed Y-up with camera looking down -Z, matching Esoterica.
vec3 XeGTAO_ComputeViewspacePosition(vec2 screenPos, float viewspaceDepth, GTAOConsts consts) {
vec3 ret;
ret.xy = (consts.NDCToViewMul * screenPos + consts.NDCToViewAdd) * viewspaceDepth;
ret.z = -viewspaceDepth;
return ret;
}
// XeGTAO.esh:125-134. Output is in [0,1] per channel, 0 = strong edge,
// 1 = no edge. Used by both the edges-output (PackEdges) and the
// normal-from-depth pass (CalculateNormal).
vec4 XeGTAO_CalculateEdges(float centerZ, float leftZ, float rightZ, float topZ, float bottomZ)
{
vec4 edgesLRTB = vec4(leftZ, rightZ, topZ, bottomZ) - centerZ;
float slopeLR = (edgesLRTB.y - edgesLRTB.x) * 0.5;
float slopeTB = (edgesLRTB.w - edgesLRTB.z) * 0.5;
vec4 edgesLRTBSlopeAdjusted = edgesLRTB + vec4(slopeLR, - slopeLR, slopeTB, - slopeTB);
edgesLRTB = min(abs(edgesLRTB), abs(edgesLRTBSlopeAdjusted));
return vec4(clamp((1.25 - edgesLRTB / (centerZ * 0.011)), 0.0, 1.0));
}
// XeGTAO.esh:137-146. Packs 4 edge gradients (2 bits each) into a single
// UNORM8 channel. The dot-product form matches the reference, rounding
// happens before the dot so the four bins are { 0, 64, 128, 192 } / 255.
float XeGTAO_PackEdges(vec4 edgesLRTB)
{
edgesLRTB = round(clamp(edgesLRTB, 0.0, 1.0) * 2.9);
return dot(edgesLRTB, vec4(64.0 / 255.0, 16.0 / 255.0, 4.0 / 255.0, 1.0 / 255.0));
}
// XeGTAO.esh:727-737. Reverse of PackEdges. Used by Denoise.
vec4 XeGTAO_UnpackEdges(float packed_val)
{
uint p = uint(packed_val * 255.5);
vec4 edgesLRTB;
edgesLRTB.x = float((p >> 6)& 0x03u) / 3.0;
edgesLRTB.y = float((p >> 4)& 0x03u) / 3.0;
edgesLRTB.z = float((p >> 2)& 0x03u) / 3.0;
edgesLRTB.w = float((p >> 0)& 0x03u) / 3.0;
return clamp(edgesLRTB, 0.0, 1.0);
}
// XeGTAO.esh:148-173 with the Esoterica reverse-Z cross-product reorder
// (cross args swapped to keep the winding consistent with view space
// pointing OUT of the screen).
vec3 XeGTAO_CalculateNormal(vec4 edgesLRTB, vec3 pixCenterPos,
vec3 pixLPos, vec3 pixRPos, vec3 pixTPos, vec3 pixBPos)
{
vec4 acceptedNormals = clamp(vec4(
edgesLRTB.x * edgesLRTB.z,
edgesLRTB.z * edgesLRTB.y,
edgesLRTB.y * edgesLRTB.w,
edgesLRTB.w * edgesLRTB.x) + 0.01, 0.0, 1.0);
pixLPos = normalize(pixLPos - pixCenterPos);
pixRPos = normalize(pixRPos - pixCenterPos);
pixTPos = normalize(pixTPos - pixCenterPos);
pixBPos = normalize(pixBPos - pixCenterPos);
vec3 pixelNormal = acceptedNormals.x * cross(pixTPos, pixLPos)
+ acceptedNormals.y * cross(pixRPos, pixTPos)
+ acceptedNormals.z * cross(pixBPos, pixRPos)
+ acceptedNormals.w * cross(pixLPos, pixBPos);
return normalize(pixelNormal);
}
// XeGTAO_Types.esh:120-142. Hilbert curve index for a 64x64 tile
// pixCoord (pixCoord & 63). Combined with the R2 sequence in the
// consumer's SpatioTemporalNoise to produce blue-noise-like spatial
// distribution. No LUT, generated in-shader, matches Esoterica's
// `#ifndef XE_GTAO_HILBERT_LUT_AVAILABLE` branch.
uint HilbertIndex(uint posX, uint posY)
{
uint index = 0u;
for (uint curLevel = XE_HILBERT_WIDTH / 2u; curLevel > 0u; curLevel /= 2u)
{
uint regionX = (posX & curLevel) > 0u ? 1u : 0u;
uint regionY = (posY & curLevel) > 0u ? 1u : 0u;
index += curLevel * curLevel * ((3u * regionX)^ regionY);
if (regionY == 0u)
{
if (regionX == 1u)
{
posX = (XE_HILBERT_WIDTH - 1u) - posX;
posY = (XE_HILBERT_WIDTH - 1u) - posY;
}
uint temp = posX;
posX = posY;
posY = temp;
}
}
return index;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,626 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/post/depth_only_cube.glsl --output E:/box/box3d/samples/shaders/generated/depth_only_cube.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'prog':
Get shader desc: depth_only_cube_prog_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_depth_only_cube_prog_in_pos => 0
Bindings:
Uniform block 'ub_frame':
C struct: depth_only_cube_ub_frame_t
Bind slot: UB_depth_only_cube_ub_frame => 0
Storage buffer 'cube_instances':
C struct: depth_only_cube_cube_instance_t
Bind slot: VIEW_depth_only_cube_cube_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before depth_only_cube.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_depth_only_cube_prog_in_pos (0)
#define UB_depth_only_cube_ub_frame (0)
#define VIEW_depth_only_cube_cube_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_cube_ub_frame_t {
Mat4 view_proj;
Mat4 view;
} depth_only_cube_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_cube_cube_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 material;
} depth_only_cube_cube_instance_t;
#pragma pack(pop)
/*
#version 430
struct cube_instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 material;
};
layout(binding = 0, std430) readonly buffer cube_instances
{
cube_instance instances[];
} _15;
uniform vec4 ub_frame[8];
layout(location = 0) in vec3 in_pos;
layout(location = 0) out float v_linear_view_z;
void main()
{
vec4 _48 = vec4(in_pos, 1.0);
vec4 _76 = vec4(dot(_15.instances[gl_InstanceID].xform_row0, _48), dot(_15.instances[gl_InstanceID].xform_row1, _48), dot(_15.instances[gl_InstanceID].xform_row2, _48), 1.0);
v_linear_view_z = -(mat4(ub_frame[4], ub_frame[5], ub_frame[6], ub_frame[7]) * _76).z;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * _76;
}
*/
static const uint8_t depth_only_cube_vs_source_glsl430[760] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,
0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,
0x20,0x30,0x2c,0x20,0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,
0x6f,0x6e,0x6c,0x79,0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x63,0x75,0x62,0x65,
0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,
0x35,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,
0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,
0x7a,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x34,0x38,0x20,0x3d,
0x20,0x76,0x65,0x63,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x37,0x36,
0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x78,
0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6c,0x69,0x6e,
0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x2d,0x28,0x6d,
0x61,0x74,0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x34,0x5d,0x2c,
0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x35,0x5d,0x2c,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x36,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,
0x61,0x6d,0x65,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x37,0x36,0x29,0x2e,0x7a,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,
0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,
0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,
0x37,0x36,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
layout(location = 0) out vec4 out_linear_depth;
layout(location = 0) in float v_linear_view_z;
void main()
{
out_linear_depth = vec4(v_linear_view_z, 0.0, 0.0, 0.0);
}
*/
static const uint8_t depth_only_cube_fs_source_glsl430[189] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,
0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,
0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct cube_instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_frame : register(b0)
{
row_major float4x4 _68_view_proj : packoffset(c0);
row_major float4x4 _68_view : packoffset(c4);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
static float v_linear_view_z;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float v_linear_view_z : TEXCOORD0;
float4 gl_Position : SV_Position;
};
void vert_main()
{
cube_instance _23;
_23.xform_row0 = asfloat(_15.Load4(gl_InstanceIndex * 80 + 0));
_23.xform_row1 = asfloat(_15.Load4(gl_InstanceIndex * 80 + 16));
_23.xform_row2 = asfloat(_15.Load4(gl_InstanceIndex * 80 + 32));
_23.base_color = asfloat(_15.Load4(gl_InstanceIndex * 80 + 48));
_23.material = asfloat(_15.Load4(gl_InstanceIndex * 80 + 64));
float4 _48 = float4(in_pos, 1.0f);
float4 _76 = float4(dot(_23.xform_row0, _48), dot(_23.xform_row1, _48), dot(_23.xform_row2, _48), 1.0f);
v_linear_view_z = -mul(_76, _68_view).z;
gl_Position = mul(_76, _68_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.v_linear_view_z = v_linear_view_z;
return stage_output;
}
*/
static const uint8_t depth_only_cube_vs_source_hlsl5[1594] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,
0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,
0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,
0x35,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,
0x3b,0x0a,0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,
0x6d,0x65,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,
0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x36,0x38,0x5f,0x76,
0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,
0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,
0x34,0x20,0x5f,0x36,0x38,0x5f,0x76,0x69,0x65,0x77,0x20,0x3a,0x20,0x70,0x61,0x63,
0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x34,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,
0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,
0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,
0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3a,0x20,
0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x63,0x75,0x62,0x65,
0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,0x32,0x33,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,
0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x30,0x29,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x31,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x38,0x30,0x20,
0x2b,0x20,0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,0x61,0x73,0x66,
0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,
0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x32,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x34,0x38,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,
0x61,0x6c,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,
0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x36,
0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x5f,0x34,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x5f,
0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x37,0x36,0x20,0x3d,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,
0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x32,0x33,0x2e,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x34,0x38,0x29,
0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x2d,
0x6d,0x75,0x6c,0x28,0x5f,0x37,0x36,0x2c,0x20,0x5f,0x36,0x38,0x5f,0x76,0x69,0x65,
0x77,0x29,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x5f,0x37,0x36,0x2c,
0x20,0x5f,0x36,0x38,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,
0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,
0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,
0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,
0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,
0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x76,0x5f,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
static float4 out_linear_depth;
static float v_linear_view_z;
struct SPIRV_Cross_Input
{
float v_linear_view_z : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 out_linear_depth : SV_Target0;
};
void frag_main()
{
out_linear_depth = float4(v_linear_view_z, 0.0f, 0.0f, 0.0f);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
v_linear_view_z = stage_input.v_linear_view_z;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.out_linear_depth = out_linear_depth;
return stage_output;
}
*/
static const uint8_t depth_only_cube_fs_source_hlsl5[539] = {
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,
0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x7a,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,
0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,
0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,
0x66,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x7a,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x6f,0x75,0x74,
0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct cube_instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 material;
};
struct cube_instances
{
cube_instance instances[1];
};
struct ub_frame
{
float4x4 view_proj;
float4x4 view;
};
struct main0_out
{
float v_linear_view_z [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _68 [[buffer(0)]], const device cube_instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float4 _48 = float4(in.in_pos, 1.0);
float4 _76 = float4(dot(_15.instances[int(gl_InstanceIndex)].xform_row0, _48), dot(_15.instances[int(gl_InstanceIndex)].xform_row1, _48), dot(_15.instances[int(gl_InstanceIndex)].xform_row2, _48), 1.0);
out.v_linear_view_z = -(_68.view * _76).z;
out.gl_Position = _68.view_proj * _76;
return out;
}
*/
static const uint8_t depth_only_cube_vs_source_metal_macos[1056] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,
0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,
0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,
0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,0x65,0x77,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,0x74,
0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,
0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x66,
0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x36,0x38,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x64,
0x65,0x76,0x69,0x63,0x65,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,
0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x34,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x37,
0x36,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x69,0x6e,0x74,
0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
0x78,0x29,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,
0x5f,0x34,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x78,
0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,
0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x34,0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,0x65,
0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x2d,0x28,0x5f,0x36,
0x38,0x2e,0x76,0x69,0x65,0x77,0x20,0x2a,0x20,0x5f,0x37,0x36,0x29,0x2e,0x7a,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x36,0x38,0x2e,0x76,0x69,0x65,0x77,0x5f,
0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x5f,0x37,0x36,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_linear_depth [[color(0)]];
};
struct main0_in
{
float v_linear_view_z [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.out_linear_depth = float4(in.v_linear_view_z, 0.0, 0.0, 0.0);
return out;
}
*/
static const uint8_t depth_only_cube_fs_source_metal_macos[369] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,
0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x7a,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,
0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,
0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,
0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,
0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,0x20,0x30,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
static inline const sg_shader_desc* depth_only_cube_prog_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_cube_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_cube_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "depth_only_cube_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_cube_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_cube_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "depth_only_cube_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_cube_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)depth_only_cube_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "depth_only_cube_prog_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,693 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/post/depth_only_geom.glsl --output E:/box/box3d/samples/shaders/generated/depth_only_geom.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'prog':
Get shader desc: depth_only_geom_prog_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_depth_only_geom_prog_in_pos => 0
Bindings:
Uniform block 'ub_draw':
C struct: depth_only_geom_ub_draw_t
Bind slot: UB_depth_only_geom_ub_draw => 2
Uniform block 'ub_frame':
C struct: depth_only_geom_ub_frame_t
Bind slot: UB_depth_only_geom_ub_frame => 0
Storage buffer 'instances':
C struct: depth_only_geom_instance_t
Bind slot: VIEW_depth_only_geom_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before depth_only_geom.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_depth_only_geom_prog_in_pos (0)
#define UB_depth_only_geom_ub_draw (2)
#define UB_depth_only_geom_ub_frame (0)
#define VIEW_depth_only_geom_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_geom_ub_draw_t {
int inst_base[4];
} depth_only_geom_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_geom_ub_frame_t {
Mat4 view_proj;
Mat4 view;
} depth_only_geom_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_geom_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 scale;
Vec4 material;
} depth_only_geom_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 scale;
vec4 material;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[8];
layout(location = 0) in vec3 in_pos;
layout(location = 0) out float v_linear_view_z;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
vec4 _68 = vec4(in_pos * _15.items[_30].scale.xyz, 1.0);
vec4 _95 = vec4(dot(_15.items[_30].xform_row0, _68), dot(_15.items[_30].xform_row1, _68), dot(_15.items[_30].xform_row2, _68), 1.0);
v_linear_view_z = -(mat4(ub_frame[4], ub_frame[5], ub_frame[6], ub_frame[7]) * _95).z;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * _95;
}
*/
static const uint8_t depth_only_geom_vs_source_glsl430[812] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x63,0x61,
0x6c,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x6d,0x61,0x74,
0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,0x73,
0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x20,
0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,0x0a,
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,0x75,
0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,
0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,
0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,
0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x30,
0x5d,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x44,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x36,
0x38,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,
0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,
0x2e,0x73,0x63,0x61,0x6c,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x39,0x35,0x20,0x3d,
0x20,0x76,0x65,0x63,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,
0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,
0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,
0x36,0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,
0x20,0x2d,0x28,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x5b,0x34,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x35,0x5d,
0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x36,0x5d,0x2c,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x39,
0x35,0x29,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,
0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,
0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,
0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x5f,0x39,0x35,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
layout(location = 0) out vec4 out_linear_depth;
layout(location = 0) in float v_linear_view_z;
void main()
{
out_linear_depth = vec4(v_linear_view_z, 0.0, 0.0, 0.0);
}
*/
static const uint8_t depth_only_geom_fs_source_glsl430[189] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,
0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,
0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 scale;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _87_view_proj : packoffset(c0);
row_major float4x4 _87_view : packoffset(c4);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
static float v_linear_view_z;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float v_linear_view_z : TEXCOORD0;
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 32));
_33.base_color = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 48));
_33.scale = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 64));
_33.material = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 80));
float4 _68 = float4(in_pos * _33.scale.xyz, 1.0f);
float4 _95 = float4(dot(_33.xform_row0, _68), dot(_33.xform_row1, _68), dot(_33.xform_row2, _68), 1.0f);
v_linear_view_z = -mul(_95, _87_view).z;
gl_Position = mul(_95, _87_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.v_linear_view_z = v_linear_view_z;
return stage_output;
}
*/
static const uint8_t depth_only_geom_vs_source_hlsl5[1880] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x73,0x63,0x61,0x6c,0x65,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,
0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,0x64,
0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,0x63,
0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x32,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,
0x74,0x5f,0x62,0x61,0x73,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,
0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x62,0x75,
0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,0x20,
0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x38,0x37,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,
0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,
0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,
0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x38,0x37,
0x5f,0x76,0x69,0x65,0x77,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,
0x65,0x74,0x28,0x63,0x34,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,
0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,
0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,
0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,
0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,
0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,
0x5f,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,
0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,
0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,
0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,
0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,
0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,
0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,
0x72,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,
0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,
0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,
0x2b,0x20,0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,
0x73,0x63,0x61,0x6c,0x65,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,
0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,
0x20,0x39,0x36,0x20,0x2b,0x20,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x5f,0x33,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,0x3d,0x20,0x61,
0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,
0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,
0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x38,0x30,0x29,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x36,
0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x20,0x2a,0x20,0x5f,0x33,0x33,0x2e,0x73,0x63,0x61,0x6c,0x65,0x2e,0x78,0x79,
0x7a,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x39,0x35,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,
0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,
0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,
0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6c,0x69,0x6e,
0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x2d,0x6d,0x75,
0x6c,0x28,0x5f,0x39,0x35,0x2c,0x20,0x5f,0x38,0x37,0x5f,0x76,0x69,0x65,0x77,0x29,
0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x5f,0x39,0x35,0x2c,0x20,0x5f,
0x38,0x37,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,
0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,
0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,
0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,
0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,
0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,
0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x20,0x3d,0x20,0x76,0x5f,0x6c,0x69,0x6e,
0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
static float4 out_linear_depth;
static float v_linear_view_z;
struct SPIRV_Cross_Input
{
float v_linear_view_z : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 out_linear_depth : SV_Target0;
};
void frag_main()
{
out_linear_depth = float4(v_linear_view_z, 0.0f, 0.0f, 0.0f);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
v_linear_view_z = stage_input.v_linear_view_z;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.out_linear_depth = out_linear_depth;
return stage_output;
}
*/
static const uint8_t depth_only_geom_fs_source_hlsl5[539] = {
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,
0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,
0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x7a,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,
0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,
0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,
0x66,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x7a,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x6f,0x75,0x74,
0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 scale;
float4 material;
};
struct instances
{
instance items[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 view_proj;
float4x4 view;
};
struct main0_out
{
float v_linear_view_z [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _87 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
float4 _68 = float4(in.in_pos * _15.items[_30].scale.xyz, 1.0);
float4 _95 = float4(dot(_15.items[_30].xform_row0, _68), dot(_15.items[_30].xform_row1, _68), dot(_15.items[_30].xform_row2, _68), 1.0);
out.v_linear_view_z = -(_87.view * _95).z;
out.gl_Position = _87.view_proj * _95;
return out;
}
*/
static const uint8_t depth_only_geom_vs_source_metal_macos[1144] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x73,0x63,0x61,0x6c,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,
0x69,0x65,0x77,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,
0x69,0x65,0x77,0x5f,0x7a,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,
0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,
0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,
0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x38,
0x37,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,
0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,
0x77,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,
0x32,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,
0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,
0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,
0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,
0x5f,0x32,0x31,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,
0x2b,0x20,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x5f,0x36,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x28,0x69,0x6e,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x73,0x63,0x61,0x6c,
0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x39,0x35,0x20,0x3d,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,
0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,
0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,
0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,
0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,
0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
0x74,0x2e,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,
0x7a,0x20,0x3d,0x20,0x2d,0x28,0x5f,0x38,0x37,0x2e,0x76,0x69,0x65,0x77,0x20,0x2a,
0x20,0x5f,0x39,0x35,0x29,0x2e,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,
0x38,0x37,0x2e,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x5f,
0x39,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_linear_depth [[color(0)]];
};
struct main0_in
{
float v_linear_view_z [[user(locn0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.out_linear_depth = float4(in.v_linear_view_z, 0.0, 0.0, 0.0);
return out;
}
*/
static const uint8_t depth_only_geom_fs_source_metal_macos[369] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,
0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,
0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x7a,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,
0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,
0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,
0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,
0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x6c,0x69,
0x6e,0x65,0x61,0x72,0x5f,0x76,0x69,0x65,0x77,0x5f,0x7a,0x2c,0x20,0x30,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
static inline const sg_shader_desc* depth_only_geom_prog_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_geom_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_geom_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "depth_only_geom_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_geom_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_geom_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "depth_only_geom_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_geom_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)depth_only_geom_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 128;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "depth_only_geom_prog_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,939 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/post/depth_only_sphere.glsl --output E:/box/box3d/samples/shaders/generated/depth_only_sphere.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'prog':
Get shader desc: depth_only_sphere_prog_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_depth_only_sphere_prog_in_pos => 0
Bindings:
Uniform block 'ub_frame':
C struct: depth_only_sphere_ub_frame_t
Bind slot: UB_depth_only_sphere_ub_frame => 0
Uniform block 'ub_pass':
C struct: depth_only_sphere_ub_pass_t
Bind slot: UB_depth_only_sphere_ub_pass => 1
Storage buffer 'instances':
C struct: depth_only_sphere_instance_t
Bind slot: VIEW_depth_only_sphere_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before depth_only_sphere.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_depth_only_sphere_prog_in_pos (0)
#define UB_depth_only_sphere_ub_frame (0)
#define UB_depth_only_sphere_ub_pass (1)
#define VIEW_depth_only_sphere_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_sphere_ub_frame_t {
Mat4 view_proj;
} depth_only_sphere_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_sphere_ub_pass_t {
Mat4 view_proj;
Mat4 view;
Vec4 camera_pos;
} depth_only_sphere_ub_pass_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct depth_only_sphere_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 params;
Vec4 material;
} depth_only_sphere_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 params;
vec4 material;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
layout(location = 0) sample out vec3 v_world_pos_proxy;
layout(location = 1) flat out vec3 v_center;
layout(location = 2) flat out float v_radius;
void main()
{
vec3 _54 = vec3(_15.items[gl_InstanceID].xform_row0.w, _15.items[gl_InstanceID].xform_row1.w, _15.items[gl_InstanceID].xform_row2.w);
vec3 _68 = _54 + (in_pos * (2.0 * _15.items[gl_InstanceID].params.x));
v_world_pos_proxy = _68;
v_center = _54;
v_radius = _15.items[gl_InstanceID].params.x;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(_68, 1.0);
}
*/
static const uint8_t depth_only_sphere_vs_source_glsl430[876] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x61,0x72,
0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x6d,0x61,
0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,
0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,
0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,
0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x30,0x29,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x6f,0x75,0x74,
0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,
0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x66,0x6c,
0x61,0x74,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x63,0x65,
0x6e,0x74,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,
0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,0x34,0x20,
0x3d,0x20,0x76,0x65,0x63,0x33,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,
0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,0x31,
0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x31,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,0x77,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x38,0x20,0x3d,0x20,0x5f,0x35,0x34,0x20,
0x2b,0x20,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,
0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x70,0x61,0x72,0x61,
0x6d,0x73,0x2e,0x78,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x77,0x6f,
0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,
0x5f,0x36,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,
0x72,0x20,0x3d,0x20,0x5f,0x35,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,
0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,
0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,
0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,
0x72,0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x36,0x38,
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
uniform vec4 ub_pass[9];
layout(location = 0) sample in vec3 v_world_pos_proxy;
layout(location = 1) flat in vec3 v_center;
layout(location = 2) flat in float v_radius;
layout(location = 0) out vec4 out_linear_depth;
void main()
{
vec3 _27 = normalize(v_world_pos_proxy - ub_pass[8].xyz);
vec3 _32 = ub_pass[8].xyz - v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (v_radius * v_radius));
if (_53 < 0.0)
{
discard;
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0)
{
discard;
}
vec4 _88 = vec4(ub_pass[8].xyz + (_27 * _66), 1.0);
vec4 _104 = mat4(ub_pass[0], ub_pass[1], ub_pass[2], ub_pass[3]) * _88;
gl_FragDepth = _104.z / _104.w;
out_linear_depth = vec4(-(mat4(ub_pass[4], ub_pass[5], ub_pass[6], ub_pass[7]) * _88).z, 0.0, 0.0, 0.0);
}
*/
static const uint8_t depth_only_sphere_fs_source_glsl430[865] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x70,0x61,
0x73,0x73,0x5b,0x39,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x73,0x61,0x6d,0x70,
0x6c,0x65,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,
0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x31,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,
0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x66,
0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,
0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,
0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,
0x32,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x76,
0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,
0x20,0x2d,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x79,
0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x33,0x32,
0x20,0x3d,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x79,
0x7a,0x20,0x2d,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x37,0x20,0x3d,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x32,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x28,0x5f,0x33,
0x37,0x20,0x2a,0x20,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x28,0x64,0x6f,0x74,0x28,
0x5f,0x33,0x32,0x2c,0x20,0x5f,0x33,0x32,0x29,0x20,0x2d,0x20,0x28,0x76,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x20,0x2a,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x35,0x33,0x20,
0x3c,0x20,0x30,0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,
0x36,0x20,0x3d,0x20,0x28,0x2d,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x73,0x71,0x72,
0x74,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
0x5f,0x36,0x36,0x20,0x3c,0x20,0x30,0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x75,0x62,0x5f,0x70,
0x61,0x73,0x73,0x5b,0x38,0x5d,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,
0x37,0x20,0x2a,0x20,0x5f,0x36,0x36,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x31,0x30,0x34,0x20,0x3d,0x20,
0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x30,0x5d,0x2c,
0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,
0x70,0x61,0x73,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x5f,
0x31,0x30,0x34,0x2e,0x7a,0x20,0x2f,0x20,0x5f,0x31,0x30,0x34,0x2e,0x77,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,
0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x2d,0x28,0x6d,0x61,
0x74,0x34,0x28,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x75,
0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,
0x73,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x37,
0x5d,0x29,0x20,0x2a,0x20,0x5f,0x38,0x38,0x29,0x2e,0x7a,0x2c,0x20,0x30,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_frame : register(b0)
{
row_major float4x4 _85_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
static float3 v_world_pos_proxy;
static float3 v_center;
static float v_radius;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
sample float3 v_world_pos_proxy : TEXCOORD0;
nointerpolation float3 v_center : TEXCOORD1;
nointerpolation float v_radius : TEXCOORD2;
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _23;
_23.xform_row0 = asfloat(_15.Load4(gl_InstanceIndex * 96 + 0));
_23.xform_row1 = asfloat(_15.Load4(gl_InstanceIndex * 96 + 16));
_23.xform_row2 = asfloat(_15.Load4(gl_InstanceIndex * 96 + 32));
_23.base_color = asfloat(_15.Load4(gl_InstanceIndex * 96 + 48));
_23.params = asfloat(_15.Load4(gl_InstanceIndex * 96 + 64));
_23.material = asfloat(_15.Load4(gl_InstanceIndex * 96 + 80));
float3 _54 = float3(_23.xform_row0.w, _23.xform_row1.w, _23.xform_row2.w);
float3 _68 = _54 + (in_pos * (2.0f * _23.params.x));
v_world_pos_proxy = _68;
v_center = _54;
v_radius = _23.params.x;
gl_Position = mul(float4(_68, 1.0f), _85_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.v_world_pos_proxy = v_world_pos_proxy;
stage_output.v_center = v_center;
stage_output.v_radius = v_radius;
return stage_output;
}
*/
static const uint8_t depth_only_sphere_vs_source_hlsl5[1890] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,
0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,
0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x38,0x35,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,
0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,
0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,
0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,
0x74,0x65,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,
0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,0x74,0x20,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,
0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,
0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,
0x6c,0x61,0x74,0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,
0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,
0x6f,0x6c,0x61,0x74,0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,
0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,0x32,
0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x39,0x36,0x20,
0x2b,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x78,
0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,
0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,
0x20,0x39,0x36,0x20,0x2b,0x20,0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,
0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,
0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,
0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,
0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x70,0x61,
0x72,0x61,0x6d,0x73,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,
0x20,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x6d,
0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x39,
0x36,0x20,0x2b,0x20,0x38,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x34,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x28,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,
0x2e,0x77,0x2c,0x20,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x31,0x2e,0x77,0x2c,0x20,0x5f,0x32,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x32,0x2e,0x77,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x5f,0x36,0x38,0x20,0x3d,0x20,0x5f,0x35,0x34,0x20,0x2b,0x20,
0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,0x66,0x20,
0x2a,0x20,0x5f,0x32,0x33,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,
0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x5f,0x36,0x38,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,0x20,0x5f,0x35,
0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x36,0x38,
0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x38,0x35,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,
0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,
0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,
0x75,0x74,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,
0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,
0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x63,0x65,0x6e,
0x74,0x65,0x72,0x20,0x3d,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,
0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x76,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,
0x0a,0x00,
};
/*
cbuffer ub_pass : register(b1)
{
row_major float4x4 _14_view_proj : packoffset(c0);
row_major float4x4 _14_view : packoffset(c4);
float4 _14_camera_pos : packoffset(c8);
};
static float gl_FragDepth;
static float3 v_world_pos_proxy;
static float3 v_center;
static float v_radius;
static float4 out_linear_depth;
struct SPIRV_Cross_Input
{
sample float3 v_world_pos_proxy : TEXCOORD0;
nointerpolation float3 v_center : TEXCOORD1;
nointerpolation float v_radius : TEXCOORD2;
};
struct SPIRV_Cross_Output
{
float4 out_linear_depth : SV_Target0;
float gl_FragDepth : SV_Depth;
};
void frag_main()
{
float3 _27 = normalize(v_world_pos_proxy - _14_camera_pos.xyz);
float3 _32 = _14_camera_pos.xyz - v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (v_radius * v_radius));
if (_53 < 0.0f)
{
discard;
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0f)
{
discard;
}
float4 _88 = float4(_14_camera_pos.xyz + (_27 * _66), 1.0f);
float4 _104 = mul(_88, _14_view_proj);
gl_FragDepth = _104.z / _104.w;
out_linear_depth = float4(-mul(_88, _14_view).z, 0.0f, 0.0f, 0.0f);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
v_world_pos_proxy = stage_input.v_world_pos_proxy;
v_center = stage_input.v_center;
v_radius = stage_input.v_radius;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_FragDepth = gl_FragDepth;
stage_output.out_linear_depth = out_linear_depth;
return stage_output;
}
*/
static const uint8_t depth_only_sphere_fs_source_hlsl5[1571] = {
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x31,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x31,0x34,0x5f,0x76,0x69,0x65,0x77,
0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,
0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,
0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,
0x31,0x34,0x5f,0x76,0x69,0x65,0x77,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,
0x66,0x73,0x65,0x74,0x28,0x63,0x34,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,
0x70,0x6f,0x73,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,
0x28,0x63,0x38,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,
0x65,0x70,0x74,0x68,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x73,
0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,
0x65,0x70,0x74,0x68,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,
0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,
0x6c,0x61,0x74,0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,
0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,
0x6f,0x6c,0x61,0x74,0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,
0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x32,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,
0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,
0x3a,0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,
0x65,0x70,0x74,0x68,0x20,0x3a,0x20,0x53,0x56,0x5f,0x44,0x65,0x70,0x74,0x68,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x5f,0x32,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,
0x7a,0x65,0x28,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,
0x72,0x6f,0x78,0x79,0x20,0x2d,0x20,0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,
0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,0x32,0x20,0x3d,0x20,0x5f,0x31,0x34,
0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,
0x2d,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x37,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,
0x5f,0x33,0x32,0x2c,0x20,0x5f,0x32,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x28,0x5f,0x33,0x37,0x20,
0x2a,0x20,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,
0x32,0x2c,0x20,0x5f,0x33,0x32,0x29,0x20,0x2d,0x20,0x28,0x76,0x5f,0x72,0x61,0x64,
0x69,0x75,0x73,0x20,0x2a,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x35,0x33,0x20,0x3c,0x20,
0x30,0x2e,0x30,0x66,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x36,
0x20,0x3d,0x20,0x28,0x2d,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x73,0x71,0x72,0x74,
0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
0x36,0x36,0x20,0x3c,0x20,0x30,0x2e,0x30,0x66,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,
0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x20,0x2a,0x20,0x5f,0x36,0x36,0x29,
0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x5f,0x31,0x30,0x34,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x5f,
0x38,0x38,0x2c,0x20,0x5f,0x31,0x34,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,
0x6a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,
0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x5f,0x31,0x30,0x34,0x2e,0x7a,0x20,0x2f,0x20,
0x5f,0x31,0x30,0x34,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,
0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x2d,0x6d,0x75,0x6c,0x28,0x5f,0x38,0x38,0x2c,0x20,
0x5f,0x31,0x34,0x5f,0x76,0x69,0x65,0x77,0x29,0x2e,0x7a,0x2c,0x20,0x30,0x2e,0x30,
0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x29,0x3b,0x0a,
0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,
0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,
0x79,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,
0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,
0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,
0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,
0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,
0x75,0x74,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,
0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,
0x74,0x68,0x20,0x3d,0x20,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,
0x64,0x65,0x70,0x74,0x68,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,
0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
struct instances
{
instance items[1];
};
struct ub_frame
{
float4x4 view_proj;
};
struct main0_out
{
float3 v_world_pos_proxy [[user(locn0)]];
float3 v_center [[user(locn1)]];
float v_radius [[user(locn2)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _85 [[buffer(0)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float3 _54 = float3(_15.items[int(gl_InstanceIndex)].xform_row0.w, _15.items[int(gl_InstanceIndex)].xform_row1.w, _15.items[int(gl_InstanceIndex)].xform_row2.w);
float3 _68 = _54 + (in.in_pos * (2.0 * _15.items[int(gl_InstanceIndex)].params.x));
out.v_world_pos_proxy = _68;
out.v_center = _54;
out.v_radius = _15.items[int(gl_InstanceIndex)].params.x;
out.gl_Position = _85.view_proj * float4(_68, 1.0);
return out;
}
*/
static const uint8_t depth_only_sphere_vs_source_metal_macos[1199] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,
0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,
0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,
0x65,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,
0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,
0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,
0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,
0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,
0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,
0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,
0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,
0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,
0x38,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,
0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,0x5b,
0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,
0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,
0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,
0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x34,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,
0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x30,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,
0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x29,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,
0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,0x6e,
0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,
0x65,0x78,0x29,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,
0x77,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,
0x36,0x38,0x20,0x3d,0x20,0x5f,0x35,0x34,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x69,
0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,0x20,0x2a,0x20,0x5f,
0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,
0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x5f,0x36,0x38,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,0x20,
0x5f,0x35,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,
0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,
0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x38,0x35,0x2e,0x76,0x69,0x65,
0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
0x5f,0x36,0x38,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct ub_pass
{
float4x4 view_proj;
float4x4 view;
float4 camera_pos;
};
struct main0_out
{
float4 out_linear_depth [[color(0)]];
float gl_FragDepth [[depth(any)]];
};
struct main0_in
{
float3 v_world_pos_proxy [[user(locn0), sample_perspective]];
float3 v_center [[user(locn1), flat]];
float v_radius [[user(locn2), flat]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant ub_pass& _14 [[buffer(1)]])
{
main0_out out = {};
float3 _27 = fast::normalize(in.v_world_pos_proxy - _14.camera_pos.xyz);
float3 _32 = _14.camera_pos.xyz - in.v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (in.v_radius * in.v_radius));
if (_53 < 0.0)
{
discard_fragment();
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0)
{
discard_fragment();
}
float4 _88 = float4(_14.camera_pos.xyz + (_27 * _66), 1.0);
float4 _104 = _14.view_proj * _88;
out.gl_FragDepth = _104.z / _104.w;
out.out_linear_depth = float4(-(_14.view * _88).z, 0.0, 0.0, 0.0);
return out;
}
*/
static const uint8_t depth_only_sphere_fs_source_metal_macos[1174] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,
0x62,0x5f,0x70,0x61,0x73,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,
0x65,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,
0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,0x70,0x74,0x68,0x20,0x5b,0x5b,
0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,
0x74,0x68,0x20,0x5b,0x5b,0x64,0x65,0x70,0x74,0x68,0x28,0x61,0x6e,0x79,0x29,0x5d,
0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
0x6e,0x30,0x29,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x5f,0x70,0x65,0x72,0x73,
0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x5b,
0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x2c,0x20,0x66,0x6c,
0x61,0x74,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
0x6c,0x6f,0x63,0x6e,0x32,0x29,0x2c,0x20,0x66,0x6c,0x61,0x74,0x5d,0x5d,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,
0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,
0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x26,0x20,0x5f,0x31,0x34,0x20,0x5b,0x5b,0x62,
0x75,0x66,0x66,0x65,0x72,0x28,0x31,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,
0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x20,0x5f,0x32,0x37,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,
0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x2d,0x20,0x5f,0x31,
0x34,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,
0x32,0x20,0x3d,0x20,0x5f,0x31,0x34,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,
0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x69,0x6e,0x2e,0x76,0x5f,0x63,0x65,
0x6e,0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x5f,0x33,0x37,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,
0x32,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
0x35,0x33,0x20,0x3d,0x20,0x28,0x5f,0x33,0x37,0x20,0x2a,0x20,0x5f,0x33,0x37,0x29,
0x20,0x2d,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x33,0x32,
0x29,0x20,0x2d,0x20,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,
0x20,0x2a,0x20,0x69,0x6e,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x35,0x33,0x20,0x3c,0x20,
0x30,0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,
0x65,0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x36,0x20,0x3d,0x20,0x28,0x2d,0x5f,
0x33,0x37,0x29,0x20,0x2d,0x20,0x73,0x71,0x72,0x74,0x28,0x5f,0x35,0x33,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x36,0x36,0x20,0x3c,0x20,0x30,
0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,
0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x38,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x28,0x5f,0x31,0x34,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,
0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x20,0x2a,0x20,
0x5f,0x36,0x36,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x30,0x34,0x20,0x3d,0x20,0x5f,0x31,
0x34,0x2e,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x5f,0x38,
0x38,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x46,0x72,
0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x5f,0x31,0x30,0x34,0x2e,0x7a,
0x20,0x2f,0x20,0x5f,0x31,0x30,0x34,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,
0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6c,0x69,0x6e,0x65,0x61,0x72,0x5f,0x64,0x65,
0x70,0x74,0x68,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x2d,0x28,0x5f,
0x31,0x34,0x2e,0x76,0x69,0x65,0x77,0x20,0x2a,0x20,0x5f,0x38,0x38,0x29,0x2e,0x7a,
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* depth_only_sphere_prog_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_sphere_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_sphere_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 144;
desc.uniform_blocks[1].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 9;
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "ub_pass";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "depth_only_sphere_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_sphere_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)depth_only_sphere_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 144;
desc.uniform_blocks[1].hlsl_register_b_n = 1;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "depth_only_sphere_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)depth_only_sphere_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)depth_only_sphere_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 144;
desc.uniform_blocks[1].msl_buffer_n = 1;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "depth_only_sphere_prog_shader";
}
return &desc;
}
return 0;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,640 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/post/mask_hull.glsl --output E:/box/box3d/samples/shaders/generated/mask_hull.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'prog':
Get shader desc: mask_hull_prog_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_mask_hull_prog_in_pos => 0
Bindings:
Uniform block 'ub_draw':
C struct: mask_hull_ub_draw_t
Bind slot: UB_mask_hull_ub_draw => 2
Uniform block 'ub_frame':
C struct: mask_hull_ub_frame_t
Bind slot: UB_mask_hull_ub_frame => 0
Storage buffer 'instances':
C struct: mask_hull_instance_t
Bind slot: VIEW_mask_hull_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before mask_hull.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_mask_hull_prog_in_pos (0)
#define UB_mask_hull_ub_draw (2)
#define UB_mask_hull_ub_frame (0)
#define VIEW_mask_hull_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_hull_ub_draw_t {
int inst_base[4];
} mask_hull_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_hull_ub_frame_t {
Mat4 view_proj;
} mask_hull_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_hull_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 scale_kind;
} mask_hull_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 scale_kind;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
layout(location = 0) flat out float v_kind;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
vec4 _62 = vec4(in_pos * _15.items[_30].scale_kind.xyz, 1.0);
v_kind = _15.items[_30].scale_kind.w;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(dot(_15.items[_30].xform_row0, _62), dot(_15.items[_30].xform_row1, _62), dot(_15.items[_30].xform_row2, _62), 1.0);
}
*/
static const uint8_t mask_hull_vs_source_glsl430[709] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x63,0x61,0x6c,0x65,0x5f,0x6b,0x69,
0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,
0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,0x73,0x74,0x64,0x34,
0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x20,0x62,0x75,0x66,
0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x74,0x65,
0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x64,
0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,
0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x34,0x5d,
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x69,
0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x66,0x6c,0x61,0x74,
0x20,0x6f,0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,
0x64,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,
0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x30,0x5d,0x2e,0x78,0x20,0x2b,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x36,0x32,0x20,0x3d,0x20,0x76,0x65,0x63,
0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,
0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x73,0x63,0x61,0x6c,0x65,0x5f,
0x6b,0x69,0x6e,0x64,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x73,0x63,0x61,0x6c,
0x65,0x5f,0x6b,0x69,0x6e,0x64,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,
0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,
0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x64,0x6f,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,
0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,
0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,
0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,
0x5f,0x36,0x32,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,
0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
layout(location = 0) out vec4 out_kind;
layout(location = 0) flat in float v_kind;
void main()
{
out_kind = vec4(v_kind * 0.5, 0.0, 0.0, 1.0);
}
*/
static const uint8_t mask_hull_fs_source_glsl430[166] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,
0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,
0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x76,
0x65,0x63,0x34,0x28,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x2a,0x20,0x30,0x2e,0x35,
0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 scale_kind;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _91_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
static float v_kind;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
nointerpolation float v_kind : TEXCOORD0;
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 64 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 64 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 64 + 32));
_33.scale_kind = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 64 + 48));
float4 _62 = float4(in_pos * _33.scale_kind.xyz, 1.0f);
v_kind = _33.scale_kind.w;
gl_Position = mul(float4(dot(_33.xform_row0, _62), dot(_33.xform_row1, _62), dot(_33.xform_row2, _62), 1.0f), _91_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.v_kind = v_kind;
return stage_output;
}
*/
static const uint8_t mask_hull_vs_source_hlsl5[1569] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x73,0x63,0x61,0x6c,0x65,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,
0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,
0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,
0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,
0x65,0x72,0x28,0x62,0x32,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
0x34,0x20,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x20,
0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,
0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,
0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,
0x39,0x31,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,
0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,
0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,
0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,
0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,
0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,0x53,0x56,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3a,0x20,
0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x20,0x5f,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,
0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,
0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,
0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,
0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x36,0x34,0x20,0x2b,0x20,0x30,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x31,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,
0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,
0x36,0x34,0x20,0x2b,0x20,0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,
0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,
0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,
0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,
0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x36,0x34,0x20,0x2b,0x20,0x33,0x32,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x73,0x63,0x61,0x6c,
0x65,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,
0x2a,0x20,0x36,0x34,0x20,0x2b,0x20,0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x36,0x32,0x20,0x3d,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x5f,0x33,
0x33,0x2e,0x73,0x63,0x61,0x6c,0x65,0x5f,0x6b,0x69,0x6e,0x64,0x2e,0x78,0x79,0x7a,
0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6b,
0x69,0x6e,0x64,0x20,0x3d,0x20,0x5f,0x33,0x33,0x2e,0x73,0x63,0x61,0x6c,0x65,0x5f,
0x6b,0x69,0x6e,0x64,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,0x20,0x64,
0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x31,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,
0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,0x32,
0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x39,0x31,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,
0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,
0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,
0x28,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x2e,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x76,0x5f,0x6b,
0x69,0x6e,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
0x00,
};
/*
static float4 out_kind;
static float v_kind;
struct SPIRV_Cross_Input
{
nointerpolation float v_kind : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 out_kind : SV_Target0;
};
void frag_main()
{
out_kind = float4(v_kind * 0.5f, 0.0f, 0.0f, 1.0f);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
v_kind = stage_input.v_kind;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.out_kind = out_kind;
return stage_output;
}
*/
static const uint8_t mask_hull_fs_source_hlsl5[477] = {
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,
0x74,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,
0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,
0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,
0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3a,0x20,0x53,0x56,0x5f,
0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x2a,0x20,0x30,
0x2e,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,
0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,
0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x6b,
0x69,0x6e,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,
0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,
0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 scale_kind;
};
struct instances
{
instance items[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 view_proj;
};
struct main0_out
{
float v_kind [[user(locn0)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _91 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
float4 _62 = float4(in.in_pos * _15.items[_30].scale_kind.xyz, 1.0);
out.v_kind = _15.items[_30].scale_kind.w;
out.gl_Position = _91.view_proj * float4(dot(_15.items[_30].xform_row0, _62), dot(_15.items[_30].xform_row1, _62), dot(_15.items[_30].xform_row2, _62), 1.0);
return out;
}
*/
static const uint8_t mask_hull_vs_source_metal_macos[1059] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x73,0x63,0x61,0x6c,0x65,0x5f,
0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,
0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,
0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,
0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,
0x6e,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,
0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,
0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,
0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x39,0x31,0x20,0x5b,
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,
0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x26,0x20,
0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x32,0x29,0x5d,
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,
0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,
0x64,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x5f,0x32,0x31,
0x2e,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x69,
0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x5f,0x36,0x32,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,
0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x73,0x63,0x61,0x6c,0x65,0x5f,0x6b,
0x69,0x6e,0x64,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,
0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x73,
0x63,0x61,0x6c,0x65,0x5f,0x6b,0x69,0x6e,0x64,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x5f,0x39,0x31,0x2e,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,
0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,
0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,0x20,0x64,
0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,
0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x36,
0x32,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,
0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x32,0x2c,0x20,0x5f,0x36,0x32,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 out_kind [[color(0)]];
};
struct main0_in
{
float v_kind [[user(locn0), flat]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.out_kind = float4(in.v_kind * 0.5, 0.0, 0.0, 1.0);
return out;
}
*/
static const uint8_t mask_hull_fs_source_metal_macos[347] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x5b,
0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,
0x69,0x6e,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,
0x29,0x2c,0x20,0x66,0x6c,0x61,0x74,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,
0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,
0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,
0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* mask_hull_prog_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_hull_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)mask_hull_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "mask_hull_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_hull_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)mask_hull_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "mask_hull_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_hull_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)mask_hull_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "mask_hull_prog_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,894 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/post/mask_sphere.glsl --output E:/box/box3d/samples/shaders/generated/mask_sphere.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'prog':
Get shader desc: mask_sphere_prog_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_mask_sphere_prog_in_pos => 0
Bindings:
Uniform block 'ub_frame':
C struct: mask_sphere_ub_frame_t
Bind slot: UB_mask_sphere_ub_frame => 0
Uniform block 'ub_pass':
C struct: mask_sphere_ub_pass_t
Bind slot: UB_mask_sphere_ub_pass => 1
Storage buffer 'instances':
C struct: mask_sphere_instance_t
Bind slot: VIEW_mask_sphere_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before mask_sphere.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_mask_sphere_prog_in_pos (0)
#define UB_mask_sphere_ub_frame (0)
#define UB_mask_sphere_ub_pass (1)
#define VIEW_mask_sphere_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_sphere_ub_frame_t {
Mat4 view_proj;
} mask_sphere_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_sphere_ub_pass_t {
Mat4 view_proj;
Vec4 camera_pos;
} mask_sphere_ub_pass_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct mask_sphere_instance_t {
Vec4 center_radius;
Vec4 kind;
} mask_sphere_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 center_radius;
vec4 kind;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
layout(location = 0) sample out vec3 v_world_pos_proxy;
layout(location = 1) flat out vec3 v_center;
layout(location = 2) flat out float v_radius;
layout(location = 3) flat out float v_kind;
void main()
{
vec3 _51 = _15.items[gl_InstanceID].center_radius.xyz + (in_pos * (2.0 * _15.items[gl_InstanceID].center_radius.w));
v_world_pos_proxy = _51;
v_center = _15.items[gl_InstanceID].center_radius.xyz;
v_radius = _15.items[gl_InstanceID].center_radius.w;
v_kind = _15.items[gl_InstanceID].kind.x;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(_51, 1.0);
}
*/
static const uint8_t mask_sphere_vs_source_glsl430[839] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,
0x72,0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,0x73,
0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x20,
0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,0x0a,
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x30,0x29,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x6f,0x75,0x74,0x20,
0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,
0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x66,0x6c,0x61,
0x74,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,
0x74,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x6f,
0x75,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,
0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x6f,0x75,0x74,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x0a,
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,0x31,0x20,0x3d,0x20,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,
0x69,0x75,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,
0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x44,0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,
0x73,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x77,0x6f,0x72,
0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x5f,
0x35,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,
0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x63,0x65,0x6e,0x74,
0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x5f,0x31,
0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6b,0x69,
0x6e,0x64,0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x6b,0x69,
0x6e,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,
0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,
0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,
0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x35,0x31,0x2c,0x20,0x31,0x2e,0x30,
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
uniform vec4 ub_pass[5];
layout(location = 0) sample in vec3 v_world_pos_proxy;
layout(location = 1) flat in vec3 v_center;
layout(location = 2) flat in float v_radius;
layout(location = 0) out vec4 out_kind;
layout(location = 3) flat in float v_kind;
void main()
{
vec3 _27 = normalize(v_world_pos_proxy - ub_pass[4].xyz);
vec3 _32 = ub_pass[4].xyz - v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (v_radius * v_radius));
if (_53 < 0.0)
{
discard;
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0)
{
discard;
}
vec4 _90 = mat4(ub_pass[0], ub_pass[1], ub_pass[2], ub_pass[3]) * vec4(ub_pass[4].xyz + (_27 * _66), 1.0);
gl_FragDepth = _90.z / _90.w;
out_kind = vec4(v_kind * 0.5, 0.0, 0.0, 1.0);
}
*/
static const uint8_t mask_sphere_fs_source_glsl430[818] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x70,0x61,
0x73,0x73,0x5b,0x35,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x73,0x61,0x6d,0x70,
0x6c,0x65,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,
0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x31,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,
0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x66,
0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,
0x76,0x65,0x63,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x6c,
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
0x20,0x33,0x29,0x20,0x66,0x6c,0x61,0x74,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
0x33,0x20,0x5f,0x32,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,
0x65,0x28,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,
0x6f,0x78,0x79,0x20,0x2d,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x34,0x5d,
0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x33,0x32,0x20,0x3d,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x34,0x5d,
0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x37,0x20,0x3d,
0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x32,0x37,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,
0x28,0x5f,0x33,0x37,0x20,0x2a,0x20,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x28,0x64,
0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x33,0x32,0x29,0x20,0x2d,0x20,0x28,
0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x2a,0x20,0x76,0x5f,0x72,0x61,0x64,
0x69,0x75,0x73,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
0x35,0x33,0x20,0x3c,0x20,0x30,0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x20,0x5f,0x36,0x36,0x20,0x3d,0x20,0x28,0x2d,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,
0x73,0x71,0x72,0x74,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x66,0x20,0x28,0x5f,0x36,0x36,0x20,0x3c,0x20,0x30,0x2e,0x30,0x29,0x0a,0x20,0x20,
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,
0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x76,
0x65,0x63,0x34,0x20,0x5f,0x39,0x30,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,
0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,
0x73,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x32,
0x5d,0x2c,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,
0x20,0x76,0x65,0x63,0x34,0x28,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x5b,0x34,0x5d,
0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x20,0x2a,0x20,0x5f,0x36,
0x36,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x5f,0x39,0x30,
0x2e,0x7a,0x20,0x2f,0x20,0x5f,0x39,0x30,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x30,0x2e,
0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,
0x0a,0x00,
};
/*
struct instance
{
float4 center_radius;
float4 kind;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_frame : register(b0)
{
row_major float4x4 _72_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
static float3 v_world_pos_proxy;
static float3 v_center;
static float v_radius;
static float v_kind;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
sample float3 v_world_pos_proxy : TEXCOORD0;
nointerpolation float3 v_center : TEXCOORD1;
nointerpolation float v_radius : TEXCOORD2;
nointerpolation float v_kind : TEXCOORD3;
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _23;
_23.center_radius = asfloat(_15.Load4(gl_InstanceIndex * 32 + 0));
_23.kind = asfloat(_15.Load4(gl_InstanceIndex * 32 + 16));
float3 _51 = _23.center_radius.xyz + (in_pos * (2.0f * _23.center_radius.w));
v_world_pos_proxy = _51;
v_center = _23.center_radius.xyz;
v_radius = _23.center_radius.w;
v_kind = _23.kind.x;
gl_Position = mul(float4(_51, 1.0f), _72_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.v_world_pos_proxy = v_world_pos_proxy;
stage_output.v_center = v_center;
stage_output.v_radius = v_radius;
stage_output.v_kind = v_kind;
return stage_output;
}
*/
static const uint8_t mask_sphere_vs_source_hlsl5[1625] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x65,0x6e,
0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x42,0x79,0x74,0x65,0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,
0x65,0x72,0x20,0x5f,0x31,0x35,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,
0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,
0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,
0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,
0x5f,0x37,0x32,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,
0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,
0x78,0x79,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,
0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,
0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,
0x79,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,
0x65,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,
0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x32,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,
0x69,0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,
0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x33,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,
0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,0x32,0x33,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x32,0x33,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,
0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x33,0x32,0x20,0x2b,0x20,0x30,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x32,0x33,0x2e,0x6b,0x69,0x6e,0x64,
0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,
0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x33,0x32,0x20,0x2b,0x20,0x31,0x36,0x29,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,
0x31,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,
0x61,0x64,0x69,0x75,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x69,0x6e,0x5f,
0x70,0x6f,0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,0x66,0x20,0x2a,0x20,0x5f,0x32,
0x33,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,
0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,
0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x5f,0x35,0x31,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,
0x20,0x5f,0x32,0x33,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x63,0x65,0x6e,0x74,0x65,
0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x5f,0x32,0x33,0x2e,0x6b,0x69,0x6e,
0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x28,0x5f,0x35,0x31,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x37,
0x32,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,
0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,
0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,
0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3d,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,
0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,
0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,
0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x76,0x5f,0x77,0x6f,
0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,
0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,0x20,0x76,0x5f,0x63,0x65,0x6e,
0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3d,
0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x76,0x5f,0x6b,0x69,
0x6e,0x64,0x20,0x3d,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,
0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
cbuffer ub_pass : register(b1)
{
row_major float4x4 _14_view_proj : packoffset(c0);
float4 _14_camera_pos : packoffset(c4);
};
static float gl_FragDepth;
static float3 v_world_pos_proxy;
static float3 v_center;
static float v_radius;
static float4 out_kind;
static float v_kind;
struct SPIRV_Cross_Input
{
sample float3 v_world_pos_proxy : TEXCOORD0;
nointerpolation float3 v_center : TEXCOORD1;
nointerpolation float v_radius : TEXCOORD2;
nointerpolation float v_kind : TEXCOORD3;
};
struct SPIRV_Cross_Output
{
float4 out_kind : SV_Target0;
float gl_FragDepth : SV_Depth;
};
void frag_main()
{
float3 _27 = normalize(v_world_pos_proxy - _14_camera_pos.xyz);
float3 _32 = _14_camera_pos.xyz - v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (v_radius * v_radius));
if (_53 < 0.0f)
{
discard;
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0f)
{
discard;
}
float4 _90 = mul(float4(_14_camera_pos.xyz + (_27 * _66), 1.0f), _14_view_proj);
gl_FragDepth = _90.z / _90.w;
out_kind = float4(v_kind * 0.5f, 0.0f, 0.0f, 1.0f);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
v_world_pos_proxy = stage_input.v_world_pos_proxy;
v_center = stage_input.v_center;
v_radius = stage_input.v_radius;
v_kind = stage_input.v_kind;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_FragDepth = gl_FragDepth;
stage_output.out_kind = out_kind;
return stage_output;
}
*/
static const uint8_t mask_sphere_fs_source_hlsl5[1548] = {
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x70,0x61,0x73,0x73,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x31,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x31,0x34,0x5f,0x76,0x69,0x65,0x77,
0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,
0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,
0x73,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,
0x34,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,
0x74,0x68,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,
0x6f,0x78,0x79,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x3b,
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,
0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,
0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,0x6f,
0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,
0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,
0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6e,0x6f,0x69,0x6e,0x74,0x65,0x72,0x70,0x6f,0x6c,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,
0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x33,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,
0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,
0x44,0x65,0x70,0x74,0x68,0x20,0x3a,0x20,0x53,0x56,0x5f,0x44,0x65,0x70,0x74,0x68,
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x20,0x5f,0x32,0x37,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x69,0x7a,0x65,0x28,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,
0x70,0x72,0x6f,0x78,0x79,0x20,0x2d,0x20,0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,
0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,0x32,0x20,0x3d,0x20,0x5f,0x31,
0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,
0x20,0x2d,0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x37,0x20,0x3d,0x20,0x64,0x6f,0x74,
0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x32,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x28,0x5f,0x33,0x37,
0x20,0x2a,0x20,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x28,0x64,0x6f,0x74,0x28,0x5f,
0x33,0x32,0x2c,0x20,0x5f,0x33,0x32,0x29,0x20,0x2d,0x20,0x28,0x76,0x5f,0x72,0x61,
0x64,0x69,0x75,0x73,0x20,0x2a,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x29,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x35,0x33,0x20,0x3c,
0x20,0x30,0x2e,0x30,0x66,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,
0x36,0x20,0x3d,0x20,0x28,0x2d,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,0x73,0x71,0x72,
0x74,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
0x5f,0x36,0x36,0x20,0x3c,0x20,0x30,0x2e,0x30,0x66,0x29,0x0a,0x20,0x20,0x20,0x20,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,
0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x5f,0x39,0x30,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x28,0x5f,0x31,0x34,0x5f,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,
0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x20,0x2a,
0x20,0x5f,0x36,0x36,0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x31,
0x34,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,
0x20,0x5f,0x39,0x30,0x2e,0x7a,0x20,0x2f,0x20,0x5f,0x39,0x30,0x2e,0x77,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x3d,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,0x2a,0x20,0x30,
0x2e,0x35,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,
0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,
0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,
0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,
0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,
0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,0x72,0x61,0x64,
0x69,0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,
0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x76,0x5f,
0x6b,0x69,0x6e,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,
0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x46,
0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6b,
0x69,0x6e,0x64,0x20,0x3d,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 center_radius;
float4 kind;
};
struct instances
{
instance items[1];
};
struct ub_frame
{
float4x4 view_proj;
};
struct main0_out
{
float3 v_world_pos_proxy [[user(locn0)]];
float3 v_center [[user(locn1)]];
float v_radius [[user(locn2)]];
float v_kind [[user(locn3)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _72 [[buffer(0)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
float3 _51 = _15.items[int(gl_InstanceIndex)].center_radius.xyz + (in.in_pos * (2.0 * _15.items[int(gl_InstanceIndex)].center_radius.w));
out.v_world_pos_proxy = _51;
out.v_center = _15.items[int(gl_InstanceIndex)].center_radius.xyz;
out.v_radius = _15.items[int(gl_InstanceIndex)].center_radius.w;
out.v_kind = _15.items[int(gl_InstanceIndex)].kind.x;
out.gl_Position = _72.view_proj * float4(_51, 1.0);
return out;
}
*/
static const uint8_t mask_sphere_vs_source_metal_macos[1144] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,
0x75,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6b,
0x69,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,
0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,
0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,
0x72,0x6f,0x78,0x79,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x20,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x6b,0x69,0x6e,0x64,0x20,
0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x33,0x29,0x5d,0x5d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,
0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x37,0x32,0x20,0x5b,0x5b,0x62,0x75,
0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,
0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,
0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,
0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x5f,0x35,0x31,0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,
0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,
0x72,0x61,0x64,0x69,0x75,0x73,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x69,0x6e,
0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x28,0x32,0x2e,0x30,0x20,0x2a,
0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,
0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,
0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x77,
0x6f,0x72,0x6c,0x64,0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x3d,
0x20,0x5f,0x35,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,
0x63,0x65,0x6e,0x74,0x65,0x72,0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,
0x6d,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,
0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x3d,0x20,
0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,
0x2e,0x63,0x65,0x6e,0x74,0x65,0x72,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x2e,0x77,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x76,0x5f,0x6b,0x69,0x6e,0x64,
0x20,0x3d,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x69,0x6e,0x74,
0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
0x78,0x29,0x5d,0x2e,0x6b,0x69,0x6e,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x5f,0x37,0x32,0x2e,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,
0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x35,0x31,0x2c,0x20,0x31,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct ub_pass
{
float4x4 view_proj;
float4 camera_pos;
};
struct main0_out
{
float4 out_kind [[color(0)]];
float gl_FragDepth [[depth(any)]];
};
struct main0_in
{
float3 v_world_pos_proxy [[user(locn0), sample_perspective]];
float3 v_center [[user(locn1), flat]];
float v_radius [[user(locn2), flat]];
float v_kind [[user(locn3), flat]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant ub_pass& _14 [[buffer(1)]])
{
main0_out out = {};
float3 _27 = fast::normalize(in.v_world_pos_proxy - _14.camera_pos.xyz);
float3 _32 = _14.camera_pos.xyz - in.v_center;
float _37 = dot(_32, _27);
float _53 = (_37 * _37) - (dot(_32, _32) - (in.v_radius * in.v_radius));
if (_53 < 0.0)
{
discard_fragment();
}
float _66 = (-_37) - sqrt(_53);
if (_66 < 0.0)
{
discard_fragment();
}
float4 _90 = _14.view_proj * float4(_14.camera_pos.xyz + (_27 * _66), 1.0);
out.gl_FragDepth = _90.z / _90.w;
out.out_kind = float4(in.v_kind * 0.5, 0.0, 0.0, 1.0);
return out;
}
*/
static const uint8_t mask_sphere_fs_source_metal_macos[1150] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,
0x62,0x5f,0x70,0x61,0x73,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x78,0x34,0x20,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x61,0x6d,0x65,
0x72,0x61,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6f,0x75,0x74,0x5f,0x6b,0x69,
0x6e,0x64,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x46,0x72,
0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x5b,0x5b,0x64,0x65,0x70,0x74,0x68,0x28,
0x61,0x6e,0x79,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,
0x5f,0x70,0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x5b,0x5b,0x75,0x73,0x65,
0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,
0x5f,0x70,0x65,0x72,0x73,0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x5d,0x5d,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x76,0x5f,0x63,0x65,0x6e,
0x74,0x65,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,
0x29,0x2c,0x20,0x66,0x6c,0x61,0x74,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x20,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x32,0x29,0x2c,0x20,0x66,0x6c,0x61,
0x74,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,
0x5f,0x6b,0x69,0x6e,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
0x6e,0x33,0x29,0x2c,0x20,0x66,0x6c,0x61,0x74,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,
0x70,0x61,0x73,0x73,0x26,0x20,0x5f,0x31,0x34,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x31,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,
0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x32,
0x37,0x20,0x3d,0x20,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x69,0x7a,0x65,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x77,0x6f,0x72,0x6c,0x64,0x5f,0x70,
0x6f,0x73,0x5f,0x70,0x72,0x6f,0x78,0x79,0x20,0x2d,0x20,0x5f,0x31,0x34,0x2e,0x63,
0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x33,0x32,0x20,0x3d,
0x20,0x5f,0x31,0x34,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,
0x78,0x79,0x7a,0x20,0x2d,0x20,0x69,0x6e,0x2e,0x76,0x5f,0x63,0x65,0x6e,0x74,0x65,
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x37,
0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x32,0x37,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x33,0x20,
0x3d,0x20,0x28,0x5f,0x33,0x37,0x20,0x2a,0x20,0x5f,0x33,0x37,0x29,0x20,0x2d,0x20,
0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x32,0x2c,0x20,0x5f,0x33,0x32,0x29,0x20,0x2d,
0x20,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x20,0x2a,0x20,
0x69,0x6e,0x2e,0x76,0x5f,0x72,0x61,0x64,0x69,0x75,0x73,0x29,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x35,0x33,0x20,0x3c,0x20,0x30,0x2e,0x30,
0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x20,0x5f,0x36,0x36,0x20,0x3d,0x20,0x28,0x2d,0x5f,0x33,0x37,0x29,
0x20,0x2d,0x20,0x73,0x71,0x72,0x74,0x28,0x5f,0x35,0x33,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x36,0x36,0x20,0x3c,0x20,0x30,0x2e,0x30,0x29,
0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,
0x69,0x73,0x63,0x61,0x72,0x64,0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x28,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x5f,0x39,0x30,0x20,0x3d,0x20,0x5f,0x31,0x34,0x2e,0x76,0x69,
0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x28,0x5f,0x31,0x34,0x2e,0x63,0x61,0x6d,0x65,0x72,0x61,0x5f,0x70,0x6f,0x73,0x2e,
0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x5f,0x32,0x37,0x20,0x2a,0x20,0x5f,0x36,0x36,
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
0x2e,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,0x20,0x3d,0x20,
0x5f,0x39,0x30,0x2e,0x7a,0x20,0x2f,0x20,0x5f,0x39,0x30,0x2e,0x77,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x6f,0x75,0x74,0x5f,0x6b,0x69,0x6e,0x64,0x20,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x76,0x5f,0x6b,0x69,
0x6e,0x64,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* mask_sphere_prog_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_sphere_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)mask_sphere_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 80;
desc.uniform_blocks[1].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[1].glsl_uniforms[0].array_count = 5;
desc.uniform_blocks[1].glsl_uniforms[0].glsl_name = "ub_pass";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "mask_sphere_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_sphere_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)mask_sphere_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 80;
desc.uniform_blocks[1].hlsl_register_b_n = 1;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "mask_sphere_prog_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)mask_sphere_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)mask_sphere_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[1].stage = SG_SHADERSTAGE_FRAGMENT;
desc.uniform_blocks[1].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[1].size = 80;
desc.uniform_blocks[1].msl_buffer_n = 1;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "mask_sphere_prog_shader";
}
return &desc;
}
return 0;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,607 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/shadow_caster_capsule.glsl --output E:/box/box3d/samples/shaders/generated/shadow_caster_capsule.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'caster':
Get shader desc: shadow_capsule_caster_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_shadow_capsule_caster_in_axis => 0
ATTR_shadow_capsule_caster_in_radial => 1
Bindings:
Uniform block 'ub_draw':
C struct: shadow_capsule_ub_draw_t
Bind slot: UB_shadow_capsule_ub_draw => 2
Uniform block 'ub_frame':
C struct: shadow_capsule_ub_frame_t
Bind slot: UB_shadow_capsule_ub_frame => 0
Storage buffer 'instances':
C struct: shadow_capsule_instance_t
Bind slot: VIEW_shadow_capsule_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before shadow_caster_capsule.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_shadow_capsule_caster_in_axis (0)
#define ATTR_shadow_capsule_caster_in_radial (1)
#define UB_shadow_capsule_ub_draw (2)
#define UB_shadow_capsule_ub_frame (0)
#define VIEW_shadow_capsule_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_capsule_ub_draw_t {
int inst_base[4];
} shadow_capsule_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_capsule_ub_frame_t {
Mat4 light_view_proj;
} shadow_capsule_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_capsule_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 params;
Vec4 material;
} shadow_capsule_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 params;
vec4 material;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_axis;
layout(location = 1) in vec3 in_radial;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
vec3 _81 = (in_axis * _15.items[_30].params.x) + (in_radial * _15.items[_30].params.y);
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(vec3(_15.items[_30].xform_row0.w, _15.items[_30].xform_row1.w, _15.items[_30].xform_row2.w) + vec3(dot(_15.items[_30].xform_row0.xyz, _81), dot(_15.items[_30].xform_row1.xyz, _81), dot(_15.items[_30].xform_row2.xyz, _81)), 1.0);
}
*/
static const uint8_t shadow_capsule_vs_source_glsl430[838] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x61,0x72,
0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x6d,0x61,
0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,
0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,
0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,
0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,
0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,
0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
0x63,0x33,0x20,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,
0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,
0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x30,0x5d,0x2e,0x78,0x20,0x2b,0x20,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x38,0x31,0x20,0x3d,0x20,0x28,0x69,
0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,
0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,
0x29,0x20,0x2b,0x20,0x28,0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,0x61,0x6c,0x20,0x2a,
0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,
0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x79,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,
0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,
0x72,0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x65,0x63,
0x33,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,
0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,
0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x2e,0x77,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,
0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,
0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x78,0x79,
0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,
0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,
0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
void main()
{
}
*/
static const uint8_t shadow_capsule_fs_source_glsl430[32] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _108_light_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_axis;
static float3 in_radial;
struct SPIRV_Cross_Input
{
float3 in_axis : TEXCOORD0;
float3 in_radial : TEXCOORD1;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 32));
_33.base_color = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 48));
_33.params = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 64));
_33.material = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 80));
float3 _81 = (in_axis * _33.params.x) + (in_radial * _33.params.y);
gl_Position = mul(float4(float3(_33.xform_row0.w, _33.xform_row1.w, _33.xform_row2.w) + float3(dot(_33.xform_row0.xyz, _81), dot(_33.xform_row1.xyz, _81), dot(_33.xform_row2.xyz, _81)), 1.0f), _108_light_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_axis = stage_input.in_axis;
in_radial = stage_input.in_radial;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}
*/
static const uint8_t shadow_capsule_vs_source_hlsl5[1860] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,
0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,
0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x32,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x32,0x31,0x5f,0x69,0x6e,
0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,
0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x62,
0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x31,0x30,0x38,0x5f,0x6c,0x69,0x67,0x68,
0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,
0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,
0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,
0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,
0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,
0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,
0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x33,0x20,0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,0x61,0x6c,0x20,0x3a,0x20,0x54,0x45,
0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,0x6e,
0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,
0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,0x33,
0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,
0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,
0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,
0x20,0x39,0x36,0x20,0x2b,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,
0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,0x3d,0x20,
0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,
0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,
0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x31,0x36,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,
0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x33,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,
0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x70,0x61,
0x72,0x61,0x6d,0x73,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,
0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,
0x39,0x36,0x20,0x2b,0x20,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,
0x33,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,0x3d,0x20,0x61,0x73,
0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,
0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,
0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x38,0x30,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x38,0x31,
0x20,0x3d,0x20,0x28,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x2a,0x20,0x5f,0x33,
0x33,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x20,0x2b,0x20,0x28,0x69,
0x6e,0x5f,0x72,0x61,0x64,0x69,0x61,0x6c,0x20,0x2a,0x20,0x5f,0x33,0x33,0x2e,0x70,
0x61,0x72,0x61,0x6d,0x73,0x2e,0x79,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x33,
0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,
0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2e,0x77,
0x2c,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,
0x2e,0x77,0x29,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x64,0x6f,0x74,
0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,
0x78,0x79,0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,
0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2e,0x78,0x79,
0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,
0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,0x78,0x79,0x7a,0x2c,
0x20,0x5f,0x38,0x31,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,
0x31,0x30,0x38,0x5f,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,
0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,
0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,0x61,0x6c,0x20,0x3d,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x72,0x61,
0x64,0x69,0x61,0x6c,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,
0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,
0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,
0x0a,0x7d,0x0a,0x00,
};
/*
void frag_main()
{
}
void main()
{
frag_main();
}
*/
static const uint8_t shadow_capsule_fs_source_hlsl5[56] = {
0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,
0x6e,0x28,0x29,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
struct instances
{
instance items[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 light_view_proj;
};
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_axis [[attribute(0)]];
float3 in_radial [[attribute(1)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _108 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
float3 _81 = (in.in_axis * _15.items[_30].params.x) + (in.in_radial * _15.items[_30].params.y);
out.gl_Position = _108.light_view_proj * float4(float3(_15.items[_30].xform_row0.w, _15.items[_30].xform_row1.w, _15.items[_30].xform_row2.w) + float3(dot(_15.items[_30].xform_row0.xyz, _81), dot(_15.items[_30].xform_row1.xyz, _81), dot(_15.items[_30].xform_row2.xyz, _81)), 1.0);
return out;
}
*/
static const uint8_t shadow_capsule_vs_source_metal_macos[1216] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,
0x61,0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x5b,0x5b,
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x72,0x61,
0x64,0x69,0x61,0x6c,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,
0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,
0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,
0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,
0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,
0x31,0x30,0x38,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x64,
0x72,0x61,0x77,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,
0x72,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,
0x76,0x69,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x26,0x20,
0x5f,0x31,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x38,0x29,0x5d,
0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,
0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,
0x3d,0x20,0x5f,0x32,0x31,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,
0x78,0x20,0x2b,0x20,0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x38,0x31,0x20,0x3d,0x20,0x28,0x69,0x6e,0x2e,
0x69,0x6e,0x5f,0x61,0x78,0x69,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,
0x78,0x29,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x5f,0x72,0x61,0x64,0x69,
0x61,0x6c,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,
0x33,0x30,0x5d,0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x79,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x30,0x38,0x2e,0x6c,0x69,0x67,0x68,0x74,0x5f,
0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,
0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,
0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,
0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,0x77,0x29,
0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,
0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x38,0x31,
0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,
0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,
0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,0x38,0x31,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,
0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x5f,
0x38,0x31,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
fragment void main0()
{
}
*/
static const uint8_t shadow_capsule_fs_source_metal_macos[100] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x20,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x29,0x0a,0x7b,0x0a,
0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* shadow_capsule_caster_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_capsule_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_capsule_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_axis";
desc.attrs[1].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[1].glsl_name = "in_radial";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "shadow_capsule_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_capsule_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_capsule_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.attrs[1].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[1].hlsl_sem_name = "TEXCOORD";
desc.attrs[1].hlsl_sem_index = 1;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "shadow_capsule_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_capsule_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)shadow_capsule_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[1].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "shadow_capsule_caster_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,544 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/shadow_caster_cube.glsl --output E:/box/box3d/samples/shaders/generated/shadow_caster_cube.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'caster':
Get shader desc: shadow_cube_caster_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_shadow_cube_caster_in_pos => 0
Bindings:
Uniform block 'ub_draw':
C struct: shadow_cube_ub_draw_t
Bind slot: UB_shadow_cube_ub_draw => 2
Uniform block 'ub_frame':
C struct: shadow_cube_ub_frame_t
Bind slot: UB_shadow_cube_ub_frame => 0
Storage buffer 'cube_instances':
C struct: shadow_cube_cube_instance_t
Bind slot: VIEW_shadow_cube_cube_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before shadow_caster_cube.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_shadow_cube_caster_in_pos (0)
#define UB_shadow_cube_ub_draw (2)
#define UB_shadow_cube_ub_frame (0)
#define VIEW_shadow_cube_cube_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_cube_ub_draw_t {
int inst_base[4];
} shadow_cube_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_cube_ub_frame_t {
Mat4 light_view_proj;
} shadow_cube_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_cube_cube_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 material;
} shadow_cube_cube_instance_t;
#pragma pack(pop)
/*
#version 430
struct cube_instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 material;
};
layout(binding = 0, std430) readonly buffer cube_instances
{
cube_instance instances[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
vec4 _58 = vec4(in_pos, 1.0);
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(dot(_15.instances[_30].xform_row0, _58), dot(_15.instances[_30].xform_row1, _58), dot(_15.instances[_30].xform_row2, _58), 1.0);
}
*/
static const uint8_t shadow_cube_vs_source_glsl430[641] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,
0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,
0x20,0x30,0x2c,0x20,0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,
0x6f,0x6e,0x6c,0x79,0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x63,0x75,0x62,0x65,
0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,
0x35,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,
0x34,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,
0x61,0x6d,0x65,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
0x76,0x65,0x63,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,
0x77,0x5b,0x30,0x5d,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x5f,0x35,0x38,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x69,0x6e,0x5f,0x70,
0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,
0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,
0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,
0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x64,0x6f,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5f,0x33,
0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,
0x35,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,
0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,
0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
/*
#version 430
void main()
{
}
*/
static const uint8_t shadow_cube_fs_source_glsl430[32] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct cube_instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _82_light_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void vert_main()
{
cube_instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 80 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 80 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 80 + 32));
_33.base_color = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 80 + 48));
_33.material = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 80 + 64));
float4 _58 = float4(in_pos, 1.0f);
gl_Position = mul(float4(dot(_33.xform_row0, _58), dot(_33.xform_row1, _58), dot(_33.xform_row2, _58), 1.0f), _82_light_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}
*/
static const uint8_t shadow_cube_vs_source_hlsl5[1546] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,
0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,
0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,
0x35,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,
0x3b,0x0a,0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,
0x77,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x32,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,
0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x38,0x32,0x5f,0x6c,0x69,0x67,
0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,
0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,
0x74,0x61,0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,
0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,
0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,
0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,
0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,
0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,
0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x30,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,
0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,
0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x62,0x61,
0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,
0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,
0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,
0x29,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x38,0x30,0x20,0x2b,0x20,
0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x5f,0x35,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,
0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,
0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,
0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x35,
0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,
0x2c,0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,
0x38,0x32,0x5f,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,
0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,
0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,
0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
void frag_main()
{
}
void main()
{
frag_main();
}
*/
static const uint8_t shadow_cube_fs_source_hlsl5[56] = {
0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,
0x6e,0x28,0x29,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct cube_instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 material;
};
struct cube_instances
{
cube_instance instances[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 light_view_proj;
};
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _82 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device cube_instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
float4 _58 = float4(in.in_pos, 1.0);
out.gl_Position = _82.light_view_proj * float4(dot(_15.instances[_30].xform_row0, _58), dot(_15.instances[_30].xform_row1, _58), dot(_15.instances[_30].xform_row2, _58), 1.0);
return out;
}
*/
static const uint8_t shadow_cube_vs_source_metal_macos[1016] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,
0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,
0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,
0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x63,0x75,0x62,0x65,0x5f,
0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x63,0x75,0x62,0x65,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x6e,
0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,
0x61,0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,
0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,
0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x38,0x32,0x20,0x5b,0x5b,0x62,0x75,0x66,
0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,
0x6e,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x26,0x20,0x5f,0x32,0x31,0x20,
0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x63,
0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x63,0x75,0x62,0x65,
0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,
0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,
0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x20,0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,
0x69,0x64,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x5f,0x32,
0x31,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,
0x69,0x6e,0x74,0x28,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x5f,0x35,0x38,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,
0x6e,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x38,0x32,0x2e,0x6c,0x69,0x67,0x68,0x74,0x5f,
0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,
0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,
0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5f,0x33,
0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,
0x35,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,
0x74,0x61,0x6e,0x63,0x65,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x35,0x38,0x29,0x2c,0x20,0x31,0x2e,
0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
fragment void main0()
{
}
*/
static const uint8_t shadow_cube_fs_source_metal_macos[100] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x20,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x29,0x0a,0x7b,0x0a,
0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* shadow_cube_caster_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_cube_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_cube_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "shadow_cube_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_cube_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_cube_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "shadow_cube_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_cube_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)shadow_cube_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "shadow_cube_caster_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,557 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/shadow_caster_geom.glsl --output E:/box/box3d/samples/shaders/generated/shadow_caster_geom.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'caster':
Get shader desc: shadow_geom_caster_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_shadow_geom_caster_in_pos => 0
Bindings:
Uniform block 'ub_draw':
C struct: shadow_geom_ub_draw_t
Bind slot: UB_shadow_geom_ub_draw => 2
Uniform block 'ub_frame':
C struct: shadow_geom_ub_frame_t
Bind slot: UB_shadow_geom_ub_frame => 0
Storage buffer 'instances':
C struct: shadow_geom_instance_t
Bind slot: VIEW_shadow_geom_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before shadow_caster_geom.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_shadow_geom_caster_in_pos (0)
#define UB_shadow_geom_ub_draw (2)
#define UB_shadow_geom_ub_frame (0)
#define VIEW_shadow_geom_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_geom_ub_draw_t {
int inst_base[4];
} shadow_geom_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_geom_ub_frame_t {
Mat4 light_view_proj;
} shadow_geom_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_geom_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 scale;
Vec4 material;
} shadow_geom_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 scale;
vec4 material;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
vec4 _68 = vec4(in_pos * _15.items[_30].scale.xyz, 1.0);
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(dot(_15.items[_30].xform_row0, _68), dot(_15.items[_30].xform_row1, _68), dot(_15.items[_30].xform_row2, _68), 1.0);
}
*/
static const uint8_t shadow_geom_vs_source_glsl430[653] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x63,0x61,
0x6c,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x6d,0x61,0x74,
0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,0x73,
0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x20,
0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,0x0a,
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,0x75,
0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,
0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,
0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x30,
0x5d,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x44,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x36,
0x38,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,
0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,
0x2e,0x73,0x63,0x61,0x6c,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x31,
0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x32,0x5d,0x2c,0x20,
0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,
0x65,0x63,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,
0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,
0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,
0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,0x38,
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
void main()
{
}
*/
static const uint8_t shadow_geom_fs_source_glsl430[32] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 scale;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _91_light_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 32));
_33.base_color = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 48));
_33.scale = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 64));
_33.material = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 80));
float4 _68 = float4(in_pos * _33.scale.xyz, 1.0f);
gl_Position = mul(float4(dot(_33.xform_row0, _68), dot(_33.xform_row1, _68), dot(_33.xform_row2, _68), 1.0f), _91_light_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}
*/
static const uint8_t shadow_geom_vs_source_hlsl5[1654] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x73,0x63,0x61,0x6c,0x65,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,
0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,0x64,
0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,0x63,
0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x32,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,
0x74,0x5f,0x62,0x61,0x73,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,
0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x62,0x75,
0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,0x20,
0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x39,0x31,0x5f,0x6c,0x69,0x67,0x68,0x74,0x5f,
0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,
0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,
0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x69,
0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,
0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,
0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x5f,
0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,
0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,0x3d,
0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,
0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,
0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x31,
0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,
0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,
0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x5f,0x33,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,
0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,
0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,
0x20,0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x73,
0x63,0x61,0x6c,0x65,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,
0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,
0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,
0x39,0x36,0x20,0x2b,0x20,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,
0x33,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,0x3d,0x20,0x61,0x73,
0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,
0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,
0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,
0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x38,0x30,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x36,0x38,
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,
0x20,0x2a,0x20,0x5f,0x33,0x33,0x2e,0x73,0x63,0x61,0x6c,0x65,0x2e,0x78,0x79,0x7a,
0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,
0x64,0x6f,0x74,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x31,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x33,
0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,0x20,0x5f,0x36,
0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x39,0x31,0x5f,0x6c,
0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x29,0x3b,
0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,
0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x5f,0x70,0x6f,
0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,
0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,
0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,
0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
void frag_main()
{
}
void main()
{
frag_main();
}
*/
static const uint8_t shadow_geom_fs_source_hlsl5[56] = {
0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,
0x6e,0x28,0x29,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 scale;
float4 material;
};
struct instances
{
instance items[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 light_view_proj;
};
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _91 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
float4 _68 = float4(in.in_pos * _15.items[_30].scale.xyz, 1.0);
out.gl_Position = _91.light_view_proj * float4(dot(_15.items[_30].xform_row0, _68), dot(_15.items[_30].xform_row1, _68), dot(_15.items[_30].xform_row2, _68), 1.0);
return out;
}
*/
static const uint8_t shadow_geom_vs_source_metal_macos[1025] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x73,0x63,0x61,0x6c,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,
0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,
0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,0x74,
0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,
0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,
0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,0x66,
0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x39,0x31,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,
0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,
0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,
0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,
0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x69,0x6e,0x73,0x74,
0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x69,0x6e,0x74,0x28,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x36,0x38,0x20,
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x5f,0x70,
0x6f,0x73,0x20,0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,
0x33,0x30,0x5d,0x2e,0x73,0x63,0x61,0x6c,0x65,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x39,0x31,0x2e,0x6c,
0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x30,0x2c,0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x64,0x6f,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2c,0x20,0x5f,0x36,0x38,0x29,
0x2c,0x20,0x64,0x6f,0x74,0x28,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,
0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2c,
0x20,0x5f,0x36,0x38,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
fragment void main0()
{
}
*/
static const uint8_t shadow_geom_fs_source_metal_macos[100] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x20,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x29,0x0a,0x7b,0x0a,
0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* shadow_geom_caster_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_geom_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_geom_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "shadow_geom_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_geom_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_geom_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "shadow_geom_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_geom_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)shadow_geom_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "shadow_geom_caster_shader";
}
return &desc;
}
return 0;
}

View file

@ -0,0 +1,546 @@
#pragma once
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/shadow_caster_sphere.glsl --output E:/box/box3d/samples/shaders/generated/shadow_caster_sphere.glsl.h --slang hlsl5:metal_macos:glsl430
Overview:
=========
Shader program: 'caster':
Get shader desc: shadow_sphere_caster_shader_desc(sg_query_backend());
Vertex Shader: vs
Fragment Shader: fs
Attributes:
ATTR_shadow_sphere_caster_in_pos => 0
Bindings:
Uniform block 'ub_draw':
C struct: shadow_sphere_ub_draw_t
Bind slot: UB_shadow_sphere_ub_draw => 2
Uniform block 'ub_frame':
C struct: shadow_sphere_ub_frame_t
Bind slot: UB_shadow_sphere_ub_frame => 0
Storage buffer 'instances':
C struct: shadow_sphere_instance_t
Bind slot: VIEW_shadow_sphere_instances => 0
Readonly: true
*/
#if !defined(SOKOL_GFX_INCLUDED)
#error "Please include sokol_gfx.h before shadow_caster_sphere.glsl.h"
#endif
#if !defined(SOKOL_SHDC_ALIGN)
#if defined(_MSC_VER)
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
#else
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
#endif
#endif
#define ATTR_shadow_sphere_caster_in_pos (0)
#define UB_shadow_sphere_ub_draw (2)
#define UB_shadow_sphere_ub_frame (0)
#define VIEW_shadow_sphere_instances (0)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_sphere_ub_draw_t {
int inst_base[4];
} shadow_sphere_ub_draw_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_sphere_ub_frame_t {
Mat4 light_view_proj;
} shadow_sphere_ub_frame_t;
#pragma pack(pop)
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct shadow_sphere_instance_t {
Vec4 xform_row0;
Vec4 xform_row1;
Vec4 xform_row2;
Vec4 base_color;
Vec4 params;
Vec4 material;
} shadow_sphere_instance_t;
#pragma pack(pop)
/*
#version 430
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 params;
vec4 material;
};
layout(binding = 0, std430) readonly buffer instances
{
instance items[];
} _15;
uniform ivec4 ub_draw[1];
uniform vec4 ub_frame[4];
layout(location = 0) in vec3 in_pos;
void main()
{
int _30 = ub_draw[0].x + gl_InstanceID;
gl_Position = mat4(ub_frame[0], ub_frame[1], ub_frame[2], ub_frame[3]) * vec4(vec3(_15.items[_30].xform_row0.w, _15.items[_30].xform_row1.w, _15.items[_30].xform_row2.w) + (in_pos * _15.items[_30].params.x), 1.0);
}
*/
static const uint8_t shadow_sphere_vs_source_glsl430[612] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
0x63,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x61,0x72,
0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x6d,0x61,
0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,
0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,
0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,
0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,
0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x69,0x76,0x65,0x63,0x34,0x20,
0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,
0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,
0x65,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
0x63,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,
0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x5b,
0x30,0x5d,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x75,0x62,0x5f,
0x66,0x72,0x61,0x6d,0x65,0x5b,0x30,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,
0x6d,0x65,0x5b,0x31,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,
0x32,0x5d,0x2c,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x76,0x65,0x63,0x33,0x28,0x5f,0x31,0x35,
0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,
0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,
0x6f,0x77,0x31,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,
0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,
0x2e,0x77,0x29,0x20,0x2b,0x20,0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,
0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x70,
0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x7d,0x0a,0x0a,0x00,
};
/*
#version 430
void main()
{
}
*/
static const uint8_t shadow_sphere_fs_source_glsl430[32] = {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
ByteAddressBuffer _15 : register(t0);
cbuffer ub_draw : register(b2)
{
int4 _21_inst_base : packoffset(c0);
};
cbuffer ub_frame : register(b0)
{
row_major float4x4 _83_light_view_proj : packoffset(c0);
};
static float4 gl_Position;
static int gl_InstanceIndex;
static float3 in_pos;
struct SPIRV_Cross_Input
{
float3 in_pos : TEXCOORD0;
uint gl_InstanceIndex : SV_InstanceID;
};
struct SPIRV_Cross_Output
{
float4 gl_Position : SV_Position;
};
void vert_main()
{
instance _33;
_33.xform_row0 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 0));
_33.xform_row1 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 16));
_33.xform_row2 = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 32));
_33.base_color = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 48));
_33.params = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 64));
_33.material = asfloat(_15.Load4((_21_inst_base.x + gl_InstanceIndex) * 96 + 80));
gl_Position = mul(float4(float3(_33.xform_row0.w, _33.xform_row1.w, _33.xform_row2.w) + (in_pos * _33.params.x), 1.0f), _83_light_view_proj);
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_InstanceIndex = int(stage_input.gl_InstanceIndex);
in_pos = stage_input.in_pos;
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
return stage_output;
}
*/
static const uint8_t shadow_sphere_vs_source_hlsl5[1611] = {
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,
0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x42,0x79,0x74,0x65,0x41,0x64,
0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,0x65,0x72,0x20,0x5f,0x31,0x35,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,0x30,0x29,0x3b,0x0a,
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x20,
0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x32,0x29,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x32,0x31,0x5f,0x69,0x6e,
0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,
0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x63,0x62,
0x75,0x66,0x66,0x65,0x72,0x20,0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x20,0x3a,
0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x38,0x33,0x5f,0x6c,0x69,0x67,0x68,0x74,
0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x3a,0x20,0x70,0x61,0x63,
0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,
0x74,0x69,0x63,0x20,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,
0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3a,0x20,
0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,
0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,
0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,
0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,
0x5f,0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,
0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,
0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,
0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,
0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x20,
0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,
0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,
0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,
0x31,0x36,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,
0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,
0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,
0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,
0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x33,0x32,0x29,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,0x62,0x61,0x73,0x65,0x5f,0x63,0x6f,0x6c,0x6f,
0x72,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,
0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,
0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,
0x2b,0x20,0x34,0x38,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x33,0x33,0x2e,
0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,
0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,
0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,
0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x20,
0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x5f,0x33,0x33,0x2e,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x20,0x3d,0x20,
0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,0x5f,0x31,0x35,0x2e,0x4c,0x6f,0x61,0x64,
0x34,0x28,0x28,0x5f,0x32,0x31,0x5f,0x69,0x6e,0x73,0x74,0x5f,0x62,0x61,0x73,0x65,
0x2e,0x78,0x20,0x2b,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x6e,0x64,0x65,0x78,0x29,0x20,0x2a,0x20,0x39,0x36,0x20,0x2b,0x20,0x38,0x30,
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x33,0x33,0x2e,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,0x33,0x33,0x2e,0x78,0x66,
0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x31,0x2e,0x77,0x2c,0x20,0x5f,0x33,0x33,0x2e,
0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,0x77,0x29,0x20,0x2b,0x20,
0x28,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x2a,0x20,0x5f,0x33,0x33,0x2e,0x70,0x61,
0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,
0x5f,0x38,0x33,0x5f,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,
0x72,0x6f,0x6a,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,
0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,0x61,
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
0x6e,0x70,0x75,0x74,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
void frag_main()
{
}
void main()
{
frag_main();
}
*/
static const uint8_t shadow_sphere_fs_source_hlsl5[56] = {
0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,
0x6e,0x28,0x29,0x3b,0x0a,0x7d,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct instance
{
float4 xform_row0;
float4 xform_row1;
float4 xform_row2;
float4 base_color;
float4 params;
float4 material;
};
struct instances
{
instance items[1];
};
struct ub_draw
{
int4 inst_base;
};
struct ub_frame
{
float4x4 light_view_proj;
};
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float3 in_pos [[attribute(0)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant ub_frame& _83 [[buffer(0)]], constant ub_draw& _21 [[buffer(2)]], const device instances& _15 [[buffer(8)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
int _30 = _21.inst_base.x + int(gl_InstanceIndex);
out.gl_Position = _83.light_view_proj * float4(float3(_15.items[_30].xform_row0.w, _15.items[_30].xform_row1.w, _15.items[_30].xform_row2.w) + (in.in_pos * _15.items[_30].params.x), 1.0);
return out;
}
*/
static const uint8_t shadow_sphere_vs_source_metal_macos[982] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x30,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x66,0x6f,0x72,
0x6d,0x5f,0x72,0x6f,0x77,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x61,0x73,0x65,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x6d,0x61,0x74,0x65,0x72,0x69,0x61,0x6c,0x3b,0x0a,0x7d,0x3b,
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,
0x65,0x20,0x69,0x74,0x65,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x62,
0x61,0x73,0x65,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x75,0x62,0x5f,0x66,0x72,0x61,0x6d,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6c,0x69,0x67,0x68,0x74,0x5f,0x76,0x69,
0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x33,0x20,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,0x5b,0x5b,0x61,
0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x62,0x5f,
0x66,0x72,0x61,0x6d,0x65,0x26,0x20,0x5f,0x38,0x33,0x20,0x5b,0x5b,0x62,0x75,0x66,
0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,
0x6e,0x74,0x20,0x75,0x62,0x5f,0x64,0x72,0x61,0x77,0x26,0x20,0x5f,0x32,0x31,0x20,
0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x32,0x29,0x5d,0x5d,0x2c,0x20,0x63,
0x6f,0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,
0x61,0x6e,0x63,0x65,0x73,0x26,0x20,0x5f,0x31,0x35,0x20,0x5b,0x5b,0x62,0x75,0x66,
0x66,0x65,0x72,0x28,0x38,0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x20,
0x5b,0x5b,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x5f,0x69,0x64,0x5d,0x5d,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,
0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,
0x6e,0x74,0x20,0x5f,0x33,0x30,0x20,0x3d,0x20,0x5f,0x32,0x31,0x2e,0x69,0x6e,0x73,
0x74,0x5f,0x62,0x61,0x73,0x65,0x2e,0x78,0x20,0x2b,0x20,0x69,0x6e,0x74,0x28,0x67,
0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x6e,0x64,0x65,0x78,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x38,0x33,0x2e,0x6c,0x69,0x67,0x68,
0x74,0x5f,0x76,0x69,0x65,0x77,0x5f,0x70,0x72,0x6f,0x6a,0x20,0x2a,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x28,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x5f,0x31,0x35,0x2e,
0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,
0x5f,0x72,0x6f,0x77,0x30,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,
0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,
0x77,0x31,0x2e,0x77,0x2c,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,
0x5f,0x33,0x30,0x5d,0x2e,0x78,0x66,0x6f,0x72,0x6d,0x5f,0x72,0x6f,0x77,0x32,0x2e,
0x77,0x29,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x5f,0x70,0x6f,0x73,0x20,
0x2a,0x20,0x5f,0x31,0x35,0x2e,0x69,0x74,0x65,0x6d,0x73,0x5b,0x5f,0x33,0x30,0x5d,
0x2e,0x70,0x61,0x72,0x61,0x6d,0x73,0x2e,0x78,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
fragment void main0()
{
}
*/
static const uint8_t shadow_sphere_fs_source_metal_macos[100] = {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,
0x20,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x29,0x0a,0x7b,0x0a,
0x7d,0x0a,0x0a,0x00,
};
static inline const sg_shader_desc* shadow_sphere_caster_shader_desc(sg_backend backend) {
if (backend == SG_BACKEND_GLCORE) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_sphere_vs_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_sphere_fs_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].glsl_name = "in_pos";
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "ub_frame";
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].glsl_uniforms[0].type = SG_UNIFORMTYPE_INT4;
desc.uniform_blocks[2].glsl_uniforms[0].array_count = 1;
desc.uniform_blocks[2].glsl_uniforms[0].glsl_name = "ub_draw";
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.glsl_binding_n = 0;
desc.label = "shadow_sphere_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_D3D11) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_sphere_vs_source_hlsl5;
desc.vertex_func.d3d11_target = "vs_5_0";
desc.vertex_func.entry = "main";
desc.fragment_func.source = (const char*)shadow_sphere_fs_source_hlsl5;
desc.fragment_func.d3d11_target = "ps_5_0";
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.attrs[0].hlsl_sem_name = "TEXCOORD";
desc.attrs[0].hlsl_sem_index = 0;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].hlsl_register_b_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].hlsl_register_b_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.hlsl_register_t_n = 0;
desc.label = "shadow_sphere_caster_shader";
}
return &desc;
}
if (backend == SG_BACKEND_METAL_MACOS) {
static sg_shader_desc desc;
static bool valid;
if (!valid) {
valid = true;
desc.vertex_func.source = (const char*)shadow_sphere_vs_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = (const char*)shadow_sphere_fs_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[0].size = 64;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.uniform_blocks[2].stage = SG_SHADERSTAGE_VERTEX;
desc.uniform_blocks[2].layout = SG_UNIFORMLAYOUT_STD140;
desc.uniform_blocks[2].size = 16;
desc.uniform_blocks[2].msl_buffer_n = 2;
desc.views[0].storage_buffer.stage = SG_SHADERSTAGE_VERTEX;
desc.views[0].storage_buffer.readonly = true;
desc.views[0].storage_buffer.msl_buffer_n = 8;
desc.label = "shadow_sphere_caster_shader";
}
return &desc;
}
return 0;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,144 @@
// BRDF integration LUT (Karis 2013 split-sum, environment term).
//
// Output is RG16F at 256^2. R = scale, G = bias for the split-sum approx:
// integrated_specular = prefiltered_env(R(N,V), roughness) * (F0 * lut.r + lut.g)
// where lut is sampled at (n_dot_v, roughness). Generated once at boot,
// independent of sun, environment, and view.
//
// The integral is importance-sampled GGX over 1024 Hammersley samples per
// pixel. Heavy for a single fragment, but it runs once and into
// a 256^2 target so the total cost is bounded (~67M iterations). The result
// is environment-independent, it stays valid for the lifetime of the
// renderer.
//
// VS sets v_uv to the SAMPLE-time UV that addresses this pixel's content,
// not the raw NDC-derived UV. sokol-shdc does NOT normalize render-target
// V orientation across backends: on GL a fragment at NDC.y=+1 stores at
// the texture row that sampling at V=1 returns, on D3D11/Metal/WGPU the
// same fragment stores at the row that sampling at V=0 returns. The FS
// uses v_uv.y as the integration roughness, so for sampling at
// (n_dot_v, roughness) to round-trip we flip via a backend-conditional
// uvYSign (+1 GL, -1 D3D11/Metal/WGPU). Same pattern as gtao.glsl /
// cube.glsl's cascade_far_view_z.w.
#pragma sokol @module brdf_lut
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
layout(binding = 0)uniform ub_brdf
{
// .x = uvYSign (+1 GL, -1 D3D11/Metal/WGPU)
vec4 params;
};
out vec2 v_uv;
void main()
{
vec2 ndc = vec2(float((gl_VertexIndex << 1)& 2),
float(gl_VertexIndex & 2)) * 2.0 - 1.0;
v_uv = vec2(ndc.x * 0.5 + 0.5, 0.5 + ndc.y * 0.5 * params.x);
gl_Position = vec4(ndc, 0.0, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
in vec2 v_uv;
out vec2 out_color;
const float BRDF_LUT_PI = 3.14159265358979323846;
const uint NUM_SAMPLES = 1024u;
// Van der Corput radical inverse, bit-reverse trick for low-discrepancy
// sequences. Together with the index, gives a Hammersley sample on [0,1)^2.
float radicalInverseVdC(uint bits)
{
bits = (bits << 16u)|(bits >> 16u);
bits = ((bits & 0x55555555u) << 1u)|((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u)|((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u)|((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u)|((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10;
}
vec2 hammersley(uint i, uint n)
{
return vec2(float(i) / float(n), radicalInverseVdC(i));
}
// GGX importance sampling, returns a microfacet half-vector H in tangent
// space (z-up). For BRDF integration N = (0,0,1) so tangent = world space.
vec3 importanceSampleGGX(vec2 Xi, float alpha)
{
float a2 = alpha * alpha;
float phi = 2.0 * BRDF_LUT_PI * Xi.x;
float cos_theta = sqrt((1.0 - Xi.y) / (1.0 + (a2 - 1.0) * Xi.y));
float sin_theta = sqrt(max(1.0 - cos_theta * cos_theta, 0.0));
return vec3(sin_theta * cos(phi), sin_theta * sin(phi), cos_theta);
}
// Smith G with Karis' IBL remap: k = a^2/2 (rather than (a+1)^2/8 used for
// direct lighting). This is the form that pairs correctly with importance-
// sampled GGX integration.
float smithGggxIbl(float n_dot_v, float n_dot_l, float alpha)
{
float k = (alpha * alpha) * 0.5;
float gv = n_dot_v / (n_dot_v * (1.0 - k) + k);
float gl = n_dot_l / (n_dot_l * (1.0 - k) + k);
return gv * gl;
}
vec2 integrateBRDF(float n_dot_v, float roughness)
{
// V is in the (x,z) plane with N = +Z. n_dot_v fully determines it.
vec3 V = vec3(sqrt(max(1.0 - n_dot_v * n_dot_v, 0.0)), 0.0, n_dot_v);
float A = 0.0;
float B = 0.0;
float alpha = roughness * roughness;
for (uint i = 0u; i < NUM_SAMPLES; ++i)
{
vec2 Xi = hammersley(i, NUM_SAMPLES);
vec3 H = importanceSampleGGX(Xi, alpha);
vec3 L = 2.0 * dot(V, H) * H - V;
float n_dot_l = max(L.z, 0.0);
float n_dot_h = max(H.z, 0.0);
float v_dot_h = max(dot(V, H), 0.0);
if (n_dot_l > 0.0)
{
float G = smithGggxIbl(n_dot_v, n_dot_l, alpha);
// pdf-cancelled visibility: G * v_dot_h / (n_dot_h * n_dot_v).
float G_Vis = (G * v_dot_h) / max(n_dot_h * n_dot_v, 1.0e-5);
// max(0, ...): v_dot_h is max -clamped to [0, inf) above but
// unit-vector drift could in principle push it just over 1.
// Wrap to dodge HLSL's pow(negative, n) warning (X3571).
float Fc = pow(max(0.0, 1.0 - v_dot_h), 5.0);
A += (1.0 - Fc) * G_Vis;
B += Fc * G_Vis;
}
}
return vec2(A, B) / float(NUM_SAMPLES);
}
void main()
{
// v_uv ranges over [0.5/N, (N-0.5)/N] across the LUT, never touches 0
// or 1 exactly, which keeps the integration well-defined at the
// (n_dot_v=0, roughness=0) corner.
float n_dot_v = max(v_uv.x, 1.0e-3);
float roughness = max(v_uv.y, 1.0e-3);
out_color = integrateBRDF(n_dot_v, roughness);
}
#pragma sokol @end
#pragma sokol @program build vs fs

View file

@ -0,0 +1,128 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// GGX prefilter fills the radiance mip chain of the IBL specular
// cubemap from the raw Preetham sky cube produced by sky_to_cube.glsl.
//
// One draw per face per mip. The C side passes the destination face's
// (right, up, forward) basis and the target mip's roughness. The FS
// importance-samples the GGX lobe centered on N (the per-pixel face
// direction), reads the input cube, and accumulates n.l-weighted
// radiance. Karis split-sum convention: assume V = N (acceptable for
// IBL, the lost direction-dependence becomes part of the BRDF LUT).
//
// At roughness 0 (mirror, mip 0) the GGX lobe collapses to a delta and
// we read the input cube directly. This both speeds up mip 0 and avoids
// the artefact of GGX importance sampling returning a numerically
// imprecise direction near the singularity.
//
// @module prefilter prefixes the generated typedefs so this header
// coexists in ibl.c alongside brdf_lut.glsl.h and sky_to_cube.glsl.h.
#pragma sokol @module prefilter
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
out vec2 v_uv;
void main()
{
vec2 ndc = vec2(float((gl_VertexIndex << 1) & 2),
float(gl_VertexIndex & 2)) * 2.0 - 1.0;
v_uv = ndc * 0.5 + 0.5;
gl_Position = vec4(ndc, 0.0, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
layout(binding = 0) uniform ub_pass
{
vec4 face_right; // .xyz = world-space face right axis
vec4 face_up; // .xyz = world-space face up axis
vec4 face_forward; // .xyz = world-space face forward axis
vec4 params; // .x = roughness in [0,1], .yzw = unused
};
// Input is the unprefiltered sky cube. Filtering sampler with linear
// mips. Although we sample LOD 0 here, the trilinear filter still
// kicks in on the texel-level lookup.
#pragma sokol @image_sample_type tex_sky float
layout(binding = 0)uniform textureCube tex_sky;
#pragma sokol @sampler_type smp_sky filtering
layout(binding = 0)uniform sampler smp_sky;
in vec2 v_uv;
out vec4 out_color;
const float PREFILTER_PI = 3.14159265358979323846;
const uint NUM_SAMPLES = 1024u;
float radicalInverseVdC(uint bits)
{
bits = (bits << 16u)|(bits >> 16u);
bits = ((bits & 0x55555555u) << 1u)|((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u)|((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u)|((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u)|((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10;
}
vec2 hammersley(uint i, uint n)
{
return vec2(float(i) / float(n), radicalInverseVdC(i));
}
vec3 importanceSampleGGX(vec2 Xi, vec3 N, float roughness)
{
float a = roughness * roughness;
float phi = 2.0 * PREFILTER_PI * Xi.x;
float cos_theta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));
float sin_theta = sqrt(max(1.0 - cos_theta * cos_theta, 0.0));
vec3 H_tan = vec3(sin_theta * cos(phi), sin_theta * sin(phi), cos_theta);
// Build an orthonormal basis around N.
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitan = cross(N, tangent);
return normalize(tangent * H_tan.x + bitan * H_tan.y + N * H_tan.z);
}
void main()
{
vec2 uv = v_uv * 2.0 - 1.0;
vec3 N = normalize(face_forward.xyz + uv.x * face_right.xyz + uv.y * face_up.xyz);
vec3 V = N; // Karis split-sum, assume V = N
float roughness = params.x;
if (roughness < 0.001)
{
// Mirror: GGX lobe is a delta, just sample the input direction.
out_color = vec4(texture(samplerCube(tex_sky, smp_sky), N).rgb, 1.0);
return;
}
vec3 prefiltered = vec3(0.0);
float total_w = 0.0;
for(uint i = 0u; i < NUM_SAMPLES; ++i)
{
vec2 Xi = hammersley(i, NUM_SAMPLES);
vec3 H = importanceSampleGGX(Xi, N, roughness);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float n_dot_l = max(dot(N, L), 0.0);
if (n_dot_l > 0.0)
{
prefiltered += texture(samplerCube(tex_sky, smp_sky), L).rgb * n_dot_l;
total_w += n_dot_l;
}
}
out_color = vec4(prefiltered / max(total_w, 1.0e-4), 1.0);
}
#pragma sokol @end
#pragma sokol @program build vs fs

View file

@ -0,0 +1,103 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Procedural sky: Preetham/Shirley/Smits 1999 analytic daylight.
//
// Drawn as a fullscreen triangle inside the main lit pass, AFTER all opaque
// shapes, with depth test GREATER_EQUAL against the reverse-Z far plane
// (clear value = 0). NDC z = 0 puts the triangle at the far plane, opaque
// fragments wrote z > 0 (closer in reverse-Z), so GREATER_EQUAL discards
// the sky there and keeps it on untouched pixels. Depth write is disabled,
// the sky is "infinitely far" and shouldn't write to z.
//
// View-ray reconstruction. VS unprojects each fullscreen-triangle vertex
// to homogeneous world coordinates via inv_view_proj and forwards them
// undivided. All three vertices have gl_Position.w = 1, so perspective-
// correct interpolation degenerates to linear interp, and matrix linearity
// means the interpolated v_world_homog at a fragment equals inv_view_proj
// times that fragment's NDC point exactly. FS divides by w and subtracts
// the camera position to get the world-space view direction.
//
// Below-horizon handling. Preetham is invalid for sun elevations near and
// below the horizon. The renderer C side computes a smoothstep fade weight
// between sin(2 deg) and sin(5 deg) and passes it as sun_dir_world.w, the FS
// just multiplies the output by it. preethamSky in common/preetham.glsl
// clamps its inputs to the upper hemisphere internally to keep the math
// finite while the fade weight drives the output to zero.
//
// Output is linear sRGB radiance, scaled by an empirical luminance factor
// chosen to land near the target sun:sky ratio (~8-15:1) under the
// renderer's sun_color premultiplied-by-pi convention.
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @vs vs
// Per-shader UBO name prefix (sky_*) to keep sokol-shdc's generated typedefs
// disjoint from cube.glsl.h's unprefixed ub_frame_t / ub_pass_t, both
// headers are included from src/gfx/renderer.c.
layout(binding = 0) uniform sky_ub_frame
{
mat4 inv_view_proj;
};
out vec4 v_world_homog; // inv_view_proj * (ndc, 0, 1), undivided
void main()
{
// Standard fullscreen-triangle trick: 3 vertices cover the NDC square
// and 25% extra outside, which the rasterizer clips. Avoids the
// two-triangle seam-discontinuity that a quad has at its diagonal.
// vert 0 -> (-1, -1)
// vert 1 -> ( 3, -1)
// vert 2 -> (-1, 3).
vec2 ndc = vec2(float((gl_VertexIndex << 1) & 2), float(gl_VertexIndex & 2)) * 2.0 - 1.0;
// NDC z = 0 -> reverse-Z far plane. Depth test GREATER_EQUAL passes
// against the cleared depth of 0 on untouched pixels and fails on any
// opaque pixel (whose depth is > 0 in reverse-Z).
vec4 clip = vec4(ndc, 0.0, 1.0);
gl_Position = clip;
v_world_homog = inv_view_proj * clip;
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/preetham.glsl
layout(binding = 1)uniform sky_ub_pass
{
vec4 sun_dir_world; // .xyz = world dir TO sun (normalized), .w = below-horizon fade weight [0,1]
vec4 sky_params; // .x = turbidity (Preetham T), .yzw = reserved
vec4 camera_pos; // .xyz = world camera position, .w = unused
};
in vec4 v_world_homog;
out vec4 out_color;
void main()
{
// World-space view direction at this fragment.
vec3 world_pos = v_world_homog.xyz / v_world_homog.w;
vec3 view_dir = normalize(world_pos - camera_pos.xyz);
// Renormalize the sun defensively. Caller is the renderer with
// sun.dirToSun already normalized, but an undetected zero vector
// here would emit NaNs.
vec3 sun_dir = normalize(sun_dir_world.xyz);
// Empirical luminance scale + below-horizon fade live in
// preethamSkyScaled so the IBL sky cubemap (sky_to_cube.glsl) sees
// the same backdrop. Fade weight comes from the C side via
// sun_dir_world.w (1 above horizon, 0 below).
vec3 rgb = preethamSkyScaled(view_dir, sun_dir, sky_params.x, sun_dir_world.w);
out_color = vec4(rgb, 1.0);
}
#pragma sokol @end
#pragma sokol @program sky vs fs

View file

@ -0,0 +1,70 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Sky cubemap renderer.
//
// Fills one face of a 6xN^2 RGBA16F cubemap per draw with the Preetham
// analytic daylight model. The C side runs six passes (one per face)
// when the sun direction or turbidity changes, the resulting cubemap
// becomes both the diffuse-irradiance source (via SH projection on the
// CPU) and the input to the GGX prefilter pass.
//
// Direction reconstruction. Each draw receives a per-face mat3 basis
// (right, up, forward). The FS computes a world-space direction from
// the fragment's v_uv in [0,1]^2 as
// dir = normalize(forward + (2*v_uv.x - 1) * right + (2*v_uv.y - 1) * up)
// The basis vectors are filled C-side to match the GL cubemap sampling
// convention (which sokol abstracts uniformly across backends), so a
// direction d written here is recovered by sampling the cubemap with
// the same d.
// @module sky_to_cube prefixes the generated typedefs (struct, slot
// enum, static byte arrays) so this header coexists in ibl.c with
// brdf_lut.glsl.h and prefilter.glsl.h without collisions.
#pragma sokol @module sky_to_cube
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
out vec2 v_uv;
void main()
{
vec2 ndc = vec2(float((gl_VertexIndex << 1) & 2),
float(gl_VertexIndex & 2)) * 2.0 - 1.0;
v_uv = ndc * 0.5 + 0.5;
gl_Position = vec4(ndc, 0.0, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/preetham.glsl
layout(binding = 0)uniform ub_face
{
// Three rows of a mat3 basis. Stored as vec4 for std140 alignment,
// .xyz are the axis vectors, .w is unused (.w on face_forward
// doubles as the below-horizon fade weight to save a UBO slot).
vec4 face_right; // .xyz = world-space face right axis
vec4 face_up; // .xyz = world-space face up axis
vec4 face_forward; // .xyz = world-space face forward axis, .w = fade weight
vec4 sun_dir_world; // .xyz = world-space direction TO sun, .w = turbidity
};
in vec2 v_uv;
out vec4 out_color;
void main()
{
vec2 uv = v_uv * 2.0 - 1.0; // [-1, +1] across the face
vec3 dir = normalize(face_forward.xyz + uv.x * face_right.xyz + uv.y * face_up.xyz);
vec3 rgb = preethamSkyScaled(dir, sun_dir_world.xyz, sun_dir_world.w, face_forward.w);
out_color = vec4(rgb, 1.0);
}
#pragma sokol @end
#pragma sokol @program build vs fs

View file

@ -0,0 +1,275 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Overlay line shader.
//
// Renders fat lines as shader-expanded screen-space quads. Per-instance
// data (two endpoints, color, thickness, mode flags) lives in a storage
// buffer indexed by gl_InstanceIndex, the VS expands six vertices per
// instance from gl_VertexIndex with no VBO/IBO bound.
//
// Vertex index -> corner layout (two triangles forming a quad):
//
// 0 -> endpoint=A, side=-1 3 -> endpoint=A, side=-1
// 1 -> endpoint=B, side=-1 4 -> endpoint=B, side=+1
// 2 -> endpoint=B, side=+1 5 -> endpoint=A, side=+1
//
// Thickness modes (instance flag bit 0):
// PIXELS, screen-space pixels, constant on-screen weight.
// WORLD, world meters, converted to pixels per endpoint using
// `viewport.y * proj[1][1] / (2 * clip.w)`. Per-endpoint, so
// a long line tapers correctly with depth.
//
// Occlusion modes (instance flag bit 1, branched in the FS):
// HIDE, output alpha=0 when occluded (single-pipeline approximation
// of a depth-tested draw, see note below on pipeline state).
// DIM, modulate color (premultiplied -> multiply both rgb and a) when
// occluded so the line stays readable through walls.
// DASHED, screen-space dash pattern (8 px on / 8 px off) when occluded.
// Pattern is zero-alpha in the gap, NOT discard, avoids
// disabling early-Z and keeps the FS flow control flat.
//
// Pipeline state notes:
// * depth_compare = ALWAYS, depth_write = off. The shader samples the
// linear-depth pre-pass (R32F view-space Z, written by GTAO's depth
// pre-pass) and compares per-fragment for the DIM/DASHED branches.
// HIDE relies on the same sample + alpha=0. MSAA silhouettes for
// HIDE may read slightly harder than a depth-tested draw would
// produce. If that bites visually, split into a second pipeline
// with depth_compare = GREATER for HIDE-mode instances.
// * Premultiplied-alpha blend (SRC_ONE, ONE_MINUS_SRC_ALPHA). CPU side
// packs `color.rgb *= color.a` into the instance before upload.
//
// UV handling: the linear-depth target is sampled at
// `gl_FragCoord.xy / textureSize(...)`. This is the same trick cube.glsl
// uses for the GTAO sample. Pixel-space gl_FragCoord matches the
// rasterizer's storage orientation on every backend, so no uvYSign flip
// is needed. The flip is required only when sampling with NDC-derived
// UVs, which we don't do here.
#pragma sokol @module overlay_line
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
layout(binding = 0) uniform ub_frame
{
mat4 view;
mat4 proj;
mat4 view_proj;
mat4 inv_view_proj;
vec4 camera_pos; // .xyz = pos, .w = time
vec4 viewport; // .xy = size px, .zw = 1/size
};
struct line_instance
{
vec4 a; // .xyz = world endpoint A, .w = thickness (px or world)
vec4 b; // .xyz = world endpoint B, .w = reserved
vec4 color; // premultiplied linear RGBA
uvec4 flags; // .x = thickness unit (0 px / 1 world)
// .y = occlusion mode (0 hide / 1 dim / 2 dashed)
// .zw = reserved
};
layout(binding = 0) readonly buffer line_instances
{
line_instance instances[];
};
out vec2 v_screen_a; // flat per-instance screen-space pixel coords of A
out vec2 v_screen_b; // flat per-instance screen-space pixel coords of B
noperspective out float v_dist_from_axis_px; // signed perpendicular pixel distance (smooth)
out float v_half_width_px; // half-width in pixels at this fragment (smooth, varies in WORLD mode)
out float v_view_z; // positive view-space depth (smooth, perspective-correct)
flat out vec4 v_color;
flat out uint v_occ_mode;
void main()
{
line_instance inst = instances[gl_InstanceIndex];
// Decode vertex index -> endpoint + side.
int index = gl_VertexIndex;
bool is_b = (index == 1)||(index == 2)||(index == 4);
float side = ((index == 2)||(index == 4)||(index == 5)) ? 1.0 : -1.0;
vec3 world_a = inst.a.xyz;
vec3 world_b = inst.b.xyz;
vec4 clip_a = view_proj * vec4(world_a, 1.0);
vec4 clip_b = view_proj * vec4(world_b, 1.0);
vec4 view_a = view * vec4(world_a, 1.0);
vec4 view_b = view * vec4(world_b, 1.0);
vec4 clip_end = is_b ? clip_b : clip_a;
float view_z_end = -(is_b ? view_b.z : view_a.z);
// Screen-space pixel coords of both endpoints (after perspective divide,
// remapped from NDC [-1,1] to pixel [0, viewport]). Used by the FS for
// dash phase computation, both endpoints needed at every vertex because
// we don't qualify "flat from provoking vertex" which is impl-defined.
vec2 ndc_a = clip_a.xy / clip_a.w;
vec2 ndc_b = clip_b.xy / clip_b.w;
v_screen_a = (ndc_a * 0.5 + 0.5) * viewport.xy;
v_screen_b = (ndc_b * 0.5 + 0.5) * viewport.xy;
// Screen-space line direction in pixels (aspect-corrected). Fallback
// direction if both endpoints project to the same pixel, line is
// effectively a point, the perpendicular doesn't matter.
vec2 dir_px = v_screen_b - v_screen_a;
float len_px = length(dir_px);
vec2 dir_n = (len_px > 1e-6) ? (dir_px / len_px) : vec2(1.0, 0.0);
vec2 perp_n = vec2(-dir_n.y, dir_n.x);
// Half-width in pixels, mode-aware. WORLD converts at the endpoint's
// view-space depth so the line tapers correctly. proj[1][1] is
// 1/tan(fovY/2) for a standard perspective projection, viewport.y *
// proj[1][1] / (2 * z) yields pixels per world unit at view-space
// distance z.
float thickness = inst.a.w;
float half_width_px;
if (inst.flags.x == 0u)
{
half_width_px = thickness * 0.5;
}
else
{
float pixels_per_world = viewport.y * proj[1][1] / (2.0 * view_z_end);
half_width_px = thickness * 0.5 * pixels_per_world;
}
// Floor at 0.5 px so very thin lines don't vanish into sub-pixel land,
// attenuation for requested widths below this happens FS-side via the
// box-filter coverage falloff.
half_width_px = max(half_width_px, 0.5);
// Expand the rasterized quad past the true half-width by an AA pad so
// the FS coverage falloff has geometry to ramp down inside. Without it
// the quad edge cuts the falloff off mid-ramp, a hard step along the
// line that reads as a jaggy no matter how good the FS filter is. The
// FS uses the TRUE half-width (v_half_width_px), so the pad adds only
// transparent margin, it does not fatten the visible line. The FS
// smoothstep falloff completes at d = half_width + fwidth, and fwidth
// (an L1 norm) peaks at sqrt(2) on a 45 deg line, so the pad must be
// >= ~1.42 px, 1.5 covers it with margin.
const float AA_PAD_PX = 1.5;
float quad_half_px = half_width_px + AA_PAD_PX;
// Offset from the axis in pixels -> in NDC at this endpoint's depth.
// Multiply by clip_end.w so that after perspective divide it lands at
// the right NDC position.
vec2 offset_px = perp_n * side * quad_half_px;
vec2 offset_ndc = offset_px * (2.0 * viewport.zw);
vec4 clip_pos = clip_end;
clip_pos.xy += offset_ndc * clip_end.w;
gl_Position = clip_pos;
v_dist_from_axis_px = side * quad_half_px;
v_half_width_px = half_width_px;
v_view_z = view_z_end;
v_color = inst.color;
v_occ_mode = inst.flags.y;
}
#pragma sokol @end
#pragma sokol @fs fs
// binding=1 (not 0): sokol-shdc enforces disjoint binding numbers between
// storage buffers and textures across all stages of a program. The line
// instance buffer holds binding=0 in the VS, so the depth texture takes 1.
#pragma sokol @image_sample_type tex_depth float
layout(binding = 1)uniform texture2D tex_depth;
#pragma sokol @sampler_type smp_depth filtering
layout(binding = 0)uniform sampler smp_depth;
in vec2 v_screen_a;
in vec2 v_screen_b;
noperspective in float v_dist_from_axis_px;
in float v_half_width_px;
in float v_view_z;
flat in vec4 v_color;
flat in uint v_occ_mode;
out vec4 out_color;
const uint OCC_HIDE = 0u;
const uint OCC_DIM = 1u;
const uint OCC_DASHED = 2u;
void main()
{
// Coverage from the capsule SDF. d is the fragment's folded
// perpendicular distance from the axis (px), coverage ramps 1->0 over a
// 2*aa band straddling the true edge at d = half_width.
//
// This is a smoothstep, not an energy-exact box filter. A box filter's
// ~1px falloff faithfully renders the intrinsic stair-stepping of a
// thin near-axis-aligned line, this wider cubic falloff spreads each
// row-to-row step into a gradient that reads smoother, the better
// tradeoff for thin debug lines. fwidth is taken of the raw signed
// v_dist_from_axis_px (not abs/sd): fwidth(abs(x)) kinks where x
// crosses 0 at the line center, the signed value is stable everywhere.
// The VS quad pad (AA_PAD_PX) must cover this 2*aa band.
float d = abs(v_dist_from_axis_px);
float aa = fwidth(v_dist_from_axis_px);
float coverage = 1.0 - smoothstep(v_half_width_px - aa, v_half_width_px + aa, d);
// Sample scene linear depth. Pixel-space gl_FragCoord divided by the
// target's textureSize is backend-canonical, no UV.y flip needed.
vec2 depth_uv = gl_FragCoord.xy / vec2(textureSize(sampler2D(tex_depth, smp_depth), 0));
float scene_z = textureLod(sampler2D(tex_depth, smp_depth), depth_uv, 0.0).r;
// Slope-scaled occlusion bias. A fixed bias can't protect a line lying
// coplanar with a surface: at grazing angles the scene depth changes
// many mm per pixel, so the sampled scene_z and the line's own v_view_z
// disagree by more than any small constant, the test flips per pixel
// and HIDE-mode chunks drop out, breaking the line. fwidth(v_view_z) is
// the line's per-pixel view-depth change: large at grazing angles, ~0
// head-on, so the bias grows exactly where it's needed without letting
// head-on lines bleed through occluders. Same idea as slope-scaled
// shadow depth bias.
const float occlusion_bias_m = 0.001; // ~1 mm floor, head-on contact
const float occlusion_slope_k = 2.0; // grazing-angle multiplier
float occlusion_bias = occlusion_bias_m + occlusion_slope_k * fwidth(v_view_z);
bool occluded = v_view_z > scene_z + occlusion_bias;
// Occlusion mode modulation. v_color is premultiplied: multiplying the
// whole vec4 stays valid (rgb*= and a*= by the same factor preserves
// the premultiplied invariant).
vec4 col = v_color;
if (v_occ_mode == OCC_HIDE && occluded)
{
col = vec4(0.0);
}
else if (v_occ_mode == OCC_DIM && occluded)
{
col *= 0.25;
}
else if (v_occ_mode == OCC_DASHED && occluded)
{
// Screen-space dash phase, in pixels along the line from A.
vec2 line_vec = v_screen_b - v_screen_a;
float line_len = max(length(line_vec), 1e-6);
vec2 line_dir = line_vec / line_len;
vec2 rel_px = gl_FragCoord.xy - v_screen_a;
float along_px = dot(rel_px, line_dir);
const float DASH_PERIOD_PX = 16.0;
const float DASH_HALF = 4.0; // half the solid run inside the period
float phase = mod(along_px, DASH_PERIOD_PX);
float dash_sd = abs(phase - DASH_HALF) - DASH_HALF;
float dash_aa = fwidth(along_px);
float dash_msk = 1.0 - smoothstep(-dash_aa, dash_aa, dash_sd);
col *= dash_msk;
}
out_color = col * coverage;
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,176 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Overlay point shader.
//
// Renders fat points as shader-expanded screen-space quads centered on the
// projected world position. Per-instance data (world point, color, size,
// mode flags) lives in a storage buffer indexed by gl_InstanceIndex, the
// VS expands six vertices per instance from gl_VertexIndex with no
// VBO/IBO bound. Two triangles form the quad:
//
// 0 -> (-1, -1) 3 -> (-1, -1)
// 1 -> (+1, -1) 4 -> (+1, +1)
// 2 -> (+1, +1) 5 -> (-1, +1)
//
// Size modes (instance flag bit 0) and occlusion modes (bit 1) match
// line.glsl's conventions exactly, see that file for the rationale.
//
// The FS is a circle SDF: signed distance from the projected point center
// in pixels, AA'd via fwidth. Square or diamond markers would be cheaper
// but circles read unambiguously as "point markers" against the line
// primitive which is a capsule SDF.
//
// Dashed-mode for a point is a bit nonsensical (the dashing axis is
// "along the line", a point has no axis), so DASHED behaves identically
// to DIM here. HIDE and DIM behave as documented.
#pragma sokol @module overlay_point
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
layout(binding = 0)uniform ub_frame
{
mat4 view;
mat4 proj;
mat4 view_proj;
mat4 inv_view_proj;
vec4 camera_pos; // .xyz = pos, .w = time
vec4 viewport; // .xy = size px, .zw = 1/size
};
struct point_instance
{
vec4 p; // .xyz = world position, .w = size (px or world)
vec4 color; // premultiplied linear RGBA
uvec4 flags; // .x = size unit (0 px / 1 world)
// .y = occlusion mode (0 hide / 1 dim / 2 dashed->dim)
// .zw = reserved
};
layout(binding = 0) readonly buffer point_instances
{
point_instance instances[];
};
out vec2 v_offset_from_center_px; // signed pixel offset from quad center (smooth)
out float v_half_size_px; // true point radius in pixels (flat-equivalent, all 6 verts share)
out float v_view_z; // positive view-space depth (smooth, perspective-correct)
flat out vec4 v_color;
flat out uint v_occ_mode;
void main()
{
point_instance inst = instances[gl_InstanceIndex];
int index = gl_VertexIndex;
float corner_x = ((index == 1)||(index == 2)||(index == 4)) ? 1.0 : -1.0;
float corner_y = ((index == 2)||(index == 4)||(index == 5)) ? 1.0 : -1.0;
vec3 world_p = inst.p.xyz;
vec4 clip_c = view_proj * vec4(world_p, 1.0);
vec4 view_c = view * vec4(world_p, 1.0);
float view_z = -view_c.z;
// Half-size in pixels, mode-aware. WORLD conversion follows the same
// formula as line.glsl: pixels per world unit = viewport.y *
// proj[1][1] / (2 * view_z).
float requested = inst.p.w;
float half_size_px;
if (inst.flags.x == 0u)
{
half_size_px = requested * 0.5;
}
else
{
float pixels_per_world = viewport.y * proj[1][1] / (2.0 * view_z);
half_size_px = requested * 0.5 * pixels_per_world;
}
half_size_px = max(half_size_px, 0.5);
// Expand the rasterized quad past the true radius by an AA pad so the
// FS circle-SDF falloff has geometry to ramp down inside (see
// overlays/line.glsl for the full rationale). The FS smoothstep
// completes at d = radius + fwidth, and fwidth (an L1 norm) peaks at
// sqrt(2), so the pad must be >= ~1.42 px, 1.5 covers it.
const float AA_PAD_PX = 1.5;
float quad_half_px = half_size_px + AA_PAD_PX;
vec2 offset_px = vec2(corner_x, corner_y) * quad_half_px;
vec2 offset_ndc = offset_px * (2.0 * viewport.zw);
vec4 clip_pos = clip_c;
clip_pos.xy += offset_ndc * clip_c.w;
gl_Position = clip_pos;
v_offset_from_center_px = offset_px;
v_half_size_px = half_size_px;
v_view_z = view_z;
v_color = inst.color;
v_occ_mode = inst.flags.y;
}
#pragma sokol @end
#pragma sokol @fs fs
// binding=1 (not 0): sokol-shdc enforces disjoint binding numbers between
// storage buffers and textures across all stages of a program. The point
// instance buffer holds binding=0 in the VS, so the depth texture takes 1.
#pragma sokol @image_sample_type tex_depth float
layout(binding = 1)uniform texture2D tex_depth;
#pragma sokol @sampler_type smp_depth filtering
layout(binding = 0)uniform sampler smp_depth;
in vec2 v_offset_from_center_px;
in float v_half_size_px;
in float v_view_z;
flat in vec4 v_color;
flat in uint v_occ_mode;
out vec4 out_color;
const uint OCC_HIDE = 0u;
void main()
{
// Coverage from the circle SDF. d is the fragment's radial distance
// from the point center (px), coverage ramps 1->0 over a 2*aa band
// straddling the true edge at d = radius. Smoothstep (cubic, wider
// than an energy-exact box filter), see overlays/line.glsl for why
// the softer falloff is preferred for thin overlay primitives.
float d = length(v_offset_from_center_px);
float aa = fwidth(d);
float coverage = 1.0 - smoothstep(v_half_size_px - aa, v_half_size_px + aa, d);
vec2 depth_uv = gl_FragCoord.xy / vec2(textureSize(sampler2D(tex_depth, smp_depth), 0));
float scene_z = textureLod(sampler2D(tex_depth, smp_depth), depth_uv, 0.0).r;
// Slope-scaled occlusion bias, see overlays/line.glsl for the full
// rationale. Keeps a point resting on a surface from flickering out in
// HIDE mode without letting head-on points bleed through occluders.
const float occlusion_bias_m = 0.001; // ~1 mm floor
const float occlusion_slope_k = 2.0;
float occlusion_bias = occlusion_bias_m + occlusion_slope_k * fwidth(v_view_z);
bool occluded = v_view_z > scene_z + occlusion_bias;
vec4 col = v_color;
if (occluded)
{
if (v_occ_mode == OCC_HIDE)
{
col = vec4(0.0);
} else {
// DIM (1) and DASHED (2, degenerates to DIM for points)
col *= 0.25;
}
}
out_color = col * coverage;
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,180 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Depth-only pre-pass for capsules. Mirrors
// depth_only_sphere: analytic ray-capsule hit, writes linear view-space
// depth into R32F + reverse-Z clip depth into gl_FragDepth.
#pragma sokol @module depth_only_capsule
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout(binding = 0) uniform ub_frame
{
mat4 view_proj;
};
struct instance
{
vec4 xform_row0; // .xyz = R row 0, .w = center.x
vec4 xform_row1; // .xyz = R row 1, .w = center.y
vec4 xform_row2; // .xyz = R row 2, .w = center.z
vec4 base_color; // unused, layout match
vec4 params; // .x = halfLength, .y = radius
vec4 material; // unused, layout match
};
layout(binding = 0) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
sample out vec3 v_world_pos_proxy;
flat out vec3 v_center;
flat out float v_half_length;
flat out float v_radius;
flat out vec3 v_axis_x_world;
void main()
{
instance inst = items[gl_InstanceIndex];
vec3 center = vec3(inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w);
float halfLength = inst.params.x;
float radius = inst.params.y;
vec3 obj_pos = vec3(
in_pos.x * 2.0 * (halfLength + radius),
in_pos.y * 2.0 * radius,
in_pos.z * 2.0 * radius
);
vec3 world_pos = center + vec3(
dot(inst.xform_row0.xyz, obj_pos),
dot(inst.xform_row1.xyz, obj_pos),
dot(inst.xform_row2.xyz, obj_pos)
);
v_world_pos_proxy = world_pos;
v_center = center;
v_half_length = halfLength;
v_radius = radius;
v_axis_x_world = vec3(inst.xform_row0.x, inst.xform_row1.x, inst.xform_row2.x);
gl_Position = view_proj * vec4(world_pos, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
layout(binding = 1) uniform ub_pass
{
mat4 view_proj;
mat4 view;
vec4 camera_pos; // .xyz = world camera position
};
sample in vec3 v_world_pos_proxy;
flat in vec3 v_center;
flat in float v_half_length;
flat in float v_radius;
flat in vec3 v_axis_x_world;
out vec4 out_linear_depth;
void main()
{
vec3 ro = camera_pos.xyz;
vec3 rd = normalize(v_world_pos_proxy - ro);
vec3 axis = v_axis_x_world;
vec3 pa = v_center - v_half_length * axis;
vec3 pb = v_center + v_half_length * axis;
vec3 ba = pb - pa;
vec3 oa = ro - pa;
float baba = dot(ba, ba);
float bard = dot(ba, rd);
float baoa = dot(ba, oa);
float rdoa = dot(rd, oa);
float oaoa = dot(oa, oa);
float a_c = baba - bard * bard;
float b_c = baba * rdoa - baoa * bard;
float c_c = baba * oaoa - baoa * baoa - v_radius * v_radius * baba;
float h_c = b_c * b_c - a_c * c_c;
float t = -1.0;
if (h_c >= 0.0 && a_c > 1e-8)
{
float t_body = (-b_c - sqrt(h_c)) / a_c;
float y = baoa + t_body * bard;
if (t_body > 0.0 && y > 0.0 && y < baba)
{
t = t_body;
}
}
// Cap A (-X).
{
vec3 oc = ro - pa;
float b = dot(oc, rd);
float c = dot(oc, oc) - v_radius * v_radius;
float h = b * b - c;
if (h >= 0.0)
{
float tc = -b - sqrt(h);
if (tc > 0.0 &&(t < 0.0 || tc < t))
{
vec3 hit = ro + tc * rd;
if (dot(hit - pa, axis) <= 0.0)
{
t = tc;
}
}
}
}
// Cap B (+X).
{
vec3 oc = ro - pb;
float b = dot(oc, rd);
float c = dot(oc, oc) - v_radius * v_radius;
float h = b * b - c;
if (h >= 0.0)
{
float tc = -b - sqrt(h);
if (tc > 0.0 &&(t < 0.0 || tc < t))
{
vec3 hit = ro + tc * rd;
if (dot(hit - pb, axis) >= 0.0)
{
t = tc;
}
}
}
}
if (t < 0.0)
{
discard;
}
vec3 hit_world = ro + t * rd;
float view_z = -(view * vec4(hit_world, 1.0)).z;
vec4 hit_clip = view_proj * vec4(hit_world, 1.0);
gl_FragDepth = hit_clip.z / hit_clip.w;
out_linear_depth = vec4(view_z, 0.0, 0.0, 0.0);
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,70 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Depth-only pre-pass for cubes. Writes positive
// linear view-space depth to an R32F color attachment, the D32F depth
// attachment is transient (rasterizer / early-Z only, never sampled). The
// full XeGTAO port reconstructs normals from depth derivatives inside
// MainPass, so the prepass produces no normal channel.
#pragma sokol @module depth_only_cube
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout(binding = 0) uniform ub_frame
{
mat4 view_proj;
mat4 view;
};
struct cube_instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color; // unused, layout match with lit pipeline
vec4 material; // unused, layout match with lit pipeline
};
layout(binding = 0) readonly buffer cube_instances
{
cube_instance instances[];
};
in vec3 in_pos;
out float v_linear_view_z;
void main()
{
cube_instance inst = instances[gl_InstanceIndex];
vec4 local_pos = vec4(in_pos, 1.0);
vec3 world_pos = vec3(
dot(inst.xform_row0, local_pos),
dot(inst.xform_row1, local_pos),
dot(inst.xform_row2, local_pos)
);
vec4 view_h = view * vec4(world_pos, 1.0);
v_linear_view_z = -view_h.z;
gl_Position = view_proj * vec4(world_pos, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
in float v_linear_view_z;
out vec4 out_linear_depth;
void main()
{
out_linear_depth = vec4(v_linear_view_z, 0.0, 0.0, 0.0);
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,84 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Depth-only pre-pass for triangle geometries (hulls, meshes,
// height fields). Same vertex math as the lit
// geom pipeline, FS writes positive linear view-space depth only.
#pragma sokol @module depth_only_geom
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout(binding = 0) uniform ub_frame
{
mat4 view_proj;
mat4 view;
};
layout(binding = 2) uniform ub_draw
{
ivec4 inst_base; // .x = base index into the global instance array
};
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color; // unused, layout match
vec4 scale; // .xyz = per-instance scale
vec4 material; // unused, layout match
};
layout(binding = 0) readonly buffer instances
{
instance items[];
};
// Position-only input. The shared vertex buffer carries position+normal
// (stride 24 bytes), but this pre-pass doesn't read the normal. We just
// don't declare an `in_normal` attribute so glslang doesn't keep it
// around (and the GL driver doesn't warn about an unused attribute slot
// after stripping). The C-side pipeline desc skips the in_normal binding
// to match.
in vec3 in_pos;
out float v_linear_view_z;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 scaled_pos = in_pos * inst.scale.xyz;
vec4 local_pos = vec4(scaled_pos, 1.0);
vec3 world_pos = vec3(
dot(inst.xform_row0, local_pos),
dot(inst.xform_row1, local_pos),
dot(inst.xform_row2, local_pos)
);
vec4 view_h = view * vec4(world_pos, 1.0);
v_linear_view_z = -view_h.z;
gl_Position = view_proj * vec4(world_pos, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
in float v_linear_view_z;
out vec4 out_linear_depth;
void main()
{
out_linear_depth = vec4(v_linear_view_z, 0.0, 0.0, 0.0);
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,100 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Depth-only pre-pass for spheres. Same shape as
// the lit sphere impostor: bounding-cube proxy in the VS, analytic
// ray-sphere intersection in the FS. Writes the analytic surface's linear
// view-space depth to an R32F color attachment and the reverse-Z clip
// depth to gl_FragDepth (transient D32F attachment, rasterizer only).
#pragma sokol @module depth_only_sphere
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout(binding = 0) uniform ub_frame
{
mat4 view_proj;
};
struct instance
{
vec4 xform_row0; // .w = center.x
vec4 xform_row1; // .w = center.y
vec4 xform_row2; // .w = center.z
vec4 base_color; // unused, layout match
vec4 params; // .x = radius
vec4 material; // unused, layout match
};
layout(binding = 0) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
sample out vec3 v_world_pos_proxy;
flat out vec3 v_center;
flat out float v_radius;
void main()
{
instance inst = items[gl_InstanceIndex];
vec3 center = vec3(inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w);
float radius = inst.params.x;
vec3 world_pos = center + (2.0 * radius) * in_pos;
v_world_pos_proxy = world_pos;
v_center = center;
v_radius = radius;
gl_Position = view_proj * vec4(world_pos, 1.0);
}
#pragma sokol @end
#pragma sokol @fs fs
layout(binding = 1) uniform ub_pass
{
mat4 view_proj; // for gl_FragDepth (reverse-Z)
mat4 view; // for linear view-space depth
vec4 camera_pos; // .xyz = world camera position
};
sample in vec3 v_world_pos_proxy;
flat in vec3 v_center;
flat in float v_radius;
out vec4 out_linear_depth;
void main()
{
vec3 ro = camera_pos.xyz;
vec3 rd = normalize(v_world_pos_proxy - ro);
vec3 oc = ro - v_center;
float b = dot(oc, rd);
float c2 = dot(oc, oc) - v_radius * v_radius;
float h = b * b - c2;
if (h < 0.0) discard;
float t = -b - sqrt(h);
if (t < 0.0) discard;
vec3 hit_world = ro + t * rd;
float view_z = -(view * vec4(hit_world, 1.0)).z;
vec4 hit_clip = view_proj * vec4(hit_world, 1.0);
gl_FragDepth = hit_clip.z / hit_clip.w;
out_linear_depth = vec4(view_z, 0.0, 0.0, 0.0);
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,260 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// GTAO Denoise compute shader.
//
// Port of Esoterica's Denoise.esf (which is XeGTAO's XeGTAO_Denoise), a
// cross-bilateral 3x3 blur of the noisy AO term, weighted by the packed
// per-pixel edges that MainPass wrote alongside the noise. The renderer
// runs N dispatches per frame: (N - 1) intermediate dispatches with
// finalApply = 0 ping-pong noisy0 <-> noisy1, then one final dispatch with
// finalApply = 1 that rescales by XE_GTAO_OCCLUSION_TERM_SCALE (1.5) on
// write and lands in `result` for the lit shaders to sample. N is chosen
// renderer-side and may be 1 (final dispatch only, no intermediates).
//
// 8x8 numthreads, each thread processes 2 horizontal pixels at coords
// (2*tid.x, tid.y) and (2*tid.x + 1, tid.y). Mirrors MainPass.esf's
// "2 pixels per thread" optimization, Esoterica calls this out explicitly
// at line 52.
//
// Departures from Esoterica's Denoise.esf / XeGTAO_Denoise:
//
// * The 3 edges + 4 AO GatherRed calls in XeGTAO.esh:815-822 are
// replaced by direct texelFetch reads of the same 12-texel
// neighbourhood (4-wide x 3-tall around pixCoordBase). Same
// rationale as gtao_prefilter_depth.glsl and gtao_main_pass.glsl:
// sidesteps the textureGather channel-ordering / backend-Y-flip
// ambiguity. Cost is 24 single-channel R32F fetches vs 7 gather ops
// per thread, predictably slower but a non-issue for a debug
// renderer.
//
// * Dispatch sized as ceil(W / 16) x ceil(H / 8) workgroups (each
// workgroup writes 16 horizontal x 8 vertical pixels). Esoterica
// dispatches ceil(W / 8) x ceil(H / 8), twice as many threads in X,
// which over-covers by 2x with the surplus writes landing OOB
// (silent no-op in D3D11/Vulkan/Metal compute). The visible output
// is identical, we just skip the wasted threads. Recorded as a
// deviation.
//
// * `lpfloat` collapses to `float` (matches Esoterica's config.
// XE_GTAO_USE_HALF_FLOAT_PRECISION=0).
//
// * `AOTermType` is a plain `float`, XE_GTAO_COMPUTE_BENT_NORMALS is
// undefined on our side (matches Esoterica's default). The
// XeGTAO_DecodeGatherPartial path collapses to identity, we inline it.
//
// * `XE_GTAO_SHOW_EDGES` / `XE_GTAO_SHOW_BENT_NORMALS` debug-viz
// branches dropped, render3d uses its own debug_view_mode plumbing.
//
// * `finalApply` is delivered as a per-dispatch UBO field instead
// HLSL root constants. Lives in a small dedicated ub_denoise UBO at
// binding=1, the shared ub_gtao at binding=0 carries the same byte
// layout as the prefilter + main_pass shaders so the renderer can
// reuse one C-side build of the constants.
//
// * Bounds clamping for the 12 neighbours uses
// `clamp(coord, 0, ViewportSize - 1)` per fetch. The edge-clamped
// duplicates feed back through the same XeGTAO weighting math, same
// replicated-edge approximation Esoterica gets implicitly through
// the gather + clamp_to_edge sampler.
#pragma sokol @module gtao_denoise
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype mat4 Mat4
#pragma sokol @cs cs
// Per-shader subset of Esoterica's XeGTAO::GTAOConstants. Denoise only
// reads `ViewportSize` (bounds checks) and `DenoiseBlurBeta` (blur
// strength). Explicit `gtao.X` instance name prevents SPIRV-Cross
// synthesizing one (`_NNN.X`), trimming to just-the-read fields
// prevents the GL linker's per-field dead-strip from producing
// `glGetUniformLocation` warnings. See the matching comment in
// gtao_prefilter_depth.glsl.
layout( binding = 0 ) uniform ub_gtao
{
ivec2 ViewportSize;
float DenoiseBlurBeta;
}
gtao;
// NoiseIndex intentionally omitted, see gtao_prefilter_depth.glsl.
// Per-dispatch knob. `FinalApply` non-zero on the final (3rd) denoise
// dispatch, rescales the AO term by XE_GTAO_OCCLUSION_TERM_SCALE before
// writing so lit shaders see the over-bright [0, 1.5] visibility range.
layout( binding = 1 ) uniform ub_denoise
{
int FinalApply;
int _Pad0;
int _Pad1;
int _Pad2;
};
// Storage-image output (R32F, same access-format rationale as MainPass
// / PrefilterDepth: sokol-shdc / SPIRV-Cross restrict storage_image
// access formats to r32f / r32i / r32ui plus rgba/rg{32,16} variants).
layout( binding = 0, r32f ) uniform writeonly image2D out_ao;
// Sampled inputs. Bind base 1: storage images take 0..0, textures start
// at 1. Same point-clamp sampler used by every GTAO compute shader.
layout( binding = 1 ) uniform texture2D tex_edges;
layout( binding = 2 ) uniform texture2D tex_noisy_ao;
layout( binding = 0 ) uniform sampler smp_point_clamp;
#pragma sokol @include ../common/xe_gtao_common.glsl
// XeGTAO.esh:745-751, additive sample with edge weight. Inlined here
// because GLSL's lack of `inout` arrays makes the HLSL helper awkward,
// the math is unchanged.
void XeGTAO_AddSample( float ssaoValue, float edgeValue, inout float sum, inout float sumWeight )
{
float weight = edgeValue;
sum += weight * ssaoValue;
sumWeight += weight;
}
// Edge-clamped texelFetch helpers. We fetch a 4x3 neighbourhood around
// each pixel pair (pixCoordBase, pixCoordBase + (1, 0)). The diagonals
// reach one step out on each side and one step up/down, so the inclusive
// fetch range is (pixCoordBase + (-1, -1)).. (pixCoordBase + (2, 1)).
float fetchEdge( ivec2 coord )
{
ivec2 vmax = gtao.ViewportSize - 1;
ivec2 c = clamp( coord, ivec2( 0 ), vmax );
return texelFetch( sampler2D( tex_edges, smp_point_clamp ), c, 0 ).r;
}
float fetchAO( ivec2 coord )
{
ivec2 vmax = gtao.ViewportSize - 1;
ivec2 c = clamp( coord, ivec2( 0 ), vmax );
return texelFetch( sampler2D( tex_noisy_ao, smp_point_clamp ), c, 0 ).r;
}
// Output helper, XeGTAO.esh:757-774 collapsed to the "kirill: float AO
// term" patch (lines 771-772) since we always carry the float term, not
// the packed-UINT variant.
void XeGTAO_Output( ivec2 pixCoord, float outputValue, bool finalApply )
{
float scale = finalApply ? XE_GTAO_OCCLUSION_TERM_SCALE : 1.0;
imageStore( out_ao, pixCoord, vec4( outputValue * scale, 0.0, 0.0, 0.0 ) );
}
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
void main()
{
ivec2 dispatchThreadID = ivec2( gl_GlobalInvocationID.xy );
// pixCoordBase = (2 * tid.x, tid.y). With the proper "2 horizontal
// pixels per thread" dispatch sizing (groups = ceil(W/16) x
// ceil(H/8)), tid.x ranges 0..ceil(W/16)*8 - 1, so pixCoordBase.x
// ranges 0..2*ceil(W/16)*8 - 2, at most one pixel past W when W is
// odd. The early-out + per-side bounds guard handles that tail.
ivec2 pixCoordBase = ivec2( dispatchThreadID.x * 2, dispatchThreadID.y );
if ( any( greaterThanEqual( pixCoordBase, gtao.ViewportSize ) ) )
{
return;
}
bool finalApply = ( FinalApply != 0 );
float blurAmount = finalApply ? gtao.DenoiseBlurBeta : ( gtao.DenoiseBlurBeta / 5.0 );
const float diagWeight = 0.85 * 0.5;
// 4 x 3 neighbourhood of edges + AO, indexed [x = -1..2][y = -1..1].
// Reading them up-front lets the per-side code below be a direct
// index lookup, mirroring Esoterica's per-side `visQk[index]` extracts
// from the gather results.
float edgesN[4][3];
float ao[4][3];
for ( int i = 0; i < 4; ++i )
{
for ( int j = 0; j < 3; ++j )
{
ivec2 c = pixCoordBase + ivec2( i - 1, j - 1 );
edgesN[i][j] = fetchEdge( c );
ao[i][j] = fetchAO( c );
}
}
// Process side 0 (pixel at pixCoordBase) then side 1 (pixCoordBase +
// (1, 0)). The unrolled per-side block matches XeGTAO.esh:824-892.
for ( int side = 0; side < 2; ++side )
{
ivec2 pixCoord = pixCoordBase + ivec2( side, 0 );
if ( pixCoord.x >= gtao.ViewportSize.x )
{
break;
}
// Index helpers: column `c` in the 4-wide patch corresponds to
// x = pixCoordBase.x + (c - 1). For side==0 the C column is 1
// (the L/R neighbours sit at columns 0 / 2), for side==1 the C
// column is 2 (neighbours at 1 / 3).
int cC = 1 + side;
int cL = cC - 1;
int cR = cC + 1;
vec4 edgesC_LRTB = XeGTAO_UnpackEdges( edgesN[cC][1] );
vec4 edgesL_LRTB = XeGTAO_UnpackEdges( edgesN[cL][1] );
vec4 edgesR_LRTB = XeGTAO_UnpackEdges( edgesN[cR][1] );
vec4 edgesT_LRTB = XeGTAO_UnpackEdges( edgesN[cC][0] );
vec4 edgesB_LRTB = XeGTAO_UnpackEdges( edgesN[cC][2] );
// Edge symmetricity nudge, XeGTAO.esh:836-837. Clamps the center
// pixel's per-direction edge weight against the matching edge on
// the neighbour pixel, sharpens the blur, especially under TAA
// (which we don't have, kept for A/B parity).
edgesC_LRTB *= vec4( edgesL_LRTB.y, edgesR_LRTB.x, edgesT_LRTB.w, edgesB_LRTB.z );
// Leak, XeGTAO.esh:839-843 (`#if 1` branch is the default and
// only path Esoterica ships). Allows a small amount of bleed
// when a pixel is surrounded by 3-4 edges, reducing aliasing.
const float leak_threshold = 2.5;
const float leak_strength = 0.5;
float edginess =
( clamp( 4.0 - leak_threshold - dot( edgesC_LRTB, vec4( 1.0 ) ), 0.0, 1.0 ) / ( 4.0 - leak_threshold ) ) *
leak_strength;
edgesC_LRTB = clamp( edgesC_LRTB + edginess, 0.0, 1.0 );
// Diagonal weights, XeGTAO.esh:852-855.
float weightTL = diagWeight * ( edgesC_LRTB.x * edgesL_LRTB.z + edgesC_LRTB.z * edgesT_LRTB.x );
float weightTR = diagWeight * ( edgesC_LRTB.z * edgesT_LRTB.y + edgesC_LRTB.y * edgesR_LRTB.z );
float weightBL = diagWeight * ( edgesC_LRTB.w * edgesB_LRTB.x + edgesC_LRTB.x * edgesL_LRTB.w );
float weightBR = diagWeight * ( edgesC_LRTB.y * edgesR_LRTB.w + edgesC_LRTB.w * edgesB_LRTB.y );
// AO neighbourhood for this side. Center at (cC, 1), L/R at
// (cL, 1) / (cR, 1), T/B at (cC, 0) / (cC, 2), diagonals at the
// 4 corners of the 3x3 around (cC, 1).
float ssaoValue = ao[cC][1];
float ssaoValueL = ao[cL][1];
float ssaoValueR = ao[cR][1];
float ssaoValueT = ao[cC][0];
float ssaoValueB = ao[cC][2];
float ssaoValueTL = ao[cL][0];
float ssaoValueTR = ao[cR][0];
float ssaoValueBL = ao[cL][2];
float ssaoValueBR = ao[cR][2];
float sumWeight = blurAmount;
float sum = ssaoValue * sumWeight;
XeGTAO_AddSample( ssaoValueL, edgesC_LRTB.x, sum, sumWeight );
XeGTAO_AddSample( ssaoValueR, edgesC_LRTB.y, sum, sumWeight );
XeGTAO_AddSample( ssaoValueT, edgesC_LRTB.z, sum, sumWeight );
XeGTAO_AddSample( ssaoValueB, edgesC_LRTB.w, sum, sumWeight );
XeGTAO_AddSample( ssaoValueTL, weightTL, sum, sumWeight );
XeGTAO_AddSample( ssaoValueTR, weightTR, sum, sumWeight );
XeGTAO_AddSample( ssaoValueBL, weightBL, sum, sumWeight );
XeGTAO_AddSample( ssaoValueBR, weightBR, sum, sumWeight );
float aoTerm = sum / sumWeight;
XeGTAO_Output( pixCoord, aoTerm, finalApply );
}
}
#pragma sokol @end
#pragma sokol @program prog cs

View file

@ -0,0 +1,412 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// GTAO MainPass compute shader.
//
// Port of Esoterica's MainPass.esf (which is XeGTAO's MainPass with
// XE_GTAO_GENERATE_NORMALS_INPLACE enabled). For each viewport pixel,
// reconstructs the view-space normal from depth derivatives, generates a
// Hilbert+R2 spatial noise pair, and runs the XeGTAO slice trace against
// the prefiltered depth chain. Slice count and steps-per-slice come from
// the ub_gtao UBO (the AmbientOcclusionQuality preset on the C side) rather than the
// hardcoded Ultra tier.
//
// Outputs:
// * out_noisy_ao (R32F, storage_image): the visibility term divided
// by XE_GTAO_OCCLUSION_TERM_SCALE (1.5) and saturated to [0,1].
// XeGTAO_OutputWorkingTerm's pre-denoise format. Denoise
// will multiply by 1.5 on finalApply to restore the over-bright
// occlusion term. (Deviation: Esoterica uses R16F. sokol-shdc /
// SPIRV-Cross only permit r32f/r32i/r32ui plus rgba/rg{32,16}
// variants for storage_image access formats, mirrors D3D11's
// typed-UAV restriction. R32F is the cheapest single-channel
// fp format that survives cross-compilation.)
// * out_edges (R32F, storage_image): packed edge gradients
// consumed by Denoise. Same R8->R32F deviation rationale as
// out_noisy_ao, the value range still fits in [0,1] so
// XeGTAO_UnpackEdges on the read side is unchanged.
//
// Departures from Esoterica's MainPass.esf:
//
// * Cardinal depth taps (center, L, R, T, B) use texelFetch on the raw
// depth target instead of two GatherRed calls. Two reasons: avoids
// the GatherRed channel-ordering / backend Y-flip ambiguity, and
// matches the same pattern already adopted by
// gtao_prefilter_depth.glsl.
//
// * The trace samples DO use textureLod since they sample at fractional
// mip levels, texelFetch can't pick a mip. The prefilter chain was
// written by the PrefilterDepth compute via imageStore, so the
// UV->texel mapping is internally consistent within the chain even
// across backends (no fragment-shader Y-flip in the producer).
//
// * `lpfloat` collapses to `float` (XE_GTAO_USE_HALF_FLOAT_PRECISION=0,
// XE_GTAO_FP32_DEPTHS=1, matches Esoterica's config).
//
// * SpatioTemporalNoise is called with temporalIndex=0 hardcoded
// (no TAA), producing the same noise pattern every frame. The
// original NoiseIndex UBO field is gone, see the comment under
// ub_gtao.
//
// * The "early-out for OOB threads" at the top of MainPass.esf is kept.
// Unlike PrefilterDepth there is no inter-thread groupshared
// reduction, so divergent control flow at the top is safe (no
// barriers).
#pragma sokol @module gtao_main_pass
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype mat4 Mat4
#pragma sokol @cs cs
// Per-shader subset of Esoterica's XeGTAO::GTAOConstants, only the
// fields MainPass actually reads (14 of 16). Explicit `gtao.X` instance
// name prevents SPIRV-Cross synthesizing one (`_NNN.X`), trimming to
// just-the-read fields prevents the GL linker's per-field dead-strip
// from producing `glGetUniformLocation` warnings. See the matching
// comment in gtao_prefilter_depth.glsl.
layout( binding = 0 ) uniform ub_gtao
{
ivec2 ViewportSize;
vec2 ViewportPixelSize;
vec2 NDCToViewMul;
vec2 NDCToViewAdd;
vec2 NDCToViewMul_x_PixelSize;
float EffectRadius;
float EffectFalloffRange;
float RadiusMultiplier;
float FinalValuePower;
float SampleDistributionPower;
float ThinOccluderCompensation;
float DepthMIPSamplingOffset;
// Runtime trace quality: slice count and steps-per-slice. Driven by
// the AmbientOcclusionQuality preset on the C side (Low/Medium/High/Ultra), the
// trace loops read these instead of hardcoded Ultra-tier constants.
float SliceCount;
float StepsPerSlice;
}
gtao;
// NoiseIndex intentionally omitted, see gtao_prefilter_depth.glsl.
// Storage-image outputs. Bindings 0..1. r32f instead of r16f/r8 (see
// header, sokol-shdc storage_image access-format restriction).
layout( binding = 0, r32f ) uniform writeonly image2D out_noisy_ao;
layout( binding = 1, r32f ) uniform writeonly image2D out_edges;
// Sampled textures. Binding base 2 (sokol-shdc shares the
// storage_image/texture bind-space across the compute stage, storage
// images take 0..1, so textures start at 2). The sampler is point-clamp,
// linear sampling on a prefiltered depth chain would inter-mip-level
// blend depth values which corrupts the trace (see XeGTAO.esh:476).
layout( binding = 2 ) uniform texture2D tex_raw_depth;
layout( binding = 3 ) uniform texture2D tex_prefilter_depth;
layout( binding = 0 ) uniform sampler smp_point_clamp;
#pragma sokol @include ../common/xe_gtao_common.glsl
// SpatioTemporalNoise, MainPass.esf:43-60 with the
// XE_GTAO_HILBERT_LUT_AVAILABLE branch removed (we generate the index
// in-shader, mirrors Esoterica's default). With NoiseIndex=0 the
// `288 * (temporalIndex % 64)` term is zero, the (288*0) is kept as a
// no-op so this function reads verbatim against the reference.
vec2 SpatioTemporalNoise( uvec2 pixCoord, int temporalIndex )
{
uint index = HilbertIndex( pixCoord.x, pixCoord.y );
index += 288u * ( uint( temporalIndex ) % 64u );
// R2 sequence, Roberts 2018.
return fract( 0.5 + float( index ) * vec2( 0.75487766624669276005, 0.5698402909980532659114 ) );
}
// XeGTAO.esh:897-921 with cardinal taps coming from texelFetch instead
// of GatherRed (see header). Identical math.
vec3 XeGTAO_ComputeViewspaceNormal( ivec2 pixCoord, GTAOConsts consts )
{
vec2 normalizedScreenPos = ( vec2( pixCoord ) + 0.5 ) * consts.ViewportPixelSize;
// Clamp the 4 cardinal taps into the viewport. At the viewport edge
// we replicate the center pixel, same approximation as gather-with-
// sampler-clamp.
ivec2 vmax = gtao.ViewportSize - 1;
ivec2 cC = clamp( pixCoord, ivec2( 0 ), vmax );
ivec2 cL = clamp( pixCoord + ivec2( -1, 0 ), ivec2( 0 ), vmax );
ivec2 cR = clamp( pixCoord + ivec2( 1, 0 ), ivec2( 0 ), vmax );
ivec2 cT = clamp( pixCoord + ivec2( 0, -1 ), ivec2( 0 ), vmax );
ivec2 cB = clamp( pixCoord + ivec2( 0, 1 ), ivec2( 0 ), vmax );
float viewspaceZ =
XeGTAO_ScreenSpaceToViewSpaceDepth( texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), cC, 0 ).r, consts );
float pixLZ =
XeGTAO_ScreenSpaceToViewSpaceDepth( texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), cL, 0 ).r, consts );
float pixRZ =
XeGTAO_ScreenSpaceToViewSpaceDepth( texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), cR, 0 ).r, consts );
float pixTZ =
XeGTAO_ScreenSpaceToViewSpaceDepth( texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), cT, 0 ).r, consts );
float pixBZ =
XeGTAO_ScreenSpaceToViewSpaceDepth( texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), cB, 0 ).r, consts );
vec4 edgesLRTB = XeGTAO_CalculateEdges( viewspaceZ, pixLZ, pixRZ, pixTZ, pixBZ );
vec3 CENTER = XeGTAO_ComputeViewspacePosition( normalizedScreenPos, viewspaceZ, consts );
vec3 LEFT =
XeGTAO_ComputeViewspacePosition( normalizedScreenPos + vec2( -1.0, 0.0 ) * consts.ViewportPixelSize, pixLZ, consts );
vec3 RIGHT =
XeGTAO_ComputeViewspacePosition( normalizedScreenPos + vec2( 1.0, 0.0 ) * consts.ViewportPixelSize, pixRZ, consts );
vec3 TOP =
XeGTAO_ComputeViewspacePosition( normalizedScreenPos + vec2( 0.0, -1.0 ) * consts.ViewportPixelSize, pixTZ, consts );
vec3 BOTTOM =
XeGTAO_ComputeViewspacePosition( normalizedScreenPos + vec2( 0.0, 1.0 ) * consts.ViewportPixelSize, pixBZ, consts );
return XeGTAO_CalculateNormal( edgesLRTB, CENTER, LEFT, RIGHT, TOP, BOTTOM );
}
// XeGTAO.esh:213-231. Stores the visibility/scale-divided term and
// returns it. `bentNormal` arg dropped, XE_GTAO_COMPUTE_BENT_NORMALS is
// undefined on our side (matches Esoterica).
float XeGTAO_OutputWorkingTerm( ivec2 pixCoord, float visibility )
{
visibility = clamp( visibility / XE_GTAO_OCCLUSION_TERM_SCALE, 0.0, 1.0 );
imageStore( out_noisy_ao, pixCoord, vec4( visibility, 0.0, 0.0, 0.0 ) );
return visibility;
}
// XeGTAO.esh:270-617 with:
// * Cardinal taps via texelFetch (see header).
// * Bent-normals branch (`XE_GTAO_COMPUTE_BENT_NORMALS`) removed,
// undefined in our config.
// * In-place normals branch (`XE_GTAO_GENERATE_NORMALS_INPLACE`) always
// taken. The cardinal-tap reads above already happened, so this
// is just the same XeGTAO_CalculateNormal call as in
// XeGTAO_ComputeViewspaceNormal. We share the call by computing the
// normal in main before invoking MainPass, and pass it in.
// * Debug-viz (`XE_GTAO_SHOW_DEBUG_VIZ`, `XE_GTAO_SHOW_NORMALS`, etc.)
// branches dropped, we use the renderer's debug_view_mode plumbing
// instead.
// * `sliceCount`/`stepsPerSlice` come from the ub_gtao UBO (the
// AmbientOcclusionQuality preset on the C side), not the hardcoded 9/3 Ultra tier of
// MainPass.esf:135. The two `for` loops iterate `float` counters with a
// `<` comparison so the runtime bound cross-compiles cleanly, the
// trade-off is the inner loop can no longer be statically unrolled.
// * Edges are packed and written before the trace, exactly as in
// MainPass.esf. The Denoise pass reads them as bilateral weights.
//
// pixCoord = dispatchThreadID.xy. Returns the saturated visibility scalar
// for visualisation in the renderer's debug_view_mode == 4.
float XeGTAO_MainPass( ivec2 pixCoord, vec2 localNoise, vec3 viewspaceNormal,
float centerViewspaceZ, // value already fetched for normal recon
vec4 edgesLRTB, // ditto, written below
GTAOConsts consts )
{
vec2 normalizedScreenPos = ( vec2( pixCoord ) + 0.5 ) * consts.ViewportPixelSize;
float viewspaceZ = centerViewspaceZ;
imageStore( out_edges, pixCoord, vec4( XeGTAO_PackEdges( edgesLRTB ), 0.0, 0.0, 0.0 ) );
// FP32 depth: push the center pixel slightly towards camera to avoid
// self-occlusion from depth imprecision. XeGTAO.esh:318-322. With
// positive linear view-Z + reverse-Z, "towards camera" is multiply by
// (1 - epsilon).
viewspaceZ *= 0.99999;
vec3 pixCenterPos = XeGTAO_ComputeViewspacePosition( normalizedScreenPos, viewspaceZ, consts );
vec3 viewVec = normalize( -pixCenterPos );
float sliceCount = consts.SliceCount;
float stepsPerSlice = consts.StepsPerSlice;
const float effectRadius = consts.EffectRadius * consts.RadiusMultiplier;
const float falloffRange = consts.EffectFalloffRange * effectRadius;
const float falloffFrom = effectRadius * ( 1.0 - consts.EffectFalloffRange );
const float falloffMul = -1.0 / falloffRange;
const float falloffAdd = falloffFrom / falloffRange + 1.0;
const float sampleDistributionPower = consts.SampleDistributionPower;
const float thinOccluderCompensation = consts.ThinOccluderCompensation;
float visibility = 0.0;
{
const float noiseSlice = localNoise.x;
const float noiseSample = localNoise.y;
const float pixelTooCloseThreshold = 1.3;
// Approx viewspace pixel size at pixCoord. XeGTAO.esh:377.
vec2 pixelDirRBViewspaceSizeAtCenterZ = vec2( viewspaceZ, viewspaceZ ) * consts.NDCToViewMul_x_PixelSize;
float screenspaceRadius = effectRadius / pixelDirRBViewspaceSizeAtCenterZ.x;
// Fade out for small screen radii, XeGTAO.esh:382.
visibility += clamp( ( 10.0 - screenspaceRadius ) / 100.0, 0.0, 1.0 ) * 0.5;
float minS = pixelTooCloseThreshold / screenspaceRadius;
for ( float slice = 0.0; slice < sliceCount; slice += 1.0 )
{
float sliceK = ( slice + noiseSlice ) / sliceCount;
float phi = sliceK * XE_GTAO_PI;
float cosPhi = cos( phi );
float sinPhi = sin( phi );
vec2 omega = vec2( cosPhi, -sinPhi );
omega *= screenspaceRadius;
vec3 directionVec = vec3( cosPhi, sinPhi, 0.0 );
vec3 orthoDirectionVec = directionVec - ( dot( directionVec, viewVec ) * viewVec );
vec3 axisVec = normalize( cross( orthoDirectionVec, viewVec ) );
vec3 projectedNormalVec = viewspaceNormal - axisVec * dot( viewspaceNormal, axisVec );
float signNorm = sign( dot( orthoDirectionVec, projectedNormalVec ) );
float projectedNormalVecLength = length( projectedNormalVec );
float cosNorm = clamp( dot( projectedNormalVec, viewVec ) / projectedNormalVecLength, 0.0, 1.0 );
float n = signNorm * XeGTAO_FastACos( cosNorm );
const float lowHorizonCos0 = cos( n + XE_GTAO_PI_HALF );
const float lowHorizonCos1 = cos( n - XE_GTAO_PI_HALF );
float horizonCos0 = lowHorizonCos0;
float horizonCos1 = lowHorizonCos1;
for ( float step_ = 0.0; step_ < stepsPerSlice; step_ += 1.0 )
{
// R1 sequence, XeGTAO.esh:459.
float stepBaseNoise = ( slice + step_ * stepsPerSlice ) * 0.6180339887498948482;
float stepNoise = fract( noiseSample + stepBaseNoise );
float s = ( step_ + stepNoise ) / stepsPerSlice;
// step_, stepNoise (=fract(.)), stepsPerSlice are all >= 0
// by construction, max(0, .) is redundant at runtime but
// silences HLSL's pow(negative, n) warning (X3571).
s = pow( max( 0.0, s ), sampleDistributionPower );
s += minS;
vec2 sampleOffset = s * omega;
float sampleOffsetLength = length( sampleOffset );
float mipLevel =
clamp( log2( sampleOffsetLength ) - consts.DepthMIPSamplingOffset, 0.0, XE_GTAO_DEPTH_MIP_LEVELS );
// Snap to pixel centers, XeGTAO.esh:481.
sampleOffset = round( sampleOffset ) * consts.ViewportPixelSize;
vec2 sampleScreenPos0 = normalizedScreenPos + sampleOffset;
float SZ0 = textureLod( sampler2D( tex_prefilter_depth, smp_point_clamp ), sampleScreenPos0, mipLevel ).x;
vec3 samplePos0 = XeGTAO_ComputeViewspacePosition( sampleScreenPos0, SZ0, consts );
vec2 sampleScreenPos1 = normalizedScreenPos - sampleOffset;
float SZ1 = textureLod( sampler2D( tex_prefilter_depth, smp_point_clamp ), sampleScreenPos1, mipLevel ).x;
vec3 samplePos1 = XeGTAO_ComputeViewspacePosition( sampleScreenPos1, SZ1, consts );
vec3 sampleDelta0 = samplePos0 - pixCenterPos;
vec3 sampleDelta1 = samplePos1 - pixCenterPos;
float sampleDist0 = length( sampleDelta0 );
float sampleDist1 = length( sampleDelta1 );
vec3 sampleHorizonVec0 = sampleDelta0 / sampleDist0;
vec3 sampleHorizonVec1 = sampleDelta1 / sampleDist1;
// Esoterica branch: thin-object heuristic (XeGTAO.esh:518-524).
// XE_GTAO_USE_DEFAULT_CONSTANTS=0 path so falloffBase uses
// thinOccluderCompensation. With thinOccluderCompensation = 0
// this is equivalent to the simpler XeGTAO.esh:516-517 form
// since the z-axis factor becomes 1.
float falloffBase0 =
length( vec3( sampleDelta0.x, sampleDelta0.y, sampleDelta0.z * ( 1.0 + thinOccluderCompensation ) ) );
float falloffBase1 =
length( vec3( sampleDelta1.x, sampleDelta1.y, sampleDelta1.z * ( 1.0 + thinOccluderCompensation ) ) );
float weight0 = clamp( falloffBase0 * falloffMul + falloffAdd, 0.0, 1.0 );
float weight1 = clamp( falloffBase1 * falloffMul + falloffAdd, 0.0, 1.0 );
float shc0 = dot( sampleHorizonVec0, viewVec );
float shc1 = dot( sampleHorizonVec1, viewVec );
shc0 = mix( lowHorizonCos0, shc0, weight0 );
shc1 = mix( lowHorizonCos1, shc1, weight1 );
horizonCos0 = max( horizonCos0, shc0 );
horizonCos1 = max( horizonCos1, shc1 );
}
// Slight over-darkening fudge, XeGTAO.esh:571.
projectedNormalVecLength = mix( projectedNormalVecLength, 1.0, 0.05 );
float h0 = -XeGTAO_FastACos( horizonCos1 );
float h1 = XeGTAO_FastACos( horizonCos0 );
float iarc0 = ( cosNorm + 2.0 * h0 * sin( n ) - cos( 2.0 * h0 - n ) ) * 0.25;
float iarc1 = ( cosNorm + 2.0 * h1 * sin( n ) - cos( 2.0 * h1 - n ) ) * 0.25;
float localVisibility = projectedNormalVecLength * ( iarc0 + iarc1 );
visibility += localVisibility;
}
visibility /= sliceCount;
// visibility is summed from non-negative localVisibility terms and
// divided by positive sliceCount, so always >= 0. max(0, .) is a
// no-op at runtime, silences HLSL's pow(negative, n) warning.
visibility = pow( max( 0.0, visibility ), consts.FinalValuePower );
// Disallow total occlusion, XeGTAO.esh:597.
visibility = max( 0.03, visibility );
}
return XeGTAO_OutputWorkingTerm( pixCoord, visibility );
}
layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in;
void main()
{
ivec2 pixCoord = ivec2( gl_GlobalInvocationID.xy );
if ( any( greaterThanEqual( pixCoord, gtao.ViewportSize ) ) )
{
return;
}
// Populate GTAOConsts from the UBO, gives the helpers in
// xe_gtao_common.glsl + the inlined XeGTAO_MainPass a single by-
// value argument matching the HLSL reference.
GTAOConsts consts;
consts.ViewportPixelSize = gtao.ViewportPixelSize;
consts.NDCToViewMul = gtao.NDCToViewMul;
consts.NDCToViewAdd = gtao.NDCToViewAdd;
consts.NDCToViewMul_x_PixelSize = gtao.NDCToViewMul_x_PixelSize;
consts.EffectRadius = gtao.EffectRadius;
consts.EffectFalloffRange = gtao.EffectFalloffRange;
consts.RadiusMultiplier = gtao.RadiusMultiplier;
consts.FinalValuePower = gtao.FinalValuePower;
consts.SampleDistributionPower = gtao.SampleDistributionPower;
consts.ThinOccluderCompensation = gtao.ThinOccluderCompensation;
consts.DepthMIPSamplingOffset = gtao.DepthMIPSamplingOffset;
consts.SliceCount = gtao.SliceCount;
consts.StepsPerSlice = gtao.StepsPerSlice;
// Cardinal-tap reads happen inside ComputeViewspaceNormal, redo the
// center read so MainPass has its viewspaceZ + edges without
// re-fetching the 4 neighbours. Cheaper to repeat the 1-tap fetch
// than to plumb the 5-tap state through a return struct.
vec3 viewspaceNormal = XeGTAO_ComputeViewspaceNormal( pixCoord, consts );
ivec2 vmax = gtao.ViewportSize - 1;
float centerZ = XeGTAO_ScreenSpaceToViewSpaceDepth(
texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), clamp( pixCoord, ivec2( 0 ), vmax ), 0 ).r, consts );
float leftZ = XeGTAO_ScreenSpaceToViewSpaceDepth(
texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), clamp( pixCoord + ivec2( -1, 0 ), ivec2( 0 ), vmax ), 0 ).r,
consts );
float rightZ = XeGTAO_ScreenSpaceToViewSpaceDepth(
texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), clamp( pixCoord + ivec2( 1, 0 ), ivec2( 0 ), vmax ), 0 ).r,
consts );
float topZ = XeGTAO_ScreenSpaceToViewSpaceDepth(
texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), clamp( pixCoord + ivec2( 0, -1 ), ivec2( 0 ), vmax ), 0 ).r,
consts );
float botZ = XeGTAO_ScreenSpaceToViewSpaceDepth(
texelFetch( sampler2D( tex_raw_depth, smp_point_clamp ), clamp( pixCoord + ivec2( 0, 1 ), ivec2( 0 ), vmax ), 0 ).r,
consts );
vec4 edgesLRTB = XeGTAO_CalculateEdges( centerZ, leftZ, rightZ, topZ, botZ );
vec2 noise = SpatioTemporalNoise( uvec2( pixCoord ), 0 );
XeGTAO_MainPass( pixCoord, noise, viewspaceNormal, centerZ, edgesLRTB, consts );
}
#pragma sokol @end
#pragma sokol @program prog cs

View file

@ -0,0 +1,248 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// GTAO PrefilterDepth compute shader.
//
// Port of Esoterica's PrefilterDepth.esf, which is XeGTAO's
// XeGTAO_PrefilterDepths16x16, a single 16x16-pixel tile per group,
// 8x8 threads, each thread handling 2x2 destination pixels. Builds the
// 5-mip prefiltered linear-depth chain consumed by the GTAO main pass.
// Mip0 is the raw input, mips 1..4 use the XeGTAO weighted-
// average depth-MIP filter which biases toward the closer of the four
// taps in each 2x2 footprint (suppresses thin-feature pulled mips).
//
// Departures from XeGTAO_PrefilterDepths16x16:
//
// * Input depth is **already positive linear view-Z** (render3d's
// R32F prepass target), not NDC reverse-Z. Esoterica's
// XeGTAO_ScreenSpaceToViewSpaceDepth call collapses to a pass-
// through, we just clamp. GTAOConstants.DepthUnpackConsts is
// therefore unused (kept in the UBO for layout parity).
//
// * Mip-0 fetches use texelFetch on the source texture instead
// GatherRed + offset(1,1). The mathematical result is identical
// (point-sampled raw texels at a 2x2 footprint), but texelFetch
// sidesteps the documented textureGather channel-ordering /
// Y-flip pitfalls. Cost is 4 texel reads vs 1 gather op,
// a single dispatch per frame, doesn't matter.
//
// * lpfloat is `float`. Matches Esoterica's
// XE_GTAO_USE_HALF_FLOAT_PRECISION=0 / XE_GTAO_FP32_DEPTHS=1
// configuration, min16float / float16_t paths don't survive
// sokol-shdc cleanly.
//
// Dispatch: ceil(width / 16) x ceil(height / 16) x 1. Each group writes
// a 16x16 mip-0 region, 8x8 mip-1, 4x4 mip-2, 2x2 mip-3, 1x1 mip-4.
//
// Esoterica early-returns OOB threads at the top of the shader. FXC
// (D3D11) rejects that as "thread sync operation in varying flow"
// (HLSL X3663) when the subsequent barrier participations diverge.
// We instead let every thread run the full reduction so all barriers
// see uniform participation, and guard each imageStore individually
// against the viewport bound. Source-texel reads are clamped to the
// in-bounds edge so OOB threads contribute consistent (replicated-
// edge) depth values to the mip-1..4 reductions. These values are
// only used to keep the groupshared scratch populated, the actual
// mip writes for those threads are skipped by the bounds guard.
#pragma sokol @module gtao_prefilter_depth
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype mat4 Mat4
#pragma sokol @cs cs
// Per-shader subset of Esoterica's XeGTAO::GTAOConstants, only the
// fields PrefilterDepth's `XeGTAO_DepthMIPFilter` and `main ` actually
// read. The block has an explicit instance name (`gtao.X`) so SPIRV-
// Cross doesn't synthesize one (`_NNN.X`) when emitting GLSL for the GL
// backend. Without that, each unread field that the driver's GLSL
// linker dead-strips triggers a sokol_gfx `glGetUniformLocation` warning
// with an unreadable synthetic name. Keeping the block trimmed to only
// the read fields means there's nothing for the linker to strip.
layout(binding = 0) uniform ub_gtao
{
ivec2 ViewportSize;
float EffectRadius;
float EffectFalloffRange;
float RadiusMultiplier;
} gtao;
// Outputs: one storage_image per mip level. R32F write-only. Each mip
// has its own bind slot (0..4), sokol-gfx wires each to a sg_view that
// targets a specific mip of the 5-mip prefilterDepth image.
layout(binding = 0, r32f) uniform writeonly image2D out_depth0;
layout(binding = 1, r32f) uniform writeonly image2D out_depth1;
layout(binding = 2, r32f) uniform writeonly image2D out_depth2;
layout(binding = 3, r32f) uniform writeonly image2D out_depth3;
layout(binding = 4, r32f) uniform writeonly image2D out_depth4;
// Source: full-res positive linear view-Z. Bound as a sampled texture so
// texelFetch is available. The sampler is point-clamp (texelFetch ignores
// it but sokol-gfx requires a sampler binding for any texture binding).
// Binding 5 because sokol-shdc shares the storage_image/texture bind-
// space across the compute stage even though the underlying backends
// use disjoint SRV/UAV register banks, storage images take 0..4 so the
// texture starts at 5.
layout(binding = 5) uniform texture2D tex_src_depth;
layout(binding = 0) uniform sampler smp_src_depth;
// XeGTAO_ClampDepth, clamps to fp32 finite. Matches XeGTAO.esh:648-655
// for the XE_GTAO_USE_HALF_FLOAT_PRECISION=0 branch (FLT_MAX upper
// bound). Our sky sentinel of 1e9 sits comfortably below this.
float XeGTAO_ClampDepth(float depth) {
return clamp(depth, 0.0, 3.402823466e+38);
}
// XeGTAO_DepthMIPFilter, weighted average that biases toward the
// closest tap (smallest depth) and suppresses contributions from taps
// outside an effect-radius-scaled falloff window. Verbatim port
// XeGTAO.esh:619-644, with XE_GTAO_USE_DEFAULT_CONSTANTS=0 branches
// since we drive everything from the UBO.
float XeGTAO_DepthMIPFilter(float depth0, float depth1, float depth2, float depth3) {
float maxDepth = max(max(depth0, depth1), max(depth2, depth3));
const float depthRangeScaleFactor = 0.75; // "found empirically :)" XeGTAO.esh:624
float effectRadius = depthRangeScaleFactor * gtao.EffectRadius * gtao.RadiusMultiplier;
float falloffRange = gtao.EffectFalloffRange * effectRadius;
float falloffFrom = effectRadius * (1.0 - gtao.EffectFalloffRange);
float falloffMul = -1.0 / falloffRange;
float falloffAdd = falloffFrom / falloffRange + 1.0;
float weight0 = clamp((maxDepth - depth0) * falloffMul + falloffAdd, 0.0, 1.0);
float weight1 = clamp((maxDepth - depth1) * falloffMul + falloffAdd, 0.0, 1.0);
float weight2 = clamp((maxDepth - depth2) * falloffMul + falloffAdd, 0.0, 1.0);
float weight3 = clamp((maxDepth - depth3) * falloffMul + falloffAdd, 0.0, 1.0);
float weightSum = weight0 + weight1 + weight2 + weight3;
return (weight0 * depth0 + weight1 * depth1 +
weight2 * depth2 + weight3 * depth3) / weightSum;
}
// Mip-2..4 inter-thread reduction scratch. groupshared, written by the
// mip-N producer threads and read by the mip-(N+1) producers after a
// barrier. Mirrors XeGTAO.esh:657.
shared float g_scratchDepths[8][8];
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1)in;
void main() {
ivec2 dispatchThreadID = ivec2(gl_GlobalInvocationID.xy);
ivec2 groupThreadID = ivec2(gl_LocalInvocationID.xy);
ivec2 viewportMax = ivec2(gtao.ViewportSize) - 1;
// MIP 0
// Esoterica reads via GatherRed at the texel-corner UV with offset
// (1,1), we read the same four texels via texelFetch to avoid the
// textureGather channel-ordering / backend-Y-flip ambiguity (see
// header). Indexing matches Esoterica's (depth0, depth1, depth2,
// depth3) = (top-left, top-right, bottom-left, bottom-right) within
// the 2x2 destination block. Source coords are clamped to the
// in-bounds edge so OOB threads still feed valid (replicated-edge)
// depths into the mip-1..4 reductions, the actual mip writes for
// those threads are gated below.
ivec2 pixCoord = dispatchThreadID * 2;
ivec2 p0 = clamp(pixCoord + ivec2(0, 0), ivec2(0), viewportMax);
ivec2 p1 = clamp(pixCoord + ivec2(1, 0), ivec2(0), viewportMax);
ivec2 p2 = clamp(pixCoord + ivec2(0, 1), ivec2(0), viewportMax);
ivec2 p3 = clamp(pixCoord + ivec2(1, 1), ivec2(0), viewportMax);
float depth0 = XeGTAO_ClampDepth(texelFetch(sampler2D(tex_src_depth, smp_src_depth), p0, 0).r);
float depth1 = XeGTAO_ClampDepth(texelFetch(sampler2D(tex_src_depth, smp_src_depth), p1, 0).r);
float depth2 = XeGTAO_ClampDepth(texelFetch(sampler2D(tex_src_depth, smp_src_depth), p2, 0).r);
float depth3 = XeGTAO_ClampDepth(texelFetch(sampler2D(tex_src_depth, smp_src_depth), p3, 0).r);
if (all(lessThan(pixCoord + ivec2(0, 0), ivec2(gtao.ViewportSize)))) {
imageStore(out_depth0, pixCoord + ivec2(0, 0), vec4(depth0, 0.0, 0.0, 0.0));
}
if (all(lessThan(pixCoord + ivec2(1, 0), ivec2(gtao.ViewportSize)))) {
imageStore(out_depth0, pixCoord + ivec2(1, 0), vec4(depth1, 0.0, 0.0, 0.0));
}
if (all(lessThan(pixCoord + ivec2(0, 1), ivec2(gtao.ViewportSize)))) {
imageStore(out_depth0, pixCoord + ivec2(0, 1), vec4(depth2, 0.0, 0.0, 0.0));
}
if (all(lessThan(pixCoord + ivec2(1, 1), ivec2(gtao.ViewportSize)))) {
imageStore(out_depth0, pixCoord + ivec2(1, 1), vec4(depth3, 0.0, 0.0, 0.0));
}
// MIP 1
// Every thread produces one mip-1 candidate (always stored in
// scratch so the mip-2 reduction has a uniform view), conditionally
// written to the mip-1 image only if dispatchThreadID is in bounds.
float dm1 = XeGTAO_DepthMIPFilter(depth0, depth1, depth2, depth3);
if (all(lessThan(dispatchThreadID, ivec2(gtao.ViewportSize)))) {
imageStore(out_depth1, dispatchThreadID, vec4(dm1, 0.0, 0.0, 0.0));
}
g_scratchDepths[groupThreadID.x][groupThreadID.y] = dm1;
barrier();
// MIP 2
// 2x2 reduction over the group's 8x8 mip-1 footprint, one thread per
// mip-2 texel, picked at the (x%2,y%2)==(0,0) corner. Reads stride 1.
// The reduction itself happens uniformly (predicated only on local
// group coords), the bounds check gates the imageStore, never the
// barrier path.
float dm2 = 0.0;
bool isMip2Producer = all(equal(groupThreadID & ivec2(1), ivec2(0)));
if (isMip2Producer) {
float inTL = g_scratchDepths[groupThreadID.x + 0][groupThreadID.y + 0];
float inTR = g_scratchDepths[groupThreadID.x + 1][groupThreadID.y + 0];
float inBL = g_scratchDepths[groupThreadID.x + 0][groupThreadID.y + 1];
float inBR = g_scratchDepths[groupThreadID.x + 1][groupThreadID.y + 1];
dm2 = XeGTAO_DepthMIPFilter(inTL, inTR, inBL, inBR);
// gl_GlobalInvocationID is unsigned by spec -> dispatchThreadID is
// always >= 0, so an unsigned right-shift produces the same value as
// `dispatchThreadID / 2` without the HLSL signed-divide warning
// (X3556). Compute once + reuse for the bounds-check + imageStore.
ivec2 dispatchID2 = ivec2(uvec2(dispatchThreadID) >> 1u);
if (all(lessThan(dispatchID2, ivec2(gtao.ViewportSize)))) {
imageStore(out_depth2, dispatchID2, vec4(dm2, 0.0, 0.0, 0.0));
}
g_scratchDepths[groupThreadID.x][groupThreadID.y] = dm2;
}
barrier();
// MIP 3
// Reads stride 2 from the same scratch slab, one mip-3 texel per
// 4x4 thread block, picked at the (x%4,y%4)==(0,0) corner.
float dm3 = 0.0;
bool isMip3Producer = all(equal(groupThreadID & ivec2(3), ivec2(0)));
if (isMip3Producer) {
float inTL = g_scratchDepths[groupThreadID.x + 0][groupThreadID.y + 0];
float inTR = g_scratchDepths[groupThreadID.x + 2][groupThreadID.y + 0];
float inBL = g_scratchDepths[groupThreadID.x + 0][groupThreadID.y + 2];
float inBR = g_scratchDepths[groupThreadID.x + 2][groupThreadID.y + 2];
dm3 = XeGTAO_DepthMIPFilter(inTL, inTR, inBL, inBR);
ivec2 dispatchID4 = ivec2(uvec2(dispatchThreadID) >> 2u);
if (all(lessThan(dispatchID4, ivec2(gtao.ViewportSize)))) {
imageStore(out_depth3, dispatchID4, vec4(dm3, 0.0, 0.0, 0.0));
}
g_scratchDepths[groupThreadID.x][groupThreadID.y] = dm3;
}
barrier();
// MIP 4
// Final reduction, single thread per group writes a single texel.
// Esoterica's commented-out scratch write at the end is dead code
// (no consumer), we drop the comment.
if (all(equal(groupThreadID, ivec2(0)))) {
float inTL = g_scratchDepths[0][0];
float inTR = g_scratchDepths[4][0];
float inBL = g_scratchDepths[0][4];
float inBR = g_scratchDepths[4][4];
float dm4 = XeGTAO_DepthMIPFilter(inTL, inTR, inBL, inBR);
ivec2 dispatchID8 = ivec2(uvec2(dispatchThreadID) >> 3u);
if (all(lessThan(dispatchID8, ivec2(gtao.ViewportSize)))) {
imageStore(out_depth4, dispatchID8, vec4(dm4, 0.0, 0.0, 0.0));
}
}
}
#pragma sokol @end
#pragma sokol @program prog cs

View file

@ -0,0 +1,132 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Highlight outline post-pass.
//
// Fullscreen triangle (no vbuf). Reads the R8 UNORM highlight mask written by
// the mask_sphere/mask_capsule/mask_hull pipelines. Each non-zero pixel is
// inside a highlighted shape (encoded 0.5 = hover, 1.0 = select). The shader
// detects silhouette pixels (center is empty but a neighbor is filled)
// and emits the appropriate outline color premultiplied for blend-over the
// resolved scene color.
//
// Two ring radii tunable from C: hoverThicknessPx, selectThicknessPx.
// Select takes priority over hover when both rings catch a neighbor.
#pragma sokol @module highlight_outline
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
// Fullscreen triangle by gl_VertexIndex, 3 verts covering NDC
// [-1, 3] x [-1, 3], clipped to the [-1,1] viewport. No vertex buffer.
void main()
{
vec2 p = vec2( ( gl_VertexIndex == 1 ) ? 3.0 : -1.0, ( gl_VertexIndex == 2 ) ? 3.0 : -1.0 );
gl_Position = vec4( p, 0.0, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
layout( binding = 0 ) uniform ub_pass
{
vec4 hover_color; // premultiplied linear RGBA
vec4 select_color; // premultiplied linear RGBA
vec4 thickness_px; // .x = hover thickness, .y = select thickness, .zw unused
};
layout( binding = 0 ) uniform texture2D tex_mask;
layout( binding = 0 ) uniform sampler smp_mask;
layout( location = 0 ) out vec4 out_color;
// Discrete-kind threshold. 0.5 encodes hover, 1.0 encodes select. Threshold
// at 0.75 splits them. Values < 0.25 are "empty".
const float KIND_EMPTY_THRESHOLD = 0.25;
const float KIND_SELECT_THRESHOLD = 0.75;
void main()
{
ivec2 px = ivec2( gl_FragCoord.xy );
ivec2 sz = textureSize( sampler2D( tex_mask, smp_mask ), 0 );
// Inside a highlighted shape, keep the scene color (output 0 alpha).
float center = texelFetch( sampler2D( tex_mask, smp_mask ), px, 0 ).x;
if ( center > KIND_EMPTY_THRESHOLD )
{
out_color = vec4( 0.0 );
return;
}
int hoverR = clamp( int( thickness_px.x + 0.5 ), 1, 4 );
int selectR = clamp( int( thickness_px.y + 0.5 ), 1, 4 );
int maxR = max( hoverR, selectR );
// Track the strongest neighbor kind found, and the smallest radius at
// which we found a select-kind / hover-kind neighbor. The outline rules:
// * a select-kind pixel anywhere within selectR -> draw select
// * else a hover-kind pixel within hoverR -> draw hover
// * else a hover-kind pixel within selectR -> still draw hover
// (so the wider ring of a hover-only shape stays visible if the
// user widened thickness).
bool sawSelectInSelectR = false;
bool sawHoverInHoverR = false;
bool sawHoverInSelectR = false;
for ( int r = 1; r <= maxR; ++r )
{
for ( int i = 0; i < 4; ++i )
{
ivec2 off;
if ( i == 0 )
off = ivec2( r, 0 );
else if ( i == 1 )
off = ivec2( -r, 0 );
else if ( i == 2 )
off = ivec2( 0, r );
else
off = ivec2( 0, -r );
ivec2 q = px + off;
if ( q.x < 0 || q.y < 0 || q.x >= sz.x || q.y >= sz.y )
continue;
float k = texelFetch( sampler2D( tex_mask, smp_mask ), q, 0 ).x;
if ( k <= KIND_EMPTY_THRESHOLD )
continue;
if ( k >= KIND_SELECT_THRESHOLD )
{
if ( r <= selectR )
sawSelectInSelectR = true;
}
else
{
if ( r <= hoverR )
sawHoverInHoverR = true;
if ( r <= selectR )
sawHoverInSelectR = true;
}
}
}
if ( sawSelectInSelectR )
{
out_color = select_color;
return;
}
if ( sawHoverInHoverR )
{
out_color = hover_color;
return;
}
if ( sawHoverInSelectR )
{
out_color = hover_color;
return;
}
out_color = vec4( 0.0 );
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,164 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Highlight mask, capsule impostor.
//
// Stripped sibling of depth_only_capsule. Same OBB proxy + analytic
// ray-capsule intersection in the FS, outputs a uint highlight kind to the
// R8_UINT mask attachment. Writes gl_FragDepth so the GREATER_EQUAL depth
// test compares against the prepass depth at the analytic surface.
#pragma sokol @module mask_capsule
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
struct instance
{
vec4 xform_row0; // .xyz = R row 0, .w = center.x
vec4 xform_row1; // .xyz = R row 1, .w = center.y
vec4 xform_row2; // .xyz = R row 2, .w = center.z
vec4 params; // .x = halfLength, .y = radius, .z = highlight kind (float)
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
sample out vec3 v_world_pos_proxy;
flat out vec3 v_center;
flat out float v_half_length;
flat out float v_radius;
flat out vec3 v_axis_x_world;
flat out float v_kind;
void main()
{
instance inst = items[gl_InstanceIndex];
vec3 center = vec3( inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w );
float halfLength = inst.params.x;
float radius = inst.params.y;
vec3 obj_pos = vec3( in_pos.x * 2.0 * ( halfLength + radius ), in_pos.y * 2.0 * radius, in_pos.z * 2.0 * radius );
vec3 world_pos = center + vec3( dot( inst.xform_row0.xyz, obj_pos ), dot( inst.xform_row1.xyz, obj_pos ),
dot( inst.xform_row2.xyz, obj_pos ) );
v_world_pos_proxy = world_pos;
v_center = center;
v_half_length = halfLength;
v_radius = radius;
v_axis_x_world = vec3( inst.xform_row0.x, inst.xform_row1.x, inst.xform_row2.x );
v_kind = inst.params.z;
gl_Position = view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
layout( binding = 1 ) uniform ub_pass
{
mat4 view_proj; // for reverse-Z gl_FragDepth
vec4 camera_pos; // .xyz = world camera position
};
sample in vec3 v_world_pos_proxy;
flat in vec3 v_center;
flat in float v_half_length;
flat in float v_radius;
flat in vec3 v_axis_x_world;
flat in float v_kind;
layout( location = 0 ) out vec4 out_kind;
void main()
{
vec3 ro = camera_pos.xyz;
vec3 rd = normalize( v_world_pos_proxy - ro );
vec3 axis = v_axis_x_world;
vec3 pa = v_center - v_half_length * axis;
vec3 pb = v_center + v_half_length * axis;
vec3 ba = pb - pa;
vec3 oa = ro - pa;
float baba = dot( ba, ba );
float bard = dot( ba, rd );
float baoa = dot( ba, oa );
float rdoa = dot( rd, oa );
float oaoa = dot( oa, oa );
float a_c = baba - bard * bard;
float b_c = baba * rdoa - baoa * bard;
float c_c = baba * oaoa - baoa * baoa - v_radius * v_radius * baba;
float h_c = b_c * b_c - a_c * c_c;
float t = -1.0;
if ( h_c >= 0.0 && a_c > 1e-8 )
{
float t_body = ( -b_c - sqrt( h_c ) ) / a_c;
float y = baoa + t_body * bard;
if ( t_body > 0.0 && y > 0.0 && y < baba )
{
t = t_body;
}
}
// Cap A.
{
vec3 oc = ro - pa;
float b = dot( oc, rd );
float c = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c;
if ( h >= 0.0 )
{
float tc = -b - sqrt( h );
if ( tc > 0.0 && ( t < 0.0 || tc < t ) )
{
vec3 hit = ro + tc * rd;
if ( dot( hit - pa, axis ) <= 0.0 )
t = tc;
}
}
}
// Cap B.
{
vec3 oc = ro - pb;
float b = dot( oc, rd );
float c = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c;
if ( h >= 0.0 )
{
float tc = -b - sqrt( h );
if ( tc > 0.0 && ( t < 0.0 || tc < t ) )
{
vec3 hit = ro + tc * rd;
if ( dot( hit - pb, axis ) >= 0.0 )
t = tc;
}
}
}
if ( t < 0.0 )
discard;
vec3 hit_world = ro + t * rd;
vec4 hit_clip = view_proj * vec4( hit_world, 1.0 );
gl_FragDepth = hit_clip.z / hit_clip.w;
// R8 UNORM mask: 1.0=hover, 2.0=select -> 0.5, 1.0.
out_kind = vec4( v_kind * 0.5, 0.0, 0.0, 1.0 );
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,78 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Highlight mask, convex hull (triangle-rasterized).
//
// Same vertex math as depth_only_geom (transform + per-instance scale), but the
// FS just emits the highlight kind into the R8_UINT mask. Rasterized depth
// is correct as-is, no gl_FragDepth write. Pipeline depth-tests GREATER_EQUAL
// against the prepass depth.
#pragma sokol @module mask_hull
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base; // .x = base index into the hull-mask instance array
};
struct instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 scale_kind; // .xyz = per-instance scale, .w = highlight kind
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
// Position-only input. The shared geom vbo carries position+normal
// (stride 24 bytes), but the mask FS only needs world position. We
// don't declare an `in_normal` attribute so the GL linker doesn't strip
// it and warn. The C-side pipeline desc skips the in_normal binding to
// match.
in vec3 in_pos;
flat out float v_kind;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 scaled_pos = in_pos * inst.scale_kind.xyz;
vec4 local_pos = vec4( scaled_pos, 1.0 );
vec3 world_pos =
vec3( dot( inst.xform_row0, local_pos ), dot( inst.xform_row1, local_pos ), dot( inst.xform_row2, local_pos ) );
v_kind = inst.scale_kind.w;
gl_Position = view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
flat in float v_kind;
layout( location = 0 ) out vec4 out_kind;
void main()
{
// R8 UNORM mask: 1.0=hover, 2.0=select -> 0.5, 1.0.
out_kind = vec4( v_kind * 0.5, 0.0, 0.0, 1.0 );
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,103 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Highlight mask, sphere impostor.
//
// Stripped sibling of depth_only_sphere. Same bounding-cube proxy + analytic
// ray-sphere intersection in the FS, outputs a uint highlight kind to the
// R8_UINT mask attachment instead of writing depth. Depth-TEST against the
// existing GTAO prepass depth (reverse-Z GREATER, no depth write) so
// highlighted shapes behind opaque geometry don't bleed outlines.
#pragma sokol @module mask_sphere
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
struct instance
{
vec4 center_radius; // .xyz = center, .w = radius
vec4 kind; // .x = highlight kind (1.0 = hover, 2.0 = select), .yzw unused
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
sample out vec3 v_world_pos_proxy;
flat out vec3 v_center;
flat out float v_radius;
flat out float v_kind;
void main()
{
instance inst = items[gl_InstanceIndex];
vec3 center = inst.center_radius.xyz;
float radius = inst.center_radius.w;
vec3 world_pos = center + ( 2.0 * radius ) * in_pos;
v_world_pos_proxy = world_pos;
v_center = center;
v_radius = radius;
v_kind = inst.kind.x;
gl_Position = view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
layout( binding = 1 ) uniform ub_pass
{
mat4 view_proj; // for reverse-Z gl_FragDepth
vec4 camera_pos; // .xyz = world camera position
};
sample in vec3 v_world_pos_proxy;
flat in vec3 v_center;
flat in float v_radius;
flat in float v_kind;
layout( location = 0 ) out vec4 out_kind;
void main()
{
vec3 ro = camera_pos.xyz;
vec3 rd = normalize( v_world_pos_proxy - ro );
vec3 oc = ro - v_center;
float b = dot( oc, rd );
float c2 = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c2;
if ( h < 0.0 )
discard;
float t = -b - sqrt( h );
if ( t < 0.0 )
discard;
// Write analytic surface depth so the depth test compares at the
// sphere's true surface, not at the bounding-cube proxy. Matches the
// prepass depth's contents bit-for-bit, so GREATER_EQUAL passes when
// unoccluded and fails when an opaque shape is in front.
vec3 hit_world = ro + t * rd;
vec4 hit_clip = view_proj * vec4( hit_world, 1.0 );
gl_FragDepth = hit_clip.z / hit_clip.w;
// R8 UNORM mask: 1.0=hover, 2.0=select -> 0.5, 1.0.
out_kind = vec4( v_kind * 0.5, 0.0, 0.0, 1.0 );
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,138 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// AgX tonemap fullscreen pass.
//
// Reads the resolved HDR scene color (RGBA16F), applies an exposure stop,
// runs AgX (Standard look, identity ASC-CDL), and writes display-encoded
// sRGB to a linear-format (non-sRGB) framebuffer.
//
// Implementation is the "Minimal AgX" port of Troy Sobotka's reference
// (https://iolite-engine.com/blog_posts/minimal_agx_implementation),
// the same shader form used by Three.js and Filament. The 6th-order
// polynomial in agxDefaultContrastApprox is a fit of the AgX sigmoid,
// mean error^2 vs. the reference curve is ~3.7e-6.
//
// Color path:
// 1. linear sRGB HDR (scene)
// 2. x exposure (pow(2, ev))
// 3. AgX inset matrix -> "AgX color space"
// 4. clamp(log2(.), MIN_EV, MAX_EV) -> [0,1] log-space
// 5. polynomial sigmoid -> [0,1] log-space, S-shaped
// 6. AgX look -> luma-preserving saturation (params.z, 1.0 = identity)
// 7. AgX outset matrix -> display-encoded sRGB (no further EOTF)
//
// Output target format is linear unorm (BGRA8/RGBA8, NOT SRGB), so the
// outset-matrix result writes verbatim, no pow(., 2.2) at the end. If
// the target ever becomes sRGB-formatted (driver does linear->sRGB encode
// on store), add `v = pow(max(v, 0.0), vec3(2.2))` after the outset
// matrix to give the driver linear values.
//
// UV handling: the scene RT was written by the rasterizer at SV_Position
// (top-origin on D3D11/Metal/WGPU, bottom-origin on GL). Sampling it here
// with `v_uv = ndc * 0.5 + 0.5` reads the wrong row on D3D11/Metal/WGPU
// because v_uv.y=1 always means "max-V texel", which is top on GL but
// bottom on the others. The C side passes a backend-conditional uvYSign
// (+1 GL, -1 D3D/Metal/WGPU), we flip v_uv.y at sample time on the
// negative-sign backends. Same pattern as brdf_lut.glsl, just applied at
// the consumer (sample-time) instead of the producer (write-time).
#pragma sokol @module tonemap
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
out vec2 v_uv;
void main()
{
vec2 ndc = vec2( float( ( gl_VertexIndex << 1 ) & 2 ), float( gl_VertexIndex & 2 ) ) * 2.0 - 1.0;
v_uv = ndc * 0.5 + 0.5;
gl_Position = vec4( ndc, 0.0, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
layout( binding = 0 ) uniform ub_tonemap
{
// .x = ev (exposure stops, final multiplier = pow(2, ev))
// .y = uvYSign (+1 GL, -1 D3D11/Metal/WGPU), flips sample-time v_uv.y
// so the scene RT reads back upright on every backend.
// .z = AgX look saturation (1.0 = identity / stock AgX Standard look)
// .w reserved
vec4 params;
};
layout( binding = 0 ) uniform texture2D tex_scene;
layout( binding = 0 ) uniform sampler smp_scene;
in vec2 v_uv;
out vec4 out_color;
// 6th-order polynomial fit of the AgX sigmoid (Sobotka). Operates on the
// [0,1] log-space encoded value, output stays in [0,1] log-space but
// S-shaped to match the AgX contrast curve.
vec3 agxDefaultContrastApprox( vec3 x )
{
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return +15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232;
}
vec3 agx( vec3 v )
{
// Inset matrix: linear sRGB primaries -> AgX inset primaries.
const mat3 inset = mat3( 0.842479062253094, 0.0423282422610123, 0.0423756549057051, 0.0784335999999992, 0.878468636469772,
0.0784336, 0.0792237451477643, 0.0791661274605434, 0.879142973793104 );
const float MIN_EV = -12.47393;
const float MAX_EV = 4.026069;
v = inset * v;
// Floor to a tiny positive so log2 stays finite at black.
v = max( v, vec3( 1.0e-10 ) );
v = clamp( log2( v ), MIN_EV, MAX_EV );
v = ( v - MIN_EV ) / ( MAX_EV - MIN_EV );
v = agxDefaultContrastApprox( v );
return v;
}
vec3 agxOutset( vec3 v )
{
// Inverse of the inset matrix, brings the sigmoid output back to display
// sRGB primaries. Result is display-encoded sRGB (ready for an unorm RT).
const mat3 outset = mat3( 1.19687900512017, -0.0528968517574562, -0.0529716355144438, -0.0980208811401368, 1.15190312990417,
-0.0980434501171241, -0.0990297440797205, -0.0989611768448433, 1.15107367264116 );
return outset * v;
}
// AgX "look": luma-preserving saturation, applied to the sigmoid output
// while it's still in AgX-encoded [0,1] space (before the outset matrix).
// saturation 1.0 is identity: AgX's stock Standard look. AgX walks bright
// colors toward white ("path to white"), which reads as desaturation.
// saturation > 1.0 pushes them back out, < 1.0 mutes them. Rec.709 luma
// weights hold perceived brightness fixed. The reference Minimal AgX look
// also exposes per-channel slope/power ("Punchy"/"Golden" presets), we
// wire only saturation, the one knob this debug renderer needs.
vec3 agxLook( vec3 v, float saturation )
{
const vec3 LUMA = vec3( 0.2126, 0.7152, 0.0722 );
float luma = dot( v, LUMA );
return luma + saturation * ( v - luma );
}
void main()
{
// Backend-conditional v_uv.y flip: when params.y < 0 (D3D11/Metal/WGPU),
// replace v_uv.y with (1 - v_uv.y) so the sample reads the correct row.
// Equivalent to `mix(1.0-y, y, step(0.0, params.y))` but cheaper.
float sampleY = ( params.y > 0.0 ) ? v_uv.y : ( 1.0 - v_uv.y );
vec3 hdr = textureLod( sampler2D( tex_scene, smp_scene ), vec2( v_uv.x, sampleY ), 0.0 ).rgb;
hdr *= pow( 2.0, params.x );
vec3 ldr = agxOutset( agxLook( agx( hdr ), params.z ) );
out_color = vec4( clamp( ldr, 0.0, 1.0 ), 1.0 );
}
#pragma sokol @end
#pragma sokol @program prog vs fs

View file

@ -0,0 +1,487 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Capsule impostor.
//
// Per-instance: a 3x4 rigid affine (orthonormal rotation rows in .xyz of each
// xform_row*, capsule center in .w of each row), an RGBA color, and a `params`
// row whose .x is halfLength (segment half-length along local +X) and .y is
// the cap radius. The capsule's long axis is the local +X axis: end caps sit
// at object-space (+/- halfLength, 0, 0) with radius `radius`.
//
// Pipeline overview:
// VS: emit a unit-cube vertex (half-extent 0.5) scaled to an OBB with
// half-extents (halfLength + radius, radius, radius), then rotated by
// the instance rotation and translated by center. Pass world position
// of the proxy vertex (interpolated) plus flat per-instance data.
// FS: reconstruct view ray as (camera, normalize(v_world_pos_proxy - camera)).
// Quilez ray-capsule intersection in world space (cylinder body + two
// end-cap spheres). discard on miss / behind-camera. Compute world-space
// normal at the hit, transform to object space via transpose(rotation),
// shade two great-circle rings at the object-space y=0 and z=0
// equators: on caps these appear as half-circles through the apex,
// on the cylinder body they continue as longitudinal lines. The X
// equator is omitted: n_obj.x is identically zero on the cylinder
// (would paint the entire body), and at the cap-cylinder seam the
// curvature discontinuity makes its line thinner than the others.
// Constant screen-space pixel thickness via fwidth, on a north/south
// hemisphere base contrast. Apply Lambert + ambient against
// world-space sun, write reverse-Z gl_FragDepth.
//
// `@module capsule` prefixes the generated C symbols (capsule_ub_frame_t,
// capsule_instance_t, capsule_shader_desc, ...) so this header coexists with
// cube.glsl.h and sphere.glsl.h in renderer.c without typedef collisions on
// ub_frame_t.
//
// UBO layout matches sphere.glsl exactly (frame data lives in ub_pass on
// the FS side because the renderer always re-applies ub_pass per draw, and
// one FS UBO is simpler than two).
//
// gl_FragDepth disables hi-Z. That's accepted for impostors.
#pragma sokol @module capsule
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
// per-draw offset into the instance buffer. See cube.glsl for the
// rationale.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0, .w = center.x
vec4 xform_row1; // .xyz = rotation row 1, .w = center.y
vec4 xform_row2; // .xyz = rotation row 2, .w = center.z
vec4 base_color; // .rgb = linear baseColor, .a = alpha
vec4 params; // .x = halfLength, .y = radius, .zw = unused
vec4 material; // .x = metallic, .y = roughness,
// .z = shadow-cast bit (, CPU-only, ignored here),
// .w = reserved
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
// Interpolated, per-pixel. The FS computes an analytical sub-pixel coverage
// from the signed silhouette distance and feeds it through alpha-to-coverage
// (opaque pipeline) or the alpha blend (transparent pipeline). Mirrors
// sphere.glsl.
out vec3 v_world_pos_proxy;
// Flat: same value for every fragment in this instance.
flat out vec3 v_center;
flat out float v_half_length;
flat out float v_radius;
flat out vec3 v_axis_x_world; // world-space direction of local +X (capsule long axis)
flat out vec3 v_rot_row0; // R rows for n_world -> n_obj transform in FS
flat out vec3 v_rot_row1;
flat out vec3 v_rot_row2;
flat out vec4 v_base_color;
flat out vec4 v_material;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 center = vec3( inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w );
float halfLength = inst.params.x;
float radius = inst.params.y;
// OBB half-extents: (halfLength + radius) along local X, radius along Y/Z.
// Multiply unit-cube vertex (half-extent 0.5) by 2*these to get exact OBB.
vec3 obj_pos = vec3( in_pos.x * 2.0 * ( halfLength + radius ), in_pos.y * 2.0 * radius, in_pos.z * 2.0 * radius );
// world = R * obj + center, each component is the dot of an R row with obj_pos.
vec3 world_pos = center + vec3( dot( inst.xform_row0.xyz, obj_pos ), dot( inst.xform_row1.xyz, obj_pos ),
dot( inst.xform_row2.xyz, obj_pos ) );
v_world_pos_proxy = world_pos;
v_center = center;
v_half_length = halfLength;
v_radius = radius;
// Local +X in world = first column of R = (R[0][0], R[1][0], R[2][0])
// = (xform_row0.x, xform_row1.x, xform_row2.x).
v_axis_x_world = vec3( inst.xform_row0.x, inst.xform_row1.x, inst.xform_row2.x );
v_rot_row0 = inst.xform_row0.xyz;
v_rot_row1 = inst.xform_row1.xyz;
v_rot_row2 = inst.xform_row2.xyz;
v_base_color = inst.base_color;
v_material = inst.material;
gl_Position = view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/pbr.glsl
layout( binding = 1 ) uniform ub_pass
{
vec4 sun_dir_world; // .xyz = world-space dir TO sun (normalized)
vec4 sun_color; // .rgb = color, .a = ambient strength (flat-ambient fallback)
ivec4 flags; // .x = debug_view_mode (0 lit, 1 view-depth, 2 cascade-index)
vec4 camera_pos; // .xyz = camera world pos, .w unused
mat4 view_proj; // for reverse-Z gl_FragDepth
mat4 view; // for view-space depth debug mode + cascade selection
vec4 cascade_far_view_z; // .xyz = far view-space Z per cascade
mat4 cascade_matrices[3]; // light-space view-proj per cascade
vec4 sh[9]; // IBL diffuse SH coefficients (band 0..2, RGB in .xyz)
vec4 ibl_params; // .x = prefilter cube max_lod, .y = IBL enable (1=IBL, 0=flat ambient), .zw reserved
};
#pragma sokol @image_sample_type tex_shadow depth
layout( binding = 1 ) uniform texture2DArray tex_shadow;
#pragma sokol @sampler_type smp_shadow comparison
layout( binding = 0 ) uniform samplerShadow smp_shadow;
// IBL bindings, same convention as cube.glsl: texture bindings 2/3,
// sampler bindings 1/2, disjoint from the shadow path's 1/0.
#pragma sokol @image_sample_type tex_ibl_spec float
layout( binding = 2 ) uniform textureCube tex_ibl_spec;
#pragma sokol @sampler_type smp_ibl_spec filtering
layout( binding = 1 ) uniform sampler smp_ibl_spec;
#pragma sokol @image_sample_type tex_brdf_lut float
layout( binding = 3 ) uniform texture2D tex_brdf_lut;
#pragma sokol @sampler_type smp_brdf_lut filtering
layout( binding = 2 ) uniform sampler smp_brdf_lut;
// GTAO, same convention as cube.glsl. Multiplies only the IBL ambient.
#pragma sokol @image_sample_type tex_ao float
layout( binding = 4 ) uniform texture2D tex_ao;
#pragma sokol @sampler_type smp_ao filtering
layout( binding = 3 ) uniform sampler smp_ao;
// 3x3 PCF over a 1-texel radius. Manually unrolled, see cube.glsl for
// the X3570 rationale.
float sampleShadowPCF( int cascade, vec3 light_uv, float bias )
{
float t = 1.0 / 2048.0;
float ly = float( cascade );
float rz = light_uv.z - bias;
vec2 c = light_uv.xy;
float s = 0.0;
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y + t, ly, rz ) );
return s / 9.0;
}
float sampleCascade( int cascade, vec3 world_pos, vec3 world_normal )
{
vec4 light_clip = cascade_matrices[cascade] * vec4( world_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
// Backend-dependent Y orientation, see cube.glsl for the longer note.
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
if ( any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) ) )
{
return 1.0;
}
float n_dot_l = max( dot( world_normal, normalize( sun_dir_world.xyz ) ), 0.0 );
float bias = mix( 0.0040, 0.0008, n_dot_l );
float pcf = sampleShadowPCF( cascade, light_uv, bias );
// See cube.glsl for the longer note. Cascade 2 has no fallback at its
// UV boundary, so fade PCF toward 1.0 over the outer 10% to hide the
// polygonal seam where cascade 2's spatial extent ends on the ground.
if ( cascade == 2 )
{
vec2 edge = min( light_uv.xy, 1.0 - light_uv.xy );
float fade = clamp( min( edge.x, edge.y ) * 10.0, 0.0, 1.0 );
pcf = mix( 1.0, pcf, fade );
}
return pcf;
}
float sampleShadowCascaded( vec3 world_pos, vec3 world_normal, float view_z )
{
int cascade = 2;
if ( view_z < cascade_far_view_z.x )
cascade = 0;
else if ( view_z < cascade_far_view_z.y )
cascade = 1;
float shadow = sampleCascade( cascade, world_pos, world_normal );
// Blend the last 10% of each cascade's range with the next cascade
// to hide the polygonal step where they meet. See cube.glsl for the
// longer note.
if ( cascade < 2 )
{
float far_z = ( cascade == 0 ) ? cascade_far_view_z.x : cascade_far_view_z.y;
float near_z = ( cascade == 0 ) ? 0.0 : cascade_far_view_z.x;
float blend_start = mix( far_z, near_z, 0.1 );
if ( view_z > blend_start )
{
float alpha = ( view_z - blend_start ) / ( far_z - blend_start );
shadow = mix( shadow, sampleCascade( cascade + 1, world_pos, world_normal ), alpha );
}
}
return shadow;
}
in vec3 v_world_pos_proxy;
flat in vec3 v_center;
flat in float v_half_length;
flat in float v_radius;
flat in vec3 v_axis_x_world;
flat in vec3 v_rot_row0;
flat in vec3 v_rot_row1;
flat in vec3 v_rot_row2;
flat in vec4 v_base_color;
flat in vec4 v_material;
out vec4 out_color;
void main()
{
// Ray construction (world space)
vec3 ro = camera_pos.xyz;
vec3 rd = normalize( v_world_pos_proxy - ro );
// Capsule endpoints in world space.
vec3 axis = v_axis_x_world; // already unit (rigid R)
vec3 pa = v_center - v_half_length * axis; // -X cap center
vec3 pb = v_center + v_half_length * axis; // +X cap center
// Ray-capsule (cylinder body), Quilez closed form
// Reference: https://iquilezles.org/articles/intersectors/
vec3 ba = pb - pa;
vec3 oa = ro - pa;
float baba = dot( ba, ba );
float bard = dot( ba, rd );
float baoa = dot( ba, oa );
float rdoa = dot( rd, oa );
float oaoa = dot( oa, oa );
float a_c = baba - bard * bard;
float b_c = baba * rdoa - baoa * bard;
float c_c = baba * oaoa - baoa * baoa - v_radius * v_radius * baba;
float h_c = b_c * b_c - a_c * c_c;
// Analytical silhouette AA. A capsule is the Minkowski sum of a segment
// and a sphere, so distance(ray-line, capsule) = distance(ray-line,
// segment) - radius. The closest point on the segment to the ray-line is
// at s_inf (unconstrained) clamped to [0,1]: when s_inf lies inside the
// segment p_cap is the cylinder's closest-axis point (perp distance =
// cylinder silhouette), when clamped p_cap is a cap center (perp
// distance = cap-sphere silhouette). One formula covers body + caps with
// a single clamp. Computed in uniform control flow before any discard.
float s_inf = ( baoa - ( b_c / max( a_c, 1e-8 ) ) * bard ) / baba;
float s_clamp = clamp( s_inf, 0.0, 1.0 );
vec3 p_cap = pa + s_clamp * ba;
vec3 oc_cap = ro - p_cap;
float bb_cap = dot( oc_cap, rd );
float perp2 = max( 0.0, dot( oc_cap, oc_cap ) - bb_cap * bb_cap );
float d_sil = sqrt( perp2 ) - v_radius;
float aa = max( fwidth( d_sil ), 1e-6 );
float coverage = 1.0 - smoothstep( -aa, aa, d_sil );
float t = -1.0; // hit parameter, -1 means "no hit yet"
vec3 n_world = vec3( 0.0 );
if ( h_c >= 0.0 && a_c > 1e-8 )
{
float t_body = ( -b_c - sqrt( h_c ) ) / a_c;
// Axial coord of the cylinder hit, normalized so 0..baba spans the body.
float y = baoa + t_body * bard;
if ( t_body > 0.0 && y > 0.0 && y < baba )
{
vec3 hit = ro + t_body * rd;
// Project hit onto the cylinder centerline, normal is (hit - axis_pt)/r.
vec3 axis_pt = pa + ba * ( y / baba );
n_world = ( hit - axis_pt ) / v_radius;
t = t_body;
}
}
// End-cap spheres
// Test both caps, keep the closer hit (smallest positive t).
//
// Cap A (-X end) at pa.
{
vec3 oc = ro - pa;
float b = dot( oc, rd );
float c = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c;
if ( h >= 0.0 )
{
float tc = -b - sqrt( h );
if ( tc > 0.0 && ( t < 0.0 || tc < t ) )
{
vec3 hit = ro + tc * rd;
// Reject the half of the cap sphere that's inside the
// cylinder. The visible part of cap A has (hit - pa). axis <= 0.
if ( dot( hit - pa, axis ) <= 0.0 )
{
n_world = ( hit - pa ) / v_radius;
t = tc;
}
}
}
}
// Cap B (+X end) at pb.
{
vec3 oc = ro - pb;
float b = dot( oc, rd );
float c = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c;
if ( h >= 0.0 )
{
float tc = -b - sqrt( h );
if ( tc > 0.0 && ( t < 0.0 || tc < t ) )
{
vec3 hit = ro + tc * rd;
if ( dot( hit - pb, axis ) >= 0.0 )
{
n_world = ( hit - pb ) / v_radius;
t = tc;
}
}
}
}
// Near-miss fallback: ray didn't hit the capsule, but coverage > 0 means
// we're inside the silhouette AA band. Shade off the closest-approach
// point on the ray to the capsule's segment, the resulting normal is
// the silhouette normal at p_cap, which is what these sub-pixel
// fragments should display.
if ( t < 0.0 )
{
t = -bb_cap;
vec3 closest = ro + t * rd;
n_world = normalize( closest - p_cap );
}
if ( coverage <= 0.0 || t < 0.0 )
{
// True miss outside the AA band, or capsule behind camera.
discard;
}
vec3 hit_world = ro + t * rd;
// Object-space normal via R^T
vec3 n_obj = vec3( v_rot_row0.x * n_world.x + v_rot_row1.x * n_world.y + v_rot_row2.x * n_world.z,
v_rot_row0.y * n_world.x + v_rot_row1.y * n_world.y + v_rot_row2.y * n_world.z,
v_rot_row0.z * n_world.x + v_rot_row1.z * n_world.y + v_rot_row2.z * n_world.z );
// Surface pattern
// Two great-circle rings at object-space y=0 and z=0 equators, drawn
// uniformly on caps and body. fwidth is taken on the signed normal
// component (abs has a derivative kink at zero that produces
// speckled lines). Constant ~LINE_PIXELS screen-space thickness.
float hemi = ( n_obj.y > 0.0 ) ? 1.0 : 0.65;
vec3 base = v_base_color.rgb * hemi;
const float LINE_PIXELS = 1.5;
float ring_y = 1.0 - smoothstep( 0.0, fwidth( n_obj.y ) * LINE_PIXELS, abs( n_obj.y ) );
float ring_z = 1.0 - smoothstep( 0.0, fwidth( n_obj.z ) * LINE_PIXELS, abs( n_obj.z ) );
float line = max( ring_y, ring_z );
vec3 line_color = base * 0.35;
vec3 surface = mix( base, line_color, line );
// Reverse-Z depth
vec4 hit_clip = view_proj * vec4( hit_world, 1.0 );
gl_FragDepth = hit_clip.z / hit_clip.w;
// Output
if ( flags.x == 1 )
{
vec3 hit_view = ( view * vec4( hit_world, 1.0 ) ).xyz;
float view_depth = -hit_view.z;
float v = clamp( view_depth / 50.0, 0.0, 1.0 );
out_color = vec4( v, v, v, 1.0 );
return;
}
if ( flags.x == 2 )
{
float view_z_dbg = -( view * vec4( hit_world, 1.0 ) ).z;
int cascade = 2;
if ( view_z_dbg < cascade_far_view_z.x )
cascade = 0;
else if ( view_z_dbg < cascade_far_view_z.y )
cascade = 1;
vec4 light_clip = cascade_matrices[cascade] * vec4( hit_world, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
bool oob = any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) );
vec3 tint = vec3( 1.0 );
if ( !oob )
{
if ( cascade == 0 )
tint = vec3( 1.0, 0.4, 0.4 );
else if ( cascade == 1 )
tint = vec3( 0.4, 1.0, 0.4 );
else
tint = vec3( 0.4, 0.4, 1.0 );
}
out_color = vec4( tint, 1.0 );
return;
}
if ( flags.x == 3 )
{
// View-space normal as RGB, [-1,1] mapped to [0,1].
vec3 n_view = ( view * vec4( n_world, 0.0 ) ).xyz;
out_color = vec4( normalize( n_view ) * 0.5 + 0.5, 1.0 );
return;
}
// GTAO sample.
vec2 ao_uv = gl_FragCoord.xy / vec2( textureSize( sampler2D( tex_ao, smp_ao ), 0 ) );
float ao = textureLod( sampler2D( tex_ao, smp_ao ), ao_uv, 0.0 ).x;
if ( flags.x == 4 )
{
out_color = vec4( vec3( ao ), 1.0 );
return;
}
vec3 L = normalize( sun_dir_world.xyz );
float n_dot_l = max( dot( n_world, L ), 0.0 );
float view_z = -( view * vec4( hit_world, 1.0 ) ).z;
float shadow = sampleShadowCascaded( hit_world, n_world, view_z );
vec3 V = normalize( camera_pos.xyz - hit_world );
vec3 direct = brdf_evaluate( n_world, V, L, sun_color.rgb * shadow, surface, v_material.x, v_material.y );
vec3 ambient = pbrEvaluateAmbient( ibl_params.y > 0.5, n_world, V, surface, v_material.x, v_material.y, sun_color.a, sh,
tex_ibl_spec, smp_ibl_spec, tex_brdf_lut, smp_brdf_lut, ibl_params.x );
// premultiplied output, see cube.glsl. Alpha is scaled by analytical
// silhouette coverage so alpha-to-coverage (opaque pipeline) or the
// premultiplied alpha blend (transparent pipeline) produces a smooth
// sub-pixel silhouette instead of a binary hit/miss edge.
float a = v_base_color.a * coverage;
out_color = vec4( ( direct + ambient * ao ) * a, a );
}
#pragma sokol @end
#pragma sokol @program impostor vs fs

View file

@ -0,0 +1,391 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Cube shader, cascaded-shadow-map sampling and
// with PBR shading (GGX+Smith+Schlick+Lambert via
// common/pbr.glsl).
//
// Per-vertex input is a unit-cube corner (8 unique positions, 36 indices).
// Per-instance data lives in a readonly storage buffer indexed by
// gl_InstanceIndex: a 3x4 row-major affine transform plus a PBR material
// (baseColor + metallic + roughness). Flat shading is recovered from
// dFdx/dFdy of view-space position, no per-vertex normals are stored or
// interpolated.
//
// Lighting math runs in VIEW space (n_view, V = normalize(-v_view_pos),
// L = sun_dir_view). Converting the cube's normal computation to world
// space produced inverted normals on D3D11 (likely a screen-Y
// handedness interaction with the cross-product derivation). dot(n, L) is
// rotation-invariant, so the shadow bias formula reuses the view-space
// dot(n, L) unchanged. Shadow projection itself needs world-space coordinates,
// so we forward v_world_pos as a separate varying for the cascade matrix
// lookup.
//
// debug_view_mode (ub_pass.flags.x) selects the output:
// 0 = Lambert + ambient * shadow factor.
// 1 = view-space distance from camera as grayscale.
// 2 = cascade-index tint (red/green/blue = cascade 0/1/2, white = UV
// out of bounds on the chosen cascade, i.e. unsampled).
//
// UBO bindings are stage-specific in sokol-shdc.
// VS uses ub_frame at binding=0, FS uses ub_pass at binding=1. The shadow
// depth array texture binds at texture-binding=0, the comparison sampler
// binds at sampler-binding=0.
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view;
mat4 proj;
mat4 view_proj;
mat4 inv_view_proj;
vec4 camera_pos; // .xyz = world pos, .w = time
vec4 viewport; // .xy = size px, .zw = 1/size
};
// per-draw offset into the cube_instances buffer. Opaque draws bind
// the contiguous opaque arena and set inst_base.x = 0 (bulk-instanced).
// Transparent draws bind the transparent arena and set inst_base.x = K to
// pick the K-th transparent instance, then sg_draw with instanceCount = 1.
// The back-to-front sort across shape types is realized through these
// per-instance picks.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct cube_instance
{
vec4 xform_row0; // 3x4 affine, rows
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color; // .rgb = linear baseColor, .a = alpha
vec4 material; // .x = metallic, .y = roughness,
// .z = shadow-cast bit (, CPU-only, ignored here),
// .w = reserved
};
layout( binding = 0 ) readonly buffer cube_instances
{
cube_instance instances[];
};
in vec3 in_pos; // per-vertex (cube corner, local space)
out vec3 v_view_pos; // for view-space normal via dFdx/dFdy
out vec3 v_world_pos; // for shadow projection (cascade matrix lookup)
flat out vec4 v_base_color;
flat out vec4 v_material;
void main()
{
cube_instance inst = instances[inst_base.x + gl_InstanceIndex];
vec4 local_pos = vec4( in_pos, 1.0 );
vec3 world_pos =
vec3( dot( inst.xform_row0, local_pos ), dot( inst.xform_row1, local_pos ), dot( inst.xform_row2, local_pos ) );
vec4 view_pos = view * vec4( world_pos, 1.0 );
v_view_pos = view_pos.xyz;
v_world_pos = world_pos;
v_base_color = inst.base_color;
v_material = inst.material;
gl_Position = proj * view_pos;
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/pbr.glsl
layout( binding = 1 ) uniform ub_pass
{
vec4 sun_dir_view; // .xyz = view-space dir TO sun (normalized), for direct lighting
vec4 sun_color; // .rgb = color, .a = ambient strength (flat-ambient fallback)
ivec4 flags; // .x = debug_view_mode
vec4 cascade_far_view_z; // .xyz = far view-space Z per cascade
mat4 cascade_matrices[3]; // light-space view-proj per cascade
mat4 view; // IBL: world->view rotation for view->world n_view transform
vec4 camera_pos_world; // IBL: world camera pos for V_world derivation
vec4 sh[9]; // IBL diffuse SH coefficients (band 0..2, RGB in .xyz)
vec4 ibl_params; // .x = prefilter cube max_lod, .y = IBL enable (1=IBL, 0=flat ambient), .zw reserved
};
// binding=1 (not 0): sokol-shdc enforces disjoint binding numbers between
// storage buffers and textures across all stages of a program. The cube
// instance buffer holds binding=0 in the VS, so the shadow texture takes 1.
#pragma sokol @image_sample_type tex_shadow depth
layout( binding = 1 ) uniform texture2DArray tex_shadow;
#pragma sokol @sampler_type smp_shadow comparison
layout( binding = 0 ) uniform samplerShadow smp_shadow;
// IBL: prefiltered sky cubemap (specular) and Karis BRDF integration
// LUT. Texture bindings 2/3 and sampler bindings 1/2, disjoint from the
// shadow path's 1/0.
#pragma sokol @image_sample_type tex_ibl_spec float
layout( binding = 2 ) uniform textureCube tex_ibl_spec;
#pragma sokol @sampler_type smp_ibl_spec filtering
layout( binding = 1 ) uniform sampler smp_ibl_spec;
#pragma sokol @image_sample_type tex_brdf_lut float
layout( binding = 3 ) uniform texture2D tex_brdf_lut;
#pragma sokol @sampler_type smp_brdf_lut filtering
layout( binding = 2 ) uniform sampler smp_brdf_lut;
// GTAO: full-res R32F ambient occlusion target written by
// post/gtao_denoise. Sampled per pixel via gl_FragCoord and used to
// modulate only the IBL ambient term (direct sun light is untouched,
// per XeGTAO).
#pragma sokol @image_sample_type tex_ao float
layout( binding = 4 ) uniform texture2D tex_ao;
#pragma sokol @sampler_type smp_ao filtering
layout( binding = 3 ) uniform sampler smp_ao;
in vec3 v_view_pos;
in vec3 v_world_pos;
flat in vec4 v_base_color;
flat in vec4 v_material;
out vec4 out_color;
// 3x3 PCF over a 1-texel radius. The comparison sampler returns 0..1
// per tap (0 = occluded, 1 = lit). Uniform 1/9 weighting.
//
// Manually unrolled: the HLSL compiler emits warning X3570 ("gradient
// instruction used in a loop with varying iteration") on the looped
// version because texture uses implicit derivatives. Unrolling here
// keeps cross-compilation clean on the D3D11 backend.
float sampleShadowPCF( int cascade, vec3 light_uv, float bias )
{
float t = 1.0 / 2048.0;
float ly = float( cascade );
float rz = light_uv.z - bias;
vec2 c = light_uv.xy;
float s = 0.0;
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y + t, ly, rz ) );
return s / 9.0;
}
float sampleCascade( int cascade, vec3 world_pos, float n_dot_l )
{
vec4 light_clip = cascade_matrices[cascade] * vec4( world_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
// UV.y orientation is BACKEND-DEPENDENT. D3D11/Metal/WebGPU sample
// render targets with V = 0 at the top (NDC.y = +1 -> texture row 0),
// they need UV.y = 0.5 - NDC.y * 0.5. OpenGL samples with V = 0 at
// the bottom (NDC.y = +1 -> top row N-1), it needs the textbook
// UV.y = NDC.y * 0.5 + 0.5. Renderer side sets cascade_far_view_z.w
// to -1 on D3D11/Metal/WGPU and +1 on glcore so a single multiply
// here picks the right convention.
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
if ( any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) ) )
{
return 1.0;
}
// Slope-scaled bias: tan(angle to light) = sqrt(1 - n.l^2) / n.l.
// Constant texel-step factor keeps the bias roughly the same world
// size across cascades (each cascade's depth range scales with its
// bounding sphere, bias scales with it via the texel step).
float ndl = clamp( n_dot_l, 0.001, 1.0 );
float tanAngle = sqrt( 1.0 - ndl * ndl ) / ndl;
float texelDepthStep = 0.001;
float bias = clamp( texelDepthStep * tanAngle, 0.0005, 0.05 );
float pcf = sampleShadowPCF( cascade, light_uv, bias );
// Cascade 2 is the last cascade, sampleShadowCascaded's view-z blend
// has nothing to blend into beyond it. On flat ground at glancing sun
// angles PCF inside the cascade reads slightly below 1.0 (bias slop
// across a 3x3 kernel that covers ~5 cm of world per texel here), while
// fragments outside the cascade's spatial sphere fall through to the
// OOB return of 1.0. Without smoothing, cascade 2's UV boundary reads
// as a hexagonal polygon on the ground. Fade PCF toward 1.0 over the
// outer 10% of UV space to hide the seam.
if ( cascade == 2 )
{
vec2 edge = min( light_uv.xy, 1.0 - light_uv.xy );
float fade = clamp( min( edge.x, edge.y ) * 10.0, 0.0, 1.0 );
pcf = mix( 1.0, pcf, fade );
}
return pcf;
}
// n_dot_l is the (clamped) dot of the surface normal with the sun
// direction, passed in by the caller in whichever space is convenient
// (rotation-invariant, same value in view and world space).
float sampleShadowCascaded( vec3 world_pos, float n_dot_l, float view_z )
{
int cascade = 2;
if ( view_z < cascade_far_view_z.x )
{
cascade = 0;
}
else if ( view_z < cascade_far_view_z.y )
{
cascade = 1;
}
float shadow = sampleCascade( cascade, world_pos, n_dot_l );
// Blend the last 10% of each cascade's range with the next cascade.
// Each cascade uses the same slope-scaled bias in shadow-UV units,
// but cascades cover very different world extents (cascade 0 ~= 1 m,
// cascade 2 ~= 25 m+), so PCF response on flat receivers differs
// slightly per cascade, without this blend the boundary reads as a
// polygonal step on the ground at glancing sun angles.
if ( cascade < 2 )
{
float far_z = ( cascade == 0 ) ? cascade_far_view_z.x : cascade_far_view_z.y;
float near_z = ( cascade == 0 ) ? 0.0 : cascade_far_view_z.x;
float blend_start = mix( far_z, near_z, 0.1 );
if ( view_z > blend_start )
{
float alpha = ( view_z - blend_start ) / ( far_z - blend_start );
shadow = mix( shadow, sampleCascade( cascade + 1, world_pos, n_dot_l ), alpha );
}
}
return shadow;
}
void main()
{
// Derivatives at top level: undefined inside non-uniform branches.
// In view space the cross-product convention works out
// consistently across GL/D3D11/Metal because dFdx/dFdy are derived
// from the same screen-space basis the camera uses to define view
// space. Computing in world space instead inverts the normal on
// D3D11 (raw screen-Y handedness leaks through the conversion).
vec3 dx = dFdx( v_view_pos );
// GL's dFdy points in +view_y (screen origin is lower-left), while HLSL
// ddy and Metal dfdy point in -view_y (screen origin is upper-left).
// sokol-shdc cross-compiles dFdy->ddy/dfdy without a sign flip, so the raw
// value's screen direction depends on the backend. cascade_far_view_z.w
// is +1 on glcore/gles3 and -1 on D3D11/Metal/WGPU (same flag used by
// the shadow UV.y remap below), negating it gives a multiplier that
// canonicalizes dFdy to the -view_y direction on every backend. With
// canonical dy, cross(dy, dx) = (-view_y) x (+view_x) = +view_z, which
// points toward the camera (out of the screen), the correct outward
// normal for a back-culled front face.
vec3 dy = dFdy( v_view_pos ) * ( -cascade_far_view_z.w );
vec3 n_view = normalize( cross( dy, dx ) );
float view_z = -v_view_pos.z;
// Debug view : depth
if ( flags.x == 1 )
{
float v = clamp( view_z / 50.0, 0.0, 1.0 );
out_color = vec4( v, v, v, 1.0 );
return;
}
// Debug view : shadow cascades
if ( flags.x == 2 )
{
int cascade = 2;
if ( view_z < cascade_far_view_z.x )
{
cascade = 0;
}
else if ( view_z < cascade_far_view_z.y )
{
cascade = 1;
}
vec4 light_clip = cascade_matrices[cascade] * vec4( v_world_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
bool oob = any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) );
vec3 tint = vec3( 1.0 );
if ( !oob )
{
if ( cascade == 0 )
{
tint = vec3( 1.0, 0.4, 0.4 );
}
else if ( cascade == 1 )
{
tint = vec3( 0.4, 1.0, 0.4 );
}
else
{
tint = vec3( 0.4, 0.4, 1.0 );
}
}
out_color = vec4( tint, 1.0 );
return;
}
// Debug view : normals
if ( flags.x == 3 )
{
// View-space normal as RGB, [-1,1] mapped to [0,1].
out_color = vec4( n_view * 0.5 + 0.5, 1.0 );
return;
}
// GTAO sample. textureSize avoids needing a viewport uniform in
// ub_pass, the AO texture matches the swapchain/offscreen target
// exactly so dividing the pixel-space gl_FragCoord by the AO size
// yields the right UV regardless of backend Y-orientation.
vec2 ao_uv = gl_FragCoord.xy / vec2( textureSize( sampler2D( tex_ao, smp_ao ), 0 ) );
float ao = textureLod( sampler2D( tex_ao, smp_ao ), ao_uv, 0.0 ).x;
// Debug view : ambient occlusion
if ( flags.x == 4 )
{
out_color = vec4( vec3( ao ), 1.0 );
return;
}
// dot(n, L) is rotation-invariant. Same value with view-space or world-space
// normals + sun directions. Use the view-space pair for direct light.
vec3 L = normalize( sun_dir_view.xyz );
float n_dot_l = max( dot( n_view, L ), 0.0 );
float shadow = sampleShadowCascaded( v_world_pos, n_dot_l, view_z );
// Camera sits at origin in view space, so V_view = normalize(-v_view_pos).
vec3 V_view = normalize( -v_view_pos );
vec3 direct = brdf_evaluate( n_view, V_view, L, sun_color.rgb * shadow, v_base_color.rgb, v_material.x, v_material.y );
// IBL needs world-space N and V. view is the world->view matrix, its
// 3x3 is orthonormal (camera rotation), so transpose(mat3(view))
// takes view-space -> world-space without inverse cost. Stays clear
// of the D3D11 cross-product handedness trap that forced n_view to
// be computed in view space. Only rotate here, no derivatives.
mat3 view_to_world = transpose( mat3( view ) );
vec3 N_world = normalize( view_to_world * n_view );
vec3 V_world = normalize( camera_pos_world.xyz - v_world_pos );
vec3 ambient = pbrEvaluateAmbient( ibl_params.y > 0.5, N_world, V_world, v_base_color.rgb, v_material.x, v_material.y,
sun_color.a, sh, tex_ibl_spec, smp_ibl_spec, tex_brdf_lut, smp_brdf_lut, ibl_params.x );
// GTAO modulates only the ambient (IBL) term, per XeGTAO. Direct sun
// is left alone so contact darkening doesn't fight the primary light's
// shadowing.
// Premultiplied output. For opaque draws (a == 1) this is bit-
// identical to the `vec4(rgb, a)` form. For transparent draws
// the renderer's premultiplied-alpha blend (ONE, ONE_MINUS_SRC_ALPHA)
// consumes (rgb * a, a) directly.
out_color = vec4( ( direct + ambient * ao ) * v_base_color.a, v_base_color.a );
}
#pragma sokol @end
#pragma sokol @program cube vs fs

View file

@ -0,0 +1,202 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Edge overlay shader.
//
// Renders per-shape edges (face boundaries for hulls, dedup'd triangle edges
// for meshes, grid + diagonals for heightfields) as shader-expanded screen-
// space quads. Edge endpoint positions live in a per-geometry storage buffer
// (GetEdgeStorageView), per-instance transforms come from the existing
// geom instance buffer (GetMeshInstanceView / GetTransparentMeshInstanceView). Six
// vertices per edge, batched as `2 * 6 * edgeCount` vertices x instanceCount
// in one sg_draw, no VBO/IBO bound, gl_VertexIndex selects edge + corner.
//
// Vertex index -> corner layout (matches overlays/line.glsl):
//
// 0 -> endpoint=A, side=-1 3 -> endpoint=A, side=-1
// 1 -> endpoint=B, side=-1 4 -> endpoint=B, side=+1
// 2 -> endpoint=B, side=+1 5 -> endpoint=A, side=+1
//
// Z-fight prevention: reverse-Z clip-space nudge in the VS,
// `clip.z += zBias * clip.w`. Positive bias = toward camera (z=1 is near in
// reverse-Z). 5e-5 is enough at typical scene scales without visible offset
// at glancing angles.
//
// Per-fragment color picks between convex/concave/flat uniforms from the
// per-endpoint flag (0 concave, 1 convex, 2 flat, stored as float to keep
// the std430 endpoint struct a flat vec4, no vec3+uint padding ambiguity).
//
// Pipeline state:
// * depth_compare = GREATER_EQUAL (reverse-Z). With the zBias nudge this
// keeps the edge on top of the shape's own surface, transparent shapes
// drawn after still over-blend the edge correctly.
// * depth_write = off. The edge isn't real surface depth.
// * Premultiplied-alpha blend (SRC_ONE, ONE_MINUS_SRC_ALPHA). FS outputs
// `color * coverage` so coverage drops below 1 at the AA band only.
#pragma sokol @module edge
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
vec4 viewport; // .xy = size px, .zw = 1/size
};
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base; // .x = base index into the geom instance buffer
vec4 edge_params; // .x = thicknessPx, .y = zBias, .zw reserved
};
struct geom_instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color;
vec4 scale;
vec4 material;
};
layout( binding = 0 ) readonly buffer geom_instances
{
geom_instance gi_items[];
};
// Endpoint = vec4 (.xyz = position, .w = flag as float). Two consecutive
// entries per edge. sokol-shdc requires storage buffers to hold a struct
// array, not a primitive array, so the vec4 is wrapped.
struct edge_endpoint
{
vec4 pos_and_flag;
};
layout( binding = 1 ) readonly buffer edge_endpoints
{
edge_endpoint ee_items[];
};
// Long edges get thinned in the middle with perspective math
noperspective out float v_dist_from_axis_px;
// Flat thickness
flat out float v_half_width_px;
flat out float v_flag;
void main()
{
// gl_VertexIndex is non-negative, an unsigned divide produces the same
// result and sidesteps HLSL's signed-divide warning (X3556).
int edge_idx = int( uint( gl_VertexIndex ) / 6u );
int corner = gl_VertexIndex - edge_idx * 6;
bool is_b = ( corner == 1 ) || ( corner == 2 ) || ( corner == 4 );
float side = ( ( corner == 2 ) || ( corner == 4 ) || ( corner == 5 ) ) ? 1.0 : -1.0;
geom_instance inst = gi_items[inst_base.x + gl_InstanceIndex];
vec4 ea = ee_items[2 * edge_idx + 0].pos_and_flag;
vec4 eb = ee_items[2 * edge_idx + 1].pos_and_flag;
// Per-instance affine: rotation row dotted with (local_pos, 1). Apply
// per-instance scale first, same convention as geom.glsl.
vec3 a_local = ea.xyz * inst.scale.xyz;
vec3 b_local = eb.xyz * inst.scale.xyz;
vec3 a_world = vec3( dot( inst.xform_row0, vec4( a_local, 1.0 ) ), dot( inst.xform_row1, vec4( a_local, 1.0 ) ),
dot( inst.xform_row2, vec4( a_local, 1.0 ) ) );
vec3 b_world = vec3( dot( inst.xform_row0, vec4( b_local, 1.0 ) ), dot( inst.xform_row1, vec4( b_local, 1.0 ) ),
dot( inst.xform_row2, vec4( b_local, 1.0 ) ) );
vec4 clip_a = view_proj * vec4( a_world, 1.0 );
vec4 clip_b = view_proj * vec4( b_world, 1.0 );
vec4 clip_end = is_b ? clip_b : clip_a;
// Screen-space pixel coords of both endpoints (post-perspective divide,
// NDC [-1,1] -> pixel [0, viewport]).
vec2 ndc_a = clip_a.xy / clip_a.w;
vec2 ndc_b = clip_b.xy / clip_b.w;
vec2 sa = ( ndc_a * 0.5 + 0.5 ) * viewport.xy;
vec2 sb = ( ndc_b * 0.5 + 0.5 ) * viewport.xy;
vec2 dir_px = sb - sa;
float len_px = length( dir_px );
vec2 dir_n = ( len_px > 1e-6 ) ? ( dir_px / len_px ) : vec2( 1.0, 0.0 );
vec2 perp_n = vec2( -dir_n.y, dir_n.x );
// Half-width in pixels, floor at 0.5 so very thin requests don't vanish
// into sub-pixel land (the SDF's AA falloff handles attenuation below).
float half_width_px = max( edge_params.x * 0.5, 0.5 );
// Expand the rasterized quad past the true half-width by an AA pad so
// the FS coverage falloff has geometry to ramp down inside (see
// overlays/line.glsl for the full rationale). The FS smoothstep
// completes at d = half_width + fwidth, and fwidth (an L1 norm) peaks
// at sqrt(2) on a 45 deg line, so the pad must be >= ~1.42 px, 1.5 covers it.
const float AA_PAD_PX = 1.5;
float quad_half_px = half_width_px + AA_PAD_PX;
vec2 offset_px = perp_n * side * quad_half_px;
vec2 offset_ndc = offset_px * ( 2.0 * viewport.zw );
vec4 clip_pos = clip_end;
clip_pos.xy += offset_ndc * clip_end.w;
// Reverse-Z z-bias nudge (toward camera, z=1 = near).
clip_pos.z += edge_params.y * clip_pos.w;
gl_Position = clip_pos;
v_dist_from_axis_px = side * quad_half_px;
v_half_width_px = half_width_px;
v_flag = ea.w; // both endpoints carry the same flag
}
#pragma sokol @end
#pragma sokol @fs fs
layout( binding = 1 ) uniform ub_pass
{
vec4 convex_color; // premultiplied linear RGBA
vec4 concave_color; // premultiplied linear RGBA
vec4 flat_color; // premultiplied linear RGBA
};
noperspective in float v_dist_from_axis_px;
flat in float v_half_width_px;
flat in float v_flag;
out vec4 out_color;
void main()
{
// Coverage from the capsule SDF. d is the fragment's folded
// perpendicular distance from the axis (px), coverage ramps 1->0 over a
// 2*aa band straddling the true edge at d = half_width. Smoothstep
// (cubic, wider than an energy-exact box filter), with fwidth of the
// raw signed v_dist_from_axis_px to avoid the abs-kink, see
// overlays/line.glsl for the full rationale.
float d = abs( v_dist_from_axis_px );
float aa = fwidth( v_dist_from_axis_px );
float coverage = 1.0 - smoothstep( v_half_width_px - aa, v_half_width_px + aa, d );
// Flag is 0 concave, 1 convex, 2 flat (coplanar).
vec4 col;
if ( v_flag > 1.5 )
{
col = flat_color;
}
else if ( v_flag > 0.5 )
{
col = convex_color;
}
else
{
col = concave_color;
}
out_color = col * coverage;
}
#pragma sokol @end
#pragma sokol @program edge_overlay vs fs

View file

@ -0,0 +1,327 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Triangle-geometry shader. Drives every shape with intrinsic topology:
// convex hulls, triangle meshes, and heightfields. One pipeline. The CPU
// builders in src/box3d/box3d_geometry.c emit duplicated-vertex meshes so
// per-face normals are baked into per-vertex data (flat shading).
//
// Per-vertex data: position (vec3), normal (vec3). Per-instance data lives
// in a readonly storage buffer indexed by `inst_base.x + gl_InstanceIndex`.
// `inst_base` is a ub_draw uniform set per draw so a single shared
// instance buffer can hold contiguous slices owned by many geometries.
// (sokol_gfx's sg_draw has no first_instance argument, hence the manual
// base offset.)
//
// Per-instance affine is a 3x4: rotation rows in .xyz of each xform_row*,
// center in .w of each row. Per-instance scale is non-uniform vec3. Mesh
// instances carry b3Mesh's per-instance scale here, hulls and heightfields
// pass (1,1,1) (their hash already includes scale, so the registry entry's
// geometry is pre-scaled). Normals are transformed by R * (n / scale) so
// non-uniform scale doesn't shear the shading.
//
// @module geom prefixes the generated C symbols (geom_instance_t,
// geom_ub_frame_t, geom_triangle_shader_desc, ...) so this header coexists
// with the existing shape-shader headers in renderer.c without typedef
// collisions on the common ub_frame_t / instance_t names.
#pragma sokol @module geom
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base; // .x = base index into the global instance array
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0, .w = center.x
vec4 xform_row1; // .xyz = rotation row 1, .w = center.y
vec4 xform_row2; // .xyz = rotation row 2, .w = center.z
vec4 base_color; // .rgb = linear baseColor, .a = alpha
vec4 scale; // .xyz = per-instance scale, .w = unused
vec4 material; // .x = metallic, .y = roughness,
// .z = materialMode (0=solid, 1=ground grid),
// .w = gridCellSize (world units)
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos;
in vec3 in_normal;
out vec3 v_view_pos; // view-space position, for debug_view_mode=1
// (forwarded as world_pos, see comment in main)
out vec3 v_world_normal; // world-space normal, normalized in FS
flat out vec4 v_base_color;
flat out vec4 v_material;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 scaled_pos = in_pos * inst.scale.xyz;
vec4 local_pos = vec4( scaled_pos, 1.0 );
vec3 world_pos =
vec3( dot( inst.xform_row0, local_pos ), dot( inst.xform_row1, local_pos ), dot( inst.xform_row2, local_pos ) );
// World normal: R * (normal / scale). Inverse-transpose for a diagonal
// scale + rotation matrix simplifies to R applied to (normal / scale).
// Renormalized in the FS, non-uniform scale denormalizes here.
vec3 inv_scaled_n = in_normal / inst.scale.xyz;
vec3 world_normal = vec3( dot( inst.xform_row0.xyz, inv_scaled_n ), dot( inst.xform_row1.xyz, inv_scaled_n ),
dot( inst.xform_row2.xyz, inv_scaled_n ) );
v_world_normal = world_normal;
v_base_color = inst.base_color;
v_material = inst.material;
gl_Position = view_proj * vec4( world_pos, 1.0 );
// View matrix lives only in ub_pass on the FS side. To keep ub_frame
// minimal (matches sphere/capsule), forward world_pos and recompute
// view_pos in the FS from the pass-side view.
v_view_pos = world_pos; // sentinel: FS treats as world if needed
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/pbr.glsl
layout( binding = 1 ) uniform ub_pass
{
vec4 sun_dir_world; // .xyz = world-space dir TO sun (normalized)
vec4 sun_color; // .rgb = color, .a = ambient strength (flat-ambient fallback)
ivec4 flags; // .x = debug_view_mode (0 lit, 1 view-depth, 2 cascade-index)
vec4 camera_pos; // .xyz = camera world pos, .w unused
mat4 view; // for view-space depth debug mode + cascade selection
vec4 cascade_far_view_z; // .xyz = far view-space Z per cascade
mat4 cascade_matrices[3]; // light-space view-proj per cascade
vec4 sh[9]; // IBL diffuse SH coefficients (band 0..2, RGB in .xyz)
vec4 ibl_params; // .x = prefilter cube max_lod, .y = IBL enable (1=IBL, 0=flat ambient), .zw reserved
};
#pragma sokol @image_sample_type tex_shadow depth
layout( binding = 1 ) uniform texture2DArray tex_shadow;
#pragma sokol @sampler_type smp_shadow comparison
layout( binding = 0 ) uniform samplerShadow smp_shadow;
// IBL bindings, same convention as cube.glsl: texture bindings 2/3,
// sampler bindings 1/2, disjoint from the shadow path's 1/0.
#pragma sokol @image_sample_type tex_ibl_spec float
layout( binding = 2 ) uniform textureCube tex_ibl_spec;
#pragma sokol @sampler_type smp_ibl_spec filtering
layout( binding = 1 ) uniform sampler smp_ibl_spec;
#pragma sokol @image_sample_type tex_brdf_lut float
layout( binding = 3 ) uniform texture2D tex_brdf_lut;
#pragma sokol @sampler_type smp_brdf_lut filtering
layout( binding = 2 ) uniform sampler smp_brdf_lut;
// GTAO, same convention as cube.glsl. Multiplies only the IBL ambient.
#pragma sokol @image_sample_type tex_ao float
layout( binding = 4 ) uniform texture2D tex_ao;
#pragma sokol @sampler_type smp_ao filtering
layout( binding = 3 ) uniform sampler smp_ao;
// 3x3 PCF over a 1-texel radius. Manually unrolled, see cube.glsl for
// the X3570 rationale.
float sampleShadowPCF( int cascade, vec3 light_uv, float bias )
{
float t = 1.0 / 2048.0;
float ly = float( cascade );
float rz = light_uv.z - bias;
vec2 c = light_uv.xy;
float s = 0.0;
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y + t, ly, rz ) );
return s / 9.0;
}
float sampleCascade( int cascade, vec3 world_pos, vec3 world_normal )
{
vec4 light_clip = cascade_matrices[cascade] * vec4( world_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
// Backend-dependent Y orientation, see cube.glsl for the longer note.
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
if ( any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) ) )
{
return 1.0;
}
float n_dot_l = max( dot( world_normal, normalize( sun_dir_world.xyz ) ), 0.0 );
float bias = mix( 0.0040, 0.0008, n_dot_l );
float pcf = sampleShadowPCF( cascade, light_uv, bias );
// See cube.glsl for the longer note. Cascade 2 has no fallback at its
// UV boundary, so fade PCF toward 1.0 over the outer 10% to hide the
// polygonal seam where cascade 2's spatial extent ends on the ground.
if ( cascade == 2 )
{
vec2 edge = min( light_uv.xy, 1.0 - light_uv.xy );
float fade = clamp( min( edge.x, edge.y ) * 10.0, 0.0, 1.0 );
pcf = mix( 1.0, pcf, fade );
}
return pcf;
}
float sampleShadowCascaded( vec3 world_pos, vec3 world_normal, float view_z )
{
int cascade = 2;
if ( view_z < cascade_far_view_z.x )
cascade = 0;
else if ( view_z < cascade_far_view_z.y )
cascade = 1;
float shadow = sampleCascade( cascade, world_pos, world_normal );
// Blend the last 10% of each cascade's range with the next cascade
// to hide the polygonal step where they meet. See cube.glsl for the
// longer note.
if ( cascade < 2 )
{
float far_z = ( cascade == 0 ) ? cascade_far_view_z.x : cascade_far_view_z.y;
float near_z = ( cascade == 0 ) ? 0.0 : cascade_far_view_z.x;
float blend_start = mix( far_z, near_z, 0.1 );
if ( view_z > blend_start )
{
float alpha = ( view_z - blend_start ) / ( far_z - blend_start );
shadow = mix( shadow, sampleCascade( cascade + 1, world_pos, world_normal ), alpha );
}
}
return shadow;
}
in vec3 v_view_pos; // actually world_pos forwarded from VS
in vec3 v_world_normal;
flat in vec4 v_base_color;
flat in vec4 v_material;
out vec4 out_color;
void main()
{
vec3 n_world = normalize( v_world_normal );
// Geom meshes render double sided, a per-instance mirror scale can flip
// winding, so face the shading normal toward the camera.
if ( dot( n_world, camera_pos.xyz - v_view_pos ) < 0.0 )
{
n_world = -n_world;
}
if ( flags.x == 1 )
{
vec3 hit_view = ( view * vec4( v_view_pos, 1.0 ) ).xyz;
float view_depth = -hit_view.z;
float v = clamp( view_depth / 50.0, 0.0, 1.0 );
out_color = vec4( v, v, v, 1.0 );
return;
}
if ( flags.x == 2 )
{
// v_view_pos is actually world_pos forwarded from the VS.
float view_z_dbg = -( view * vec4( v_view_pos, 1.0 ) ).z;
int cascade = 2;
if ( view_z_dbg < cascade_far_view_z.x )
cascade = 0;
else if ( view_z_dbg < cascade_far_view_z.y )
cascade = 1;
vec4 light_clip = cascade_matrices[cascade] * vec4( v_view_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
bool oob = any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) );
vec3 tint = vec3( 1.0 );
if ( !oob )
{
if ( cascade == 0 )
tint = vec3( 1.0, 0.4, 0.4 );
else if ( cascade == 1 )
tint = vec3( 0.4, 1.0, 0.4 );
else
tint = vec3( 0.4, 0.4, 1.0 );
}
out_color = vec4( tint, 1.0 );
return;
}
if ( flags.x == 3 )
{
// View-space normal as RGB, [-1,1] mapped to [0,1].
vec3 n_view = ( view * vec4( n_world, 0.0 ) ).xyz;
out_color = vec4( normalize( n_view ) * 0.5 + 0.5, 1.0 );
return;
}
// GTAO sample.
vec2 ao_uv = gl_FragCoord.xy / vec2( textureSize( sampler2D( tex_ao, smp_ao ), 0 ) );
float ao = textureLod( sampler2D( tex_ao, smp_ao ), ao_uv, 0.0 ).x;
if ( flags.x == 4 )
{
out_color = vec4( vec3( ao ), 1.0 );
return;
}
// v_view_pos here is actually world_pos (see VS comment).
vec3 world_pos = v_view_pos;
// Procedural ground grid: when materialMode selects it, replace the
// solid baseColor with the antialiased grid over world XZ. The branch
// is on a flat per-instance varying. Within any quad of a single draw
// every invocation takes the same path, so the fwidth inside is in
// dynamically uniform control flow (legal for derivatives).
//
// The grid is sampled in world XZ, which only makes sense on horizontal
// surfaces. On side faces of a ground box (or any tilted surface) the
// pattern degenerates to stripes/aliasing, so we fade the grid
// contribution toward zero as the surface tilts away from horizontal.
// pow(n.y, 8) gives a soft falloff while leaving the top face fully
// patterned and the strictly vertical sides flat.
vec3 baseColor = v_base_color.rgb;
if ( v_material.z > 0.5 )
{
vec3 grid_color = proceduralGrid( world_pos.xz, v_base_color.rgb, v_material.w );
float grid_blend = pow( clamp( n_world.y, 0.0, 1.0 ), 8.0 );
baseColor = mix( v_base_color.rgb, grid_color, grid_blend );
}
vec3 L = normalize( sun_dir_world.xyz );
float n_dot_l = max( dot( n_world, L ), 0.0 );
float view_z = -( view * vec4( world_pos, 1.0 ) ).z;
float shadow = sampleShadowCascaded( world_pos, n_world, view_z );
vec3 V = normalize( camera_pos.xyz - world_pos );
vec3 direct = brdf_evaluate( n_world, V, L, sun_color.rgb * shadow, baseColor, v_material.x, v_material.y );
vec3 ambient = pbrEvaluateAmbient( ibl_params.y > 0.5, n_world, V, baseColor, v_material.x, v_material.y, sun_color.a, sh,
tex_ibl_spec, smp_ibl_spec, tex_brdf_lut, smp_brdf_lut, ibl_params.x );
// premultiplied output, see cube.glsl.
out_color = vec4( ( direct + ambient * ao ) * v_base_color.a, v_base_color.a );
}
#pragma sokol @end
#pragma sokol @program triangle vs fs

View file

@ -0,0 +1,86 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Shadow caster for capsules. As with the sphere caster, we substitute
// a low-poly proxy mesh for the analytic impostor. The proxy is a
// 12-slice cylinder with two hemispherical caps. Vertices are authored in
// a "unit-capsule" coordinate frame where each component carries enough
// information to scale independently by halfLength and radius.
//
// Each vertex is encoded as two attributes:
// in_axis, direction along the long axis (vec3). Scaled by halfLength.
// For body verts: (+/-1, 0, 0). For cap verts: same as the
// attached cap (i.e., (+1,0,0) for +X cap, (-1,0,0) for -X).
// in_radial, radial offset (vec3). Scaled by radius. For body verts:
// (0, cos theta, sin theta). For cap verts: an extension of the
// hemisphere parameterization that includes the cap's
// axial bulge, e.g. for +X cap at latitude alpha: in_radial =
// (sin alpha, cos alpha cos beta, cos alpha sin beta).
//
// The world position is then
// world = center + R * (in_axis * halfLength + in_radial * radius)
// where R is the capsule's rotation. Since rotation is orthonormal and
// halfLength/radius are scalars, the encoding scales linearly and
// produces a true capsule for any (halfLength, radius) pair.
//
// `@module shadow_capsule` namespaces the generated symbols.
#pragma sokol @module shadow_capsule
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 light_view_proj;
};
// per-draw offset, see shadow_caster_cube.glsl.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0, .w = center.x
vec4 xform_row1; // .xyz = rotation row 1, .w = center.y
vec4 xform_row2; // .xyz = rotation row 2, .w = center.z
vec4 base_color; // unused in caster, present so layout matches lit pipeline
vec4 params; // .x = halfLength, .y = radius
vec4 material; // unused in caster, present so layout matches lit pipeline
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_axis; // axis-direction component, scaled by halfLength
in vec3 in_radial; // radial component, scaled by radius
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 center = vec3( inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w );
float halfLength = inst.params.x;
float radius = inst.params.y;
vec3 local_pos = in_axis * halfLength + in_radial * radius;
vec3 world_pos = center + vec3( dot( inst.xform_row0.xyz, local_pos ), dot( inst.xform_row1.xyz, local_pos ),
dot( inst.xform_row2.xyz, local_pos ) );
gl_Position = light_view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
void main()
{
}
#pragma sokol @end
#pragma sokol @program caster vs fs

View file

@ -0,0 +1,78 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Shadow caster for cubes. Depth-only, no fragment output, the
// pipeline runs with color_count=0 and writes only into the cascade's
// depth attachment.
//
// Shares the cube instance buffer layout with cube.glsl: each instance is
// a 3x4 row-major affine plus PBR material data (base_color + material are
// unused here but kept in the layout so one storage buffer feeds both
// pipelines without any repacking, struct stride MUST match the lit
// pipeline's, otherwise indexing breaks).
//
// Shadow space is standard Z (0 near = closer to light, 1 far). The light
// matrix uploaded as ub_frame.light_view_proj is constructed with
// an orthographic projection and mat4LookAt on the C side, which already
// produces the correct convention. No reverse-Z swap.
//
// `@module shadow_cube` keeps the generated symbols (shadow_cube_*) out
// collision with the lit cube pipeline's symbols.
#pragma sokol @module shadow_cube
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 light_view_proj;
};
// per-draw offset. Opaque draws set inst_base.x = 0, transparent
// draws (per the SHADOW_FULL flag) pick one instance at a time from the
// transparent arena.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct cube_instance
{
vec4 xform_row0;
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color; // unused in caster, present so layout matches lit pipeline
vec4 material; // unused in caster, present so layout matches lit pipeline
};
layout( binding = 0 ) readonly buffer cube_instances
{
cube_instance instances[];
};
in vec3 in_pos;
void main()
{
cube_instance inst = instances[inst_base.x + gl_InstanceIndex];
vec4 local_pos = vec4( in_pos, 1.0 );
vec3 world_pos =
vec3( dot( inst.xform_row0, local_pos ), dot( inst.xform_row1, local_pos ), dot( inst.xform_row2, local_pos ) );
gl_Position = light_view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
// Empty FS: pipeline is created with color_count = 0. The rasterizer
// generates depth values from gl_Position, nothing else gets written.
void main()
{
}
#pragma sokol @end
#pragma sokol @program caster vs fs

View file

@ -0,0 +1,79 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Shadow caster for triangle geometries (hulls, meshes, heightfields).
// Depth-only: color_count=0, empty fragment shader, writes only the
// cascade's depth attachment.
//
// Mirrors geom.glsl exactly in instance/vertex layout so the same
// per-frame instance buffer + per-entry vbo/ibo bindings drive both
// pipelines. The lit pipeline samples the surface normal for shading,
// here it's accepted as a vertex attribute and ignored. Keeping the
// vertex layout identical means the renderer doesn't have to maintain
// two parallel buffer schemes.
//
// `@module shadow_geom` keeps the generated symbols out of collision
// with the lit geom pipeline's symbols.
#pragma sokol @module shadow_geom
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 light_view_proj;
};
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base; // .x = first-instance offset into the global geom instance buffer
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0, .w = center.x
vec4 xform_row1;
vec4 xform_row2;
vec4 base_color; // unused here, layout matches lit pipeline
vec4 scale; // .xyz = per-instance scale (mesh only), hulls/heightfields = 1
vec4 material; // unused here, layout matches lit pipeline
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
// Position-only input. The shared vertex buffer carries position+normal
// (stride 24 bytes), but this caster doesn't read the normal. We just
// don't declare an `in_normal` attribute so glslang doesn't keep it
// around (and the GL driver doesn't warn about an unused attribute slot
// after stripping). The C-side pipeline desc skips the in_normal binding
// to match.
in vec3 in_pos;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 scaled_pos = in_pos * inst.scale.xyz;
vec4 local_pos = vec4( scaled_pos, 1.0 );
vec3 world_pos =
vec3( dot( inst.xform_row0, local_pos ), dot( inst.xform_row1, local_pos ), dot( inst.xform_row2, local_pos ) );
gl_Position = light_view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
void main()
{
}
#pragma sokol @end
#pragma sokol @program caster vs fs

View file

@ -0,0 +1,71 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Shadow caster for spheres. The lit sphere pipeline ray-casts an
// analytic sphere from a bounding-cube proxy, but we can't afford to
// write gl_FragDepth in a depth-only shadow pass (early-Z killed, high
// shadow-map resolution makes the cost prohibitive). Instead the shadow
// pipeline rasterizes a low-poly icosphere proxy (subdiv-1, 42 verts, 80
// tris) generated at InitRenderer and stored in dedicated icosphere vbuf/ibuf.
//
// Per-vertex: in_pos is a unit-sphere position (length == 1). Per-instance
// reads from the same sphere instance buffer the lit pipeline uses, the
// rotation rows are ignored (a sphere is rotation-invariant) and only
// the center (xform_row*.w) and radius (params.x) participate.
//
// `@module shadow_sphere` namespaces the generated symbols.
#pragma sokol @module shadow_sphere
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 light_view_proj;
};
// per-draw offset, see shadow_caster_cube.glsl.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0 (unused), .w = center.x
vec4 xform_row1; // .xyz = rotation row 1 (unused), .w = center.y
vec4 xform_row2; // .xyz = rotation row 2 (unused), .w = center.z
vec4 base_color; // unused in caster, present so layout matches lit pipeline
vec4 params; // .x = radius
vec4 material; // unused in caster, present so layout matches lit pipeline
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-icosphere vertex (length == 1)
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
vec3 center = vec3( inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w );
float radius = inst.params.x;
vec3 world_pos = center + radius * in_pos;
gl_Position = light_view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
void main()
{
}
#pragma sokol @end
#pragma sokol @program caster vs fs

View file

@ -0,0 +1,416 @@
// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
// Sphere impostor.
//
// Per-instance: a 3x4 rigid affine (orthonormal rotation rows in .xyz of each
// xform_row*, sphere center in .w of each row), an RGBA color, and a `params`
// row whose .x is the world-space radius. Rotation does not change the
// silhouette (a sphere is rotation-invariant) so the bounding-cube proxy is
// emitted axis-aligned. Rotation feeds the surface pattern in the FS so spin
// is visible.
//
// Pipeline overview:
// VS: emit a unit-cube vertex scaled by 2*radius and translated by center.
// Pass world position of the proxy vertex (interpolated) plus flat
// per-instance data (center, radius, rotation rows, color) to FS.
// FS: reconstruct view ray as (camera, normalize(v_world_pos_proxy - camera)).
// Analytic ray-sphere intersection. discard on miss / behind-camera.
// Compute world-space normal at the hit, transform to object space via
// transpose(rotation), shade three great-circle rings at the
// object-space x=0, y=0, z=0 equators (constant screen-space pixel
// thickness via fwidth) over a north/south hemisphere base contrast,
// apply Lambert + ambient against world-space sun, write reverse-Z
// gl_FragDepth.
//
// `@module sphere` prefixes the generated C symbols (sphere_ub_frame_t,
// sphere_instance_t, sphere_shader_desc, ...) so this header coexists with
// cube.glsl.h in renderer.c without typedef collisions on ub_frame_t.
//
// UBO layout. UBOs are per-stage in sokol-shdc:
// VS binding=0 ub_frame: just view_proj. That's all the VS needs to emit
// the proxy in clip space.
// FS binding=1 ub_pass: sun + debug flags + camera_pos + view_proj + view.
// The frame-level matrices live here (rather than in
// a second FS UBO at a different binding) because
// the renderer always re-applies ub_pass per draw,
// and one FS UBO is simpler than two. Naming is a
// slight stretch (some fields are per-frame, not
// per-pass) but correctness-wise irrelevant in a
// single-pass renderer.
//
// gl_FragDepth disables hi-Z. That's accepted for impostors.
#pragma sokol @module sphere
#pragma sokol @ctype mat4 Mat4
#pragma sokol @ctype vec4 Vec4
#pragma sokol @ctype vec3 b3Vec3
#pragma sokol @ctype vec2 b3Vec2
#pragma sokol @vs vs
layout( binding = 0 ) uniform ub_frame
{
mat4 view_proj;
};
// per-draw offset into the instance buffer. See cube.glsl for the
// rationale. Opaque draws set inst_base.x = 0 + bulk-instance, transparent
// draws pick one instance at a time.
layout( binding = 2 ) uniform ub_draw
{
ivec4 inst_base;
};
struct instance
{
vec4 xform_row0; // .xyz = rotation row 0, .w = center.x
vec4 xform_row1; // .xyz = rotation row 1, .w = center.y
vec4 xform_row2; // .xyz = rotation row 2, .w = center.z
vec4 base_color; // .rgb = linear baseColor, .a = alpha
vec4 params; // .x = radius, .yzw = unused
vec4 material; // .x = metallic, .y = roughness,
// .z = shadow-cast bit (, CPU-only, ignored here),
// .w = reserved
};
layout( binding = 0 ) readonly buffer instances
{
instance items[];
};
in vec3 in_pos; // unit-cube corner, half-extent 0.5
// Interpolated: any point along the camera-to-pixel ray works as a far
// reference, we re-normalize in FS. Per-pixel (not per-sample): the FS
// computes analytical sub-pixel coverage from the signed silhouette
// distance and feeds it through alpha-to-coverage, which replaces the
// per-sample ray test the `sample` qualifier used to do.
out vec3 v_world_pos_proxy;
// Flat: same value for every fragment in this instance.
flat out vec3 v_center;
flat out float v_radius;
flat out vec3 v_rot_row0;
flat out vec3 v_rot_row1;
flat out vec3 v_rot_row2;
flat out vec4 v_base_color;
flat out vec4 v_material;
void main()
{
instance inst = items[inst_base.x + gl_InstanceIndex];
// sphere center in world space
vec3 center = vec3( inst.xform_row0.w, inst.xform_row1.w, inst.xform_row2.w );
float radius = inst.params.x;
// Local in_pos has half-extent 0.5, multiply by 2*radius to get a cube
// half-extent radius exactly enclosing the sphere.
// This creates an AABB in world space
vec3 world_pos = center + ( 2.0 * radius ) * in_pos;
v_world_pos_proxy = world_pos;
v_center = center;
v_radius = radius;
v_rot_row0 = inst.xform_row0.xyz;
v_rot_row1 = inst.xform_row1.xyz;
v_rot_row2 = inst.xform_row2.xyz;
v_base_color = inst.base_color;
v_material = inst.material;
gl_Position = view_proj * vec4( world_pos, 1.0 );
}
#pragma sokol @end
#pragma sokol @fs fs
#pragma sokol @include ../common/pbr.glsl
layout( binding = 1 ) uniform ub_pass
{
vec4 sun_dir_world; // .xyz = world-space dir TO sun (normalized)
vec4 sun_color; // .rgb = color, .a = ambient strength (flat-ambient fallback)
ivec4 flags; // .x = debug_view_mode (0 lit, 1 view-depth, 2 cascade-index)
vec4 camera_pos; // .xyz = camera world pos, .w unused
mat4 view_proj; // for reverse-Z gl_FragDepth
mat4 view; // for view-space depth debug mode + cascade selection
vec4 cascade_far_view_z; // .xyz = far view-space Z per cascade
mat4 cascade_matrices[3]; // light-space view-proj per cascade
vec4 sh[9]; // IBL diffuse SH coefficients (band 0..2, RGB in .xyz)
vec4 ibl_params; // .x = prefilter cube max_lod, .y = IBL enable (1=IBL, 0=flat ambient), .zw reserved
};
#pragma sokol @image_sample_type tex_shadow depth
layout( binding = 1 ) uniform texture2DArray tex_shadow;
#pragma sokol @sampler_type smp_shadow comparison
layout( binding = 0 ) uniform samplerShadow smp_shadow;
// IBL bindings, same convention as cube.glsl: texture bindings 2/3,
// sampler bindings 1/2, disjoint from the shadow path's 1/0.
#pragma sokol @image_sample_type tex_ibl_spec float
layout( binding = 2 ) uniform textureCube tex_ibl_spec;
#pragma sokol @sampler_type smp_ibl_spec filtering
layout( binding = 1 ) uniform sampler smp_ibl_spec;
#pragma sokol @image_sample_type tex_brdf_lut float
layout( binding = 3 ) uniform texture2D tex_brdf_lut;
#pragma sokol @sampler_type smp_brdf_lut filtering
layout( binding = 2 ) uniform sampler smp_brdf_lut;
// GTAO, same convention as cube.glsl. Multiplies only the IBL ambient.
#pragma sokol @image_sample_type tex_ao float
layout( binding = 4 ) uniform texture2D tex_ao;
#pragma sokol @sampler_type smp_ao filtering
layout( binding = 3 ) uniform sampler smp_ao;
// 3x3 PCF over a 1-texel radius. Manually unrolled, see cube.glsl for
// the X3570 rationale.
float sampleShadowPCF( int cascade, vec3 light_uv, float bias )
{
float t = 1.0 / 2048.0;
float ly = float( cascade );
float rz = light_uv.z - bias;
vec2 c = light_uv.xy;
float s = 0.0;
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y - t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x - t, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x, c.y + t, ly, rz ) );
s += texture( sampler2DArrayShadow( tex_shadow, smp_shadow ), vec4( c.x + t, c.y + t, ly, rz ) );
return s / 9.0;
}
float sampleCascade( int cascade, vec3 world_pos, vec3 world_normal )
{
vec4 light_clip = cascade_matrices[cascade] * vec4( world_pos, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
// Backend-dependent Y orientation, see cube.glsl for the longer note.
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
if ( any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) ) )
{
return 1.0;
}
float n_dot_l = max( dot( world_normal, normalize( sun_dir_world.xyz ) ), 0.0 );
float bias = mix( 0.0040, 0.0008, n_dot_l );
float pcf = sampleShadowPCF( cascade, light_uv, bias );
// See cube.glsl for the longer note. Cascade 2 has no fallback at its
// UV boundary, so fade PCF toward 1.0 over the outer 10% to hide the
// polygonal seam where cascade 2's spatial extent ends on the ground.
if ( cascade == 2 )
{
vec2 edge = min( light_uv.xy, 1.0 - light_uv.xy );
float fade = clamp( min( edge.x, edge.y ) * 10.0, 0.0, 1.0 );
pcf = mix( 1.0, pcf, fade );
}
return pcf;
}
float sampleShadowCascaded( vec3 world_pos, vec3 world_normal, float view_z )
{
int cascade = 2;
if ( view_z < cascade_far_view_z.x )
cascade = 0;
else if ( view_z < cascade_far_view_z.y )
cascade = 1;
float shadow = sampleCascade( cascade, world_pos, world_normal );
// Blend the last 10% of each cascade's range with the next cascade
// to hide the polygonal step where they meet. See cube.glsl for the
// longer note.
if ( cascade < 2 )
{
float far_z = ( cascade == 0 ) ? cascade_far_view_z.x : cascade_far_view_z.y;
float near_z = ( cascade == 0 ) ? 0.0 : cascade_far_view_z.x;
float blend_start = mix( far_z, near_z, 0.1 );
if ( view_z > blend_start )
{
float alpha = ( view_z - blend_start ) / ( far_z - blend_start );
shadow = mix( shadow, sampleCascade( cascade + 1, world_pos, world_normal ), alpha );
}
}
return shadow;
}
in vec3 v_world_pos_proxy;
// sphere center in world space
flat in vec3 v_center;
flat in float v_radius;
flat in vec3 v_rot_row0;
flat in vec3 v_rot_row1;
flat in vec3 v_rot_row2;
flat in vec4 v_base_color;
flat in vec4 v_material;
out vec4 out_color;
void main()
{
// Ray construction (world space)
// ray origin
vec3 ro = camera_pos.xyz;
// ray direction
vec3 rd = normalize( v_world_pos_proxy - ro );
// Ray-sphere intersection
// |ro + t*rd - c|^2 = r^2 => t^2 + 2*b*t + c2 = 0
vec3 oc = ro - v_center;
float b = dot( oc, rd );
float c2 = dot( oc, oc ) - v_radius * v_radius;
float h = b * b - c2;
// Analytical silhouette AA. `d` is the signed perpendicular distance from
// the ray-line to the sphere surface (in world units): negative when the
// ray hits, positive when it misses by `d`. fwidth(d) gives world-units
// per pixel near the silhouette, which becomes the AA half-width. See
// https://iquilezles.org/articles/spherefunctions . Computed in uniform
// control flow before any discard so derivatives are defined.
float d = sqrt( max( 0.0, v_radius * v_radius - h ) ) - v_radius;
float aa = max( fwidth( d ), 1e-6 );
float coverage = 1.0 - smoothstep( -aa, aa, d );
// For hits use the near intersection. For near-misses (h<0) the ray
// doesn't actually touch the sphere, use the closest-approach distance
// -b instead, and shade from the closest-approach point. The resulting
// normal (direction from center to closest-approach) is the silhouette
// normal, which is what these sub-pixel fragments should display anyway.
float t = ( h >= 0.0 ) ? ( -b - sqrt( h ) ) : -b;
if ( coverage <= 0.0 || t < 0.0 )
{
// True miss outside the AA band, or sphere behind camera, or camera
// inside the sphere.
discard;
}
vec3 hit_world = ro + t * rd;
vec3 n_world = normalize( hit_world - v_center );
// Object-space normal via R^T
// n_obj = R^T * n_world. R^T's rows are the columns of R. The .x
// components of v_rot_row0/1/2 form row 0 of R^T, .y components form row
// 1, .z components form row 2.
vec3 n_obj = vec3( v_rot_row0.x * n_world.x + v_rot_row1.x * n_world.y + v_rot_row2.x * n_world.z,
v_rot_row0.y * n_world.x + v_rot_row1.y * n_world.y + v_rot_row2.y * n_world.z,
v_rot_row0.z * n_world.x + v_rot_row1.z * n_world.y + v_rot_row2.z * n_world.z );
// Surface pattern
// Hemisphere split: north 1.0, south 0.65, base shading contrast.
float hemi = ( n_obj.y > 0.0 ) ? 1.0 : 0.65;
// Three great-circle rings at the equators of object-space X, Y, Z.
// Each equator is the locus where the corresponding object-space normal
// component is zero, so the distance-to-equator is just the absolute
// value of that component (a chord-distance metric in [0, 1] that's
// monotonic in the geodesic distance from the great circle).
//
// Constant screen-space thickness via per-component fwidth: each ring's
// band scales with the per-pixel rate of change of *its own* normal
// component, so it stays ~LINE_PIXELS wide independent of camera zoom
// and viewing angle. fwidth is taken on the *signed* component (not on
// abs(.)): abs has a derivative kink at zero (the equator itself),
// so fwidth(abs(x)) gives garbage on 2x2 quads that straddle the
// equator. Don't use max of all three fwidths as the shared band:
// near the silhouette of one ring, the *other* two components change
// huge amounts per pixel (the surface is edge-on), and a shared band
// would over-fatten this ring.
const float LINE_PIXELS = 1.5;
float ring_x = 1.0 - smoothstep( 0.0, fwidth( n_obj.x ) * LINE_PIXELS, abs( n_obj.x ) );
float ring_y = 1.0 - smoothstep( 0.0, fwidth( n_obj.y ) * LINE_PIXELS, abs( n_obj.y ) );
float ring_z = 1.0 - smoothstep( 0.0, fwidth( n_obj.z ) * LINE_PIXELS, abs( n_obj.z ) );
float line = max( ring_x, max( ring_y, ring_z ) );
vec3 base = v_base_color.rgb * hemi;
vec3 line_color = base * 0.35;
vec3 surface = mix( base, line_color, line );
// Reverse-Z depth
vec4 hit_clip = view_proj * vec4( hit_world, 1.0 );
gl_FragDepth = hit_clip.z / hit_clip.w;
// Output
if ( flags.x == 1 )
{
// view-space depth grayscale, matches cube debug mode.
vec3 hit_view = ( view * vec4( hit_world, 1.0 ) ).xyz;
float view_depth = -hit_view.z;
float v = clamp( view_depth / 50.0, 0.0, 1.0 );
out_color = vec4( v, v, v, 1.0 );
return;
}
if ( flags.x == 2 )
{
float view_z_dbg = -( view * vec4( hit_world, 1.0 ) ).z;
int cascade = 2;
if ( view_z_dbg < cascade_far_view_z.x )
cascade = 0;
else if ( view_z_dbg < cascade_far_view_z.y )
cascade = 1;
vec4 light_clip = cascade_matrices[cascade] * vec4( hit_world, 1.0 );
vec3 light_ndc = light_clip.xyz / light_clip.w;
float ny = light_ndc.y * cascade_far_view_z.w;
vec3 light_uv = vec3( light_ndc.x * 0.5 + 0.5, ny * 0.5 + 0.5, light_ndc.z );
bool oob = any( lessThan( light_uv, vec3( 0.0 ) ) ) || any( greaterThan( light_uv, vec3( 1.0 ) ) );
vec3 tint = vec3( 1.0 );
if ( !oob )
{
if ( cascade == 0 )
tint = vec3( 1.0, 0.4, 0.4 );
else if ( cascade == 1 )
tint = vec3( 0.4, 1.0, 0.4 );
else
tint = vec3( 0.4, 0.4, 1.0 );
}
out_color = vec4( tint, 1.0 );
return;
}
if ( flags.x == 3 )
{
// View-space normal as RGB, [-1,1] mapped to [0,1].
vec3 n_view = ( view * vec4( n_world, 0.0 ) ).xyz;
out_color = vec4( normalize( n_view ) * 0.5 + 0.5, 1.0 );
return;
}
// GTAO sample.
vec2 ao_uv = gl_FragCoord.xy / vec2( textureSize( sampler2D( tex_ao, smp_ao ), 0 ) );
float ao = textureLod( sampler2D( tex_ao, smp_ao ), ao_uv, 0.0 ).x;
if ( flags.x == 4 )
{
out_color = vec4( vec3( ao ), 1.0 );
return;
}
vec3 L = normalize( sun_dir_world.xyz );
float n_dot_l = max( dot( n_world, L ), 0.0 );
float view_z = -( view * vec4( hit_world, 1.0 ) ).z;
float shadow = sampleShadowCascaded( hit_world, n_world, view_z );
vec3 V = normalize( camera_pos.xyz - hit_world );
vec3 direct = brdf_evaluate( n_world, V, L, sun_color.rgb * shadow, surface, v_material.x, v_material.y );
vec3 ambient = pbrEvaluateAmbient( ibl_params.y > 0.5, n_world, V, surface, v_material.x, v_material.y, sun_color.a, sh,
tex_ibl_spec, smp_ibl_spec, tex_brdf_lut, smp_brdf_lut, ibl_params.x );
// premultiplied output, see cube.glsl. Alpha is scaled by analytical
// silhouette coverage so alpha-to-coverage (opaque pipeline) or the
// premultiplied alpha blend (transparent pipeline) produces a smooth
// sub-pixel silhouette instead of a binary hit/miss edge.
float a = v_base_color.a * coverage;
out_color = vec4( ( direct + ambient * ao ) * a, a );
}
#pragma sokol @end
#pragma sokol @program impostor vs fs