diff --git a/apps/playable/src/lib.rs b/apps/playable/src/lib.rs index 7a228544..3e467b0c 100644 --- a/apps/playable/src/lib.rs +++ b/apps/playable/src/lib.rs @@ -60,7 +60,7 @@ enum Sounds { /// What a page carries beside the game and the host, as the lint found the game needs it #[derive(Clone, Copy, PartialEq, Debug)] struct Carry { - /// three.js, for a game with a 3D kind (PA15) + /// a 3D drawer (Bevy's programs, its scene read by three.js), for a game with a 3D kind (PA11, PA15) with_3d: bool, sounds: Sounds, /// Bevy's world as wasm, for a game that makes a raea/ecs World (PA12) @@ -68,15 +68,15 @@ struct Carry { } /// The bundle's entry: Bevy's world first for a game on raea/ecs (PA12: a World made as the game's module loads is -/// already Bevy's), the game, then the host started with three.js as its 3D drawer only for a game with 3D (PA15: a -/// 2D game's page carries no renderer) and a sound player only for a game with sound, Tone.js in it only for a +/// already Bevy's), the game, then the host started with Bevy's PBR programs as its 3D drawer (PA11) only for a game +/// with 3D (PA15: a 2D game's page carries no renderer) and a sound player only for a game with sound, Tone.js in it only for a /// raea/tone graph (PA6) fn entry(game: &Path, host: &Path, carry: Carry) -> String { let Carry { with_3d, sounds, ecs } = carry; let first = if ecs { format!("import {:?};\n", spec(&host.join("ecs.ts"))) } else { String::new() }; let mut e = format!("{first}import {:?};\nimport {{ start }} from {:?};\n", spec(game), spec(&host.join("main.tsx"))); if with_3d { - e.push_str(&format!("import {{ three3d }} from {:?};\n", spec(&host.join("three.ts")))); + e.push_str(&format!("import {{ bevy3d }} from {:?};\n", spec(&host.join("bevy.ts")))); } if sounds != Sounds::None { e.push_str(&format!("import {{ sound }} from {:?};\n", spec(&host.join("sound.ts")))); @@ -84,9 +84,9 @@ fn entry(game: &Path, host: &Path, carry: Carry) -> String { if sounds == Sounds::Tone { e.push_str(&format!("import {{ tone }} from {:?};\n", spec(&host.join("tone.ts")))); } - let d3 = if with_3d { "three3d" } else { "undefined" }; + let d3 = if with_3d { "bevy3d" } else { "undefined" }; e.push_str(&match sounds { - Sounds::None if with_3d => "start(three3d);\n".into(), + Sounds::None if with_3d => "start(bevy3d);\n".into(), Sounds::None => "start();\n".into(), Sounds::Media => format!("start({d3}, sound());\n"), Sounds::Tone => format!("start({d3}, sound(tone));\n"), @@ -217,7 +217,7 @@ mod tests { #[test] fn a_3d_game_starts_with_three() { let e = e(true, Sounds::None, false); - assert!(e.contains("three3d } from \"/h/host/three.ts\"") && e.contains("start(three3d);"), "{e}"); + assert!(e.contains("bevy3d } from \"/h/host/bevy.ts\"") && e.contains("start(bevy3d);"), "{e}"); } #[test] @@ -225,7 +225,7 @@ mod tests { let media = e(false, Sounds::Media, false); assert!(media.contains("start(undefined, sound());") && !media.contains("tone"), "{media}"); let tone = e(true, Sounds::Tone, false); - assert!(tone.contains("tone } from \"/h/host/tone.ts\"") && tone.contains("start(three3d, sound(tone));"), "{tone}"); + assert!(tone.contains("tone } from \"/h/host/tone.ts\"") && tone.contains("start(bevy3d, sound(tone));"), "{tone}"); } #[test] @@ -242,4 +242,13 @@ mod tests { let built = std::fs::read_to_string(root.join("sdk/playable/src/host/ecs.wasm.from")).unwrap_or_default(); assert_eq!(built.trim(), now, "runtime/ecs changed since ecs.wasm was built: bash sdk/playable/ecs/build.sh"); } + + #[test] + fn the_carried_bevy_programs_are_made_from_bevys_shaders_as_they_are() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); + let out = std::process::Command::new("bash").arg(root.join("sdk/playable/bevy/from.sh")).output().expect("bash"); + let now = String::from_utf8_lossy(&out.stdout).trim().to_string(); + let built = std::fs::read_to_string(root.join("sdk/playable/src/host/bevy/programs.from")).unwrap_or_default(); + assert_eq!(built.trim(), now, "Bevy's shaders or tools/bevy-glsl changed since programs.ts was made: bash sdk/playable/bevy/build.sh"); + } } diff --git a/docs/manual/reference/cli/playable.md b/docs/manual/reference/cli/playable.md index 111b1a91..4ef557fa 100644 --- a/docs/manual/reference/cli/playable.md +++ b/docs/manual/reference/cli/playable.md @@ -20,8 +20,9 @@ import the file instead), URLs and network calls, modules that need the native e kinds the playable's renderer doesn't draw. It notes a game with only one orientation, and one that never imports `raea/playable` (``, ``, `install()`) to open the store itself. -The 3D is drawn by three.js on raea's scene contract, with Bevy's light units and tone mapping. It comes from the -project (`raea add three@0.185.0`). +The 3D is drawn by Bevy's own PBR shaders, translated to WebGL2 when raea is built, with Bevy's light units, +shadows, fog and TonyMcMapface tone mapping. three.js reads the page's 3D parts into a scene for them, so it comes from +the project (`raea add three@0.185.0`). A game with no 3D ships without either. diff --git a/docs/playables.feature b/docs/playables.feature index c953cdb4..991e61cf 100644 --- a/docs/playables.feature +++ b/docs/playables.feature @@ -185,7 +185,7 @@ Feature: raea games as playable ads, exported for every ad network from the TSX curves on the converted units scored Reinhard 14.5, Neutral 21.2, AgX 23.3, none 30.4, ACES 37.9; what is left is the shading itself (the bricks' side faces a touch darker), PA11's job - @needs:PA9 + @done @needs:PA9 Scenario: PA11. Bevy's own shading in the light renderer Then Bevy's PBR shaders, composed for the pipelines a playable uses, are translated to GLSL ES 3.00 with naga at export time, and the light renderer draws with them instead of three.js's own materials @@ -204,6 +204,35 @@ Feature: raea games as playable ads, exported for every ad network from the TSX View (784 B), Lights (2,176 B), the cluster offsets, index lists and clustered lights (16 KB each, so the host clusters lights on the CPU as Bevy does on WebGL2), the StandardMaterial (192 B), the Mesh batch and Globals. That packing, and the shadow passes, are PA11's real work; the shaders themselves come over unchanged + # Status 12-03: built. tools/bevy-glsl composes the three programs with Bevy's own ShaderCache (raea's vendored + # bevy_pbr, bevy_render and bevy_core_pipeline 0.20.0, WebGL2's defs, 10 directional lights, Gaussian shadow + # filtering, MSAA, distance fog, the projection's kind read from the view) and naga 30 translates them; + # sdk/playable/bevy/build.sh writes them into host/bevy/programs.ts (105 KB, 21 KB gzipped) with each block's field offsets and which of Bevy's bindings each + # block and sampler is, and apps/playable's test fails when Bevy's shaders or the translator change and it isn't + # rebuilt. host/bevy.ts replaces three.js's renderer (three.ts and tonemap.ts are gone): it reads raea's three.js + # scene graph (scene.ts) for the parts, geometry and transforms, and fills Bevy's blocks as Bevy's render world + # does (bevy/fill.ts: prepare_view_uniforms, prepare_lights, MeshUniform::new, StandardMaterial's uniform; the + # lights back in Bevy's units through units.ts): reverse Z, one 1x1x1 light cluster packed as Bevy packs it for + # WebGL2, one directional shadow cascade (as Bevy on WebGL2 has) fitted to what the camera sees of the scene, + # point and spot lights, distance fog (Bevy's GpuFog from the scene's Fog: linear from near to far, or + # exponential for a density, as the native engine makes it), a forward pass into half float with 4x MSAA, then + # TonyMcMapface through Bevy's table. A Plane3d is drawn as its one face (Bevy's PlaneMeshBuilder), not as the + # flat Box three.js was given, whose top face three points down. Not drawn yet, each warned once in the + # console: an environment's light, a camera's own (Bevy's DistanceFog component), normal maps, transmission, vertex colours, point and + # spot shadows, rect lights, a shadow catcher, a paint look + # Measured on brick-rush against `raea render --frame` (mean difference over the drawn pixels / 255, both pages + # against the same native frames; landscape frame 300 rendered with --despite type-over-part): portrait frame 90 + # three.js 6.1 -> Bevy 4.3 (PA10 recorded 5.4), landscape frame 300 9.8 -> 7.7, what is left in landscape mostly + # the page's pulsing hint text. star-catch portrait frame 150: 17.0 -> 15.6 over the frame, 6.7 -> 5.0 over the + # 3D above the hint text. A scene of a floor, six boxes, a ball, a sun with shadows, a point light and a spot + # light (frame 10): perspective portrait 1.3, orthographic landscape 0.8, with linear fog 0.7, with exponential + # fog 0.7. The page: brick-rush 1,889 -> 1,794 KB (three's renderer out, the programs in). + # First frame in a fresh WebKit (served from localhost, to the GPU finishing it, 25 interleaved runs): three.js + # median 131 ms, mean 129.8; Bevy median 131 ms, mean 131.8. The GL work is about 5 ms on both pages; the rest + # is script and the page. Chrome's 4x CPU throttle isn't used (raea doesn't test in Chrome); with every WebKit + # process clamped to the efficiency cores at background priority (taskpolicy -b), 142 and 145 ms over 11 runs. + # brick-rush and star-catch play to their end cards and store taps in WebKit (tools/check.ts) in portrait and + # landscape, with instant and 150 ms taps @done Scenario: PA12. Bevy systems in a playable @@ -245,9 +274,9 @@ Feature: raea games as playable ads, exported for every ad network from the TSX Scenario: PA15. A 2D playable carries no three.js Given 11-28's tiles bundle: three.js 924 KB of 1,393 KB, react-dom 178 KB, for a game that draws no 3D Then the export builds the host without the three.js scene when the lint finds no 3D kind (about 470 KB a page) - # Status 12-03: built. The host asks for its 3D through one interface (host/draw3d.ts); three.ts draws it with - # three.js, and the export's entry passes it to start() only when the lint found a 3D kind, so a 2D game's - # bundle never imports three.js. Measured (preview page, before -> after, the after with PA8's ~95 KB of Inter): + # Status 12-03: built. The host asks for its 3D through one interface (host/draw3d.ts); a drawer (three.ts then, + # Bevy's programs in bevy.ts since PA11) draws it, and the export's entry passes it to start() only when the lint + # found a 3D kind, so a 2D game's bundle never imports three.js. Measured (preview page, before -> after, the after with PA8's ~95 KB of Inter): # tiles 1,345 -> 378 KB, gates 1,347 -> 380 KB, three 2D brand playables 2,752 -> 1,782, 3,409 -> 2,440 and # 2,693 -> 1,724 KB; brick-rush (3D, keeps three.js) 1,384 -> 1,478 KB. Each of the six played to its end card # and its store tap in WebKit (tools/check.ts), with instant taps (TAP_MS=0) and 150 ms taps. diff --git a/sdk/guides/craft/motion/playable.md b/sdk/guides/craft/motion/playable.md index 263fca2d..34bfe862 100644 --- a/sdk/guides/craft/motion/playable.md +++ b/sdk/guides/craft/motion/playable.md @@ -57,6 +57,12 @@ import { EndCard, InstallButton, install } from "raea/playable"; standard, physical and basic materials, perspective and orthographic cameras, the five light kinds, fog, tone mapping, shadows and anti-aliasing. Models, splats and water stay in the video ad. +The host draws that 3D with Bevy's own PBR shaders, so a frame of the playable matches `raea render --frame` closely. +It has the sun's shadow, point and spot lights, fog from `` and Bevy's tone mapping. Some things are left out, +and the page's console names each one once: normal maps, transmission, vertex colours, point and spot shadows, rect +lights, an environment's light, a camera's own `` child, a shadow catcher and a paint look. Check how the 3D looks +in the `preview` page, not only in the video ad. + ## Rules on raea/ecs A game whose rules are systems on a raea/ecs `World` keeps Bevy's world in the playable: the export sees a World made @@ -95,14 +101,14 @@ carried for you, as the video ad draws them. Any other family named but not impo ## Export and check ```sh -raea add three@0.185.0 # once per project: the playable's 3D renderer +raea add three@0.185.0 # once per project with 3D: it reads the scene for the playable raea add tone@15.1.22 # once per project, if it uses raea/tone raea render game.tsx -o out/video-ad.mp4 # the video ad raea playable game.tsx -o out/playable --ios https://apps.apple.com/app/id123 --android https://play.google.com/store/apps/details?id=com.example ``` -It prints each network's file and its size against the 5 MB cap. A 2D game's page is about 400 KB; three.js adds about -1 MB for 3D and Tone.js about 360 KB for raea/tone, and the rest is the game's own pictures and sounds. `--networks applovin,google,preview` makes fewer, `--title` and `--cta` set the host's own card, and +It prints each network's file and its size against the 5 MB cap. A 2D game's page is about 400 KB; 3D adds about +1 MB (three.js's scene graph and Bevy's shaders) and Tone.js about 360 KB for raea/tone, and the rest is the game's own pictures and sounds. `--networks applovin,google,preview` makes fewer, `--title` and `--cta` set the host's own card, and `--orientation` sets what Google and TikTok are told. Play the `preview` page yourself before handing it over: open it at a phone's size, drag, lose, and tap the card. In diff --git a/sdk/playable/NOTICE b/sdk/playable/NOTICE index 51223e07..6507a158 100644 --- a/sdk/playable/NOTICE +++ b/sdk/playable/NOTICE @@ -9,5 +9,15 @@ src/host/tony.bin is the tone-mapping table Tony McMapface, resampled by tools/t https://github.com/bevyengine/bevy Licensed under MIT OR Apache-2.0. -host/tonemap.ts samples it as Bevy's tonemapping shader does. The rest of raea/playable is raea's own, under the -repository's licence. +host/bevy.ts samples it as Bevy's tonemapping shader does. + +src/host/bevy/programs.ts holds Bevy's PBR shaders (bevy_pbr's mesh, pbr and prepass programs, with bevy_render's +and bevy_core_pipeline's shader imports), composed by Bevy's shader cache and translated to GLSL ES by naga +(tools/bevy-glsl). + + Bevy + By the Bevy contributors + https://github.com/bevyengine/bevy + Licensed under MIT OR Apache-2.0. + +The rest of raea/playable is raea's own, under the repository's licence. diff --git a/sdk/playable/bevy/build.sh b/sdk/playable/bevy/build.sh new file mode 100644 index 00000000..14029295 --- /dev/null +++ b/sdk/playable/bevy/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Bevy's PBR programs for a playable (docs/playables.feature PA11): tools/bevy-glsl composes Bevy's mesh, pbr and +# prepass shaders with WebGL2's defs and translates them to GLSL ES 3.00, into sdk/playable/src/host/bevy/programs.ts, +# with the hash of what they were made from beside it (programs.from). apps/playable's test fails when Bevy's shaders +# or the translator change and this isn't run. +# usage: bash sdk/playable/bevy/build.sh [TARGET_DIR] +set -euo pipefail +root=$(cd "$(dirname "$0")/../../.." && pwd) +target=${1:-$root/target/bevy-glsl} +out=$root/sdk/playable/src/host/bevy +work=$(mktemp -d) +trap 'rm -r "$work"' EXIT +cargo run -q --release --manifest-path "$root/tools/bevy-glsl/Cargo.toml" --target-dir "$target" -- "$root" "$work" +cp "$work/programs.ts" "$out/programs.ts" +bash "$root/sdk/playable/bevy/from.sh" > "$out/programs.from" +echo "programs.ts: $(wc -c < "$out/programs.ts" | tr -d ' ') bytes, $(gzip -9c "$out/programs.ts" | wc -c | tr -d ' ') gzipped" diff --git a/sdk/playable/bevy/from.sh b/sdk/playable/bevy/from.sh new file mode 100644 index 00000000..29cb094c --- /dev/null +++ b/sdk/playable/bevy/from.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# what programs.ts is made from (build.sh): the translator, raea's vendored bevy_pbr shaders, and the Bevy and naga it +# composes them with (Cargo.lock's lines) +set -euo pipefail +root=$(cd "$(dirname "$0")/../../.." && pwd) +{ + cat "$root"/tools/bevy-glsl/Cargo.toml "$root"/tools/bevy-glsl/src/*.rs + find "$root/vendor/bevy_pbr/src" \( -name '*.wesl' -o -name '*.wgsl' \) | LC_ALL=C sort | xargs cat + grep -A1 -E '^name = "(bevy_render|bevy_core_pipeline|bevy_shader)"$' "$root/Cargo.lock" +} | shasum -a 256 | cut -c1-64 diff --git a/sdk/playable/src/host/bevy.ts b/sdk/playable/src/host/bevy.ts new file mode 100644 index 00000000..31c6335d --- /dev/null +++ b/sdk/playable/src/host/bevy.ts @@ -0,0 +1,415 @@ +// A playable's 3D drawn by Bevy's own PBR programs (docs/playables.feature PA11): Bevy's mesh, pbr and prepass shaders +// as Bevy composes them for a WebGL2 device, translated to GLSL ES by naga (tools/bevy-glsl, bevy/programs.ts), fed the +// uniform blocks Bevy's render world fills (bevy/fill.ts). The page's parts are read by raea's three.js host into a +// scene graph (scene.ts), which this reads back without three's renderer: each mesh's geometry and world transform, +// each material's values, each light in Bevy's units. As Bevy on WebGL2 draws: one directional shadow cascade, a +// forward pass into half float with 4x MSAA and reverse Z, the point and spot lights in one cluster, distance fog; then +// Bevy's TonyMcMapface through its own table, as the native engine's frame pass does. The export bundles it only for a +// game whose lint found a 3D kind (PA15). +import * as THREE from "three"; +import type { Draw3d } from "./draw3d"; +import { Scene3d } from "./scene"; +import tony from "./tony.bin"; +import { Block } from "./bevy/block"; +import { Meshes, POINTS, Program, Textures, UNITS, programs } from "./bevy/gl"; +import { PBR_FRAG, PBR_VERT, SHADOW_VERT } from "./bevy/programs"; +import { ambientOf, cascade, fillFog, fillLights, fillMaterial, fillMesh, fillView, toLight, type Cascade, type Lights, type Surface } from "./bevy/fill"; + +const BATCH = 93; // PER_OBJECT_BUFFER_BATCH_SIZE: the meshes one uniform block holds +const N = Math.round(Math.cbrt(tony.length / 3)); + +const EMPTY_FS = "#version 300 es\nprecision highp float;\nvoid main() {}\n"; +const TONE_VS = `#version 300 es +out vec2 uv; +void main() { vec2 p = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2); uv = p; gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0); }`; +// the HDR target is drawn upside down (naga's coordinate flip): its first row is the picture's top +const TONE_FS = `#version 300 es +precision highp float; +precision highp sampler3D; +uniform sampler2D scene; +uniform sampler3D lut; +uniform float exposure; +in vec2 uv; +out vec4 color; +void main() { + vec4 c = texture(scene, vec2(uv.x, 1.0 - uv.y)); + vec3 x = max(c.rgb / max(c.a, 1e-5), vec3(0.0)) * exposure; + vec3 t = (x / (x + 1.0)) * (${N - 1}.0 / ${N}.0) + 0.5 / ${N}.0; + color = vec4(texture(lut, clamp(t, 0.0, 1.0)).rgb * c.a, c.a); +}`; + +/** One draw: a mesh (or one of an instanced mesh's copies), its geometry's range and its material's slot */ +type Draw = { + geometry: THREE.BufferGeometry; + world: THREE.Matrix4; + material: number; + surface: Surface; + start: number; + count: number; + casts: boolean; + receives: boolean; + depth: number; +}; + +const ALIGN = (n: number, a: number) => Math.ceil(n / a) * a; + +export function bevy3d(canvas: HTMLCanvasElement): Draw3d { + const gl = canvas.getContext("webgl2", { alpha: true, premultipliedAlpha: true, antialias: false, depth: false, stencil: false, powerPreference: "high-performance" }); + if (!gl) throw new Error("raea playable: this browser has no WebGL2"); + const hdr = !!gl.getExtension("EXT_color_buffer_float") || !!gl.getExtension("EXT_color_buffer_half_float"); + const warned = new Set(); + const warn = (why: string) => { + if (warned.has(why)) return; + warned.add(why); + console.warn(`raea playable: ${why}`); + }; + if (!hdr) warn("this browser can't draw into half float: the 3D's highlights clip before the tone curve"); + + // linked while the page's first frame is built; bound at the first draw + const [pbr, shadowProgram, tone] = programs(gl, [[PBR_VERT, PBR_FRAG], [SHADOW_VERT, EMPTY_FS], [TONE_VS, TONE_FS]]) as [Program, Program, Program]; + let exposureAt: WebGLUniformLocation | null = null; + + const align = gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT) as number; + const blocks = { + view: new Block("view"), + lightView: new Block("view"), + lights: new Block("lights"), + clustered: new Block("clustered_lights"), + offsets: new Block("cluster_offsets_and_counts"), + lists: new Block("clusterable_object_index_lists"), + globals: new Block("globals"), + fog: new Block("fog"), + metadata: new Block("metadata"), + mesh: new Block("mesh", 1, ALIGN(new Block("mesh").size, align)), + material: new Block("material", 1, ALIGN(new Block("material").size, align)), + }; + const buffers = new Map(); + const upload = (block: Block) => { + let k = buffers.get(block); + if (!k) buffers.set(block, (k = { b: gl.createBuffer()!, bytes: 0 })); + gl.bindBuffer(gl.UNIFORM_BUFFER, k.b); + if (k.bytes !== block.bytes.byteLength) { + gl.bufferData(gl.UNIFORM_BUFFER, block.bytes, gl.DYNAMIC_DRAW); + k.bytes = block.bytes.byteLength; + } else gl.bufferSubData(gl.UNIFORM_BUFFER, 0, block.bytes); + return k.b; + }; + const bind = (name: string, block: Block, copy = 0) => { + const k = buffers.get(block)!; + gl.bindBufferRange(gl.UNIFORM_BUFFER, POINTS[name], k.b, copy * block.stride, block.size); + }; + + const textures = new Textures(gl); + const meshes = new Meshes(gl); + + // Bevy's table for TonyMcMapface (tools/tony.ts), sRGB bytes already + const lut = gl.createTexture()!; + gl.bindTexture(gl.TEXTURE_3D, lut); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); + gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGB8, N, N, N, 0, gl.RGB, gl.UNSIGNED_BYTE, tony); + for (const [k, v] of [[gl.TEXTURE_MIN_FILTER, gl.LINEAR], [gl.TEXTURE_MAG_FILTER, gl.LINEAR], [gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE], [gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE], [gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE]]) gl.texParameteri(gl.TEXTURE_3D, k, v); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4); + + // a depth texture sampled with comparison, as Bevy's shadow samplers are (reverse Z: greater-or-equal is lit) + const depthTexture = (target: number, size: number) => { + const t = gl.createTexture()!; + gl.bindTexture(target, t); + if (target === gl.TEXTURE_CUBE_MAP) for (let f = 0; f < 6; f++) gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, gl.DEPTH_COMPONENT32F, size, size, 0, gl.DEPTH_COMPONENT, gl.FLOAT, null); + else gl.texImage2D(target, 0, gl.DEPTH_COMPONENT32F, size, size, 0, gl.DEPTH_COMPONENT, gl.FLOAT, null); + gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE); + gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, gl.GEQUAL); + gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + return t; + }; + // point lights' shadows aren't drawn: their cube is one texel, never sampled + const pointShadows = depthTexture(gl.TEXTURE_CUBE_MAP, 1); + let shadowSize = 0; + let shadowMap: WebGLTexture | null = null; + const shadowFbo = gl.createFramebuffer()!; + const shadowTarget = (size: number) => { + if (size === shadowSize && shadowMap) return; + if (shadowMap) gl.deleteTexture(shadowMap); + shadowSize = size; + shadowMap = depthTexture(gl.TEXTURE_2D, size); + gl.bindFramebuffer(gl.FRAMEBUFFER, shadowFbo); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, shadowMap, 0); + gl.drawBuffers([gl.NONE]); + gl.readBuffer(gl.NONE); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + }; + shadowTarget(2048); + + // the forward pass's targets: multisampled colour and depth, resolved into a texture the tone pass reads + const samples = Math.min(4, gl.getParameter(gl.MAX_SAMPLES) as number); + const msaaFbo = gl.createFramebuffer()!; + const resolveFbo = gl.createFramebuffer()!; + let color: WebGLRenderbuffer | null = null; + let depth: WebGLRenderbuffer | null = null; + let resolved: WebGLTexture | null = null; + let width = 1; + let height = 1; + const targets = () => { + if (color) gl.deleteRenderbuffer(color); + if (depth) gl.deleteRenderbuffer(depth); + if (resolved) gl.deleteTexture(resolved); + const format = hdr ? gl.RGBA16F : gl.RGBA8; + color = gl.createRenderbuffer()!; + gl.bindRenderbuffer(gl.RENDERBUFFER, color); + gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, format, width, height); + depth = gl.createRenderbuffer()!; + gl.bindRenderbuffer(gl.RENDERBUFFER, depth); + gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT32F, width, height); + gl.bindFramebuffer(gl.FRAMEBUFFER, msaaFbo); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, color); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depth); + resolved = gl.createTexture()!; + gl.bindTexture(gl.TEXTURE_2D, resolved); + gl.texStorage2D(gl.TEXTURE_2D, 1, format, width, height); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.bindFramebuffer(gl.FRAMEBUFFER, resolveFbo); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, resolved, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + }; + + const scene = new Scene3d(); + let frame = 0; + let seconds = 0; + + /** The scene's meshes and lights, as Bevy's extraction would find them */ + const gather = () => { + const draws: Draw[] = []; + const lights: Lights = { ambient: null, directional: [], points: [], spots: [] }; + const materials = new Map(); + const ids = new WeakMap(); + let nextId = 0; + const order: { m: THREE.Material; tint: THREE.Color | null; surface: Surface }[] = []; + const slotOf = (m: THREE.Material, tint: THREE.Color | null) => { + let id = ids.get(m); + if (id === undefined) ids.set(m, (id = nextId++)); + const key = tint ? `${id}:${tint.getHexString()}` : `${id}`; + let k = materials.get(key); + if (!k) { + k = { slot: order.length, surface: { blend: false, doubleSided: false } }; + materials.set(key, k); + order.push({ m, tint, surface: k.surface }); + } + return k; + }; + const camInv = scene.camera.matrixWorldInverse; + const p = new THREE.Vector3(); + const add = (mesh: THREE.Mesh, world: THREE.Matrix4, tint: THREE.Color | null) => { + const g = mesh.geometry; + const mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material]; + const groups = Array.isArray(mesh.material) && g.groups.length ? g.groups : [{ start: 0, count: Infinity, materialIndex: 0 }]; + for (const gr of groups) { + const m = mats[gr.materialIndex ?? 0]; + if (!m || !m.visible) continue; + if (m instanceof THREE.ShadowMaterial) { + warn("a shadow catcher isn't drawn in a playable yet"); + continue; + } + const k = slotOf(m, tint); + p.setFromMatrixPosition(world).applyMatrix4(camInv); + draws.push({ geometry: g, world, material: k.slot, surface: k.surface, start: gr.start, count: gr.count, casts: mesh.castShadow, receives: mesh.receiveShadow, depth: p.z }); + } + }; + scene.scene.updateMatrixWorld(); + scene.scene.traverseVisible((o) => { + if (o instanceof THREE.InstancedMesh) { + const one = new THREE.Matrix4(); + for (let i = 0; i < o.count; i++) { + o.getMatrixAt(i, one); + const tint = o.instanceColor ? new THREE.Color().fromArray(o.instanceColor.array, i * 3) : null; + add(o, o.matrixWorld.clone().multiply(one), tint); + } + } else if (o instanceof THREE.Mesh) add(o, o.matrixWorld, null); + else if (o instanceof THREE.AmbientLight || o instanceof THREE.HemisphereLight) lights.ambient = ambientOf(o, lights.ambient); + else if (o instanceof THREE.DirectionalLight) lights.directional.push(o); + else if (o instanceof THREE.SpotLight) { + lights.spots.push(o); + if (o.castShadow) warn("a spot light's shadow isn't drawn in a playable yet"); + } else if (o instanceof THREE.PointLight) { + lights.points.push(o); + if (o.castShadow) warn("a point light's shadow isn't drawn in a playable yet"); + } else if (o instanceof THREE.RectAreaLight) warn("a rect light isn't drawn in a playable yet"); + else if (o instanceof THREE.Points || o instanceof THREE.Line || o instanceof THREE.Sprite) warn(`a ${o.type} isn't drawn in a playable yet`); + }); + if (scene.scene.userData.raeaEnvironment) warn("an environment's light isn't drawn in a playable yet"); + if (scene.effects.some((e) => e.kind === "Look")) warn("a paint look isn't drawn in a playable yet"); + blocks.material.resize(order.length); + order.forEach(({ m, tint, surface }, slot) => Object.assign(surface, fillMaterial(blocks.material, slot, m, tint, warn))); + return { draws, lights, materials: order.length }; + }; + + const drawAll = (list: Draw[], program: Program, main: boolean) => { + let batch = -1; + let cull: boolean | null = null; + for (let i = 0; i < list.length; i++) { + const d = list[i]; + const m = meshes.get(d.geometry); + if (!m) continue; + const at = (d as Draw & { at: number }).at; + const b = Math.floor(at / BATCH); + if (b !== batch) { + bind("mesh", blocks.mesh, b); + batch = b; + } + gl.uniform1ui(program.first, at % BATCH); + const two = d.surface.doubleSided; + if (cull !== !two) { + if (two) gl.disable(gl.CULL_FACE); + else gl.enable(gl.CULL_FACE); + cull = !two; + } + if (main) { + bind("material", blocks.material, d.material); + const s = d.surface; + const tex = (unit: number, t: THREE.Texture | null | undefined) => { + gl.activeTexture(gl.TEXTURE0 + unit); + gl.bindTexture(gl.TEXTURE_2D, textures.get(t) ?? textures.white); + }; + tex(UNITS.base_color_texture, s.map); + tex(UNITS.emissive_texture, s.emissiveMap); + tex(UNITS.metallic_roughness_texture, s.mrMap); + tex(UNITS.occlusion_texture, s.aoMap); + } + gl.bindVertexArray(m.vao); + const start = d.start; + const count = Math.min(d.count, m.count - start); + if (m.index) gl.drawElements(gl.TRIANGLES, count, m.index, start * (m.index === gl.UNSIGNED_INT ? 4 : 2)); + else gl.drawArrays(gl.TRIANGLES, start, count); + } + gl.bindVertexArray(null); + }; + + return { + fit(w, h, scale) { + // the canvas is drawn at the screen's pixels, not the composition's + const ratio = Math.min(2, devicePixelRatio || 1) * scale; + const cw = Math.max(1, Math.floor(w * ratio)); + const ch = Math.max(1, Math.floor(h * ratio)); + if (cw !== width || ch !== height || !color) { + width = canvas.width = cw; + height = canvas.height = ch; + targets(); + } + scene.fit(w, h); + }, + sync(page, s) { + seconds = s; + scene.sync(page, s); + return scene.any; + }, + draw() { + frame++; + const { draws, lights } = gather(); + draws.forEach((d, i) => ((d as Draw & { at: number }).at = i)); + blocks.mesh.resize(Math.ceil(draws.length / BATCH)); + draws.forEach((d, i) => fillMesh(blocks.mesh, Math.floor(i / BATCH), i % BATCH, d.world, d.receives)); + + // the shadow: the first directional light that casts one, its cascade over what casts and catches + const sun = scene.settings.shadows ? lights.directional.find((l) => l.castShadow) : undefined; + let shadow: { light: THREE.DirectionalLight; cascade: Cascade } | null = null; + if (sun) { + shadowTarget(Math.min(scene.settings.shadowMap || 2048, gl.getParameter(gl.MAX_TEXTURE_SIZE) as number)); + const bounds = new THREE.Box3(); + const box = new THREE.Box3(); + for (const d of draws) { + if (!d.geometry.boundingBox) d.geometry.computeBoundingBox(); + bounds.union(box.copy(d.geometry.boundingBox!).applyMatrix4(d.world)); + } + const c = cascade(toLight(sun), bounds, scene.camera, shadowSize); + if (c) shadow = { light: sun, cascade: c }; + } + + for (const b of [blocks.view, blocks.lightView, blocks.lights, blocks.clustered, blocks.offsets, blocks.lists, blocks.globals, blocks.fog]) b.resize(1); + fillFog(blocks.fog, scene.scene.fog as THREE.Fog | THREE.FogExp2 | null); + fillView(blocks.view, scene.camera, width, height, frame); + fillLights(blocks.lights, blocks.clustered, blocks.offsets, blocks.lists, lights, shadow, width, height); + blocks.globals.f("time", seconds); + blocks.globals.u("frame_count", frame); + for (const b of Object.values(blocks)) upload(b); + for (const [name, b] of [["lights", blocks.lights], ["clustered_lights", blocks.clustered], ["cluster_offsets_and_counts", blocks.offsets], ["clusterable_object_index_lists", blocks.lists], ["globals", blocks.globals], ["metadata", blocks.metadata], ["fog", blocks.fog]] as [string, Block][]) bind(name, b); + + // Bevy's clip space flipped in y by naga: front faces wind clockwise in GL's + gl.frontFace(gl.CW); + gl.cullFace(gl.BACK); + gl.enable(gl.DEPTH_TEST); + gl.depthFunc(gl.GEQUAL); + gl.clearDepth(0); + + // the shadow pass, from the light, as Bevy's prepass draws it + if (shadow) { + fillView(blocks.lightView, scene.camera, shadowSize, shadowSize, frame, undefined); + blocks.lightView.f("clip_from_world", shadow.cascade.clipFromWorld.elements); + upload(blocks.lightView); + bind("view", blocks.lightView); + // not sampled while it's drawn into + gl.activeTexture(gl.TEXTURE0 + UNITS.directional_shadow_textures); + gl.bindTexture(gl.TEXTURE_2D, null); + gl.bindFramebuffer(gl.FRAMEBUFFER, shadowFbo); + gl.viewport(0, 0, shadowSize, shadowSize); + gl.depthMask(true); + gl.disable(gl.BLEND); + gl.clear(gl.DEPTH_BUFFER_BIT); + shadowProgram.use(); + drawAll(draws.filter((d) => d.casts && !d.surface.blend), shadowProgram, false); + } + + // the forward pass: opaque, then blended back to front without writing depth + bind("view", blocks.view); + gl.bindFramebuffer(gl.FRAMEBUFFER, msaaFbo); + gl.viewport(0, 0, width, height); + gl.clearColor(0, 0, 0, 0); + gl.depthMask(true); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + pbr.use(); + gl.activeTexture(gl.TEXTURE0 + UNITS.directional_shadow_textures); + gl.bindTexture(gl.TEXTURE_2D, shadowMap); + gl.activeTexture(gl.TEXTURE0 + UNITS.point_shadow_textures); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, pointShadows); + gl.activeTexture(gl.TEXTURE0 + UNITS.raea_gi); + gl.bindTexture(gl.TEXTURE_2D, textures.none); + gl.disable(gl.BLEND); + drawAll(draws.filter((d) => !d.surface.blend), pbr, true); + const blended = draws.filter((d) => d.surface.blend).sort((a, b) => a.depth - b.depth); + if (blended.length) { + gl.enable(gl.BLEND); + // BlendState::ALPHA_BLENDING + gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.depthMask(false); + drawAll(blended, pbr, true); + gl.depthMask(true); + gl.disable(gl.BLEND); + } + + // resolved, then tone-mapped onto the canvas + gl.bindFramebuffer(gl.READ_FRAMEBUFFER, msaaFbo); + gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, resolveFbo); + gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, gl.COLOR_BUFFER_BIT, gl.NEAREST); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.viewport(0, 0, width, height); + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + if (!exposureAt) { + tone.use(); + gl.uniform1i(gl.getUniformLocation(tone.p, "scene"), 0); + gl.uniform1i(gl.getUniformLocation(tone.p, "lut"), 1); + exposureAt = gl.getUniformLocation(tone.p, "exposure"); + } + tone.use(); + gl.uniform1f(exposureAt, scene.settings.exposure * scene.settings.grade); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, resolved); + gl.activeTexture(gl.TEXTURE1); + gl.bindTexture(gl.TEXTURE_3D, lut); + gl.drawArrays(gl.TRIANGLES, 0, 3); + textures.done(); + meshes.done(); + }, + }; +} diff --git a/sdk/playable/src/host/bevy/block.ts b/sdk/playable/src/host/bevy/block.ts new file mode 100644 index 00000000..f24ff480 --- /dev/null +++ b/sdk/playable/src/host/bevy/block.ts @@ -0,0 +1,82 @@ +// One of Bevy's uniform blocks as bytes (docs/playables.feature PA11): its fields written by their names in Bevy's +// shader structs, at the offsets naga laid them out (programs.ts LAYOUT), so the host fills a block as Bevy's render +// world fills its buffer. A path names nested fields with dots; each array on the way takes the next index. +import { LAYOUT } from "./programs"; + +type Plan = { at: number; strides: number[] }; + +export class Block { + readonly size: number; + bytes: ArrayBuffer; + f32: Float32Array; + u32: Uint32Array; + i32: Int32Array; + private readonly layout: Record; + private readonly plans = new Map(); + + /** `name` is the binding's name in Bevy's files (view, lights, mesh, material ...); `count` copies of it, each + * `stride` bytes apart (a buffer of many materials, or of batches of meshes) */ + constructor(readonly name: string, count = 1, readonly stride = 0) { + const layout = LAYOUT[name]; + if (!layout) throw new Error(`raea playable: Bevy's programs have no ${name} block`); + this.layout = layout; + this.size = layout.$size; + this.bytes = new ArrayBuffer(0); + this.f32 = new Float32Array(0); + this.u32 = new Uint32Array(0); + this.i32 = new Int32Array(0); + this.resize(count); + } + + /** Room for `count` copies, cleared */ + resize(count: number) { + const bytes = Math.max(1, count) * Math.max(this.stride, this.size); + if (bytes !== this.bytes.byteLength) { + this.bytes = new ArrayBuffer(bytes); + this.f32 = new Float32Array(this.bytes); + this.u32 = new Uint32Array(this.bytes); + this.i32 = new Int32Array(this.bytes); + } else new Uint8Array(this.bytes).fill(0); + } + + private plan(path: string): Plan { + let p = this.plans.get(path); + if (p) return p; + p = { at: 0, strides: [] }; + const top = this.layout["[]"]; + if (top !== undefined) p.strides.push(top); + let pre = ""; + for (const seg of path.split(".")) { + pre = pre ? `${pre}.${seg}` : seg; + const at = this.layout[pre]; + if (at === undefined) throw new Error(`raea playable: Bevy's ${this.name} has no ${pre}`); + p.at += at; + const s = this.layout[`${pre}[]`]; + if (s !== undefined) p.strides.push(s); + } + this.plans.set(path, p); + return p; + } + + /** A field's byte offset in copy `copy`, each array on its path at the index given in turn */ + at(path: string, copy = 0, ...index: number[]): number { + const p = this.plan(path); + let at = copy * this.stride + p.at; + for (let k = 0; k < p.strides.length; k++) at += (index[k] ?? 0) * p.strides[k]; + return at; + } + + f(path: string, v: number | ArrayLike, copy = 0, ...index: number[]) { + const at = this.at(path, copy, ...index) >> 2; + if (typeof v === "number") this.f32[at] = v; + else this.f32.set(v, at); + } + + u(path: string, v: number, copy = 0, ...index: number[]) { + this.u32[this.at(path, copy, ...index) >> 2] = v >>> 0; + } + + i(path: string, v: number, copy = 0, ...index: number[]) { + this.i32[this.at(path, copy, ...index) >> 2] = v | 0; + } +} diff --git a/sdk/playable/src/host/bevy/fill.ts b/sdk/playable/src/host/bevy/fill.ts new file mode 100644 index 00000000..e1f0637e --- /dev/null +++ b/sdk/playable/src/host/bevy/fill.ts @@ -0,0 +1,319 @@ +// Bevy's uniform blocks filled from the scene (docs/playables.feature PA11), as Bevy's render world fills them: +// bevy_render's prepare_view_uniforms (the view), bevy_pbr's prepare_lights (lights, clustered lights, the light +// cluster's lists), MeshUniform::new (each mesh) and StandardMaterial's as_bind_group_shader_type (each material). +// The scene is raea's three.js scene graph (scene.ts); its lights are back in Bevy's units through units.ts, and its +// colours are linear already (three's working space is linear sRGB, Bevy's LinearRgba). +import * as THREE from "three"; +import { AMBIENT, LUMENS, LUX, toRaea } from "@raea/r3f/units"; +import type { Block } from "./block"; + +/** Bevy's default camera exposure, EV100 9.7 (Exposure::default) */ +export const EXPOSURE = 1 / (1.2 * 2 ** 9.7); + +const MAX_DIRECTIONAL = 10; // the programs' MAX_DIRECTIONAL_LIGHTS +const MAX_CLUSTERED = 204; // the clustered lights' array in a uniform block +const SQRT_2 = Math.SQRT2; + +/** Bevy's matrices for a three.js camera: clip_from_view as Bevy makes it (reverse Z; a perspective one with no far + * plane), from three's projection's own terms so its zoom and view offset carry */ +export function clipFromView(cam: THREE.Camera): THREE.Matrix4 { + const p = cam.projectionMatrix.elements; + const m = new THREE.Matrix4(); + if (cam instanceof THREE.OrthographicCamera) { + const r = 1 / (cam.far - cam.near); + // glam's orthographic_rh(left, right, bottom, top, far, near): Bevy swaps near and far for reverse Z + m.set(p[0], 0, 0, p[12], 0, p[5], 0, p[13], 0, 0, r, cam.far * r, 0, 0, 0, 1); + } else { + const near = (cam as THREE.PerspectiveCamera).near ?? 0.1; + // perspective_infinite_reverse_rh, with three's x and y terms + m.set(p[0], 0, p[8], 0, 0, p[5], p[9], 0, 0, 0, 0, near, 0, 0, -1, 0); + } + return m; +} + +/** The View block for a camera on a viewport of `width` x `height` pixels */ +export function fillView(b: Block, cam: THREE.Camera, width: number, height: number, frame: number, clip?: THREE.Matrix4) { + const clipFromViewM = clip ?? clipFromView(cam); + const worldFromView = cam.matrixWorld.clone(); + const viewFromWorld = worldFromView.clone().invert(); + const viewFromClip = clipFromViewM.clone().invert(); + const clipFromWorld = clipFromViewM.clone().multiply(viewFromWorld); + b.f("clip_from_world", clipFromWorld.elements); + b.f("unjittered_clip_from_world", clipFromWorld.elements); + b.f("world_from_clip", worldFromView.clone().multiply(viewFromClip).elements); + b.f("world_from_view", worldFromView.elements); + b.f("view_from_world", viewFromWorld.elements); + b.f("clip_from_view", clipFromViewM.elements); + b.f("view_from_clip", viewFromClip.elements); + const at = new THREE.Vector3().setFromMatrixPosition(worldFromView); + b.f("world_position", [at.x, at.y, at.z]); + b.f("lod_view_world_position", [at.x, at.y, at.z]); + b.f("exposure", EXPOSURE); + b.f("viewport", [0, 0, width, height]); + b.f("main_pass_viewport", [0, 0, width, height]); + // ColorGrading::default (it acts only where the tone curve is in this pass; the tone curve is the frame pass's) + b.f("color_grading.balance", [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]); + for (const k of ["saturation", "contrast", "gamma", "gain"]) b.f(`color_grading.${k}`, [1, 1, 1]); + b.f("color_grading.midtone_range", [0.2, 0.7]); + b.f("color_grading.post_saturation", 1); + b.u("frame_count", frame); +} + +/** A three.js light's colour in Bevy's LinearRgba */ +const rgb = (c: THREE.Color, k: number) => [c.r * k, c.g * k, c.b * k, 1]; + +/** The scene's lights, found by walking it */ +export type Lights = { + ambient: THREE.Color | null; + directional: THREE.DirectionalLight[]; + points: THREE.PointLight[]; + spots: THREE.SpotLight[]; +}; + +/** The one shadow cascade (WebGL2 has room for one, as Bevy on WebGL2 does) */ +export type Cascade = { clipFromWorld: THREE.Matrix4; texel: number }; + +/** The light's world rotation as Bevy's looking_to gives it: -Z along the light, +Z back toward it */ +function worldFromLight(toLight: THREE.Vector3): THREE.Matrix4 { + const z = toLight.clone().normalize(); + const up = Math.abs(z.y) > 0.9999 ? new THREE.Vector3(0, 0, 1) : new THREE.Vector3(0, 1, 0); + const x = new THREE.Vector3().crossVectors(up, z).normalize(); + const y = new THREE.Vector3().crossVectors(z, x); + return new THREE.Matrix4().makeBasis(x, y, z); +} + +/** Where a directional light shines from: its position less its target's */ +export function toLight(l: THREE.DirectionalLight | THREE.SpotLight): THREE.Vector3 { + const from = new THREE.Vector3().setFromMatrixPosition(l.matrixWorld); + const to = new THREE.Vector3().setFromMatrixPosition(l.target.matrixWorld); + const d = from.sub(to); + return d.lengthSq() > 0 ? d.normalize() : new THREE.Vector3(0, 1, 0); +} + +/** One cascade as bevy_light's calculate_cascade makes it, fitted to what casts and catches shadow: the scene's + * bounds, narrowed (across the light) to what the camera sees of them, as Bevy's cascades cover the view */ +export function cascade(toward: THREE.Vector3, bounds: THREE.Box3, cam: THREE.Camera, size: number): Cascade | null { + if (bounds.isEmpty()) return null; + const wfl = worldFromLight(toward); + const lfw = wfl.clone().transpose(); + const box = new THREE.Box3(); + const p = new THREE.Vector3(); + for (let i = 0; i < 8; i++) { + p.set(i & 1 ? bounds.max.x : bounds.min.x, i & 2 ? bounds.max.y : bounds.min.y, i & 4 ? bounds.max.z : bounds.min.z); + box.expandByPoint(p.applyMatrix4(lfw)); + } + // what the camera sees, as far as the scene reaches from it: its frustum's corners in the light's space + const eye = new THREE.Vector3().setFromMatrixPosition(cam.matrixWorld); + const reach = Math.max(1, Math.sqrt(Math.max(bounds.distanceToPoint(eye) ** 2, ...[0, 1, 2, 3, 4, 5, 6, 7].map((i) => eye.distanceToSquared(new THREE.Vector3(i & 1 ? bounds.max.x : bounds.min.x, i & 2 ? bounds.max.y : bounds.min.y, i & 4 ? bounds.max.z : bounds.min.z)))))); + const seen = new THREE.Box3(); + const lfc = lfw.clone().multiply(cam.matrixWorld); + const inv = cam.projectionMatrixInverse; + for (let i = 0; i < 8; i++) { + // three's NDC corner, at the near plane or at `reach` along the view + p.set(i & 1 ? 1 : -1, i & 2 ? 1 : -1, -1).applyMatrix4(inv); + if (i & 4) { + if (cam instanceof THREE.OrthographicCamera) p.z = -reach; + else p.multiplyScalar(reach / Math.max(1e-6, -p.z)); + } + seen.expandByPoint(p.applyMatrix4(lfc)); + } + const min = new THREE.Vector2(Math.max(box.min.x, seen.min.x), Math.max(box.min.y, seen.min.y)); + const max = new THREE.Vector2(Math.min(box.max.x, seen.max.x), Math.min(box.max.y, seen.max.y)); + if (min.x >= max.x || min.y >= max.y) return null; + const margin = 0.02 * Math.max(max.x - min.x, max.y - min.y) + 0.05; + const diameter = Math.max(max.x - min.x, max.y - min.y) + 2 * margin; + const texel = diameter / size; + const near = new THREE.Vector3( + Math.floor((0.5 * (min.x + max.x)) / texel) * texel, + Math.floor((0.5 * (min.y + max.y)) / texel) * texel, + box.max.z + margin, + ); + const cascadeFromWorld = lfw.clone().setPosition(-near.x, -near.y, -near.z); + const r = 1 / (near.z - (box.min.z - margin)); + const clipFromCascade = new THREE.Matrix4().set(2 / diameter, 0, 0, 0, 0, 2 / diameter, 0, 0, 0, 0, r, 1, 0, 0, 0, 1); + return { clipFromWorld: clipFromCascade.multiply(cascadeFromWorld), texel }; +} + +/** The Lights block, the clustered lights and the one cluster's lists, as prepare_lights fills them for a 1x1x1 + * cluster grid: every point and spot light in the one cluster */ +export function fillLights(lights: Block, clustered: Block, offsets: Block, lists: Block, l: Lights, shadow: { light: THREE.DirectionalLight; cascade: Cascade } | null, width: number, height: number) { + const ambient = l.ambient ?? new THREE.Color(1, 1, 1).multiplyScalar(80); + lights.f("ambient_color", [ambient.r, ambient.g, ambient.b, 1]); + const dirs = l.directional.slice(0, MAX_DIRECTIONAL); + dirs.forEach((d, i) => { + const lux = toRaea("DirectionalLight", d.intensity) * LUX; + lights.f("directional_lights.color", rgb(d.color, lux), 0, i); + const t = toLight(d); + lights.f("directional_lights.direction_to_light", [t.x, t.y, t.z], 0, i); + const casts = shadow?.light === d; + lights.u("directional_lights.flags", casts ? 1 : 0, 0, i); // SHADOW_MAPS_ENABLED + lights.f("directional_lights.shadow_depth_bias", 0.02, 0, i); + lights.f("directional_lights.shadow_normal_bias", 1.8 * SQRT_2, 0, i); + lights.u("directional_lights.num_cascades", casts ? 1 : 0, 0, i); + lights.f("directional_lights.cascades_overlap_proportion", 0.3, 0, i); + lights.u("directional_lights.depth_texture_base_index", 0, 0, i); + lights.u("directional_lights.decal_index", 0xffffffff, 0, i); + lights.f("directional_lights.sun_disk_angular_size", 0.00930842, 0, i); + lights.f("directional_lights.sun_disk_intensity", 1, 0, i); + if (casts && shadow) { + lights.f("directional_lights.cascades.clip_from_world", shadow.cascade.clipFromWorld.elements, 0, i, 0); + lights.f("directional_lights.cascades.texel_size", shadow.cascade.texel, 0, i, 0); + lights.f("directional_lights.cascades.far_bound", 1e9, 0, i, 0); + } + }); + const points = l.points.slice(0, MAX_CLUSTERED); + const spots = l.spots.slice(0, MAX_CLUSTERED - points.length); + const p = new THREE.Vector3(); + const put = (k: number, light: THREE.PointLight | THREE.SpotLight, lumens: number) => { + const range = light.distance > 0 ? light.distance : 1000; + const c = rgb(light.color, lumens / (4 * Math.PI)); + clustered.f("data.color_inverse_square_range", [c[0], c[1], c[2], 1 / (range * range)], 0, k); + p.setFromMatrixPosition(light.matrixWorld); + clustered.f("data.position_radius", [p.x, p.y, p.z, 0], 0, k); + clustered.f("data.shadow_depth_bias", 0.08, 0, k); + clustered.f("data.shadow_normal_bias", 0.6, 0, k); + clustered.f("data.shadow_map_near_z", 0.1, 0, k); + clustered.u("data.decal_index", 0xffffffff, 0, k); + clustered.f("data.range", range, 0, k); + }; + points.forEach((pl, k) => put(k, pl, toRaea("PointLight", pl.intensity) * LUMENS)); + spots.forEach((s, j) => { + const k = points.length + j; + put(k, s, toRaea("SpotLight", s.intensity) * LUMENS); + const dir = toLight(s).negate(); + const outer = s.angle; + const inner = outer * (1 - s.penumbra); + const scale = 1 / Math.max(Math.cos(inner) - Math.cos(outer), 1e-4); + clustered.f("data.light_custom_data", [dir.x, dir.z, scale, -Math.cos(outer) * scale], 0, k); + clustered.u("data.flags", (1 << 5) | (dir.y < 0 ? 1 << 1 : 0), 0, k); // SPOT_LIGHT, SPOT_LIGHT_Y_NEGATIVE + clustered.f("data.spot_light_tan_angle", Math.tan(outer), 0, k); + }); + // the one cluster: its lights from offset 0, its point lights then its spot lights (9 bits a count), and their + // indices four to a u32 (clustered_forward.wesl's WebGL2 unpacking) + offsets.u32[offsets.at("data") >> 2] = (points.length << 9) | spots.length; + for (let k = 0; k < points.length + spots.length; k++) lists.u32[(lists.at("data", 0, k >> 4) >> 2) + ((k >> 2) & 3)] |= k << (8 * (k & 3)); + lights.u("cluster_dimensions", 1); + lights.u32[(lights.at("cluster_dimensions") >> 2) + 1] = 1; + lights.u32[(lights.at("cluster_dimensions") >> 2) + 2] = 1; + lights.u32[(lights.at("cluster_dimensions") >> 2) + 3] = 1; + lights.f("cluster_factors", [1 / width, 1 / height, 0, 0]); + lights.u("n_directional_lights", dirs.length); + lights.i("spot_light_shadowmap_offset", (shadow ? 1 : 0) - points.length); + lights.u("ambient_light_flags", 1); // AFFECTS_LIGHTMAPPED_MESHES + lights.u("n_rect_lights", 0); +} + +/** One mesh's MeshUniform in its batch's slot */ +export function fillMesh(b: Block, copy: number, slot: number, world: THREE.Matrix4, receives: boolean) { + const e = world.elements; + // world_from_local as Affine3::to_transpose: the affine's three rows, its translation in each w + const rows = [e[0], e[4], e[8], e[12], e[1], e[5], e[9], e[13], e[2], e[6], e[10], e[14]]; + b.f("world_from_local", rows, copy, slot); + b.f("previous_world_from_local", rows, copy, slot); + // inverse_transpose_3x3, packed into a mat2x4 and an f32 + const n = new THREE.Matrix3().getNormalMatrix(world).elements; + b.f("local_from_world_transpose_a", [n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]], copy, slot); + b.f("local_from_world_transpose_b", n[8], copy, slot); + // no LOD (u16::MAX), SHADOW_RECEIVER, SIGN_DETERMINANT_MODEL_3X3 + b.u("flags", 0xffff | (receives ? 1 << 29 : 0) | (world.determinant() > 0 ? 1 << 31 : 0), copy, slot); + b.u("current_skin_index", 0xffffffff, copy, slot); + b.u("material_and_lightmap_bind_group_slot", 0xffff << 16, copy, slot); + b.u("morph_descriptor_index", 0xffffffff, copy, slot); +} + +/** What a material draws with: its block's flags say which pictures it samples */ +export type Surface = { + map?: THREE.Texture | null; + emissiveMap?: THREE.Texture | null; + mrMap?: THREE.Texture | null; + aoMap?: THREE.Texture | null; + blend: boolean; + doubleSided: boolean; +}; + +type AnyMaterial = THREE.Material & Partial & { color?: THREE.Color; map?: THREE.Texture | null }; + +/** One material's StandardMaterialUniform, from a three.js material raea's host made (materials.ts), times an + * instance's colour */ +export function fillMaterial(b: Block, copy: number, material: THREE.Material, tint: THREE.Color | null, warn: (why: string) => void): Surface { + const m = material as AnyMaterial; + const c = m.color ?? new THREE.Color(1, 1, 1); + const t = tint ?? { r: 1, g: 1, b: 1 }; + b.f("base_color", [c.r * t.r, c.g * t.g, c.b * t.b, m.opacity], copy); + const unlit = m instanceof THREE.MeshBasicMaterial; + const e = m.emissive; + const k = m.emissiveIntensity ?? 1; + // a StandardMaterial's emissive in nits, its exposure weight 0 (it skips the camera's exposure, as natively) + if (e) b.f("emissive", [e.r * k, e.g * k, e.b * k, 0], copy); + b.f("attenuation_color", [1, 1, 1, 1], copy); + const map = m.map ?? null; + const uv = map ? (map.matrixAutoUpdate && map.updateMatrix(), map.matrix.elements) : [1, 0, 0, 0, 1, 0, 0, 0, 1]; + b.f("uv_transform", [uv[0], uv[1], uv[2], 0, uv[3], uv[4], uv[5], 0, uv[6], uv[7], uv[8], 0], copy); + // Bevy's reflectance 0.5 is three's specularIntensity 1 (materials.ts), tinted by the specular colour + const r = 0.5 * (m.specularIntensity ?? 1); + const st = m.specularColor ?? { r: 1, g: 1, b: 1 }; + b.f("reflectance", [st.r * r, st.g * r, st.b * r], copy); + b.f("perceptual_roughness", m.roughness ?? 0.5, copy); + b.f("metallic", m.metalness ?? 0, copy); + b.f("ior", m.ior ?? 1.5, copy); + b.f("attenuation_distance", Infinity, copy); + b.f("clearcoat", m.clearcoat ?? 0, copy); + b.f("clearcoat_perceptual_roughness", m.clearcoatRoughness ?? 0.5, copy); + b.f("anisotropy_rotation", [1, 0], copy); + b.f("parallax_depth_scale", 0.1, copy); + b.f("max_parallax_layer_count", 16, copy); + b.f("lightmap_exposure", 1, copy); + b.u("max_relief_mapping_search_steps", 5, copy); + b.u("deferred_lighting_pass_id", 1, copy); + if ((m.transmission ?? 0) > 0) warn("transmission isn't drawn in a playable yet"); + if (m.normalMap) warn("a normal map isn't drawn in a playable yet"); + if ((m as { vertexColors?: boolean }).vertexColors) warn("vertex colours aren't drawn in a playable yet"); + const s: Surface = { map, emissiveMap: m.emissiveMap, aoMap: m.aoMap, blend: false, doubleSided: m.side === THREE.DoubleSide }; + if (m.roughnessMap || m.metalnessMap) { + if (!m.roughnessMap || m.roughnessMap === m.metalnessMap) s.mrMap = m.roughnessMap ?? m.metalnessMap; + else warn("separate roughness and metalness maps aren't drawn in a playable yet (one metallic-roughness map is)"); + } + let flags = 1 << 8; // FOG_ENABLED + if (s.map) flags |= 1 << 0; + if (s.emissiveMap) flags |= 1 << 1; + if (s.mrMap) flags |= 1 << 2; + if (s.aoMap) flags |= 1 << 3; + if (s.doubleSided) flags |= 1 << 4; + if (unlit) flags |= 1 << 5; + let cutoff = 0.5; + if (m.alphaTest > 0) { + flags |= 1 << 29; // ALPHA_MODE_MASK + cutoff = m.alphaTest; + } else if (m.transparent && (m.opacity < 1 || !!map)) { + flags |= 2 << 29; // ALPHA_MODE_BLEND + s.blend = true; + } + b.u("flags", flags, copy); + b.f("alpha_cutoff", cutoff, copy); + return s; +} + +/** The ambient light's colour times its brightness in cd/m² (a hemisphere light is drawn as the ambient between its + * two colours) */ +export function ambientOf(l: THREE.AmbientLight | THREE.HemisphereLight, had: THREE.Color | null): THREE.Color { + const nits = toRaea("AmbientLight", l.intensity) * AMBIENT; + const c = l instanceof THREE.HemisphereLight ? l.color.clone().lerp(l.groundColor, 0.5) : l.color.clone(); + return (had ?? new THREE.Color(0, 0, 0)).add(c.multiplyScalar(nits)); +} + +/** Bevy's distance fog (prepare_fog's GpuFog) from the scene's, as the native engine makes it from a Fog part: a + * density makes it exponential, else linear from near to far; none is mode 0, which the shader passes over */ +export function fillFog(b: Block, fog: THREE.Fog | THREE.FogExp2 | null) { + if (!fog) return; + const c = fog.color; + b.f("base_color", [c.r, c.g, c.b, 1]); + b.f("directional_light_color", [0, 0, 0, 0]); + b.f("directional_light_exponent", 8); + if (fog instanceof THREE.FogExp2) { + b.f("be", [fog.density, 0, 0]); + b.u("mode", 2); + } else { + b.f("be", [fog.near, fog.far, 0]); + b.u("mode", 1); + } +} diff --git a/sdk/playable/src/host/bevy/gl.ts b/sdk/playable/src/host/bevy/gl.ts new file mode 100644 index 00000000..e5349566 --- /dev/null +++ b/sdk/playable/src/host/bevy/gl.ts @@ -0,0 +1,214 @@ +// WebGL2 plumbing for Bevy's programs in a playable (docs/playables.feature PA11): programs linked with each uniform +// block on its binding's point and each sampler on its unit, by the names Bevy's files give them (programs.ts), and +// the scene's geometry and pictures as GL buffers and textures, kept while the scene holds them. +import * as THREE from "three"; +import { BLOCKS, SAMPLERS } from "./programs"; + +/** Each of Bevy's uniform bindings on its own binding point */ +export const POINTS: Record = { + view: 0, lights: 1, cluster_offsets_and_counts: 2, clusterable_object_index_lists: 3, clustered_lights: 4, + globals: 5, mesh: 6, material: 7, metadata: 8, fog: 9, +}; + +/** Each of Bevy's textures on its own unit */ +export const UNITS: Record = { + base_color_texture: 0, emissive_texture: 1, metallic_roughness_texture: 2, occlusion_texture: 3, + directional_shadow_textures: 4, point_shadow_textures: 5, raea_gi: 6, +}; + +/** A program linking: compiled and linked as soon as it's asked for, its blocks and samplers bound (which waits for + * the link) only when it's first drawn with, so the driver compiles it while the page's first frame is being built */ +export class Program { + private done = false; + first: WebGLUniformLocation | null = null; + constructor(private gl: WebGL2RenderingContext, readonly p: WebGLProgram, private shaders: WebGLShader[]) {} + + /** Linked and bound; throws when it didn't link */ + use() { + const gl = this.gl; + gl.useProgram(this.p); + if (this.done) return; + this.done = true; + const p = this.p; + if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { + const why = this.shaders.map((s) => gl.getShaderInfoLog(s)).find(Boolean) || gl.getProgramInfoLog(p); + throw new Error(`raea playable: Bevy's programs didn't link: ${why}`); + } + for (const s of this.shaders) gl.deleteShader(s); + const blocks = gl.getProgramParameter(p, gl.ACTIVE_UNIFORM_BLOCKS) as number; + for (let i = 0; i < blocks; i++) { + const name = gl.getActiveUniformBlockName(p, i) ?? ""; + const point = POINTS[BLOCKS[name] ?? ""]; + if (point === undefined) throw new Error(`raea playable: Bevy's uniform block ${name} has no binding`); + gl.uniformBlockBinding(p, i, point); + } + for (const [name, texture] of Object.entries(SAMPLERS)) { + const at = gl.getUniformLocation(p, name); + if (at) gl.uniform1i(at, UNITS[texture]); + } + this.first = gl.getUniformLocation(p, "naga_vs_first_instance"); + } +} + +function shader(gl: WebGL2RenderingContext, type: number, src: string): WebGLShader { + const s = gl.createShader(type)!; + gl.shaderSource(s, src); + gl.compileShader(s); + return s; +} + +/** Programs compiled and linked, without waiting for either */ +export function programs(gl: WebGL2RenderingContext, pairs: [string, string][]): Program[] { + return pairs.map(([vs, fs]) => { + const p = gl.createProgram()!; + const v = shader(gl, gl.VERTEX_SHADER, vs); + const f = shader(gl, gl.FRAGMENT_SHADER, fs); + gl.attachShader(p, v); + gl.attachShader(p, f); + gl.linkProgram(p); + return new Program(gl, p, [v, f]); + }); +} + +/** One picture's texture, made again when three.js marks it changed */ +type Kept = { tex: WebGLTexture; version: number; seen: number }; + +const WRAP: Record = { [THREE.RepeatWrapping]: 0x2901, [THREE.ClampToEdgeWrapping]: 0x812f, [THREE.MirroredRepeatWrapping]: 0x8370 }; + +/** The scene's pictures as textures: a colour picture in sRGB (sampled as linear, as Bevy's Rgba8UnormSrgb is) */ +export class Textures { + private kept = new Map(); + private frame = 0; + /** Bevy's fallback for a texture a material doesn't have: white */ + readonly white: WebGLTexture; + /** raea GI's screen with nothing in it: every pixel's light comes from the ambient light, as natively without GI */ + readonly none: WebGLTexture; + + constructor(private gl: WebGL2RenderingContext) { + this.white = this.pixel([255, 255, 255, 255]); + this.none = this.pixel([0, 0, 0, 0]); + } + + private pixel(rgba: number[]): WebGLTexture { + const gl = this.gl; + const t = gl.createTexture()!; + gl.bindTexture(gl.TEXTURE_2D, t); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(rgba)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + return t; + } + + /** A three.js texture's GL texture, or undefined until its picture has loaded */ + get(t: THREE.Texture | null | undefined): WebGLTexture | undefined { + if (!t) return undefined; + const img = t.image as (TexImageSource & { width?: number; height?: number; complete?: boolean; data?: ArrayBufferView }) | undefined; + if (!img || img.complete === false || !(img.width ?? 0)) return undefined; + const gl = this.gl; + let k = this.kept.get(t); + if (k && k.version === t.version) { + k.seen = this.frame; + return k.tex; + } + const tex = k?.tex ?? gl.createTexture()!; + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, t.flipY); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultiplyAlpha); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, t.unpackAlignment); + const srgb = t.colorSpace === THREE.SRGBColorSpace; + const internal = srgb ? gl.SRGB8_ALPHA8 : gl.RGBA8; + if (img.data) gl.texImage2D(gl.TEXTURE_2D, 0, internal, img.width!, img.height!, 0, gl.RGBA, gl.UNSIGNED_BYTE, img.data); + else gl.texImage2D(gl.TEXTURE_2D, 0, internal, gl.RGBA, gl.UNSIGNED_BYTE, img); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); + gl.generateMipmap(gl.TEXTURE_2D); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, WRAP[t.wrapS] ?? gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, WRAP[t.wrapT] ?? gl.CLAMP_TO_EDGE); + this.kept.set(t, { tex, version: t.version, seen: this.frame }); + return tex; + } + + /** The end of a frame: a texture the scene no longer draws is let go */ + done() { + for (const [t, k] of this.kept) + if (k.seen < this.frame - 1) { + this.gl.deleteTexture(k.tex); + this.kept.delete(t); + } + this.frame++; + } +} + +/** One geometry's vertex array: positions, normals and UVs at Bevy's locations 0, 1 and 2, and its indices */ +export type Mesh = { vao: WebGLVertexArrayObject; count: number; index: number; buffers: WebGLBuffer[]; version: string; seen: number }; + +export class Meshes { + private kept = new Map(); + private frame = 0; + + constructor(private gl: WebGL2RenderingContext) {} + + get(g: THREE.BufferGeometry): Mesh | undefined { + const pos = g.attributes.position as THREE.BufferAttribute | undefined; + if (!pos) return undefined; + const nor = g.attributes.normal as THREE.BufferAttribute | undefined; + const uv = g.attributes.uv as THREE.BufferAttribute | undefined; + const version = `${pos.version}.${nor?.version ?? -1}.${uv?.version ?? -1}.${g.index?.version ?? -1}`; + let m = this.kept.get(g); + if (m && m.version === version) { + m.seen = this.frame; + return m; + } + const gl = this.gl; + if (m) this.free(m); + const vao = gl.createVertexArray()!; + gl.bindVertexArray(vao); + const buffers: WebGLBuffer[] = []; + const attr = (loc: number, a: THREE.BufferAttribute | undefined, size: number) => { + if (!a) { + gl.disableVertexAttribArray(loc); + gl.vertexAttrib4f(loc, 0, 0, 0, 0); + return; + } + const b = gl.createBuffer()!; + buffers.push(b); + gl.bindBuffer(gl.ARRAY_BUFFER, b); + gl.bufferData(gl.ARRAY_BUFFER, a.array as Float32Array, gl.STATIC_DRAW); + gl.enableVertexAttribArray(loc); + gl.vertexAttribPointer(loc, size, gl.FLOAT, false, 0, 0); + }; + attr(0, pos, 3); + attr(1, nor, 3); + attr(2, uv, 2); + let index = 0; + if (g.index) { + const b = gl.createBuffer()!; + buffers.push(b); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, b); + const arr = g.index.array; + const wide = arr instanceof Uint32Array || (!(arr instanceof Uint16Array) && pos.count > 65535); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, wide ? Uint32Array.from(arr) : Uint16Array.from(arr), gl.STATIC_DRAW); + index = wide ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT; + } + gl.bindVertexArray(null); + m = { vao, count: g.index ? g.index.count : pos.count, index, buffers, version, seen: this.frame }; + this.kept.set(g, m); + return m; + } + + private free(m: Mesh) { + this.gl.deleteVertexArray(m.vao); + for (const b of m.buffers) this.gl.deleteBuffer(b); + } + + done() { + for (const [g, m] of this.kept) + if (m.seen < this.frame - 1) { + this.free(m); + this.kept.delete(g); + } + this.frame++; + } +} diff --git a/sdk/playable/src/host/bevy/programs.from b/sdk/playable/src/host/bevy/programs.from new file mode 100644 index 00000000..65f708cd --- /dev/null +++ b/sdk/playable/src/host/bevy/programs.from @@ -0,0 +1 @@ +e79d0a380e1b6a00a0c7a9f21f1d6aa19fa1ec3673f1aea423c4ba4f087b9a65 diff --git a/sdk/playable/src/host/bevy/programs.ts b/sdk/playable/src/host/bevy/programs.ts new file mode 100644 index 00000000..92b4eaee --- /dev/null +++ b/sdk/playable/src/host/bevy/programs.ts @@ -0,0 +1,10 @@ +// Bevy's PBR programs for a playable, as tools/bevy-glsl makes them (docs/playables.feature PA11): generated by +// sdk/playable/bevy/build.sh, not edited. Each program's GLSL ES 3.00; which of Bevy's bindings each uniform block +// and sampler is; each binding's fields at their byte offsets (nested fields from their struct's start, an array's +// stride under `name[]`). +export const PBR_VERT = "#version 300 es\nprecision highp float;\nprecision highp int;\nuniform uint naga_vs_first_instance;\nstruct _1bevy_pbr_render_1forward_io_Vertex {\nuint instance_index;\nvec3 position;\nvec3 normal;\nvec2 uv;\n};\nstruct _1bevy_pbr_render_1forward_io_VertexOutput {\nvec4 position;\nvec4 world_position;\nvec3 world_normal;\nvec2 uv;\nuint instance_index;\n};\nstruct _1bevy_pbr_render_1forward_io_UncompressedVertex {\nuint instance_index;\nvec3 position;\nvec3 normal;\nvec2 uv;\n};\nstruct _1bevy_render_mesh_1metadata_types_MeshMetadata {\nvec3 aabb_center;\nuint pad_a;\nvec3 aabb_half_extents;\nuint pad_b;\nvec4 uv_channels_min_and_extents[2];\n};\nstruct _1bevy_pbr_render_1mesh_types_Mesh {\nmat3x4 world_from_local;\nmat3x4 previous_world_from_local;\nmat2x4 local_from_world_transpose_a;\nfloat local_from_world_transpose_b;\nuint flags;\nuvec2 lightmap_uv_rect;\nuint first_vertex_index;\nuint current_skin_index;\nuint material_and_lightmap_bind_group_slot;\nuint tag;\nuint morph_descriptor_index;\nuint metadata_index;\n};\nstruct _1bevy_render_view_ColorGrading {\nmat3x3 balance;\nvec3 saturation;\nvec3 contrast;\nvec3 gamma;\nvec3 gain;\nvec3 lift;\nvec2 midtone_range;\nfloat exposure;\nfloat hue;\nfloat post_saturation;\n};\nstruct _1bevy_render_view_View {\nmat4x4 clip_from_world;\nmat4x4 unjittered_clip_from_world;\nmat4x4 world_from_clip;\nmat4x4 world_from_view;\nmat4x4 view_from_world;\nmat4x4 clip_from_view;\nmat4x4 view_from_clip;\nvec3 world_position;\nfloat exposure;\nvec4 viewport;\nvec4 main_pass_viewport;\nvec4 frustum[6];\nvec3 lod_view_world_position;\n_1bevy_render_view_ColorGrading color_grading;\nfloat mip_bias;\nuint frame_count;\n};\nlayout(std140) uniform _1bevy_render_mesh_1metadata_types_MeshMetadata_block_0Vertex { _1bevy_render_mesh_1metadata_types_MeshMetadata _group_2_binding_9_vs; };\nlayout(std140) uniform type_10_block_1Vertex { _1bevy_pbr_render_1mesh_types_Mesh _group_2_binding_0_vs[93]; };\nlayout(std140) uniform _1bevy_render_view_View_block_2Vertex { _1bevy_render_view_View _group_0_binding_0_vs; };\nlayout(location = 0) in vec3 _p2vs_location0;\nlayout(location = 1) in vec3 _p2vs_location1;\nlayout(location = 2) in vec2 _p2vs_location2;\nsmooth out vec4 _vs2fs_location0;\nsmooth out vec3 _vs2fs_location1;\nsmooth out vec2 _vs2fs_location2;\nflat out uint _vs2fs_location6;\n_1bevy_render_mesh_1metadata_types_MeshMetadata _1bevy_pbr_render_1mesh_functions_1get_metadata(uint instance_index) {\n_1bevy_render_mesh_1metadata_types_MeshMetadata _e2 = _group_2_binding_9_vs;\nreturn _e2;\n}\n_1bevy_pbr_render_1forward_io_UncompressedVertex _1bevy_pbr_render_1forward_io_1decompress_vertex(_1bevy_pbr_render_1forward_io_Vertex vertex_in, uint instance_index_1) {\n_1bevy_pbr_render_1forward_io_UncompressedVertex uncompressed_vertex = _1bevy_pbr_render_1forward_io_UncompressedVertex(0u, vec3(0.0), vec3(0.0), vec2(0.0));\n_1bevy_render_mesh_1metadata_types_MeshMetadata _e2 = _1bevy_pbr_render_1mesh_functions_1get_metadata(instance_index_1);\nuncompressed_vertex.instance_index = instance_index_1;\nuncompressed_vertex.position = vertex_in.position;\nuncompressed_vertex.normal = vertex_in.normal;\nuncompressed_vertex.uv = vertex_in.uv;\n_1bevy_pbr_render_1forward_io_UncompressedVertex _e11 = uncompressed_vertex;\nreturn _e11;\n}\nmat4x4 _1bevy_render_maths_2affine3_to_square(mat3x4 affine) {\nreturn transpose(mat4x4(affine[0], affine[1], affine[2], vec4(0.0, 0.0, 0.0, 1.0)));\n}\nmat4x4 _1bevy_pbr_render_1mesh_functions_3get_world_from_local(uint instance_index_2) {\nmat3x4 _e4 = _group_2_binding_0_vs[instance_index_2].world_from_local;\nmat4x4 _e5 = _1bevy_render_maths_2affine3_to_square(_e4);\nreturn _e5;\n}\nmat3x3 _1bevy_render_maths_4mat2x4_f32_to_mat3x3_unpack(mat2x4 a, float b) {\nreturn mat3x3(a[0].xyz, vec3(a[0].w, a[1].xy), vec3(a[1].zw, b));\n}\nvec3 _1bevy_pbr_render_1mesh_functions_4mesh_normal_local_to_world(vec3 vertex_normal, uint instance_index_3) {\nif (any(notEqual(vertex_normal, vec3(0.0)))) {\nmat2x4 _e9 = _group_2_binding_0_vs[instance_index_3].local_from_world_transpose_a;\nfloat _e13 = _group_2_binding_0_vs[instance_index_3].local_from_world_transpose_b;\nmat3x3 _e14 = _1bevy_render_maths_4mat2x4_f32_to_mat3x3_unpack(_e9, _e13);\nreturn normalize((_e14 * vertex_normal));\n} else {\nreturn vertex_normal;\n}\n}\nvec4 _1bevy_pbr_render_1mesh_functions_4mesh_position_local_to_world(mat4x4 world_from_local_1, vec4 vertex_position) {\nreturn (world_from_local_1 * vertex_position);\n}\nvec4 _1bevy_pbr_render_1view_transformations_3position_world_to_clip(vec3 world_pos) {\nmat4x4 _e3 = _group_0_binding_0_vs.clip_from_world;\nvec4 clip_pos = (_e3 * vec4(world_pos, 1.0));\nreturn clip_pos;\n}\nvoid main() {\n_1bevy_pbr_render_1forward_io_Vertex vertex_no_morph = _1bevy_pbr_render_1forward_io_Vertex((uint(gl_InstanceID) + naga_vs_first_instance), _p2vs_location0, _p2vs_location1, _p2vs_location2);\n_1bevy_pbr_render_1forward_io_VertexOutput out_ = _1bevy_pbr_render_1forward_io_VertexOutput(vec4(0.0), vec4(0.0), vec3(0.0), vec2(0.0), 0u);\n_1bevy_pbr_render_1forward_io_UncompressedVertex vertex_1 = _1bevy_pbr_render_1forward_io_UncompressedVertex(0u, vec3(0.0), vec3(0.0), vec2(0.0));\nmat4x4 world_from_local = mat4x4(0.0);\n_1bevy_pbr_render_1forward_io_UncompressedVertex _e3 = _1bevy_pbr_render_1forward_io_1decompress_vertex(vertex_no_morph, vertex_no_morph.instance_index);\nvertex_1 = _e3;\nmat4x4 _e6 = _1bevy_pbr_render_1mesh_functions_3get_world_from_local(vertex_no_morph.instance_index);\nworld_from_local = _e6;\nvec3 _e10 = vertex_1.normal;\nvec3 _e12 = _1bevy_pbr_render_1mesh_functions_4mesh_normal_local_to_world(_e10, vertex_no_morph.instance_index);\nout_.world_normal = _e12;\nmat4x4 _e14 = world_from_local;\nvec3 _e16 = vertex_1.position;\nvec4 _e19 = _1bevy_pbr_render_1mesh_functions_4mesh_position_local_to_world(_e14, vec4(_e16, 1.0));\nout_.world_position = _e19;\nvec4 _e22 = out_.world_position;\nvec4 _e24 = _1bevy_pbr_render_1view_transformations_3position_world_to_clip(_e22.xyz);\nout_.position = _e24;\nvec2 _e27 = vertex_1.uv;\nout_.uv = _e27;\nout_.instance_index = vertex_no_morph.instance_index;\n_1bevy_pbr_render_1forward_io_VertexOutput _e30 = out_;\ngl_Position = _e30.position;\n_vs2fs_location0 = _e30.world_position;\n_vs2fs_location1 = _e30.world_normal;\n_vs2fs_location2 = _e30.uv;\n_vs2fs_location6 = _e30.instance_index;\ngl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);\ngl_PointSize = 1.0;\nreturn;\n}"; +export const PBR_FRAG = "#version 300 es\nprecision highp float;\nprecision highp int;\nstruct _1bevy_pbr_render_1forward_io_VertexOutput {\nvec4 position;\nvec4 world_position;\nvec3 world_normal;\nvec2 uv;\nuint instance_index;\n};\nstruct _1bevy_pbr_render_1forward_io_FragmentOutput {\nvec4 color;\n};\nstruct _1bevy_pbr_render_1pbr_types_StandardMaterial {\nvec4 base_color;\nvec4 emissive;\nvec4 attenuation_color;\nmat3x3 uv_transform;\nvec3 reflectance;\nfloat perceptual_roughness;\nfloat metallic;\nfloat diffuse_transmission;\nfloat specular_transmission;\nfloat thickness;\nfloat ior;\nfloat attenuation_distance;\nfloat clearcoat;\nfloat clearcoat_perceptual_roughness;\nfloat anisotropy_strength;\nvec2 anisotropy_rotation;\nuint flags;\nfloat alpha_cutoff;\nfloat parallax_depth_scale;\nfloat max_parallax_layer_count;\nfloat lightmap_exposure;\nuint max_relief_mapping_search_steps;\nuint deferred_lighting_pass_id;\n};\nstruct _1bevy_pbr_render_1pbr_types_PbrInput {\n_1bevy_pbr_render_1pbr_types_StandardMaterial material;\nvec3 diffuse_occlusion;\nfloat specular_occlusion;\nvec4 frag_coord;\nvec4 world_position;\nvec3 world_normal;\nvec3 N;\nvec3 V;\nvec3 lightmap_light;\nvec3 clearcoat_N;\nfloat anisotropy_strength;\nvec3 anisotropy_T;\nvec3 anisotropy_B;\nbool is_orthographic;\nuint flags;\nfloat directional_shadow_factor;\n};\nstruct _1bevy_pbr_render_1mesh_types_Mesh {\nmat3x4 world_from_local;\nmat3x4 previous_world_from_local;\nmat2x4 local_from_world_transpose_a;\nfloat local_from_world_transpose_b;\nuint flags;\nuvec2 lightmap_uv_rect;\nuint first_vertex_index;\nuint current_skin_index;\nuint material_and_lightmap_bind_group_slot;\nuint tag;\nuint morph_descriptor_index;\nuint metadata_index;\n};\nstruct _1bevy_render_view_ColorGrading {\nmat3x3 balance;\nvec3 saturation;\nvec3 contrast;\nvec3 gamma;\nvec3 gain;\nvec3 lift;\nvec2 midtone_range;\nfloat exposure;\nfloat hue;\nfloat post_saturation;\n};\nstruct _1bevy_render_view_View {\nmat4x4 clip_from_world;\nmat4x4 unjittered_clip_from_world;\nmat4x4 world_from_clip;\nmat4x4 world_from_view;\nmat4x4 view_from_world;\nmat4x4 clip_from_view;\nmat4x4 view_from_clip;\nvec3 world_position;\nfloat exposure;\nvec4 viewport;\nvec4 main_pass_viewport;\nvec4 frustum[6];\nvec3 lod_view_world_position;\n_1bevy_render_view_ColorGrading color_grading;\nfloat mip_bias;\nuint frame_count;\n};\nstruct _1bevy_pbr_render_1pbr_functions_SampleBias {\nfloat mip_bias;\n};\nstruct _1bevy_pbr_render_1pbr_lighting_LayerLightingInput {\nvec3 N;\nvec3 R;\nfloat NdotV;\nfloat perceptual_roughness;\nfloat roughness;\n};\nstruct _1bevy_pbr_render_1pbr_lighting_LightingInput {\n_1bevy_pbr_render_1pbr_lighting_LayerLightingInput layers[1];\nvec3 P;\nvec3 V;\nvec3 diffuse_color;\nfloat metallic;\nvec3 F0_dielectric;\nvec3 F0_metallic;\nvec2 F_ab;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_DirectionalCascade {\nmat4x4 clip_from_world;\nfloat texel_size;\nfloat far_bound;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_DirectionalLight {\n_1bevy_pbr_render_2mesh_view_types_DirectionalCascade cascades[1];\nvec4 color;\nvec3 direction_to_light;\nuint flags;\nfloat soft_shadow_size;\nfloat shadow_depth_bias;\nfloat shadow_normal_bias;\nuint num_cascades;\nfloat cascades_overlap_proportion;\nuint depth_texture_base_index;\nuint decal_index;\nfloat sun_disk_angular_size;\nfloat sun_disk_intensity;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_RectLight {\nvec4 color;\nvec3 position;\nfloat width;\nvec3 right;\nfloat height;\nvec3 up;\nfloat range;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_Lights {\n_1bevy_pbr_render_2mesh_view_types_DirectionalLight directional_lights[10];\nvec4 ambient_color;\nuvec4 cluster_dimensions;\nvec4 cluster_factors;\nuint n_directional_lights;\nint spot_light_shadowmap_offset;\nuint ambient_light_flags;\nuint n_rect_lights;\n_1bevy_pbr_render_2mesh_view_types_RectLight rect_lights[8];\n};\nstruct _1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges {\nuint first_point_light_index_offset;\nuint first_spot_light_index_offset;\nuint first_rect_light_index_offset;\nuint first_reflection_probe_index_offset;\nuint first_irradiance_volume_index_offset;\nuint first_decal_offset;\nuint last_clusterable_object_index_offset;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_ClusterOffsetsAndCounts {\nuvec4 data[1024];\n};\nstruct _1bevy_pbr_render_2mesh_view_types_ClusterableObjectIndexLists {\nuvec4 data[1024];\n};\nstruct _1bevy_pbr_render_2mesh_view_types_ClusteredLight {\nvec4 light_custom_data;\nvec4 color_inverse_square_range;\nvec4 position_radius;\nuint flags;\nfloat shadow_depth_bias;\nfloat shadow_normal_bias;\nfloat spot_light_tan_angle;\nfloat soft_shadow_size;\nfloat shadow_map_near_z;\nuint decal_index;\nfloat range;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_ClusteredLights {\n_1bevy_pbr_render_2mesh_view_types_ClusteredLight data[204];\n};\nstruct _1bevy_render_globals_Globals {\nfloat time;\nfloat delta_time;\nuint frame_count;\nfloat _webgl2_padding;\n};\nstruct _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput {\nvec3 H;\nfloat NdotL;\nfloat NdotH;\nfloat LdotH;\n};\nstruct _1bevy_pbr_render_2mesh_view_types_Fog {\nvec4 base_color;\nvec4 directional_light_color;\nvec3 be;\nfloat directional_light_exponent;\nvec3 bi;\nuint mode;\n};\nconst uint _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT = 16u;\nconst uint _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE = 0u;\nconst uint _1bevy_pbr_render_1mesh_types_6MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT = 2147483648u;\nconst uint _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT = 1u;\nconst uint _1bevy_pbr_render_1pbr_types_4STANDARD_MATERIAL_FLAGS_UNLIT_BIT = 32u;\nconst uint _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT = 2u;\nconst uint _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT = 4u;\nconst uint _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_RG_BIT = 1048576u;\nconst uint _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT = 8u;\nconst uint _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_ALPHA_MODE_RESERVED_BITS = 3758096384u;\nconst uint _1bevy_pbr_render_1pbr_lighting_1LAYER_BASE = 0u;\nconst uint _1bevy_pbr_render_1clustered_forward_2CLUSTER_COUNT_SIZE = 9u;\nconst uint _1bevy_pbr_render_1mesh_types_4MESH_FLAGS_SHADOW_RECEIVER_BIT = 536870912u;\nconst uint _1bevy_pbr_render_2mesh_view_types_5POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT = 1u;\nconst vec2 _1bevy_pbr_render_1shadow_sampling_3D3D_SAMPLE_POINT_POSITIONS[8] = vec2[8](vec2(0.125, -0.375), vec2(-0.125, 0.375), vec2(0.625, 0.125), vec2(-0.375, -0.625), vec2(-0.625, 0.625), vec2(-0.875, -0.125), vec2(0.375, 0.875), vec2(0.875, -0.875));\nconst float _1bevy_render_maths_PI = 3.1415927;\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_0_ = vec2(-0.7071, 0.7071);\nconst float _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE = 0.5;\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_1_ = vec2(-0.0, -0.875);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_2_ = vec2(0.5303, 0.5303);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_3_ = vec2(-0.625, -0.0);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_4_ = vec2(0.3536, -0.3536);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_5_ = vec2(-0.0, 0.375);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_6_ = vec2(-0.1768, -0.1768);\nconst vec2 _1bevy_pbr_render_utils_3SPIRAL_OFFSET_7_ = vec2(0.125, 0.0);\nconst float _1bevy_pbr_render_1shadow_sampling_2POINT_SHADOW_SCALE = 0.003;\nconst vec3 _1bevy_pbr_render_shadows_1flip_z = vec3(1.0, 1.0, -1.0);\nconst float _1bevy_pbr_render_1shadow_sampling_3D3D_SAMPLE_POINT_COEFFS[8] = float[8](0.157112, 0.157112, 0.138651, 0.130251, 0.114946, 0.114946, 0.107982, 0.079001);\nconst uint _1bevy_pbr_render_2mesh_view_types_6POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE = 2u;\nconst float _1bevy_pbr_render_1shadow_sampling_3SPOT_SHADOW_TEXEL_SIZE = 0.013427734;\nconst uint _1bevy_pbr_render_2mesh_view_types_5DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT = 1u;\nconst uint _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_FOG_ENABLED_BIT = 256u;\nconst uint _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_LINEAR = 1u;\nconst uint _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_EXPONENTIAL = 2u;\nconst uint _1bevy_pbr_render_2mesh_view_types_3FOG_MODE_EXPONENTIAL_SQUARED = 3u;\nconst uint _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_ATMOSPHERIC = 4u;\nlayout(std140) uniform type_10_block_0Fragment { _1bevy_pbr_render_1mesh_types_Mesh _group_2_binding_0_fs[93]; };\nlayout(std140) uniform _1bevy_pbr_render_1pbr_types_StandardMaterial_block_1Fragment { _1bevy_pbr_render_1pbr_types_StandardMaterial _group_3_binding_0_fs; };\nlayout(std140) uniform _1bevy_render_view_View_block_2Fragment { _1bevy_render_view_View _group_0_binding_0_fs; };\nuniform highp sampler2D _group_3_binding_1_fs;\nuniform highp sampler2D _group_3_binding_3_fs;\nuniform highp sampler2D _group_3_binding_5_fs;\nuniform highp sampler2D _group_3_binding_7_fs;\nlayout(std140) uniform _1bevy_pbr_render_2mesh_view_types_Lights_block_3Fragment { _1bevy_pbr_render_2mesh_view_types_Lights _group_0_binding_1_fs; };\nlayout(std140) uniform _1bevy_pbr_render_2mesh_view_types_ClusterOffsetsAndCounts_block_4Fragment { _1bevy_pbr_render_2mesh_view_types_ClusterOffsetsAndCounts _group_0_binding_10_fs; };\nlayout(std140) uniform _1bevy_pbr_render_2mesh_view_types_ClusterableObjectIndexLists_block_5Fragment { _1bevy_pbr_render_2mesh_view_types_ClusterableObjectIndexLists _group_0_binding_9_fs; };\nlayout(std140) uniform _1bevy_pbr_render_2mesh_view_types_ClusteredLights_block_6Fragment { _1bevy_pbr_render_2mesh_view_types_ClusteredLights _group_0_binding_8_fs; };\nlayout(std140) uniform _1bevy_render_globals_Globals_block_7Fragment { _1bevy_render_globals_Globals _group_0_binding_11_fs; };\nuniform highp samplerCubeShadow _group_0_binding_2_fs;\nuniform highp sampler2DShadow _group_0_binding_5_fs;\nuniform highp sampler2D _group_0_binding_41_fs;\nlayout(std140) uniform _1bevy_pbr_render_2mesh_view_types_Fog_block_8Fragment { _1bevy_pbr_render_2mesh_view_types_Fog _group_0_binding_13_fs; };\nsmooth in vec4 _vs2fs_location0;\nsmooth in vec3 _vs2fs_location1;\nsmooth in vec2 _vs2fs_location2;\nflat in uint _vs2fs_location6;\nlayout(location = 0) out vec4 _fs2p_location0;\n_1bevy_pbr_render_1pbr_types_StandardMaterial _1bevy_pbr_render_1pbr_types_2standard_material_new() {\n_1bevy_pbr_render_1pbr_types_StandardMaterial material = _1bevy_pbr_render_1pbr_types_StandardMaterial(vec4(0.0), vec4(0.0), vec4(0.0), mat3x3(0.0), vec3(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, vec2(0.0), 0u, 0.0, 0.0, 0.0, 0.0, 0u, 0u);\nmaterial.base_color = vec4(1.0, 1.0, 1.0, 1.0);\nmaterial.emissive = vec4(0.0, 0.0, 0.0, 1.0);\nmaterial.perceptual_roughness = 0.5;\nmaterial.metallic = 0.0;\nmaterial.reflectance = vec3(0.5);\nmaterial.diffuse_transmission = 0.0;\nmaterial.specular_transmission = 0.0;\nmaterial.thickness = 0.0;\nmaterial.ior = 1.5;\nmaterial.attenuation_distance = 1.0;\nmaterial.attenuation_color = vec4(1.0, 1.0, 1.0, 1.0);\nmaterial.clearcoat = 0.0;\nmaterial.clearcoat_perceptual_roughness = 0.0;\nmaterial.flags = _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE;\nmaterial.alpha_cutoff = 0.5;\nmaterial.parallax_depth_scale = 0.1;\nmaterial.max_parallax_layer_count = 16.0;\nmaterial.max_relief_mapping_search_steps = 5u;\nmaterial.deferred_lighting_pass_id = 1u;\nmaterial.uv_transform = mat3x3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));\n_1bevy_pbr_render_1pbr_types_StandardMaterial _e66 = material;\nreturn _e66;\n}\n_1bevy_pbr_render_1pbr_types_PbrInput _1bevy_pbr_render_1pbr_types_2pbr_input_new() {\n_1bevy_pbr_render_1pbr_types_PbrInput pbr_input_1 = _1bevy_pbr_render_1pbr_types_PbrInput(_1bevy_pbr_render_1pbr_types_StandardMaterial(vec4(0.0), vec4(0.0), vec4(0.0), mat3x3(0.0), vec3(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, vec2(0.0), 0u, 0.0, 0.0, 0.0, 0.0, 0u, 0u), vec3(0.0), 0.0, vec4(0.0), vec4(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), false, 0u, 0.0);\n_1bevy_pbr_render_1pbr_types_StandardMaterial _e2 = _1bevy_pbr_render_1pbr_types_2standard_material_new();\npbr_input_1.material = _e2;\npbr_input_1.diffuse_occlusion = vec3(1.0);\npbr_input_1.specular_occlusion = 1.0;\npbr_input_1.frag_coord = vec4(0.0, 0.0, 0.0, 1.0);\npbr_input_1.world_position = vec4(0.0, 0.0, 0.0, 1.0);\npbr_input_1.world_normal = vec3(0.0, 0.0, 1.0);\npbr_input_1.is_orthographic = false;\npbr_input_1.N = vec3(0.0, 0.0, 1.0);\npbr_input_1.V = vec3(1.0, 0.0, 0.0);\npbr_input_1.clearcoat_N = vec3(0.0);\npbr_input_1.anisotropy_T = vec3(0.0);\npbr_input_1.anisotropy_B = vec3(0.0);\npbr_input_1.lightmap_light = vec3(0.0);\npbr_input_1.flags = 0u;\npbr_input_1.directional_shadow_factor = 1.0;\n_1bevy_pbr_render_1pbr_types_PbrInput _e53 = pbr_input_1;\nreturn _e53;\n}\nvec3 _1bevy_pbr_render_1pbr_functions_1calculate_view(vec4 world_position, bool is_orthographic) {\nvec3 V = vec3(0.0);\nif (is_orthographic) {\nfloat _e7 = _group_0_binding_0_fs.clip_from_world[0][2];\nfloat _e12 = _group_0_binding_0_fs.clip_from_world[1][2];\nfloat _e17 = _group_0_binding_0_fs.clip_from_world[2][2];\nV = normalize(vec3(_e7, _e12, _e17));\n} else {\nvec3 _e22 = _group_0_binding_0_fs.world_position;\nV = normalize((_e22.xyz - world_position.xyz));\n}\nvec3 _e27 = V;\nreturn _e27;\n}\nbool _1bevy_pbr_render_1pbr_functions_3winding_corrected_front_facing(uint mesh_flags, bool is_front_1) {\nbool positive_determinant = ((mesh_flags & _1bevy_pbr_render_1mesh_types_6MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT) != 0u);\nreturn (is_front_1 == positive_determinant);\n}\nvec3 _1bevy_pbr_render_1pbr_functions_2prepare_world_normal(vec3 world_normal, bool double_sided, bool is_front_2) {\nvec3 output_ = vec3(0.0);\nbool local = false;\noutput_ = world_normal;\nif (!(!(double_sided))) {\nlocal = is_front_2;\n} else {\nlocal = true;\n}\nbool _e9 = local;\nvec3 _e15 = output_;\noutput_ = (((float(_e9) * 2.0) - 1.0) * _e15);\nvec3 _e17 = output_;\nreturn _e17;\n}\n_1bevy_pbr_render_1pbr_types_PbrInput _1bevy_pbr_render_1pbr_fragment_4pbr_input_from_vertex_output(_1bevy_pbr_render_1forward_io_VertexOutput in_1, bool is_front_3, bool double_sided_1) {\n_1bevy_pbr_render_1pbr_types_PbrInput pbr_input_2 = _1bevy_pbr_render_1pbr_types_PbrInput(_1bevy_pbr_render_1pbr_types_StandardMaterial(vec4(0.0), vec4(0.0), vec4(0.0), mat3x3(0.0), vec3(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, vec2(0.0), 0u, 0.0, 0.0, 0.0, 0.0, 0u, 0u), vec3(0.0), 0.0, vec4(0.0), vec4(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), false, 0u, 0.0);\n_1bevy_pbr_render_1pbr_types_PbrInput _e3 = _1bevy_pbr_render_1pbr_types_2pbr_input_new();\npbr_input_2 = _e3;\nuint _e10 = _group_2_binding_0_fs[in_1.instance_index].flags;\npbr_input_2.flags = _e10;\nfloat _e16 = _group_0_binding_0_fs.clip_from_view[3][3];\npbr_input_2.is_orthographic = (_e16 == 1.0);\nbool _e22 = pbr_input_2.is_orthographic;\nvec3 _e23 = _1bevy_pbr_render_1pbr_functions_1calculate_view(in_1.world_position, _e22);\npbr_input_2.V = _e23;\npbr_input_2.frag_coord = in_1.position;\npbr_input_2.world_position = in_1.world_position;\nuint _e29 = pbr_input_2.flags;\nbool _e30 = _1bevy_pbr_render_1pbr_functions_3winding_corrected_front_facing(_e29, is_front_3);\nvec3 _e33 = _1bevy_pbr_render_1pbr_functions_2prepare_world_normal(in_1.world_normal, double_sided_1, _e30);\npbr_input_2.world_normal = _e33;\nvec3 _e36 = pbr_input_2.world_normal;\npbr_input_2.N = normalize(_e36);\n_1bevy_pbr_render_1pbr_types_PbrInput _e38 = pbr_input_2;\nreturn _e38;\n}\n_1bevy_pbr_render_1pbr_types_PbrInput _1bevy_pbr_render_1pbr_fragment_4pbr_input_from_standard_material(_1bevy_pbr_render_1forward_io_VertexOutput in_2, bool is_front_4) {\n_1bevy_pbr_render_1pbr_types_PbrInput pbr_input_3 = _1bevy_pbr_render_1pbr_types_PbrInput(_1bevy_pbr_render_1pbr_types_StandardMaterial(vec4(0.0), vec4(0.0), vec4(0.0), mat3x3(0.0), vec3(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, vec2(0.0), 0u, 0.0, 0.0, 0.0, 0.0, 0u, 0u), vec3(0.0), 0.0, vec4(0.0), vec4(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), false, 0u, 0.0);\n_1bevy_pbr_render_1pbr_functions_SampleBias bias = _1bevy_pbr_render_1pbr_functions_SampleBias(0.0);\nvec2 uv = vec2(0.0);\nvec2 uv_b = vec2(0.0);\nvec4 emissive = vec4(0.0);\nfloat metallic = 0.0;\nfloat perceptual_roughness = 0.0;\nfloat specular_transmission = 0.0;\nfloat thickness = 0.0;\nfloat diffuse_transmission = 0.0;\nvec3 diffuse_occlusion = vec3(1.0);\nfloat specular_occlusion = 1.0;\nuint _e6 = _group_2_binding_0_fs[in_2.instance_index].material_and_lightmap_bind_group_slot;\nuint slot = (_e6 & 65535u);\nuint flags = _group_3_binding_0_fs.flags;\nvec4 base_color_3 = _group_3_binding_0_fs.base_color;\nuint deferred_lighting_pass_id = _group_3_binding_0_fs.deferred_lighting_pass_id;\nfloat alpha_cutoff_1 = _group_3_binding_0_fs.alpha_cutoff;\nbool double_sided_2 = ((flags & _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u);\n_1bevy_pbr_render_1pbr_types_PbrInput _e25 = _1bevy_pbr_render_1pbr_fragment_4pbr_input_from_vertex_output(in_2, is_front_4, double_sided_2);\npbr_input_3 = _e25;\npbr_input_3.material.flags = flags;\nvec4 _e31 = pbr_input_3.material.base_color;\npbr_input_3.material.base_color = (_e31 * base_color_3);\npbr_input_3.material.deferred_lighting_pass_id = deferred_lighting_pass_id;\nuint _e36 = pbr_input_3.flags;\nbool _e37 = _1bevy_pbr_render_1pbr_functions_3winding_corrected_front_facing(_e36, is_front_4);\nvec3 _e39 = pbr_input_3.N;\nvec3 _e41 = pbr_input_3.V;\nfloat NdotV_3 = max(dot(_e39, _e41), 0.0001);\nfloat _e49 = _group_0_binding_0_fs.mip_bias;\nbias.mip_bias = _e49;\nmat3x3 uv_transform = _group_3_binding_0_fs.uv_transform;\npbr_input_3.material.uv_transform = uv_transform;\nuv = (uv_transform * vec3(in_2.uv, 1.0)).xy;\nvec2 _e61 = uv;\nuv_b = _e61;\nif (((flags & _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u)) {\nvec2 coords = uv;\nvec4 _e72 = pbr_input_3.material.base_color;\nfloat _e74 = bias.mip_bias;\nvec4 _e75 = texture(_group_3_binding_1_fs, vec2(coords), _e74);\npbr_input_3.material.base_color = (_e72 * _e75);\n}\npbr_input_3.material.flags = flags;\npbr_input_3.material.alpha_cutoff = alpha_cutoff_1;\nif (((flags & _1bevy_pbr_render_1pbr_types_4STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u)) {\nfloat _e89 = _group_3_binding_0_fs.ior;\npbr_input_3.material.ior = _e89;\nvec4 _e94 = _group_3_binding_0_fs.attenuation_color;\npbr_input_3.material.attenuation_color = _e94;\nfloat _e99 = _group_3_binding_0_fs.attenuation_distance;\npbr_input_3.material.attenuation_distance = _e99;\nvec3 _e104 = _group_3_binding_0_fs.reflectance;\npbr_input_3.material.reflectance = _e104;\nvec4 _e107 = _group_3_binding_0_fs.emissive;\nemissive = _e107;\nif (((flags & _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u)) {\nvec2 coords_1 = uv;\nvec4 _e116 = emissive;\nfloat _e119 = bias.mip_bias;\nvec4 _e120 = texture(_group_3_binding_3_fs, vec2(coords_1), _e119);\nfloat _e124 = emissive.w;\nemissive = vec4((_e116.xyz * _e120.xyz), _e124);\n}\nvec4 _e128 = emissive;\npbr_input_3.material.emissive = _e128;\nfloat _e131 = _group_3_binding_0_fs.metallic;\nmetallic = _e131;\nfloat _e135 = _group_3_binding_0_fs.perceptual_roughness;\nperceptual_roughness = _e135;\nif (((flags & _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT) != 0u)) {\nvec2 coords_2 = uv;\nfloat _e145 = bias.mip_bias;\nvec4 metallic_roughness = texture(_group_3_binding_5_fs, vec2(coords_2), _e145);\nif (((flags & _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_RG_BIT) != 0u)) {\nfloat _e151 = perceptual_roughness;\nperceptual_roughness = (_e151 * metallic_roughness.x);\nfloat _e154 = metallic;\nmetallic = (_e154 * metallic_roughness.y);\n} else {\nfloat _e157 = perceptual_roughness;\nperceptual_roughness = (_e157 * metallic_roughness.y);\nfloat _e160 = metallic;\nmetallic = (_e160 * metallic_roughness.z);\n}\n}\nfloat _e165 = metallic;\npbr_input_3.material.metallic = _e165;\nfloat _e168 = perceptual_roughness;\npbr_input_3.material.perceptual_roughness = _e168;\nfloat _e173 = _group_3_binding_0_fs.clearcoat;\npbr_input_3.material.clearcoat = _e173;\nfloat _e178 = _group_3_binding_0_fs.clearcoat_perceptual_roughness;\npbr_input_3.material.clearcoat_perceptual_roughness = _e178;\nfloat _e181 = _group_3_binding_0_fs.specular_transmission;\nspecular_transmission = _e181;\nfloat _e185 = specular_transmission;\npbr_input_3.material.specular_transmission = _e185;\nfloat _e188 = _group_3_binding_0_fs.thickness;\nthickness = _e188;\nfloat _e190 = thickness;\nmat3x4 _e195 = _group_2_binding_0_fs[in_2.instance_index].world_from_local;\nvec3 _e198 = pbr_input_3.N;\nthickness = (_e190 * length((transpose(_e195) * vec4(_e198, 0.0)).xyz));\nfloat _e207 = thickness;\npbr_input_3.material.thickness = _e207;\nfloat _e210 = _group_3_binding_0_fs.diffuse_transmission;\ndiffuse_transmission = _e210;\nfloat _e214 = diffuse_transmission;\npbr_input_3.material.diffuse_transmission = _e214;\nif (((flags & _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT) != 0u)) {\nvec2 coords_3 = uv;\nvec3 _e227 = diffuse_occlusion;\nfloat _e229 = bias.mip_bias;\nvec4 _e230 = texture(_group_3_binding_7_fs, vec2(coords_3), _e229);\ndiffuse_occlusion = (_e227 * _e230.x);\n}\nvec3 _e234 = diffuse_occlusion;\npbr_input_3.diffuse_occlusion = _e234;\nfloat _e236 = specular_occlusion;\npbr_input_3.specular_occlusion = _e236;\nvec3 _e239 = pbr_input_3.world_normal;\npbr_input_3.N = normalize(_e239);\nvec3 _e243 = pbr_input_3.N;\npbr_input_3.clearcoat_N = _e243;\n}\n_1bevy_pbr_render_1pbr_types_PbrInput _e244 = pbr_input_3;\nreturn _e244;\n}\nvec4 _1bevy_pbr_render_1pbr_functions_1alpha_discard(uint material_flags, float alpha_cutoff, vec4 output_color) {\nvec4 color = vec4(0.0);\ncolor = output_color;\nuint alpha_mode = (material_flags & _1bevy_pbr_render_1pbr_types_6STANDARD_MATERIAL_FLAGS_ALPHA_MODE_RESERVED_BITS);\nif ((alpha_mode == _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE)) {\ncolor.w = 1.0;\n}\nvec4 _e10 = color;\nreturn _e10;\n}\nvoid _1bevy_pbr_decal_clustered_1apply_decals(inout _1bevy_pbr_render_1pbr_types_PbrInput pbr_input_4) {\nvec4 base_color = vec4(0.0);\nvec4 emissive_1 = vec4(0.0);\nvec3 Nt = vec3(0.0);\nfloat metallic_1 = 0.0;\nfloat perceptual_roughness_1 = 0.0;\nvec4 _e2 = pbr_input_4.world_position;\nvec3 world_position_2 = _e2.xyz;\nvec3 world_normal_2 = pbr_input_4.world_normal;\nvec4 _e7 = pbr_input_4.frag_coord;\nvec2 frag_coord_1 = _e7.xy;\nvec4 _e11 = pbr_input_4.material.base_color;\nbase_color = _e11;\nvec4 _e15 = pbr_input_4.material.emissive;\nemissive_1 = _e15;\nvec3 _e18 = pbr_input_4.N;\nNt = _e18;\nfloat _e22 = pbr_input_4.material.metallic;\nmetallic_1 = _e22;\nfloat _e26 = pbr_input_4.material.perceptual_roughness;\nperceptual_roughness_1 = _e26;\nvec4 _e30 = base_color;\npbr_input_4.material.base_color = _e30;\nvec4 _e33 = emissive_1;\npbr_input_4.material.emissive = _e33;\nvec3 _e35 = Nt;\npbr_input_4.N = normalize(_e35);\nfloat _e39 = metallic_1;\npbr_input_4.material.metallic = _e39;\nfloat _e42 = perceptual_roughness_1;\npbr_input_4.material.perceptual_roughness = _e42;\nreturn;\n}\nfloat _1bevy_pbr_render_1pbr_lighting_perceptualRoughnessToRoughness(float perceptualRoughness) {\nfloat clampedPerceptualRoughness = clamp(perceptualRoughness, 0.089, 1.0);\nreturn (clampedPerceptualRoughness * clampedPerceptualRoughness);\n}\nvec3 _1bevy_pbr_render_1pbr_functions_2calculate_diffuse_color(vec3 base_color_1, float metallic_2, float specular_transmission_1, float diffuse_transmission_1) {\nreturn (((base_color_1 * (1.0 - metallic_2)) * (1.0 - specular_transmission_1)) * (1.0 - diffuse_transmission_1));\n}\nvec3 _1bevy_pbr_render_1pbr_functions_2calculate_F0_dielectric(vec3 reflectance) {\nreturn ((0.16 * reflectance) * reflectance);\n}\nvec3 _1bevy_pbr_render_1pbr_functions_1calculate_F0_(vec3 base_color_2, float metallic_3, vec3 reflectance_1) {\nvec3 _e3 = _1bevy_pbr_render_1pbr_functions_2calculate_F0_dielectric(reflectance_1);\nreturn mix(_e3, base_color_2, metallic_3);\n}\nvec2 _1bevy_pbr_render_1pbr_lighting_1F_AB(float perceptual_roughness_2, float NdotV) {\nvec4 c0_ = vec4(-1.0, -0.0275, -0.572, 0.022);\nvec4 c1_ = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = ((perceptual_roughness_2 * c0_) + c1_);\nfloat a004_ = ((min((r.x * r.x), exp2((-9.28 * NdotV))) * r.x) + r.y);\nreturn max(((vec2(-1.04, 1.04) * a004_) + r.zw), vec2(5e-5));\n}\nuint _1bevy_pbr_render_1clustered_forward_4view_z_to_z_slice(vec2 cluster_factors, uint z_slices, float view_z, bool is_orthographic_1) {\nuint z_slice = 0u;\nif (is_orthographic_1) {\nz_slice = uint(floor(((view_z - cluster_factors.x) * cluster_factors.y)));\n} else {\nz_slice = uint((((log(-(view_z)) * cluster_factors.x) - cluster_factors.y) + 1.0));\n}\nuint _e21 = z_slice;\nreturn min(_e21, (z_slices - 1u));\n}\nuint _1bevy_pbr_render_1clustered_forward_2fragment_cluster_index(uvec3 p, uvec4 cluster_dimensions) {\nreturn min(((((p.y * cluster_dimensions.x) + p.x) * cluster_dimensions.z) + p.z), (cluster_dimensions.w - 1u));\n}\nuint _1bevy_pbr_render_1clustered_forward_3view_fragment_cluster_index(vec2 frag_coord, float view_z_1, bool is_orthographic_2) {\nvec4 _e5 = _group_0_binding_0_fs.viewport;\nvec4 _e10 = _group_0_binding_1_fs.cluster_factors;\nuvec2 xy = uvec2(floor(((frag_coord - _e5.xy) * _e10.xy)));\nvec4 _e17 = _group_0_binding_1_fs.cluster_factors;\nuint _e22 = _group_0_binding_1_fs.cluster_dimensions.z;\nuint _e23 = _1bevy_pbr_render_1clustered_forward_4view_z_to_z_slice(_e17.zw, _e22, view_z_1, is_orthographic_2);\nuvec4 _e27 = _group_0_binding_1_fs.cluster_dimensions;\nuint _e28 = _1bevy_pbr_render_1clustered_forward_2fragment_cluster_index(uvec3(xy, _e23), _e27);\nreturn _e28;\n}\n_1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges _1bevy_pbr_render_1clustered_forward_4unpack_clusterable_object_index_ranges(uint cluster_index) {\nuint raw_offset_and_counts = _group_0_binding_10_fs.data[(cluster_index >> 2u)][(cluster_index & 3u)];\nuvec3 offset_and_counts = uvec3(((raw_offset_and_counts >> 18u) & 16383u), ((raw_offset_and_counts >> _1bevy_pbr_render_1clustered_forward_2CLUSTER_COUNT_SIZE) & 511u), (raw_offset_and_counts & 511u));\nuint offset_a = offset_and_counts.x;\nuint offset_b = (offset_a + offset_and_counts.y);\nuint offset_c = (offset_b + offset_and_counts.z);\nreturn _1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges(offset_a, offset_b, offset_c, offset_c, offset_c, offset_c, offset_c);\n}\nuint _1bevy_pbr_render_1clustered_forward_3get_clusterable_object_id(uint index) {\nuint indices = _group_0_binding_9_fs.data[(index >> 4u)][((index >> 2u) & 3u)];\nreturn ((indices >> (8u * (index & 3u))) & 255u);\n}\nfloat _1bevy_render_maths_copysign(float a, float b) {\nreturn uintBitsToFloat(((floatBitsToUint(a) & 2147483647u) | (floatBitsToUint(b) & 2147483648u)));\n}\nmat3x3 _1bevy_render_maths_orthonormalize(vec3 z_basis) {\nfloat _e3 = _1bevy_render_maths_copysign(1.0, z_basis.z);\nfloat a_2 = (-1.0 / (_e3 + z_basis.z));\nfloat b_1 = ((z_basis.x * z_basis.y) * a_2);\nvec3 x_basis_2 = vec3((1.0 + (((_e3 * z_basis.x) * z_basis.x) * a_2)), (_e3 * b_1), (-(_e3) * z_basis.x));\nvec3 y_basis_2 = vec3(b_1, (_e3 + ((z_basis.y * z_basis.y) * a_2)), -(z_basis.y));\nreturn mat3x3(x_basis_2, y_basis_2, z_basis);\n}\nvec2 _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_cubemap_hardware(vec3 light_local, float depth, uint light_id) {\nreturn vec2(0.0);\n}\nvec2 _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2 position, vec3 x_basis, vec3 y_basis, vec3 light_local_1, float depth_1, uint light_id_1) {\nvec2 _e12 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_cubemap_hardware(((light_local_1 + (position.x * x_basis)) + (position.y * y_basis)), depth_1, light_id_1);\nreturn _e12;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_5search_for_blockers_in_shadow_cubemap(vec3 light_local_2, float depth_2, float scale, float distance_to_light, uint light_id_2) {\nvec2 sum = vec2(0.0);\nmat3x3 _e6 = _1bevy_render_maths_orthonormalize(normalize(light_local_2));\nmat3x3 basis = ((_e6 * scale) * distance_to_light);\nvec2 _e12 = sum;\nvec2 _e18 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(0.125, -0.375), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e12 + _e18);\nvec2 _e20 = sum;\nvec2 _e26 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(-0.125, 0.375), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e20 + _e26);\nvec2 _e28 = sum;\nvec2 _e34 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(0.625, 0.125), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e28 + _e34);\nvec2 _e36 = sum;\nvec2 _e42 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(-0.375, -0.625), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e36 + _e42);\nvec2 _e44 = sum;\nvec2 _e50 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(-0.625, 0.625), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e44 + _e50);\nvec2 _e52 = sum;\nvec2 _e58 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(-0.875, -0.125), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e52 + _e58);\nvec2 _e60 = sum;\nvec2 _e66 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(0.375, 0.875), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e60 + _e66);\nvec2 _e68 = sum;\nvec2 _e74 = _1bevy_pbr_render_1shadow_sampling_7search_for_blockers_in_shadow_cubemap_at_offset(vec2(0.875, -0.875), basis[0], basis[1], light_local_2, depth_2, light_id_2);\nsum = (_e68 + _e74);\nfloat _e77 = sum.y;\nif ((_e77 == 0.0)) {\nreturn 0.0;\n}\nfloat _e82 = sum.x;\nfloat _e84 = sum.y;\nreturn (_e82 / _e84);\n}\nfloat _1bevy_pbr_render_utils_2interleaved_gradient_noise(vec2 pixel_coordinates, uint frame) {\nvec2 xy_1 = (pixel_coordinates + vec2((5.588238 * float((frame % 64u)))));\nreturn fract((52.982918 * fract(((0.06711056 * xy_1.x) + (0.00583715 * xy_1.y)))));\n}\nmat2x2 _1bevy_pbr_render_1shadow_sampling_2random_rotation_matrix(vec2 scale_1, bool temporal) {\nuint _e6 = _group_0_binding_11_fs.frame_count;\nfloat _e8 = _1bevy_pbr_render_utils_2interleaved_gradient_noise(scale_1, (temporal ? _e6 : 1u));\nfloat random_angle = (6.2831855 * _e8);\nvec2 m = vec2(sin(random_angle), cos(random_angle));\nreturn mat2x2(vec2(m.y, -(m.x)), vec2(m.x, m.y));\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_hardware(vec3 light_local_3, float depth_3, uint light_id_3) {\nfloat _e5 = texture(_group_0_binding_2_fs, vec4(light_local_3, depth_3));\nreturn _e5;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2 position_1, float coeff, vec3 x_basis_1, vec3 y_basis_1, vec3 light_local_4, float depth_4, uint light_id_4) {\nfloat _e13 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_hardware(((light_local_4 + (position_1.x * x_basis_1)) + (position_1.y * y_basis_1)), depth_4, light_id_4);\nreturn (_e13 * coeff);\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_jittered(vec3 light_local_5, float depth_5, vec2 frag_coord_xy, float scale_2, float distance_to_light_1, uint light_id_5, bool temporal_1) {\nfloat sum_1 = 0.0;\nmat2x2 _e7 = _1bevy_pbr_render_1shadow_sampling_2random_rotation_matrix(frag_coord_xy, temporal_1);\nvec2 sample_offset0_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_0_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset1_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_1_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset2_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_2_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset3_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_3_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset4_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_4_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset5_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_5_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset6_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_6_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nvec2 sample_offset7_ = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_7_) * _1bevy_pbr_render_1shadow_sampling_4POINT_SHADOW_TEMPORAL_OFFSET_SCALE);\nmat3x3 _e41 = _1bevy_render_maths_orthonormalize(normalize(light_local_5));\nmat3x3 basis_1 = ((_e41 * scale_2) * distance_to_light_1);\nfloat _e46 = sum_1;\nfloat _e50 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset0_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e46 + _e50);\nfloat _e52 = sum_1;\nfloat _e56 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset1_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e52 + _e56);\nfloat _e58 = sum_1;\nfloat _e62 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset2_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e58 + _e62);\nfloat _e64 = sum_1;\nfloat _e68 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset3_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e64 + _e68);\nfloat _e70 = sum_1;\nfloat _e74 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset4_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e70 + _e74);\nfloat _e76 = sum_1;\nfloat _e80 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset5_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e76 + _e80);\nfloat _e82 = sum_1;\nfloat _e86 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset6_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e82 + _e86);\nfloat _e88 = sum_1;\nfloat _e92 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(sample_offset7_, 0.125, basis_1[0], basis_1[1], light_local_5, depth_5, light_id_5);\nsum_1 = (_e88 + _e92);\nfloat _e94 = sum_1;\nreturn _e94;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_pcss(vec3 light_local_6, float distance_to_light_2, float depth_6, uint light_id_6, float light_size, vec2 frag_coord_xy_1) {\nfloat _e6 = _1bevy_pbr_render_1shadow_sampling_5search_for_blockers_in_shadow_cubemap(light_local_6, depth_6, light_size, distance_to_light_2, light_id_6);\nfloat blur_size_2 = max((((_e6 - depth_6) * light_size) / depth_6), 0.5);\nfloat _e15 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_jittered(light_local_6, depth_6, frag_coord_xy_1, (_1bevy_pbr_render_1shadow_sampling_2POINT_SHADOW_SCALE * blur_size_2), distance_to_light_2, light_id_6, false);\nreturn _e15;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_gaussian(vec3 light_local_7, float depth_7, float scale_3, float distance_to_light_3, uint light_id_7) {\nfloat sum_2 = 0.0;\nmat3x3 _e6 = _1bevy_render_maths_orthonormalize(normalize(light_local_7));\nmat3x3 basis_2 = ((_e6 * scale_3) * distance_to_light_3);\nfloat _e11 = sum_2;\nfloat _e18 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(0.125, -0.375), 0.157112, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e11 + _e18);\nfloat _e20 = sum_2;\nfloat _e27 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(-0.125, 0.375), 0.157112, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e20 + _e27);\nfloat _e29 = sum_2;\nfloat _e36 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(0.625, 0.125), 0.138651, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e29 + _e36);\nfloat _e38 = sum_2;\nfloat _e45 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(-0.375, -0.625), 0.130251, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e38 + _e45);\nfloat _e47 = sum_2;\nfloat _e54 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(-0.625, 0.625), 0.114946, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e47 + _e54);\nfloat _e56 = sum_2;\nfloat _e63 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(-0.875, -0.125), 0.114946, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e56 + _e63);\nfloat _e65 = sum_2;\nfloat _e72 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(0.375, 0.875), 0.107982, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e65 + _e72);\nfloat _e74 = sum_2;\nfloat _e81 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_cubemap_at_offset(vec2(0.875, -0.875), 0.079001, basis_2[0], basis_2[1], light_local_7, depth_7, light_id_7);\nsum_2 = (_e74 + _e81);\nfloat _e83 = sum_2;\nreturn _e83;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_2sample_shadow_cubemap(vec3 light_local_8, float distance_to_light_4, float depth_8, uint light_id_8, vec2 frag_coord_xy_2) {\nfloat _e6 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_gaussian(light_local_8, depth_8, _1bevy_pbr_render_1shadow_sampling_2POINT_SHADOW_SCALE, distance_to_light_4, light_id_8);\nreturn _e6;\n}\nfloat _1bevy_pbr_render_shadows_2fetch_point_shadow(uint light_id_9, vec4 frag_position, vec3 surface_normal, vec2 frag_coord_xy_3) {\nvec4 _e8 = _group_0_binding_8_fs.data[light_id_9].position_radius;\nvec3 surface_to_light = (_e8.xyz - frag_position.xyz);\nvec3 surface_to_light_abs = abs(surface_to_light);\nfloat distance_to_light_5 = max(surface_to_light_abs.x, max(surface_to_light_abs.y, surface_to_light_abs.z));\nfloat _e19 = _group_0_binding_8_fs.data[light_id_9].shadow_normal_bias;\nvec3 normal_offset = ((_e19 * distance_to_light_5) * surface_normal.xyz);\nfloat _e24 = _group_0_binding_8_fs.data[light_id_9].shadow_depth_bias;\nvec3 depth_offset = (_e24 * normalize(surface_to_light.xyz));\nvec3 offset_position_1 = ((frag_position.xyz + normal_offset) + depth_offset);\nvec4 _e33 = _group_0_binding_8_fs.data[light_id_9].position_radius;\nvec3 frag_ls = (offset_position_1.xyz - _e33.xyz);\nvec3 abs_position_ls = abs(frag_ls);\nfloat major_axis_magnitude = max(abs_position_ls.x, max(abs_position_ls.y, abs_position_ls.z));\nvec4 _e44 = _group_0_binding_8_fs.data[light_id_9].light_custom_data;\nvec4 _e48 = _group_0_binding_8_fs.data[light_id_9].light_custom_data;\nvec2 zw = ((-(major_axis_magnitude) * _e44.xy) + _e48.zw);\nfloat depth_16 = (zw.x / zw.y);\nfloat _e55 = _group_0_binding_8_fs.data[light_id_9].soft_shadow_size;\nif ((_e55 > 0.0)) {\nfloat _e61 = _group_0_binding_8_fs.data[light_id_9].soft_shadow_size;\nfloat _e62 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_cubemap_pcss((frag_ls * _1bevy_pbr_render_shadows_1flip_z), distance_to_light_5, depth_16, light_id_9, _e61, frag_coord_xy_3);\nreturn _e62;\n}\nfloat _e65 = _1bevy_pbr_render_1shadow_sampling_2sample_shadow_cubemap((frag_ls * _1bevy_pbr_render_shadows_1flip_z), distance_to_light_5, depth_16, light_id_9, frag_coord_xy_3);\nreturn _e65;\n}\nfloat _1bevy_pbr_render_1pbr_lighting_getRangeFalloff(float distanceSquare, float inverseRangeSquared) {\nfloat factor = (distanceSquare * inverseRangeSquared);\nfloat smoothFactor = clamp((1.0 - (factor * factor)), 0.0, 1.0);\nreturn (smoothFactor * smoothFactor);\n}\nfloat _1bevy_pbr_render_1pbr_lighting_getDistanceAttenuation(float distanceSquare_1, float inverseRangeSquared_1) {\nfloat _e2 = _1bevy_pbr_render_1pbr_lighting_getRangeFalloff(distanceSquare_1, inverseRangeSquared_1);\nreturn ((_e2 * 1.0) / max(distanceSquare_1, 0.0001));\n}\nvec4 _1bevy_pbr_render_1pbr_lighting_6compute_specular_layer_values_for_point_light(inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_, uint layer, vec3 V_1, vec3 light_to_frag, float light_radius, float distance_) {\nfloat LtFdotR = 0.0;\nvec3 R = input_.layers[layer].R;\nfloat a_3 = input_.layers[layer].roughness;\nLtFdotR = dot(light_to_frag, R);\nfloat _e16 = LtFdotR;\nLtFdotR = max(0.0001, _e16);\nfloat _e19 = LtFdotR;\nvec3 centerToRay = ((_e19 * R) - light_to_frag);\nvec3 closestPoint = (light_to_frag + (centerToRay * clamp((light_radius * inversesqrt(dot(centerToRay, centerToRay))), 0.0, 1.0)));\nfloat LspecLengthInverse = inversesqrt(dot(closestPoint, closestPoint));\nfloat a_prime = clamp((a_3 + (light_radius / (2.0 * distance_))), 0.0, 1.0);\nvec3 L_1 = (closestPoint * LspecLengthInverse);\nreturn vec4(L_1, a_prime);\n}\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput _1bevy_pbr_render_1pbr_lighting_2derive_lighting_input(vec3 N, vec3 V_2, vec3 L) {\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput input_1 = _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput(vec3(0.0), 0.0, 0.0, 0.0);\nvec3 H = vec3(0.0);\nH = normalize((L + V_2));\nvec3 _e8 = H;\ninput_1.H = _e8;\ninput_1.NdotL = clamp(dot(N, L), 0.0, 1.0);\nvec3 _e13 = H;\ninput_1.NdotH = clamp(dot(N, _e13), 0.0, 1.0);\nvec3 _e17 = H;\ninput_1.LdotH = clamp(dot(L, _e17), 0.0, 1.0);\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput _e20 = input_1;\nreturn _e20;\n}\nfloat _1bevy_pbr_render_1pbr_lighting_2specular_fix_remap(float a_1) {\nfloat inv_a_sq = ((1.0 - a_1) * (1.0 - a_1));\nreturn (1.0 - (inv_a_sq * inv_a_sq));\n}\nfloat _1bevy_pbr_render_1pbr_lighting_1D_GGX(float roughness, float NdotH) {\nfloat oneMinusNdotHSquared = (1.0 - (NdotH * NdotH));\nfloat a_4 = (NdotH * roughness);\nfloat k = (roughness / (oneMinusNdotHSquared + (a_4 * a_4)));\nfloat d = ((k * k) * 0.31830987);\nreturn d;\n}\nfloat _1bevy_pbr_render_1pbr_lighting_1V_SmithGGXCorrelated(float roughness_1, float NdotV_1, float NdotL) {\nfloat a2_ = (roughness_1 * roughness_1);\nfloat lambdaV = (NdotL * sqrt((((NdotV_1 - (a2_ * NdotV_1)) * NdotV_1) + a2_)));\nfloat lambdaL = (NdotV_1 * sqrt((((NdotL - (a2_ * NdotL)) * NdotL) + a2_)));\nfloat v = (0.5 / (lambdaV + lambdaL));\nreturn v;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_2F_Schlick_vec(vec3 f0_, float f90_, float VdotH) {\nreturn (f0_ + ((vec3(f90_) - f0_) * pow((1.0 - VdotH), 5.0)));\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_fresnel(vec3 f0_1, float LdotH) {\nfloat f90_2 = clamp(dot(f0_1, vec3(16.5)), 0.0, 1.0);\nvec3 _e6 = _1bevy_pbr_render_1pbr_lighting_2F_Schlick_vec(f0_1, f90_2, LdotH);\nreturn _e6;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_1specular_multiscatter(float D, float V_3, vec3 F, vec3 F0_, vec2 F_ab, float specular_intensity) {\nvec3 Fr = vec3(0.0);\nFr = (((specular_intensity * D) * V_3) * F);\nvec3 _e10 = Fr;\nFr = (_e10 * (vec3(1.0) + (F0_ * ((1.0 / (F_ab.x + F_ab.y)) - 1.0))));\nvec3 _e23 = Fr;\nreturn _e23;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_specular(inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_2, inout _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput derived_input, float roughness_2, float specular_intensity_1) {\nfloat NdotV_4 = input_2.layers[0].NdotV;\nvec3 _e9 = input_2.F0_dielectric;\nvec3 _e11 = input_2.F0_metallic;\nfloat _e13 = input_2.metallic;\nvec3 F0_2 = mix(_e9, _e11, _e13);\nfloat NdotL_1 = derived_input.NdotL;\nfloat NdotH_1 = derived_input.NdotH;\nfloat LdotH_1 = derived_input.LdotH;\nfloat _e21 = _1bevy_pbr_render_1pbr_lighting_1D_GGX(roughness_2, NdotH_1);\nfloat _e22 = _1bevy_pbr_render_1pbr_lighting_1V_SmithGGXCorrelated(roughness_2, NdotV_4, NdotL_1);\nvec3 _e23 = _1bevy_pbr_render_1pbr_lighting_fresnel(F0_2, LdotH_1);\nvec2 _e25 = input_2.F_ab;\nvec3 _e26 = _1bevy_pbr_render_1pbr_lighting_1specular_multiscatter(_e21, _e22, _e23, F0_2, _e25, specular_intensity_1);\nreturn _e26;\n}\nfloat _1bevy_pbr_render_1pbr_lighting_1F_Schlick(float f0_2, float f90_1, float VdotH_1) {\nreturn (f0_2 + ((f90_1 - f0_2) * pow((1.0 - VdotH_1), 5.0)));\n}\nfloat _1bevy_pbr_render_1pbr_lighting_1Fd_Burley(inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_3, inout _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput derived_input_1) {\nfloat roughness_3 = input_3.layers[0].roughness;\nfloat NdotV_5 = input_3.layers[0].NdotV;\nfloat NdotL_2 = derived_input_1.NdotL;\nfloat LdotH_2 = derived_input_1.LdotH;\nfloat f90_3 = (0.5 + (((2.0 * roughness_3) * LdotH_2) * LdotH_2));\nfloat _e21 = _1bevy_pbr_render_1pbr_lighting_1F_Schlick(1.0, f90_3, NdotL_2);\nfloat _e23 = _1bevy_pbr_render_1pbr_lighting_1F_Schlick(1.0, f90_3, NdotV_5);\nreturn ((_e21 * _e23) * 0.31830987);\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_1point_light(uint light_id_10, inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_4, bool enable_diffuse, bool enable_texture) {\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput specular_derived_input = _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput(vec3(0.0), 0.0, 0.0, 0.0);\nvec3 specular_light = vec3(0.0);\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput derived_input_2 = _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput(vec3(0.0), 0.0, 0.0, 0.0);\nvec3 diffuse = vec3(0.0);\nvec3 color_times_NdotL = vec3(0.0);\nfloat texture_sample = 1.0;\nvec3 diffuse_color_1 = input_4.diffuse_color;\nvec3 P = input_4.P;\nvec3 N_1 = input_4.layers[0].N;\nvec3 V_5 = input_4.V;\nvec4 _e18 = _group_0_binding_8_fs.data[light_id_10].position_radius;\nvec3 light_to_frag_1 = (_e18.xyz - P);\nvec3 L_2 = normalize(light_to_frag_1);\nfloat distance_square = dot(light_to_frag_1, light_to_frag_1);\nfloat distance_5 = sqrt(distance_square);\nfloat _e26 = _group_0_binding_8_fs.data[light_id_10].color_inverse_square_range.w;\nfloat _e27 = _1bevy_pbr_render_1pbr_lighting_getDistanceAttenuation(distance_square, _e26);\nfloat a_5 = input_4.layers[0].roughness;\nfloat _e35 = _group_0_binding_8_fs.data[light_id_10].position_radius.w;\nvec4 _e36 = _1bevy_pbr_render_1pbr_lighting_6compute_specular_layer_values_for_point_light(input_4, _1bevy_pbr_render_1pbr_lighting_1LAYER_BASE, V_5, light_to_frag_1, _e35, distance_5);\nvec3 L_spec = _e36.xyz;\nfloat a_prime_1 = _e36.w;\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput _e39 = _1bevy_pbr_render_1pbr_lighting_2derive_lighting_input(N_1, V_5, L_spec);\nspecular_derived_input = _e39;\nfloat normalizationFactor = (a_5 / a_prime_1);\nfloat specular_intensity_2 = (normalizationFactor * normalizationFactor);\nfloat _e43 = _1bevy_pbr_render_1pbr_lighting_2specular_fix_remap(a_5);\nfloat brdf_roughness = mix(a_5, a_prime_1, _e43);\nvec3 _e45 = _1bevy_pbr_render_1pbr_lighting_specular(input_4, specular_derived_input, brdf_roughness, specular_intensity_2);\nspecular_light = _e45;\nfloat light_radius_1 = _group_0_binding_8_fs.data[light_id_10].position_radius.w;\nif ((light_radius_1 > 0.0)) {\nfloat solid_angle = ((light_radius_1 * light_radius_1) / (distance_5 * distance_5));\nvec3 _e55 = specular_light;\nfloat _e57 = specular_derived_input.NdotL;\nfloat _e59 = specular_derived_input.NdotL;\nspecular_light = (_e55 * clamp((_e57 / max((_e59 + solid_angle), 0.0001)), 0.0, 1.0));\n}\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput _e66 = _1bevy_pbr_render_1pbr_lighting_2derive_lighting_input(N_1, V_5, L_2);\nderived_input_2 = _e66;\nif (enable_diffuse) {\nfloat _e71 = _1bevy_pbr_render_1pbr_lighting_1Fd_Burley(input_4, derived_input_2);\ndiffuse = (diffuse_color_1 * _e71);\n}\nvec3 _e74 = diffuse;\nfloat _e76 = derived_input_2.NdotL;\nvec3 _e78 = specular_light;\nfloat _e80 = specular_derived_input.NdotL;\ncolor_times_NdotL = ((_e74 * _e76) + (_e78 * _e80));\nvec3 _e85 = color_times_NdotL;\nvec4 _e87 = _group_0_binding_8_fs.data[light_id_10].color_inverse_square_range;\nfloat _e91 = texture_sample;\nreturn (((_e85 * _e87.xyz) * _e27) * _e91);\n}\nvec2 _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware(vec2 light_local_9, float depth_9, int array_index) {\nreturn vec2(0.0);\n}\nfloat _1bevy_pbr_render_1shadow_sampling_5search_for_blockers_in_shadow_map(vec2 light_local_10, float depth_10, int array_index_1, float texel_size, float search_size) {\nvec2 sum_3 = vec2(0.0);\nvec2 shadow_map_size = vec2(uvec2(textureSize(_group_0_binding_5_fs, 0).xy));\nvec2 uv_offset_scale = (vec2(search_size) / (texel_size * shadow_map_size));\nvec2 offset0_ = (vec2(0.125, -0.375) * uv_offset_scale);\nvec2 offset1_ = (vec2(-0.125, 0.375) * uv_offset_scale);\nvec2 offset2_ = (vec2(0.625, 0.125) * uv_offset_scale);\nvec2 offset3_ = (vec2(-0.375, -0.625) * uv_offset_scale);\nvec2 offset4_ = (vec2(-0.625, 0.625) * uv_offset_scale);\nvec2 offset5_ = (vec2(-0.875, -0.125) * uv_offset_scale);\nvec2 offset6_ = (vec2(0.375, 0.875) * uv_offset_scale);\nvec2 offset7_ = (vec2(0.875, -0.875) * uv_offset_scale);\nvec2 _e46 = sum_3;\nvec2 _e48 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset0_), depth_10, array_index_1);\nsum_3 = (_e46 + _e48);\nvec2 _e50 = sum_3;\nvec2 _e52 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset1_), depth_10, array_index_1);\nsum_3 = (_e50 + _e52);\nvec2 _e54 = sum_3;\nvec2 _e56 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset2_), depth_10, array_index_1);\nsum_3 = (_e54 + _e56);\nvec2 _e58 = sum_3;\nvec2 _e60 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset3_), depth_10, array_index_1);\nsum_3 = (_e58 + _e60);\nvec2 _e62 = sum_3;\nvec2 _e64 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset4_), depth_10, array_index_1);\nsum_3 = (_e62 + _e64);\nvec2 _e66 = sum_3;\nvec2 _e68 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset5_), depth_10, array_index_1);\nsum_3 = (_e66 + _e68);\nvec2 _e70 = sum_3;\nvec2 _e72 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset6_), depth_10, array_index_1);\nsum_3 = (_e70 + _e72);\nvec2 _e74 = sum_3;\nvec2 _e76 = _1bevy_pbr_render_1shadow_sampling_6search_for_blockers_in_shadow_map_hardware((light_local_10 + offset7_), depth_10, array_index_1);\nsum_3 = (_e74 + _e76);\nfloat _e79 = sum_3.y;\nif ((_e79 == 0.0)) {\nreturn 0.0;\n}\nfloat _e84 = sum_3.x;\nfloat _e86 = sum_3.y;\nreturn (_e84 / _e86);\n}\nfloat _1bevy_pbr_render_1shadow_sampling_map(float min1_, float max1_, float min2_, float max2_, float value) {\nreturn (min2_ + (((value - min1_) * (max2_ - min2_)) / (max1_ - min1_)));\n}\nvec2 _1bevy_pbr_render_1shadow_sampling_5calculate_uv_offset_scale_jimenez_fourteen(float texel_size_1, float blur_size) {\nvec2 shadow_map_size_1 = vec2(uvec2(textureSize(_group_0_binding_5_fs, 0).xy));\nfloat _e9 = _1bevy_pbr_render_1shadow_sampling_map(0.00390625, 0.022949219, 0.015, 0.035, texel_size_1);\nreturn (vec2((_e9 * blur_size)) / (texel_size_1 * shadow_map_size_1));\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware(vec2 light_local_11, float depth_11, int array_index_2) {\nfloat _e5 = texture(_group_0_binding_5_fs, vec3(light_local_11, depth_11));\nreturn _e5;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_4sample_shadow_map_jimenez_fourteen(vec2 light_local_12, float depth_12, int array_index_3, vec2 frag_coord_xy_4, float texel_size_2, float blur_size_1, bool temporal_2) {\nfloat sum_4 = 0.0;\nmat2x2 _e7 = _1bevy_pbr_render_1shadow_sampling_2random_rotation_matrix(frag_coord_xy_4, temporal_2);\nvec2 _e8 = _1bevy_pbr_render_1shadow_sampling_5calculate_uv_offset_scale_jimenez_fourteen(texel_size_2, blur_size_1);\nvec2 sample_offset0_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_0_) * _e8);\nvec2 sample_offset1_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_1_) * _e8);\nvec2 sample_offset2_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_2_) * _e8);\nvec2 sample_offset3_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_3_) * _e8);\nvec2 sample_offset4_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_4_) * _e8);\nvec2 sample_offset5_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_5_) * _e8);\nvec2 sample_offset6_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_6_) * _e8);\nvec2 sample_offset7_1 = ((_e7 * _1bevy_pbr_render_utils_3SPIRAL_OFFSET_7_) * _e8);\nfloat _e35 = sum_4;\nfloat _e37 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset0_1), depth_12, array_index_3);\nsum_4 = (_e35 + _e37);\nfloat _e39 = sum_4;\nfloat _e41 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset1_1), depth_12, array_index_3);\nsum_4 = (_e39 + _e41);\nfloat _e43 = sum_4;\nfloat _e45 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset2_1), depth_12, array_index_3);\nsum_4 = (_e43 + _e45);\nfloat _e47 = sum_4;\nfloat _e49 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset3_1), depth_12, array_index_3);\nsum_4 = (_e47 + _e49);\nfloat _e51 = sum_4;\nfloat _e53 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset4_1), depth_12, array_index_3);\nsum_4 = (_e51 + _e53);\nfloat _e55 = sum_4;\nfloat _e57 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset5_1), depth_12, array_index_3);\nsum_4 = (_e55 + _e57);\nfloat _e59 = sum_4;\nfloat _e61 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset6_1), depth_12, array_index_3);\nsum_4 = (_e59 + _e61);\nfloat _e63 = sum_4;\nfloat _e65 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((light_local_12 + sample_offset7_1), depth_12, array_index_3);\nsum_4 = (_e63 + _e65);\nfloat _e67 = sum_4;\nreturn (_e67 / 8.0);\n}\nfloat _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_pcss(vec2 light_local_13, float depth_13, int array_index_4, vec2 frag_coord_xy_5, float texel_size_3, float light_size_1) {\nfloat _e6 = _1bevy_pbr_render_1shadow_sampling_5search_for_blockers_in_shadow_map(light_local_13, depth_13, array_index_4, texel_size_3, light_size_1);\nfloat blur_size_3 = max((((_e6 - depth_13) * light_size_1) / depth_13), 0.5);\nfloat _e13 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_map_jimenez_fourteen(light_local_13, depth_13, array_index_4, frag_coord_xy_5, texel_size_3, blur_size_3, false);\nreturn _e13;\n}\nfloat _1bevy_pbr_render_1shadow_sampling_4sample_shadow_map_castano_thirteen(vec2 light_local_14, float depth_14, int array_index_5) {\nvec2 base_uv = vec2(0.0);\nfloat sum_5 = 0.0;\nvec2 shadow_map_size_2 = vec2(uvec2(textureSize(_group_0_binding_5_fs, 0).xy));\nvec2 inv_shadow_map_size = (vec2(1.0) / shadow_map_size_2);\nvec2 uv_1 = (light_local_14 * shadow_map_size_2);\nbase_uv = floor((uv_1 + vec2(0.5)));\nfloat _e19 = base_uv.x;\nfloat s = ((uv_1.x + 0.5) - _e19);\nfloat _e25 = base_uv.y;\nfloat t = ((uv_1.y + 0.5) - _e25);\nvec2 _e27 = base_uv;\nbase_uv = (_e27 - vec2(0.5));\nvec2 _e31 = base_uv;\nbase_uv = (_e31 * inv_shadow_map_size);\nfloat uw0_ = (4.0 - (3.0 * s));\nfloat uw2_ = (1.0 + (3.0 * s));\nfloat u0_ = (((3.0 - (2.0 * s)) / uw0_) - 2.0);\nfloat u1_ = ((3.0 + s) / 7.0);\nfloat u2_ = ((s / uw2_) + 2.0);\nfloat vw0_ = (4.0 - (3.0 * t));\nfloat vw2_ = (1.0 + (3.0 * t));\nfloat v0_ = (((3.0 - (2.0 * t)) / vw0_) - 2.0);\nfloat v1_ = ((3.0 + t) / 7.0);\nfloat v2_ = ((t / vw2_) + 2.0);\nfloat _e79 = sum_5;\nvec2 _e81 = base_uv;\nfloat _e85 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e81 + (vec2(u0_, v0_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e79 + ((uw0_ * vw0_) * _e85));\nfloat _e88 = sum_5;\nvec2 _e90 = base_uv;\nfloat _e94 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e90 + (vec2(u1_, v0_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e88 + ((7.0 * vw0_) * _e94));\nfloat _e97 = sum_5;\nvec2 _e99 = base_uv;\nfloat _e103 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e99 + (vec2(u2_, v0_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e97 + ((uw2_ * vw0_) * _e103));\nfloat _e106 = sum_5;\nvec2 _e108 = base_uv;\nfloat _e112 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e108 + (vec2(u0_, v1_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e106 + ((uw0_ * 7.0) * _e112));\nfloat _e115 = sum_5;\nvec2 _e117 = base_uv;\nfloat _e121 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e117 + (vec2(u1_, v1_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e115 + ((7.0 * 7.0) * _e121));\nfloat _e124 = sum_5;\nvec2 _e126 = base_uv;\nfloat _e130 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e126 + (vec2(u2_, v1_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e124 + ((uw2_ * 7.0) * _e130));\nfloat _e133 = sum_5;\nvec2 _e135 = base_uv;\nfloat _e139 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e135 + (vec2(u0_, v2_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e133 + ((uw0_ * vw2_) * _e139));\nfloat _e142 = sum_5;\nvec2 _e144 = base_uv;\nfloat _e148 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e144 + (vec2(u1_, v2_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e142 + ((7.0 * vw2_) * _e148));\nfloat _e151 = sum_5;\nvec2 _e153 = base_uv;\nfloat _e157 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_hardware((_e153 + (vec2(u2_, v2_) * inv_shadow_map_size)), depth_14, array_index_5);\nsum_5 = (_e151 + ((uw2_ * vw2_) * _e157));\nfloat _e160 = sum_5;\nreturn (_e160 * 0.0069444445);\n}\nfloat _1bevy_pbr_render_1shadow_sampling_2sample_shadow_map(vec2 light_local_15, float depth_15, int array_index_6, vec2 frag_coord_xy_6, float texel_size_4) {\nfloat _e5 = _1bevy_pbr_render_1shadow_sampling_4sample_shadow_map_castano_thirteen(light_local_15, depth_15, array_index_6);\nreturn _e5;\n}\nfloat _1bevy_pbr_render_shadows_2fetch_spot_shadow(uint light_id_11, vec4 frag_position_1, vec3 surface_normal_1, float near_z, vec2 frag_coord_xy_7) {\nvec3 spot_dir = vec3(0.0);\nvec4 _e9 = _group_0_binding_8_fs.data[light_id_11].position_radius;\nvec3 surface_to_light_1 = (_e9.xyz - frag_position_1.xyz);\nfloat _e15 = _group_0_binding_8_fs.data[light_id_11].light_custom_data.x;\nfloat _e18 = _group_0_binding_8_fs.data[light_id_11].light_custom_data.y;\nspot_dir = vec3(_e15, 0.0, _e18);\nfloat _e24 = spot_dir.x;\nfloat _e26 = spot_dir.x;\nfloat _e31 = spot_dir.z;\nfloat _e33 = spot_dir.z;\nspot_dir.y = sqrt(max(0.0, ((1.0 - (_e24 * _e26)) - (_e31 * _e33))));\nuint _e40 = _group_0_binding_8_fs.data[light_id_11].flags;\nif (((_e40 & _1bevy_pbr_render_2mesh_view_types_6POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE) != 0u)) {\nfloat _e47 = spot_dir.y;\nspot_dir.y = -(_e47);\n}\nvec3 _e49 = spot_dir;\nvec3 fwd = -(_e49);\nfloat distance_to_light_6 = dot(fwd, surface_to_light_1);\nfloat _e54 = _group_0_binding_8_fs.data[light_id_11].shadow_depth_bias;\nfloat _e60 = _group_0_binding_8_fs.data[light_id_11].shadow_normal_bias;\nvec3 offset_position_2 = ((-(surface_to_light_1) + (_e54 * normalize(surface_to_light_1))) + ((surface_normal_1.xyz * _e60) * distance_to_light_6));\nmat3x3 _e64 = _1bevy_render_maths_orthonormalize(fwd);\nvec3 projected_position = (offset_position_2 * _e64);\nfloat _e67 = _group_0_binding_8_fs.data[light_id_11].spot_light_tan_angle;\nfloat f_div_minus_z = (1.0 / (_e67 * -(projected_position.z)));\nvec2 shadow_xy_ndc = (projected_position.xy * f_div_minus_z);\nvec2 shadow_uv = ((shadow_xy_ndc * vec2(0.5, -0.5)) + vec2(0.5, 0.5));\nfloat depth_17 = (near_z / -(projected_position.z));\nint _e89 = _group_0_binding_1_fs.spot_light_shadowmap_offset;\nint array_index_7 = (int(light_id_11) + _e89);\nfloat _e92 = _group_0_binding_8_fs.data[light_id_11].soft_shadow_size;\nif ((_e92 > 0.0)) {\nfloat _e97 = _group_0_binding_8_fs.data[light_id_11].soft_shadow_size;\nfloat _e98 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_pcss(shadow_uv, depth_17, array_index_7, frag_coord_xy_7, _1bevy_pbr_render_1shadow_sampling_3SPOT_SHADOW_TEXEL_SIZE, _e97);\nreturn _e98;\n}\nfloat _e100 = _1bevy_pbr_render_1shadow_sampling_2sample_shadow_map(shadow_uv, depth_17, array_index_7, frag_coord_xy_7, _1bevy_pbr_render_1shadow_sampling_3SPOT_SHADOW_TEXEL_SIZE);\nreturn _e100;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_1spot_light(uint light_id_12, inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_5, bool enable_diffuse_1) {\nvec3 spot_dir_1 = vec3(0.0);\nfloat texture_sample_1 = 1.0;\nvec3 _e4 = _1bevy_pbr_render_1pbr_lighting_1point_light(light_id_12, input_5, enable_diffuse_1, false);\nfloat _e10 = _group_0_binding_8_fs.data[light_id_12].light_custom_data.x;\nfloat _e13 = _group_0_binding_8_fs.data[light_id_12].light_custom_data.y;\nspot_dir_1 = vec3(_e10, 0.0, _e13);\nfloat _e19 = spot_dir_1.x;\nfloat _e21 = spot_dir_1.x;\nfloat _e26 = spot_dir_1.z;\nfloat _e28 = spot_dir_1.z;\nspot_dir_1.y = sqrt(max(0.0, ((1.0 - (_e19 * _e21)) - (_e26 * _e28))));\nuint _e35 = _group_0_binding_8_fs.data[light_id_12].flags;\nif (((_e35 & _1bevy_pbr_render_2mesh_view_types_6POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE) != 0u)) {\nfloat _e42 = spot_dir_1.y;\nspot_dir_1.y = -(_e42);\n}\nvec4 _e45 = _group_0_binding_8_fs.data[light_id_12].position_radius;\nvec3 _e48 = input_5.P;\nvec3 light_to_frag_2 = (_e45.xyz - _e48.xyz);\nvec3 _e51 = spot_dir_1;\nfloat cd = dot(-(_e51), normalize(light_to_frag_2));\nfloat _e57 = _group_0_binding_8_fs.data[light_id_12].light_custom_data.z;\nfloat _e61 = _group_0_binding_8_fs.data[light_id_12].light_custom_data.w;\nfloat attenuation = clamp(((cd * _e57) + _e61), 0.0, 1.0);\nfloat spot_attenuation = (attenuation * attenuation);\nfloat _e68 = texture_sample_1;\nreturn ((_e4 * spot_attenuation) * _e68);\n}\nuint _1bevy_pbr_render_shadows_2get_cascade_index(uint light_id_13, float view_z_2) {\nuint i = 0u;\nbool loop_init = true;\nwhile(true) {\nif (!loop_init) {\nuint _e19 = i;\ni = (_e19 + 1u);\n}\nloop_init = false;\nuint _e7 = i;\nuint _e9 = _group_0_binding_1_fs.directional_lights[light_id_13].num_cascades;\nif ((_e7 < _e9)) {\n} else {\nbreak;\n}\n{\nuint _e13 = i;\nfloat _e16 = _group_0_binding_1_fs.directional_lights[light_id_13].cascades[_e13].far_bound;\nif ((-(view_z_2) < _e16)) {\nuint _e18 = i;\nreturn _e18;\n}\n}\n}\nuint _e23 = _group_0_binding_1_fs.directional_lights[light_id_13].num_cascades;\nreturn _e23;\n}\nvec4 _1bevy_pbr_render_shadows_4world_to_directional_light_local(uint light_id_14, uint cascade_index, vec4 offset_position) {\nbool local_1 = false;\nbool local_2 = false;\nmat4x4 _e9 = _group_0_binding_1_fs.directional_lights[light_id_14].cascades[cascade_index].clip_from_world;\nvec4 offset_position_clip = (_e9 * offset_position);\nif ((offset_position_clip.w <= 0.0)) {\nreturn vec4(0.0);\n}\nvec3 offset_position_ndc = (offset_position_clip.xyz / vec3(offset_position_clip.w));\nif (!(any(lessThan(offset_position_ndc.xy, vec2(-1.0))))) {\nlocal_1 = (offset_position_ndc.z < 0.0);\n} else {\nlocal_1 = true;\n}\nbool _e32 = local_1;\nif (!(_e32)) {\nlocal_2 = any(greaterThan(offset_position_ndc, vec3(1.0)));\n} else {\nlocal_2 = true;\n}\nbool _e41 = local_2;\nif (_e41) {\nreturn vec4(0.0);\n}\nvec2 flip_correction = vec2(0.5, -0.5);\nvec2 light_local_16 = ((offset_position_ndc.xy * flip_correction) + vec2(0.5, 0.5));\nfloat depth_18 = offset_position_ndc.z;\nreturn vec4(light_local_16, depth_18, 1.0);\n}\nfloat _1bevy_pbr_render_shadows_2sample_directional_cascade(uint light_id_15, uint cascade_index_1, vec4 frag_position_2, vec3 surface_normal_2, vec2 frag_coord_xy_8) {\nfloat _e11 = _group_0_binding_1_fs.directional_lights[light_id_15].shadow_normal_bias;\nfloat _e13 = _group_0_binding_1_fs.directional_lights[light_id_15].cascades[cascade_index_1].texel_size;\nvec3 normal_offset_1 = ((_e11 * _e13) * surface_normal_2.xyz);\nfloat _e18 = _group_0_binding_1_fs.directional_lights[light_id_15].shadow_depth_bias;\nvec3 _e20 = _group_0_binding_1_fs.directional_lights[light_id_15].direction_to_light;\nvec3 depth_offset_1 = (_e18 * _e20.xyz);\nvec4 offset_position_3 = vec4(((frag_position_2.xyz + normal_offset_1) + depth_offset_1), frag_position_2.w);\nvec4 _e28 = _1bevy_pbr_render_shadows_4world_to_directional_light_local(light_id_15, cascade_index_1, offset_position_3);\nif ((_e28.w == 0.0)) {\nreturn 1.0;\n}\nuint _e34 = _group_0_binding_1_fs.directional_lights[light_id_15].depth_texture_base_index;\nint array_index_8 = int((_e34 + cascade_index_1));\nfloat texel_size_5 = _group_0_binding_1_fs.directional_lights[light_id_15].cascades[cascade_index_1].texel_size;\nfloat _e40 = _group_0_binding_1_fs.directional_lights[light_id_15].soft_shadow_size;\nif ((_e40 > 0.0)) {\nfloat _e46 = _group_0_binding_1_fs.directional_lights[light_id_15].soft_shadow_size;\nfloat _e47 = _1bevy_pbr_render_1shadow_sampling_3sample_shadow_map_pcss(_e28.xy, _e28.z, array_index_8, frag_coord_xy_8, texel_size_5, _e46);\nreturn _e47;\n}\nfloat _e50 = _1bevy_pbr_render_1shadow_sampling_2sample_shadow_map(_e28.xy, _e28.z, array_index_8, frag_coord_xy_8, texel_size_5);\nreturn _e50;\n}\nfloat _1bevy_pbr_render_shadows_2fetch_directional_shadow(uint light_id_16, vec4 frag_position_3, vec3 surface_normal_3, float view_z_3, vec2 frag_coord_xy_9) {\nfloat shadow = 0.0;\nuint _e8 = _1bevy_pbr_render_shadows_2get_cascade_index(light_id_16, view_z_3);\nuint _e10 = _group_0_binding_1_fs.directional_lights[light_id_16].num_cascades;\nif ((_e8 >= _e10)) {\nreturn 1.0;\n}\nfloat _e13 = _1bevy_pbr_render_shadows_2sample_directional_cascade(light_id_16, _e8, frag_position_3, surface_normal_3, frag_coord_xy_9);\nshadow = _e13;\nuint next_cascade_index = (_e8 + 1u);\nuint _e18 = _group_0_binding_1_fs.directional_lights[light_id_16].num_cascades;\nif ((next_cascade_index < _e18)) {\nfloat this_far_bound = _group_0_binding_1_fs.directional_lights[light_id_16].cascades[_e8].far_bound;\nfloat _e25 = _group_0_binding_1_fs.directional_lights[light_id_16].cascades_overlap_proportion;\nfloat next_near_bound = ((1.0 - _e25) * this_far_bound);\nif ((-(view_z_3) >= next_near_bound)) {\nfloat _e31 = _1bevy_pbr_render_shadows_2sample_directional_cascade(light_id_16, next_cascade_index, frag_position_3, surface_normal_3, frag_coord_xy_9);\nfloat _e32 = shadow;\nshadow = mix(_e32, _e31, ((-(view_z_3) - next_near_bound) / (this_far_bound - next_near_bound)));\n}\n}\nfloat _e38 = shadow;\nreturn _e38;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_1directional_light(uint light_id_17, inout _1bevy_pbr_render_1pbr_lighting_LightingInput input_6, bool enable_diffuse_2) {\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput derived_input_3 = _1bevy_pbr_render_1pbr_lighting_DerivedLightingInput(vec3(0.0), 0.0, 0.0, 0.0);\nvec3 diffuse_1 = vec3(0.0);\nvec3 color_1 = vec3(0.0);\nfloat texture_sample_2 = 1.0;\nvec3 diffuse_color_2 = input_6.diffuse_color;\nfloat NdotV_6 = input_6.layers[0].NdotV;\nvec3 N_2 = input_6.layers[0].N;\nvec3 V_6 = input_6.V;\nfloat roughness_4 = input_6.layers[0].roughness;\nvec3 _e23 = _group_0_binding_1_fs.directional_lights[light_id_17].direction_to_light;\nvec3 L_3 = _e23.xyz;\n_1bevy_pbr_render_1pbr_lighting_DerivedLightingInput _e25 = _1bevy_pbr_render_1pbr_lighting_2derive_lighting_input(N_2, V_6, L_3);\nderived_input_3 = _e25;\nif (enable_diffuse_2) {\nfloat _e30 = _1bevy_pbr_render_1pbr_lighting_1Fd_Burley(input_6, derived_input_3);\ndiffuse_1 = (diffuse_color_2 * _e30);\n}\nvec3 _e33 = _1bevy_pbr_render_1pbr_lighting_specular(input_6, derived_input_3, roughness_4, 1.0);\nvec3 _e35 = diffuse_1;\nfloat _e38 = derived_input_3.NdotL;\ncolor_1 = ((_e35 + _e33) * _e38);\nvec3 _e42 = color_1;\nvec4 _e44 = _group_0_binding_1_fs.directional_lights[light_id_17].color;\nfloat _e46 = texture_sample_2;\ncolor_1 = (_e42 * (_e44.xyz * _e46));\nvec3 _e49 = color_1;\nreturn _e49;\n}\nvec3 _1bevy_pbr_render_1pbr_lighting_EnvBRDFApprox(vec3 F0_1, vec2 F_ab_1) {\nreturn ((F0_1 * F_ab_1.x) + vec3(F_ab_1.y));\n}\nvec3 _1bevy_pbr_render_1pbr_ambient_1ambient_light(vec4 world_position_1, vec3 world_normal_1, vec3 V_4, float NdotV_2, vec3 diffuse_color, vec3 specular_color, float perceptual_roughness_3, vec3 occlusion) {\nvec2 _e9 = _1bevy_pbr_render_1pbr_lighting_1F_AB(1.0, NdotV_2);\nvec3 _e10 = _1bevy_pbr_render_1pbr_lighting_EnvBRDFApprox(diffuse_color, _e9);\nvec2 _e11 = _1bevy_pbr_render_1pbr_lighting_1F_AB(perceptual_roughness_3, NdotV_2);\nvec3 _e12 = _1bevy_pbr_render_1pbr_lighting_EnvBRDFApprox(specular_color, _e11);\nfloat specular_occlusion_1 = clamp(dot(specular_color, vec3(16.5)), 0.0, 1.0);\nvec4 _e21 = _group_0_binding_1_fs.ambient_color;\nreturn (((_e10 + (_e12 * specular_occlusion_1)) * _e21.xyz) * occlusion);\n}\nvec4 _1bevy_pbr_render_1clustered_forward_2cluster_debug_visualization(vec4 input_color, float view_z_4, bool is_orthographic_3, _1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges clusterable_object_index_ranges, uint cluster_index_1) {\nvec4 output_color_1 = vec4(0.0);\noutput_color_1 = input_color;\nvec4 _e6 = output_color_1;\nreturn _e6;\n}\nvec4 _1bevy_pbr_render_1pbr_functions_2apply_pbr_lighting(_1bevy_pbr_render_1pbr_types_PbrInput in_3) {\nvec4 output_color_2 = vec4(0.0);\nvec3 direct_light = vec3(0.0);\nvec3 transmitted_light = vec3(0.0);\n_1bevy_pbr_render_1pbr_lighting_LightingInput lighting_input = _1bevy_pbr_render_1pbr_lighting_LightingInput(_1bevy_pbr_render_1pbr_lighting_LayerLightingInput[1](_1bevy_pbr_render_1pbr_lighting_LayerLightingInput(vec3(0.0), vec3(0.0), 0.0, 0.0, 0.0)), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), vec2(0.0));\n_1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges clusterable_object_index_ranges_1 = _1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges(0u, 0u, 0u, 0u, 0u, 0u, 0u);\nuint i_1 = 0u;\nfloat shadow_1 = 0.0;\nbool local_3 = false;\nuint i_2 = 0u;\nfloat shadow_2 = 0.0;\nbool local_4 = false;\nuint i_3 = 0u;\nfloat shadow_3 = 0.0;\nbool local_5 = false;\nvec3 light_contrib = vec3(0.0);\nvec3 indirect_light = vec3(0.0);\nbool found_diffuse_indirect = false;\nbool raea_gi_found = false;\nbool local_6 = false;\nvec3 specular_transmitted_environment_light = vec3(0.0);\nvec3 emissive_light = vec3(0.0);\noutput_color_2 = in_3.material.base_color;\nvec4 emissive_2 = in_3.material.emissive;\nfloat metallic_4 = in_3.material.metallic;\nfloat perceptual_roughness_4 = in_3.material.perceptual_roughness;\nfloat _e10 = _1bevy_pbr_render_1pbr_lighting_perceptualRoughnessToRoughness(perceptual_roughness_4);\nfloat ior = in_3.material.ior;\nfloat thickness_1 = in_3.material.thickness;\nvec3 reflectance_2 = in_3.material.reflectance;\nfloat diffuse_transmission_2 = in_3.material.diffuse_transmission;\nfloat specular_transmission_2 = in_3.material.specular_transmission;\nvec3 specular_transmissive_color = (specular_transmission_2 * in_3.material.base_color.xyz);\nvec3 diffuse_occlusion_1 = in_3.diffuse_occlusion;\nfloat specular_occlusion_2 = in_3.specular_occlusion;\nfloat NdotV_7 = max(dot(in_3.N, in_3.V), 0.0001);\nvec3 R_1 = reflect(-(in_3.V), in_3.N);\nvec4 _e36 = output_color_2;\nvec3 _e38 = _1bevy_pbr_render_1pbr_functions_2calculate_diffuse_color(_e36.xyz, metallic_4, specular_transmission_2, diffuse_transmission_2);\nvec4 _e39 = output_color_2;\nvec3 diffuse_transmissive_color = (((_e39.xyz * (1.0 - metallic_4)) * (1.0 - specular_transmission_2)) * diffuse_transmission_2);\nvec4 diffuse_transmissive_lobe_world_position = (in_3.world_position - (vec4(in_3.world_normal, 0.0) * thickness_1));\nvec4 _e54 = output_color_2;\nvec3 _e56 = _1bevy_pbr_render_1pbr_functions_1calculate_F0_(_e54.xyz, metallic_4, reflectance_2);\nvec2 _e57 = _1bevy_pbr_render_1pbr_lighting_1F_AB(perceptual_roughness_4, NdotV_7);\nlighting_input.layers[0].NdotV = NdotV_7;\nlighting_input.layers[0].N = in_3.N;\nlighting_input.layers[0].R = R_1;\nlighting_input.layers[0].perceptual_roughness = perceptual_roughness_4;\nlighting_input.layers[0].roughness = _e10;\nlighting_input.P = in_3.world_position.xyz;\nlighting_input.V = in_3.V;\nlighting_input.diffuse_color = _e38;\nlighting_input.metallic = metallic_4;\nvec3 _e89 = _1bevy_pbr_render_1pbr_functions_2calculate_F0_dielectric(reflectance_2);\nlighting_input.F0_dielectric = _e89;\nvec4 _e91 = output_color_2;\nlighting_input.F0_metallic = _e91.xyz;\nlighting_input.F_ab = _e57;\nfloat _e98 = _group_0_binding_0_fs.view_from_world[0][2];\nfloat _e103 = _group_0_binding_0_fs.view_from_world[1][2];\nfloat _e108 = _group_0_binding_0_fs.view_from_world[2][2];\nfloat _e113 = _group_0_binding_0_fs.view_from_world[3][2];\nfloat view_z_5 = dot(vec4(_e98, _e103, _e108, _e113), in_3.world_position);\nuint _e120 = _1bevy_pbr_render_1clustered_forward_3view_fragment_cluster_index(in_3.frag_coord.xy, view_z_5, in_3.is_orthographic);\n_1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges _e121 = _1bevy_pbr_render_1clustered_forward_4unpack_clusterable_object_index_ranges(_e120);\nclusterable_object_index_ranges_1 = _e121;\nuint _e124 = clusterable_object_index_ranges_1.first_point_light_index_offset;\ni_1 = _e124;\nbool loop_init_1 = true;\nwhile(true) {\nif (!loop_init_1) {\nuint _e164 = i_1;\ni_1 = (_e164 + 1u);\n}\nloop_init_1 = false;\nuint _e126 = i_1;\nuint _e128 = clusterable_object_index_ranges_1.first_spot_light_index_offset;\nif ((_e126 < _e128)) {\n} else {\nbreak;\n}\n{\nuint _e130 = i_1;\nuint _e131 = _1bevy_pbr_render_1clustered_forward_3get_clusterable_object_id(_e130);\nshadow_1 = 1.0;\nif (((in_3.flags & _1bevy_pbr_render_1mesh_types_4MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u)) {\nuint _e146 = _group_0_binding_8_fs.data[_e131].flags;\nlocal_3 = ((_e146 & _1bevy_pbr_render_2mesh_view_types_5POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u);\n} else {\nlocal_3 = false;\n}\nbool _e152 = local_3;\nif (_e152) {\nfloat _e157 = _1bevy_pbr_render_shadows_2fetch_point_shadow(_e131, in_3.world_position, in_3.world_normal, in_3.frag_coord.xy);\nshadow_1 = _e157;\n}\nvec3 _e159 = _1bevy_pbr_render_1pbr_lighting_1point_light(_e131, lighting_input, true, true);\nvec3 _e160 = direct_light;\nfloat _e161 = shadow_1;\ndirect_light = (_e160 + (_e159 * _e161));\n}\n}\nuint _e168 = clusterable_object_index_ranges_1.first_spot_light_index_offset;\ni_2 = _e168;\nbool loop_init_2 = true;\nwhile(true) {\nif (!loop_init_2) {\nuint _e212 = i_2;\ni_2 = (_e212 + 1u);\n}\nloop_init_2 = false;\nuint _e170 = i_2;\nuint _e172 = clusterable_object_index_ranges_1.first_rect_light_index_offset;\nif ((_e170 < _e172)) {\n} else {\nbreak;\n}\n{\nuint _e174 = i_2;\nuint _e175 = _1bevy_pbr_render_1clustered_forward_3get_clusterable_object_id(_e174);\nshadow_2 = 1.0;\nif (((in_3.flags & _1bevy_pbr_render_1mesh_types_4MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u)) {\nuint _e190 = _group_0_binding_8_fs.data[_e175].flags;\nlocal_4 = ((_e190 & _1bevy_pbr_render_2mesh_view_types_5POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u);\n} else {\nlocal_4 = false;\n}\nbool _e196 = local_4;\nif (_e196) {\nfloat _e203 = _group_0_binding_8_fs.data[_e175].shadow_map_near_z;\nfloat _e206 = _1bevy_pbr_render_shadows_2fetch_spot_shadow(_e175, in_3.world_position, in_3.world_normal, _e203, in_3.frag_coord.xy);\nshadow_2 = _e206;\n}\nvec3 _e207 = _1bevy_pbr_render_1pbr_lighting_1spot_light(_e175, lighting_input, true);\nvec3 _e208 = direct_light;\nfloat _e209 = shadow_2;\ndirect_light = (_e208 + (_e207 * _e209));\n}\n}\nuint n_directional_lights = _group_0_binding_1_fs.n_directional_lights;\nbool loop_init_3 = true;\nwhile(true) {\nif (!loop_init_3) {\nuint _e265 = i_3;\ni_3 = (_e265 + 1u);\n}\nloop_init_3 = false;\nuint _e220 = i_3;\nif ((_e220 < n_directional_lights)) {\n} else {\nbreak;\n}\n{\nuint _e224 = i_3;\nshadow_3 = 1.0;\nif (((in_3.flags & _1bevy_pbr_render_1mesh_types_4MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u)) {\nuint _e238 = i_3;\nuint _e241 = _group_0_binding_1_fs.directional_lights[_e238].flags;\nlocal_5 = ((_e241 & _1bevy_pbr_render_2mesh_view_types_5DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u);\n} else {\nlocal_5 = false;\n}\nbool _e247 = local_5;\nif (_e247) {\nuint _e248 = i_3;\nfloat _e253 = _1bevy_pbr_render_shadows_2fetch_directional_shadow(_e248, in_3.world_position, in_3.world_normal, view_z_5, in_3.frag_coord.xy);\nshadow_3 = _e253;\nfloat _e254 = shadow_3;\nshadow_3 = (_e254 * in_3.directional_shadow_factor);\n}\nuint _e257 = i_3;\nvec3 _e258 = _1bevy_pbr_render_1pbr_lighting_1directional_light(_e257, lighting_input, true);\nlight_contrib = _e258;\nvec3 _e260 = direct_light;\nvec3 _e261 = light_contrib;\nfloat _e262 = shadow_3;\ndirect_light = (_e260 + (_e261 * _e262));\n}\n}\nbool _e275 = found_diffuse_indirect;\nif (!(_e275)) {\nivec2 gi_size = ivec2(uvec2(textureSize(_group_0_binding_41_fs, 0).xy));\nvec4 gi = texelFetch(_group_0_binding_41_fs, min(ivec2(in_3.frag_coord.xy), (gi_size - ivec2(1))), 0);\nif ((gi.w > 0.0)) {\nvec3 _e293 = indirect_light;\nindirect_light = (_e293 + ((gi.xyz * _e38) * diffuse_occlusion_1));\nfound_diffuse_indirect = true;\nraea_gi_found = true;\n}\n}\nif (true) {\nbool _e303 = raea_gi_found;\nlocal_6 = !(_e303);\n} else {\nlocal_6 = false;\n}\nbool _e306 = local_6;\nif (_e306) {\nvec3 _e307 = indirect_light;\nvec3 _e311 = _1bevy_pbr_render_1pbr_ambient_1ambient_light(in_3.world_position, in_3.N, in_3.V, NdotV_7, _e38, _e56, perceptual_roughness_4, diffuse_occlusion_1);\nindirect_light = (_e307 + _e311);\n}\nfloat _e317 = output_color_2.w;\nemissive_light = (emissive_2.xyz * _e317);\nvec3 _e320 = emissive_light;\nfloat _e323 = _group_0_binding_0_fs.exposure;\nemissive_light = (_e320 * mix(1.0, _e323, emissive_2.w));\nfloat _e330 = _group_0_binding_0_fs.exposure;\nvec3 _e331 = transmitted_light;\nvec3 _e332 = direct_light;\nvec3 _e334 = indirect_light;\nvec3 _e337 = emissive_light;\nfloat _e340 = output_color_2.w;\noutput_color_2 = vec4(((_e330 * ((_e331 + _e332) + _e334)) + _e337), _e340);\nvec4 _e342 = output_color_2;\n_1bevy_pbr_render_1clustered_forward_ClusterableObjectIndexRanges _e344 = clusterable_object_index_ranges_1;\nvec4 _e345 = _1bevy_pbr_render_1clustered_forward_2cluster_debug_visualization(_e342, view_z_5, in_3.is_orthographic, _e344, _e120);\noutput_color_2 = _e345;\nvec4 _e346 = output_color_2;\nreturn _e346;\n}\nvec3 _1bevy_pbr_render_1view_transformations_3position_world_to_view(vec3 world_pos) {\nmat4x4 _e3 = _group_0_binding_0_fs.view_from_world;\nvec4 view_pos = (_e3 * vec4(world_pos, 1.0));\nreturn view_pos.xyz;\n}\nvec4 _1bevy_pbr_render_fog_3scattering_adjusted_fog_color(_1bevy_pbr_render_2mesh_view_types_Fog fog_params, vec3 scattering) {\nif ((fog_params.directional_light_color.w > 0.0)) {\nreturn vec4((fog_params.base_color.xyz + ((scattering * fog_params.directional_light_color.xyz) * fog_params.directional_light_color.w)), fog_params.base_color.w);\n} else {\nreturn fog_params.base_color;\n}\n}\nvec4 _1bevy_pbr_render_fog_1linear_fog(_1bevy_pbr_render_2mesh_view_types_Fog fog_params_1, vec4 input_color_1, float distance_1, vec3 scattering_1) {\nvec4 fog_color = vec4(0.0);\nvec4 _e4 = _1bevy_pbr_render_fog_3scattering_adjusted_fog_color(fog_params_1, scattering_1);\nfog_color = _e4;\nfloat start = fog_params_1.be.x;\nfloat end = fog_params_1.be.y;\nfloat _e11 = fog_color.w;\nfog_color.w = (_e11 * (1.0 - clamp(((end - distance_1) / (end - start)), 0.0, 1.0)));\nvec4 _e22 = fog_color;\nfloat _e25 = fog_color.w;\nreturn vec4(mix(input_color_1.xyz, _e22.xyz, _e25), input_color_1.w);\n}\nvec4 _1bevy_pbr_render_fog_1exponential_fog(_1bevy_pbr_render_2mesh_view_types_Fog fog_params_2, vec4 input_color_2, float distance_2, vec3 scattering_2) {\nvec4 fog_color_1 = vec4(0.0);\nvec4 _e4 = _1bevy_pbr_render_fog_3scattering_adjusted_fog_color(fog_params_2, scattering_2);\nfog_color_1 = _e4;\nfloat density = fog_params_2.be.x;\nfloat _e9 = fog_color_1.w;\nfog_color_1.w = (_e9 * (1.0 - (1.0 / exp((distance_2 * density)))));\nvec4 _e18 = fog_color_1;\nfloat _e21 = fog_color_1.w;\nreturn vec4(mix(input_color_2.xyz, _e18.xyz, _e21), input_color_2.w);\n}\nvec4 _1bevy_pbr_render_fog_2exponential_squared_fog(_1bevy_pbr_render_2mesh_view_types_Fog fog_params_3, vec4 input_color_3, float distance_3, vec3 scattering_3) {\nvec4 fog_color_2 = vec4(0.0);\nvec4 _e4 = _1bevy_pbr_render_fog_3scattering_adjusted_fog_color(fog_params_3, scattering_3);\nfog_color_2 = _e4;\nfloat distance_times_density = (distance_3 * fog_params_3.be.x);\nfloat _e10 = fog_color_2.w;\nfog_color_2.w = (_e10 * (1.0 - (1.0 / exp((distance_times_density * distance_times_density)))));\nvec4 _e19 = fog_color_2;\nfloat _e22 = fog_color_2.w;\nreturn vec4(mix(input_color_3.xyz, _e19.xyz, _e22), input_color_3.w);\n}\nvec4 _1bevy_pbr_render_fog_1atmospheric_fog(_1bevy_pbr_render_2mesh_view_types_Fog fog_params_4, vec4 input_color_4, float distance_4, vec3 scattering_4) {\nvec4 fog_color_3 = vec4(0.0);\nvec4 _e4 = _1bevy_pbr_render_fog_3scattering_adjusted_fog_color(fog_params_4, scattering_4);\nfog_color_3 = _e4;\nvec3 extinction_factor = (vec3(1.0) - (vec3(1.0) / exp((distance_4 * fog_params_4.be))));\nvec3 inscattering_factor = (vec3(1.0) - (vec3(1.0) / exp((distance_4 * fog_params_4.bi))));\nfloat _e26 = fog_color_3.w;\nvec4 _e32 = fog_color_3;\nfloat _e36 = fog_color_3.w;\nreturn vec4(((input_color_4.xyz * (vec3(1.0) - (extinction_factor * _e26))) + ((_e32.xyz * inscattering_factor) * _e36)), input_color_4.w);\n}\nvec4 _1bevy_pbr_render_1pbr_functions_1apply_fog(_1bevy_pbr_render_2mesh_view_types_Fog fog_params_5, vec4 input_color_5, vec3 fragment_world_position, vec3 view_world_position, vec2 frag_coord_xy_10) {\nvec3 scattering_5 = vec3(0.0);\nuint i_4 = 0u;\nfloat shadow_4 = 0.0;\nvec3 view_to_world = (fragment_world_position.xyz - view_world_position.xyz);\nfloat distance_6 = length(view_to_world);\nvec3 _e9 = _1bevy_pbr_render_1view_transformations_3position_world_to_view(fragment_world_position);\nfloat view_z_6 = _e9.z;\nvec3 view_direction_normal = normalize(-(view_to_world));\nvec4 fragment_world_position_vec4_ = vec4(fragment_world_position, 1.0);\nif ((fog_params_5.directional_light_color.w > 0.0)) {\nvec3 view_to_world_normalized = (view_to_world / vec3(distance_6));\nuint n_directional_lights_1 = _group_0_binding_1_fs.n_directional_lights;\nbool loop_init_4 = true;\nwhile(true) {\nif (!loop_init_4) {\nuint _e62 = i_4;\ni_4 = (_e62 + 1u);\n}\nloop_init_4 = false;\nuint _e29 = i_4;\nif ((_e29 < n_directional_lights_1)) {\n} else {\nbreak;\n}\n{\nuint _e33 = i_4;\n_1bevy_pbr_render_2mesh_view_types_DirectionalLight light = _group_0_binding_1_fs.directional_lights[_e33];\nfloat _e47 = _group_0_binding_0_fs.exposure;\nvec3 scattering_contribution = ((pow(max(dot(view_to_world_normalized, light.direction_to_light), 0.0), fog_params_5.directional_light_exponent) * light.color.xyz) * _e47);\nshadow_4 = 1.0;\nif (((light.flags & _1bevy_pbr_render_2mesh_view_types_5DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u)) {\nuint _e56 = i_4;\nfloat _e57 = _1bevy_pbr_render_shadows_2fetch_directional_shadow(_e56, fragment_world_position_vec4_, view_direction_normal, view_z_6, frag_coord_xy_10);\nshadow_4 = _e57;\n}\nvec3 _e58 = scattering_5;\nfloat _e59 = shadow_4;\nscattering_5 = (_e58 + (scattering_contribution * _e59));\n}\n}\n}\nif ((fog_params_5.mode == _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_LINEAR)) {\nvec3 _e68 = scattering_5;\nvec4 _e69 = _1bevy_pbr_render_fog_1linear_fog(fog_params_5, input_color_5, distance_6, _e68);\nreturn _e69;\n} else {\nif ((fog_params_5.mode == _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_EXPONENTIAL)) {\nvec3 _e73 = scattering_5;\nvec4 _e74 = _1bevy_pbr_render_fog_1exponential_fog(fog_params_5, input_color_5, distance_6, _e73);\nreturn _e74;\n} else {\nif ((fog_params_5.mode == _1bevy_pbr_render_2mesh_view_types_3FOG_MODE_EXPONENTIAL_SQUARED)) {\nvec3 _e78 = scattering_5;\nvec4 _e79 = _1bevy_pbr_render_fog_2exponential_squared_fog(fog_params_5, input_color_5, distance_6, _e78);\nreturn _e79;\n} else {\nif ((fog_params_5.mode == _1bevy_pbr_render_2mesh_view_types_2FOG_MODE_ATMOSPHERIC)) {\nvec3 _e83 = scattering_5;\nvec4 _e84 = _1bevy_pbr_render_fog_1atmospheric_fog(fog_params_5, input_color_5, distance_6, _e83);\nreturn _e84;\n} else {\nreturn input_color_5;\n}\n}\n}\n}\n}\nvec4 _1bevy_pbr_render_1pbr_functions_4main_pass_post_lighting_processing(_1bevy_pbr_render_1pbr_types_PbrInput pbr_input_5, vec4 input_color_6) {\nvec4 output_color_3 = vec4(0.0);\noutput_color_3 = input_color_6;\nif (((pbr_input_5.material.flags & _1bevy_pbr_render_1pbr_types_5STANDARD_MATERIAL_FLAGS_FOG_ENABLED_BIT) != 0u)) {\n_1bevy_pbr_render_2mesh_view_types_Fog _e10 = _group_0_binding_13_fs;\nvec4 _e11 = output_color_3;\nvec3 _e16 = _group_0_binding_0_fs.world_position;\nvec4 _e20 = _1bevy_pbr_render_1pbr_functions_1apply_fog(_e10, _e11, pbr_input_5.world_position.xyz, _e16.xyz, pbr_input_5.frag_coord.xy);\noutput_color_3 = _e20;\n}\nvec4 _e21 = output_color_3;\nreturn _e21;\n}\nvoid main() {\n_1bevy_pbr_render_1forward_io_VertexOutput vertex_output = _1bevy_pbr_render_1forward_io_VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1, _vs2fs_location2, _vs2fs_location6);\nbool is_front = gl_FrontFacing;\n_1bevy_pbr_render_1forward_io_VertexOutput in_ = _1bevy_pbr_render_1forward_io_VertexOutput(vec4(0.0), vec4(0.0), vec3(0.0), vec2(0.0), 0u);\n_1bevy_pbr_render_1pbr_types_PbrInput pbr_input = _1bevy_pbr_render_1pbr_types_PbrInput(_1bevy_pbr_render_1pbr_types_StandardMaterial(vec4(0.0), vec4(0.0), vec4(0.0), mat3x3(0.0), vec3(0.0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, vec2(0.0), 0u, 0.0, 0.0, 0.0, 0.0, 0u, 0u), vec3(0.0), 0.0, vec4(0.0), vec4(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), false, 0u, 0.0);\n_1bevy_pbr_render_1forward_io_FragmentOutput out_ = _1bevy_pbr_render_1forward_io_FragmentOutput(vec4(0.0));\nin_ = vertex_output;\n_1bevy_pbr_render_1forward_io_VertexOutput _e3 = in_;\n_1bevy_pbr_render_1pbr_types_PbrInput _e4 = _1bevy_pbr_render_1pbr_fragment_4pbr_input_from_standard_material(_e3, is_front);\npbr_input = _e4;\nuint _e10 = pbr_input.material.flags;\nfloat _e13 = pbr_input.material.alpha_cutoff;\nvec4 _e16 = pbr_input.material.base_color;\nvec4 _e17 = _1bevy_pbr_render_1pbr_functions_1alpha_discard(_e10, _e13, _e16);\npbr_input.material.base_color = _e17;\n_1bevy_pbr_decal_clustered_1apply_decals(pbr_input);\nuint _e21 = pbr_input.material.flags;\nif (((_e21 & _1bevy_pbr_render_1pbr_types_4STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u)) {\n_1bevy_pbr_render_1pbr_types_PbrInput _e27 = pbr_input;\nvec4 _e28 = _1bevy_pbr_render_1pbr_functions_2apply_pbr_lighting(_e27);\nout_.color = _e28;\n} else {\nvec4 _e32 = pbr_input.material.base_color;\nout_.color = _e32;\n}\n_1bevy_pbr_render_1pbr_types_PbrInput _e34 = pbr_input;\nvec4 _e36 = out_.color;\nvec4 _e37 = _1bevy_pbr_render_1pbr_functions_4main_pass_post_lighting_processing(_e34, _e36);\nout_.color = _e37;\n_1bevy_pbr_render_1forward_io_FragmentOutput _e38 = out_;\n_fs2p_location0 = _e38.color;\nreturn;\n}"; +export const SHADOW_VERT = "#version 300 es\nprecision highp float;\nprecision highp int;\nuniform uint naga_vs_first_instance;\nstruct _1bevy_pbr_prepass_io_Vertex {\nuint instance_index;\nvec3 position;\n};\nstruct _1bevy_pbr_prepass_io_VertexOutput {\nvec4 position;\nvec4 world_position;\nfloat unclipped_depth;\nuint instance_index;\n};\nstruct _1bevy_pbr_prepass_io_UncompressedVertex {\nuint instance_index;\nvec3 position;\n};\nstruct _1bevy_render_mesh_1metadata_types_MeshMetadata {\nvec3 aabb_center;\nuint pad_a;\nvec3 aabb_half_extents;\nuint pad_b;\nvec4 uv_channels_min_and_extents[2];\n};\nstruct _1bevy_pbr_render_1mesh_types_Mesh {\nmat3x4 world_from_local;\nmat3x4 previous_world_from_local;\nmat2x4 local_from_world_transpose_a;\nfloat local_from_world_transpose_b;\nuint flags;\nuvec2 lightmap_uv_rect;\nuint first_vertex_index;\nuint current_skin_index;\nuint material_and_lightmap_bind_group_slot;\nuint tag;\nuint morph_descriptor_index;\nuint metadata_index;\n};\nstruct _1bevy_render_view_ColorGrading {\nmat3x3 balance;\nvec3 saturation;\nvec3 contrast;\nvec3 gamma;\nvec3 gain;\nvec3 lift;\nvec2 midtone_range;\nfloat exposure;\nfloat hue;\nfloat post_saturation;\n};\nstruct _1bevy_render_view_View {\nmat4x4 clip_from_world;\nmat4x4 unjittered_clip_from_world;\nmat4x4 world_from_clip;\nmat4x4 world_from_view;\nmat4x4 view_from_world;\nmat4x4 clip_from_view;\nmat4x4 view_from_clip;\nvec3 world_position;\nfloat exposure;\nvec4 viewport;\nvec4 main_pass_viewport;\nvec4 frustum[6];\nvec3 lod_view_world_position;\n_1bevy_render_view_ColorGrading color_grading;\nfloat mip_bias;\nuint frame_count;\n};\nlayout(std140) uniform _1bevy_render_mesh_1metadata_types_MeshMetadata_block_0Vertex { _1bevy_render_mesh_1metadata_types_MeshMetadata _group_2_binding_9_vs; };\nlayout(std140) uniform type_9_block_1Vertex { _1bevy_pbr_render_1mesh_types_Mesh _group_2_binding_0_vs[93]; };\nlayout(std140) uniform _1bevy_render_view_View_block_2Vertex { _1bevy_render_view_View _group_0_binding_0_vs; };\nlayout(location = 0) in vec3 _p2vs_location0;\nsmooth out vec4 _vs2fs_location4;\nsmooth out float _vs2fs_location6;\nflat out uint _vs2fs_location7;\n_1bevy_render_mesh_1metadata_types_MeshMetadata _1bevy_pbr_render_1mesh_functions_1get_metadata(uint instance_index) {\n_1bevy_render_mesh_1metadata_types_MeshMetadata _e2 = _group_2_binding_9_vs;\nreturn _e2;\n}\n_1bevy_pbr_prepass_io_UncompressedVertex _1bevy_pbr_prepass_io_1decompress_vertex(_1bevy_pbr_prepass_io_Vertex vertex_in, uint instance_index_1) {\n_1bevy_pbr_prepass_io_UncompressedVertex uncompressed_vertex = _1bevy_pbr_prepass_io_UncompressedVertex(0u, vec3(0.0));\n_1bevy_render_mesh_1metadata_types_MeshMetadata _e2 = _1bevy_pbr_render_1mesh_functions_1get_metadata(instance_index_1);\nuncompressed_vertex.instance_index = instance_index_1;\nuncompressed_vertex.position = vertex_in.position;\n_1bevy_pbr_prepass_io_UncompressedVertex _e7 = uncompressed_vertex;\nreturn _e7;\n}\nmat4x4 _1bevy_render_maths_2affine3_to_square(mat3x4 affine) {\nreturn transpose(mat4x4(affine[0], affine[1], affine[2], vec4(0.0, 0.0, 0.0, 1.0)));\n}\nmat4x4 _1bevy_pbr_render_1mesh_functions_3get_world_from_local(uint instance_index_2) {\nmat3x4 _e4 = _group_2_binding_0_vs[instance_index_2].world_from_local;\nmat4x4 _e5 = _1bevy_render_maths_2affine3_to_square(_e4);\nreturn _e5;\n}\nvec4 _1bevy_pbr_render_1mesh_functions_4mesh_position_local_to_world(mat4x4 world_from_local_1, vec4 vertex_position) {\nreturn (world_from_local_1 * vertex_position);\n}\nvec4 _1bevy_pbr_render_1view_transformations_3position_world_to_clip(vec3 world_pos) {\nmat4x4 _e3 = _group_0_binding_0_vs.clip_from_world;\nvec4 clip_pos = (_e3 * vec4(world_pos, 1.0));\nreturn clip_pos;\n}\nvoid main() {\n_1bevy_pbr_prepass_io_Vertex vertex_no_morph = _1bevy_pbr_prepass_io_Vertex((uint(gl_InstanceID) + naga_vs_first_instance), _p2vs_location0);\n_1bevy_pbr_prepass_io_VertexOutput out_ = _1bevy_pbr_prepass_io_VertexOutput(vec4(0.0), vec4(0.0), 0.0, 0u);\n_1bevy_pbr_prepass_io_UncompressedVertex vertex_1 = _1bevy_pbr_prepass_io_UncompressedVertex(0u, vec3(0.0));\nmat4x4 world_from_local = mat4x4(0.0);\n_1bevy_pbr_prepass_io_UncompressedVertex _e3 = _1bevy_pbr_prepass_io_1decompress_vertex(vertex_no_morph, vertex_no_morph.instance_index);\nvertex_1 = _e3;\nmat4x4 _e6 = _1bevy_pbr_render_1mesh_functions_3get_world_from_local(vertex_no_morph.instance_index);\nworld_from_local = _e6;\nmat4x4 _e9 = world_from_local;\nvec3 _e11 = vertex_1.position;\nvec4 _e14 = _1bevy_pbr_render_1mesh_functions_4mesh_position_local_to_world(_e9, vec4(_e11, 1.0));\nout_.world_position = _e14;\nvec4 _e17 = out_.world_position;\nvec4 _e19 = _1bevy_pbr_render_1view_transformations_3position_world_to_clip(_e17.xyz);\nout_.position = _e19;\nfloat _e23 = out_.position.z;\nout_.unclipped_depth = _e23;\nfloat _e28 = out_.position.z;\nout_.position.z = min(_e28, 1.0);\nout_.instance_index = vertex_no_morph.instance_index;\n_1bevy_pbr_prepass_io_VertexOutput _e33 = out_;\ngl_Position = _e33.position;\n_vs2fs_location4 = _e33.world_position;\n_vs2fs_location6 = _e33.unclipped_depth;\n_vs2fs_location7 = _e33.instance_index;\ngl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);\ngl_PointSize = 1.0;\nreturn;\n}"; +export const BLOCKS: Record = {"_1bevy_pbr_render_1pbr_types_StandardMaterial_block_1Fragment":"material","_1bevy_pbr_render_2mesh_view_types_ClusterOffsetsAndCounts_block_4Fragment":"cluster_offsets_and_counts","_1bevy_pbr_render_2mesh_view_types_ClusterableObjectIndexLists_block_5Fragment":"clusterable_object_index_lists","_1bevy_pbr_render_2mesh_view_types_ClusteredLights_block_6Fragment":"clustered_lights","_1bevy_pbr_render_2mesh_view_types_Fog_block_8Fragment":"fog","_1bevy_pbr_render_2mesh_view_types_Lights_block_3Fragment":"lights","_1bevy_render_globals_Globals_block_7Fragment":"globals","_1bevy_render_mesh_1metadata_types_MeshMetadata_block_0Vertex":"metadata","_1bevy_render_view_View_block_2Fragment":"view","_1bevy_render_view_View_block_2Vertex":"view","type_10_block_0Fragment":"mesh","type_10_block_1Vertex":"mesh","type_9_block_1Vertex":"mesh"}; +export const SAMPLERS: Record = {"_group_0_binding_2_fs":"point_shadow_textures","_group_0_binding_41_fs":"raea_gi","_group_0_binding_5_fs":"directional_shadow_textures","_group_3_binding_1_fs":"base_color_texture","_group_3_binding_3_fs":"emissive_texture","_group_3_binding_5_fs":"metallic_roughness_texture","_group_3_binding_7_fs":"occlusion_texture"}; +export const LAYOUT: Record> = {"cluster_offsets_and_counts":{"$size":16384,"data":0,"data[]":16},"clusterable_object_index_lists":{"$size":16384,"data":0,"data[]":16},"clustered_lights":{"$size":16320,"data":0,"data.color_inverse_square_range":16,"data.decal_index":72,"data.flags":48,"data.light_custom_data":0,"data.position_radius":32,"data.range":76,"data.shadow_depth_bias":52,"data.shadow_map_near_z":68,"data.shadow_normal_bias":56,"data.soft_shadow_size":64,"data.spot_light_tan_angle":60,"data[]":80},"fog":{"$size":64,"base_color":0,"be":32,"bi":48,"directional_light_color":16,"directional_light_exponent":44,"mode":60},"globals":{"$size":16,"_webgl2_padding":12,"delta_time":4,"frame_count":8,"time":0},"lights":{"$size":2176,"ambient_color":1600,"ambient_light_flags":1656,"cluster_dimensions":1616,"cluster_factors":1632,"directional_lights":0,"directional_lights.cascades":0,"directional_lights.cascades.clip_from_world":0,"directional_lights.cascades.far_bound":68,"directional_lights.cascades.texel_size":64,"directional_lights.cascades[]":80,"directional_lights.cascades_overlap_proportion":128,"directional_lights.color":80,"directional_lights.decal_index":136,"directional_lights.depth_texture_base_index":132,"directional_lights.direction_to_light":96,"directional_lights.flags":108,"directional_lights.num_cascades":124,"directional_lights.shadow_depth_bias":116,"directional_lights.shadow_normal_bias":120,"directional_lights.soft_shadow_size":112,"directional_lights.sun_disk_angular_size":140,"directional_lights.sun_disk_intensity":144,"directional_lights[]":160,"n_directional_lights":1648,"n_rect_lights":1660,"rect_lights":1664,"rect_lights.color":0,"rect_lights.height":44,"rect_lights.position":16,"rect_lights.range":60,"rect_lights.right":32,"rect_lights.up":48,"rect_lights.width":28,"rect_lights[]":64,"spot_light_shadowmap_offset":1652},"material":{"$size":192,"alpha_cutoff":164,"anisotropy_rotation":152,"anisotropy_strength":144,"attenuation_color":32,"attenuation_distance":132,"base_color":0,"clearcoat":136,"clearcoat_perceptual_roughness":140,"deferred_lighting_pass_id":184,"diffuse_transmission":116,"emissive":16,"flags":160,"ior":128,"lightmap_exposure":176,"max_parallax_layer_count":172,"max_relief_mapping_search_steps":180,"metallic":112,"parallax_depth_scale":168,"perceptual_roughness":108,"reflectance":96,"specular_transmission":120,"thickness":124,"uv_transform":48},"mesh":{"$size":16368,"[]":176,"current_skin_index":148,"first_vertex_index":144,"flags":132,"lightmap_uv_rect":136,"local_from_world_transpose_a":96,"local_from_world_transpose_b":128,"material_and_lightmap_bind_group_slot":152,"metadata_index":164,"morph_descriptor_index":160,"previous_world_from_local":48,"tag":156,"world_from_local":0},"metadata":{"$size":64,"aabb_center":0,"aabb_half_extents":16,"pad_a":12,"pad_b":28,"uv_channels_min_and_extents":32,"uv_channels_min_and_extents[]":16},"view":{"$size":784,"clip_from_view":320,"clip_from_world":0,"color_grading":608,"color_grading.balance":0,"color_grading.contrast":64,"color_grading.exposure":136,"color_grading.gain":96,"color_grading.gamma":80,"color_grading.hue":140,"color_grading.lift":112,"color_grading.midtone_range":128,"color_grading.post_saturation":144,"color_grading.saturation":48,"exposure":460,"frame_count":772,"frustum":496,"frustum[]":16,"lod_view_world_position":592,"main_pass_viewport":480,"mip_bias":768,"unjittered_clip_from_world":64,"view_from_clip":384,"view_from_world":256,"viewport":464,"world_from_clip":128,"world_from_view":192,"world_position":448}}; diff --git a/sdk/playable/src/host/three.ts b/sdk/playable/src/host/three.ts deleted file mode 100644 index 4a1bd6af..00000000 --- a/sdk/playable/src/host/three.ts +++ /dev/null @@ -1,31 +0,0 @@ -// A playable's 3D drawn by three.js (raea's three.js host, sdk/r3f/src/three, through scene.ts), tone-mapped by -// Bevy's own curve (tonemap.ts). The export bundles it only for a game whose lint found a 3D kind (PA15). -import * as THREE from "three"; -import type { Draw3d } from "./draw3d"; -import { Scene3d } from "./scene"; -import { Tonemap } from "./tonemap"; - -export function three3d(canvas: HTMLCanvasElement): Draw3d { - // the 3D is tone-mapped by its own pass (antialiased in its target) and left transparent where nothing was drawn - const renderer = new THREE.WebGLRenderer({ canvas, antialias: false, alpha: true, premultipliedAlpha: true, powerPreference: "high-performance" }); - renderer.shadowMap.enabled = true; - renderer.shadowMap.type = THREE.PCFSoftShadowMap; - const tonemap = new Tonemap(renderer); - const scene = new Scene3d(); - return { - fit(width, height, scale) { - // the canvas is drawn at the screen's pixels, not the composition's - renderer.setPixelRatio(Math.min(2, devicePixelRatio || 1) * scale); - renderer.setSize(width, height, false); - tonemap.resize(); - scene.fit(width, height); - }, - sync(page, seconds) { - scene.sync(page, seconds); - return scene.any; - }, - draw() { - tonemap.render(scene.scene, scene.camera); - }, - }; -} diff --git a/sdk/playable/src/host/tonemap.ts b/sdk/playable/src/host/tonemap.ts deleted file mode 100644 index fa61d79b..00000000 --- a/sdk/playable/src/host/tonemap.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Bevy's tone mapping in the playable (docs/playables.feature PA10): the 3D drawn into a half-float target with no -// tone curve, then one full-screen pass maps it through TonyMcMapface (Bevy's default, tools/tony.ts's table) and -// encodes sRGB, as bevy_core_pipeline's tonemapping.wesl does. Where nothing was drawn it stays transparent, so the -// page's background shows through as it does under the native engine's 3D. -import * as THREE from "three"; -import tony from "./tony.bin"; - -const N = Math.round(Math.cbrt(tony.length / 3)); - -const FRAG = /* glsl */ ` -precision highp float; -precision highp sampler3D; -uniform sampler2D scene; -uniform sampler3D lut; -in vec2 vUv; -out vec4 color; -void main() { - vec4 c = texture(scene, vUv); - vec3 x = max(c.rgb / max(c.a, 1e-5), vec3(0.0)); - vec3 uv = (x / (x + 1.0)) * (${N - 1}.0 / ${N}.0) + 0.5 / ${N}.0; - // the table holds sRGB-encoded bytes, already the screen's values - color = vec4(texture(lut, clamp(uv, 0.0, 1.0)).rgb * c.a, c.a); -}`; - -const VERT = /* glsl */ ` -in vec3 position; -in vec2 uv; -out vec2 vUv; -void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`; - -export class Tonemap { - private target: THREE.WebGLRenderTarget; - private quad: THREE.Mesh; - private camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); - - constructor(private renderer: THREE.WebGLRenderer) { - renderer.toneMapping = THREE.NoToneMapping; - renderer.outputColorSpace = THREE.LinearSRGBColorSpace; - this.target = new THREE.WebGLRenderTarget(1, 1, { type: THREE.HalfFloatType, samples: 4, colorSpace: THREE.LinearSRGBColorSpace }); - const rgba = new Uint8Array(N * N * N * 4); - for (let i = 0; i < N * N * N; i++) rgba.set([tony[i * 3], tony[i * 3 + 1], tony[i * 3 + 2], 255], i * 4); - const lut = new THREE.Data3DTexture(rgba, N, N, N); - lut.minFilter = lut.magFilter = THREE.LinearFilter; - lut.unpackAlignment = 1; - lut.needsUpdate = true; - const material = new THREE.RawShaderMaterial({ glslVersion: THREE.GLSL3, vertexShader: VERT, fragmentShader: FRAG, uniforms: { scene: { value: this.target.texture }, lut: { value: lut } }, transparent: true, premultipliedAlpha: true, blending: THREE.NoBlending, depthTest: false, depthWrite: false }); - this.quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), material); - } - - /** The target sized to the canvas's drawing buffer */ - resize() { - const s = this.renderer.getDrawingBufferSize(new THREE.Vector2()); - this.target.setSize(s.x, s.y); - } - - render(scene: THREE.Scene, camera: THREE.Camera) { - const r = this.renderer; - r.setRenderTarget(this.target); - r.setClearColor(0x000000, 0); - r.clear(); - r.render(scene, camera); - r.setRenderTarget(null); - r.render(this.quad, this.camera); - } -} diff --git a/sdk/playable/tools/tony.ts b/sdk/playable/tools/tony.ts index 4b1086e3..74f86f78 100644 --- a/sdk/playable/tools/tony.ts +++ b/sdk/playable/tools/tony.ts @@ -1,6 +1,6 @@ // Bevy's TonyMcMapface tone-mapping table for the playable host (docs/playables.feature PA10): bevy_core_pipeline's // tony_mc_mapface.ktx2 (48³, E5B9G9R9 floats, zstd; MIT, Tomasz Stachowiak) resampled to N³ and stored as sRGB-encoded -// RGB bytes, which host/tonemap.ts samples as Bevy's tonemapping.wesl does. +// RGB bytes, which host/bevy.ts's tone pass samples as Bevy's tonemapping.wesl does. // `bun tools/tony.ts N OUT.bin` (N = 48 keeps Bevy's own size). import { readdirSync } from "node:fs"; import { homedir } from "node:os"; diff --git a/sdk/r3f/src/three/geometry.ts b/sdk/r3f/src/three/geometry.ts index e8a98871..2159e920 100644 --- a/sdk/r3f/src/three/geometry.ts +++ b/sdk/r3f/src/three/geometry.ts @@ -16,6 +16,18 @@ export const GEOMETRY: Record THREE.BufferGeometry> = { Ring: (a) => new THREE.RingGeometry(a[0] ?? 0.5, a[1] ?? 1, 48), }; +/** A Plane3d's one face (its Mesh's data-shape "plane(nx, ny, nz, w, h)"), as Bevy's PlaneMeshBuilder makes it: the +Y + * plane, w along x and h along -z, turned to its normal by the shortest arc. Its Box child (a box with no depth, for + * three's sake) would face both ways, and three's BoxGeometry points a flat side's normal down */ +export function planeOf(kind: string, el: Element): THREE.BufferGeometry | undefined { + const m = kind === "Box" ? /^plane\(([^)]*)\)$/.exec(el.parentElement?.getAttribute("data-shape") ?? "") : null; + if (!m) return undefined; + const [nx, ny, nz, w, h] = m[1].split(",").map(Number); + const g = new THREE.PlaneGeometry(w, h).rotateX(-Math.PI / 2); + const n = new THREE.Vector3(nx, ny, nz).normalize(); + return g.applyQuaternion(new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), n)); +} + interface BufferSpec { positions: number[]; indices?: number[]; diff --git a/sdk/r3f/src/three/scene.ts b/sdk/r3f/src/three/scene.ts index f546888b..e7c3f935 100644 --- a/sdk/r3f/src/three/scene.ts +++ b/sdk/r3f/src/three/scene.ts @@ -8,7 +8,7 @@ import { HDRLoader } from "three/examples/jsm/loaders/HDRLoader.js"; import type { Sky } from "three/examples/jsm/objects/Sky.js"; import { paintLook, paintTone } from "./paint"; import { fire, flat, grass, placeFlat, plateTexture, richText, screenCard, sky, splatPoints } from "./extras"; -import { GEOMETRY, geometryOfShape, shapesReady } from "./geometry"; +import { GEOMETRY, geometryOfShape, planeOf, shapesReady } from "./geometry"; import { KINDS, PRIMITIVES } from "./kinds"; import { TONE, fitCamera, makeLight, setCamera, setLight, vec } from "./lights"; import { MATERIAL, paint, texture, vertexColoured } from "./materials"; @@ -390,7 +390,7 @@ export class Scene3d { const mesh = owner?.obj instanceof THREE.Mesh ? owner.obj : undefined; if (mesh) { k.geometry?.dispose(); - k.geometry = GEOMETRY[kind](Array.isArray(p.args) ? (p.args as number[]) : []); + k.geometry = planeOf(kind, el) ?? GEOMETRY[kind](Array.isArray(p.args) ? (p.args as number[]) : []); mesh.geometry = k.geometry; } return k; diff --git a/tools/bevy-glsl/Cargo.lock b/tools/bevy-glsl/Cargo.lock new file mode 100644 index 00000000..96e817bb --- /dev/null +++ b/tools/bevy-glsl/Cargo.lock @@ -0,0 +1,2221 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags", + "cc", + "jni", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "annotate-snippets" +version = "0.12.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0258346f92c78dbc5b336b9a5b27c64447aa10643bc64e651db2edb145361564" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + +[[package]] +name = "anstream" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c097ce94629611e0a15ef1078a2fe2ce3b4a0f4b44708e85eeb09dd5f188eb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c7a9e344b352bef7873e51ff425c2f90d5aa2a252db2b84289c93ff30beb3d7" + +[[package]] +name = "anstyle-parse" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0571a23d2188b4aae7adc1df454cc81d6232cf37674fa717ac119f6c74d0dc1" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a5cf9d05ffa9c878c447b33b069605e890ebcd36d2761f86367873c2ecaa7f" +dependencies = [ + "windows-sys 0.101.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c2d00c1b2d84cef823d89d4da02ad8ff1e76c969e029da990b40f16dc834221" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.101.0", +] + +[[package]] +name = "arrayvec" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a64a0fd06e123e9e3cf3ad01432af17dcab8185e8023edcf184fe696f9675d" + +[[package]] +name = "assert_type_match" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f548ad2c4031f2902e3edc1f29c29e835829437de49562d8eb5dc5584d3a1043" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "atomicow" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301801c08259e328a1c7da556608c0c22687708831b22024dbd3a57ea741e6de" +dependencies = [ + "portable-atomic", + "portable-atomic-util", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bevy-glsl" +version = "0.1.0" +dependencies = [ + "bevy_asset", + "bevy_shader", + "naga", + "serde_json", + "uuid", +] + +[[package]] +name = "bevy_android" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e06593a351f0220be555b4a2e2c4a8ff9173756791f245613fffb6b7904fae57" +dependencies = [ + "android-activity", +] + +[[package]] +name = "bevy_app" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2549c23ffdf3d3a49483c6716a3502b386f1f9fa523435630b733a77fa414e4f" +dependencies = [ + "bevy_derive", + "bevy_ecs", + "bevy_platform", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "console_error_panic_hook", + "downcast-rs", + "log", + "thiserror 2.0.21", + "variadics_please", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "bevy_asset" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88b3767a2c3f5a017b2febca08a670819ea2acb46846e4d8cd02980aeb0ed3e" +dependencies = [ + "async-broadcast", + "async-channel", + "async-fs", + "async-io", + "async-lock", + "atomicow", + "bevy_android", + "bevy_app", + "bevy_asset_macros", + "bevy_diagnostic", + "bevy_ecs", + "bevy_platform", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "bitflags", + "blake3", + "crossbeam-channel", + "derive_more", + "disqualified", + "downcast-rs", + "either", + "futures-io", + "futures-lite", + "futures-util", + "js-sys", + "ron", + "serde", + "stackfuture", + "thiserror 2.0.21", + "tracing", + "uuid", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "bevy_asset_macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b986dd0378a4ab84ec0acdd0660c79c5fe8db5eaec6161227e77d0a81d051f7" +dependencies = [ + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "bevy_derive" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7be8813fd429ff1237bcc5391d1abf4e88ca360302217125d76a1c3cb131b18" +dependencies = [ + "bevy_macro_utils", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "bevy_diagnostic" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a243742d6d3ad9d4ae889b67b307f38a86179b46fadb3acabbdf8bf5d15535" +dependencies = [ + "atomic-waker", + "bevy_app", + "bevy_ecs", + "bevy_platform", + "bevy_tasks", + "bevy_time", + "const-fnv1a-hash", + "log", +] + +[[package]] +name = "bevy_ecs" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c546460b4e5dbe72a5e8fce733e9306f747d9a74fd0cd67842ee10831d09aa3" +dependencies = [ + "arrayvec", + "bevy_ecs_macros", + "bevy_platform", + "bevy_ptr", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "bitflags", + "bumpalo", + "concurrent-queue", + "derive_more", + "fixedbitset", + "indexmap", + "log", + "nonmax", + "slotmap", + "smallvec", + "thiserror 2.0.21", + "variadics_please", +] + +[[package]] +name = "bevy_ecs_macro_logic" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb57340122cc39ac36b9ed9c98745c3739dd88c5c89b117c9faf2828978b13f5" +dependencies = [ + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "bevy_ecs_macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e50a452e8705504c04f80d359be23bcae829053ef58fdd17572d509a1f460b8" +dependencies = [ + "bevy_ecs_macro_logic", + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "bevy_macro_utils" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdafa048d2bafad7fda1d5a207ab52a6513bbc3a778e5d9e6ab35ac6a41ae11d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "toml_edit", +] + +[[package]] +name = "bevy_platform" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c1280bc12c975ddb041b8341b005415024994477479861ea4490b9b7f9f6185" +dependencies = [ + "critical-section", + "foldhash", + "futures-channel", + "futures-lite", + "hashbrown 0.16.1", + "js-sys", + "portable-atomic", + "portable-atomic-util", + "serde", + "spin", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-time", + "windows-sys 0.101.0", +] + +[[package]] +name = "bevy_ptr" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "845b9f43ea7e4be1a19b93673325d47c091df8e3a57a2cd30dd003d0972796be" + +[[package]] +name = "bevy_reflect" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e275d95c84140ae51d58a9e8cae5cf9ed687b59d10e69bfec8da480f5c667f" +dependencies = [ + "assert_type_match", + "bevy_platform", + "bevy_ptr", + "bevy_reflect_derive", + "bevy_utils", + "derive_more", + "disqualified", + "downcast-rs", + "erased-serde", + "foldhash", + "glam", + "indexmap", + "inventory", + "serde", + "smallvec", + "smol_str", + "thiserror 2.0.21", + "uuid", + "variadics_please", + "wgpu-types", +] + +[[package]] +name = "bevy_reflect_derive" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1f0add6e1437551a7f26d22458b6eece9a3e38a5dba0a663a753ab4385d9bfc" +dependencies = [ + "bevy_macro_utils", + "indexmap", + "proc-macro2", + "quote", + "syn 2.0.119", + "uuid", +] + +[[package]] +name = "bevy_shader" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2becafd54079da13835d6a42fc743e305d6270c27a91de613afe6e3f4b5de19" +dependencies = [ + "bevy_asset", + "bevy_platform", + "bevy_reflect", + "bevy_utils", + "serde", + "thiserror 2.0.21", + "tracing", + "wesl", + "wgpu-types", +] + +[[package]] +name = "bevy_tasks" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c634a7f09e9ccd26137a2f541ab670c84854a1af4107fecca1541cfcd1b466" +dependencies = [ + "async-executor", + "async-task", + "atomic-waker", + "bevy_platform", + "crossbeam-queue", + "derive_more", + "futures-lite", + "heapless", + "web-task", +] + +[[package]] +name = "bevy_time" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f52269fa80326e6d0a9c6e53431fc448651d7fbbb719aa9dfbd4895369ef54" +dependencies = [ + "bevy_app", + "bevy_ecs", + "bevy_platform", + "log", +] + +[[package]] +name = "bevy_utils" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1565ae7a124e68a39321620c5339eb501694357c40f50a74413034ed683cdf9" +dependencies = [ + "async-channel", + "bevy_platform", + "disqualified", + "indexmap", + "thread_local", +] + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "blake3" +version = "1.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68fe79e887dd9b3d00ffb29973ff39df3d99b81e6fefbde49636989bd56264d6" +dependencies = [ + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "cpufeatures", +] + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "byteorder" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34fb07aac3b9f547c7af8dc897dfe73c10847b6c71130c364bdd7891d979c816" + +[[package]] +name = "bytes" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c" + +[[package]] +name = "cc" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "colorchoice" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f7f11958434c85b6efac08f8299dc08bd263184ce080232e2168940cda4368e" + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", + "portable-atomic", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "const-fnv1a-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" + +[[package]] +name = "const_panic" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9603f79528ece8163c496f8932121cb36cfe46259e9c907bb3d8205139d7caa3" +dependencies = [ + "typewit", +] + +[[package]] +name = "constant_time_eq" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144e7f1de087984240b7816d47f698b414979faa6f40839c5b86d6bd47db57b7" +dependencies = [ + "rustversion", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", + "unicode-xid", +] + +[[package]] +name = "disqualified" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90a5dd66beeca277ae954f8055b02a712792b6b6b43f2bc2f92b0b7d8291614" + +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "erased-serde" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e59b668157f32d3459d4bd634861a06ffa2503a461ca5f0916b9f0252605e66" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8" + +[[package]] +name = "fixedbitset" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28aadd44bf60a243dd4f49b467a5ff30fee9e4dbaed326795d433ffa8a561730" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "glam" +version = "0.33.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37bfe73dc8ec21f54d181e5a60554327ec3f1c600c455a75ccbfc65d2106a6c4" +dependencies = [ + "serde_core", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "equivalent", + "serde", + "serde_core", +] + +[[package]] +name = "hashbrown" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heapless" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411fdef4df93751117bd9ef8caa0e7f99c65dafec5bd84313eb8e2fdd75e32f2" +dependencies = [ + "hash32", + "portable-atomic", + "stable_deref_trait", +] + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.2", + "serde", + "serde_core", +] + +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link 0.2.1", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lalrpop-util" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "364b49d1c98c07972e16fe1346463becc08bcd663da04e6e37ab1bea068dce6a" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "lexical" +version = "7.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc8a009b2ff1f419ccc62706f04fe0ca6e67b37460513964a3dfdb919bb37d6" +dependencies = [ + "lexical-core", +] + +[[package]] +name = "lexical-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8d125a277f807e55a77304455eb7b1cb52f2b18c143b60e766c120bd64a594" +dependencies = [ + "lexical-parse-float", + "lexical-parse-integer", + "lexical-util", + "lexical-write-float", + "lexical-write-integer", +] + +[[package]] +name = "lexical-parse-float" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a9f232fbd6f550bc0137dcb5f99ab674071ac2d690ac69704593cb4abbea56" +dependencies = [ + "lexical-parse-integer", + "lexical-util", +] + +[[package]] +name = "lexical-parse-integer" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7a039f8fb9c19c996cd7b2fcce303c1b2874fe1aca544edc85c4a5f8489b34" +dependencies = [ + "lexical-util", +] + +[[package]] +name = "lexical-util" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2604dd126bb14f13fb5d1bd6a66155079cb9fa655b37f875b3a742c705dbed17" + +[[package]] +name = "lexical-write-float" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c438c87c013188d415fbabbb1dceb44249ab81664efbd31b14ae55dabb6361" +dependencies = [ + "lexical-util", + "lexical-write-integer", +] + +[[package]] +name = "lexical-write-integer" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "409851a618475d2d5796377cad353802345cba92c867d9fbcde9cf4eac4e14df" +dependencies = [ + "lexical-util", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "logos" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2c55a318a87600ea870ff8c2012148b44bf18b74fad48d0f835c38c7d07c5f" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58b3ffaa284e1350d017a57d04ada118c4583cf260c8fb01e0fe28a2e9cf8970" +dependencies = [ + "fnv", + "proc-macro2", + "quote", + "regex-automata", + "regex-syntax", + "syn 2.0.119", +] + +[[package]] +name = "logos-derive" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52d3a9855747c17eaf4383823f135220716ab49bea5fbea7dd42cc9a92f8aa31" +dependencies = [ + "logos-codegen", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "mutants" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126" + +[[package]] +name = "naga" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.2", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14474170feb673cfb18b3565111a9869797cc1d290fb9ec969c53f5e1e231c6d" +dependencies = [ + "hashbrown 0.17.2", + "indexmap", + "rustc-hash 1.1.0", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nonmax" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "pin-project-lite" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f120c8d5021b34abd2f2ffd7ee96687cbcd6c54a3e68d86b6169f4a5cd480ffe" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + +[[package]] +name = "ron" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3fe97c18ff24299ea56f802c5693eb34266fb0bc8317f4e101debc8a3ceaf" +dependencies = [ + "bitflags", + "serde", + "serde_derive", + "typeid", + "unicode-ident", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +dependencies = [ + "serde_core", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59" + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "spin" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0134f9043ed38b087ac4f7d4af44c79e2c9e5094421fe3164f435ce585953b10" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stackfuture" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115beb9c69db2393ff10b75a1b8587a51716e5551d015001e55320ed279d32f9" +dependencies = [ + "const_panic", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml" +version = "1.2.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.21+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88497dab46de5bf343ec66b05c251e48c6213f3e9170c70a70a823f7abe886a4" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.7+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.2.0+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typewit" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214ca0b2191785cbc06209b9ca1861e048e39b5ba33574b3cedd58363d5bb5f6" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "unsynn" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501a7adf1a4bd9951501e5c66621e972ef8874d787628b7f90e64f936ef7ec0a" +dependencies = [ + "mutants", + "proc-macro2", + "rustc-hash 2.1.3", +] + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64" +dependencies = [ + "getrandom", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "variadics_please" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b53d0f7f2d0182759a549f1f313ce16b07d8f9ba93098157b5fa10ee3e61117f" +dependencies = [ + "quote", + "unsynn", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-task" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdc136a53ccd64a1211f107ccc34404769fbcc0f165f1afa065f5d88ab93538" +dependencies = [ + "async-task", + "cfg-if", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wesl" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd8f9619baa4c7bde4df0899d6f626b70ee92d6e9c18c5f74473419b5bb6fa6" +dependencies = [ + "annotate-snippets", + "anstream", + "derive_more", + "glob", + "half", + "itertools", + "num-traits", + "serde", + "thiserror 2.0.21", + "toml", + "wesl-core", + "wesl-macros", + "wgsl-parse", + "wgsl-types", +] + +[[package]] +name = "wesl-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84dd3e600497eda0b47afcd21bd84c8953a9dfce7e93ed27a38ba97ac0747e03" + +[[package]] +name = "wesl-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac8767ec26e75262a8e581d5f188b1f63a288baaf885bb33c9f4f73a693e06fc" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "wgpu-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f6ee0bd50f5ab79fb8c25e3f33afb27126f034af4ba5909c7a0967058659e6" +dependencies = [ + "bitflags", + "bytemuck", + "js-sys", + "log", + "naga-types", + "raw-window-handle", + "serde", + "static_assertions", + "web-sys", +] + +[[package]] +name = "wgsl-parse" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37cee524ba5cfabfd65d10a316b646f8a4c50f3663e7e787471f21b783261f47" +dependencies = [ + "annotate-snippets", + "derive_more", + "itertools", + "lalrpop-util", + "lexical", + "logos", + "thiserror 2.0.21", + "wgsl-types", +] + +[[package]] +name = "wgsl-types" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e119dd12e57d937397535201959ddddb5dbf26505402db5ef305ebb1ca9a7e5f" +dependencies = [ + "half", + "itertools", + "num-traits", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-link" +version = "0.101.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e57b2aae53a240c62b65069a63eaf8d5fa747f5d0d8e670c5210a98847bce4" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-sys" +version = "0.101.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed2df9f5f458664c87437f6758f0d93085b06433bf66b2b84c23c19f3d2012c" +dependencies = [ + "windows-link 0.101.0", +] + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "zerocopy" +version = "0.8.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba8a86aee14fc8cc6c208af60854b3d4ab7185a9a369a12c648faa2716ff42a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f89bca3b96ceb3cfcb4572790402f977442270d252b9a8504ebc258760c55f94" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/tools/bevy-glsl/Cargo.toml b/tools/bevy-glsl/Cargo.toml new file mode 100644 index 00000000..b497270b --- /dev/null +++ b/tools/bevy-glsl/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "bevy-glsl" +version = "0.1.0" +edition = "2024" +license = "FSL-1.1-ALv2" +publish = false +description = "Bevy's PBR programs for a playable (docs/playables.feature PA11): composed by Bevy's own ShaderCache with WebGL2's defs, translated to GLSL ES 3.00 by naga, with each uniform block's layout" + +# its own workspace: run on demand (sdk/playable/bevy/build.sh), not part of raea's build +[workspace] + +[dependencies] +bevy_shader = "=0.20.0" +bevy_asset = "=0.20.0" +naga = { version = "=30.0.1", features = ["wgsl-in", "glsl-out"] } +serde_json = "1" +uuid = { version = "1", features = ["v4"] } diff --git a/tools/bevy-glsl/src/main.rs b/tools/bevy-glsl/src/main.rs new file mode 100644 index 00000000..af8a46f8 --- /dev/null +++ b/tools/bevy-glsl/src/main.rs @@ -0,0 +1,283 @@ +//! Bevy's PBR programs for a playable (docs/playables.feature PA11). Bevy's own ShaderCache composes them, from Bevy's +//! shader files (raea's vendored bevy_pbr, and bevy_render and bevy_core_pipeline at the version raea builds), with the +//! defs Bevy's mesh and prepass pipelines give a WebGL2 device; naga translates each entry point to GLSL ES 3.00 for +//! WebGL. Beside the sources, bevy.json says for each program which uniform block and sampler is which binding and +//! lays out each block's struct (offsets, sizes, strides), so the host fills them as Bevy's render world does. +//! +//! cargo run --release --manifest-path tools/bevy-glsl/Cargo.toml -- RAEA_ROOT OUT_DIR + +use bevy_asset::AssetId; +use bevy_shader::{Shader, ShaderCache, ShaderCacheError, ShaderCacheSource, ShaderDefVal, ValidateShader}; +use naga::back::glsl; +use naga::proc::{BoundsCheckPolicies, Layouter}; +use naga::{AddressSpace, ShaderStage, TypeInner}; +use serde_json::{Map, Value, json}; +use std::collections::BTreeMap; +use std::path::{Path, PathBuf}; + +fn keep(_: &(), source: ShaderCacheSource, _: &ValidateShader) -> Result { + match source { + ShaderCacheSource::Wgsl(s) => Ok(s), + ShaderCacheSource::SpirV(_) => panic!("a SPIR-V shader in the pbr program"), + } +} + +fn def(name: &str) -> ShaderDefVal { + ShaderDefVal::Bool(name.to_string().into(), true) +} +fn uint(name: &str, v: u32) -> ShaderDefVal { + ShaderDefVal::UInt(name.to_string().into(), v) +} + +/// WebGL2's limits as Bevy reads them (render/light.rs under `webgl`, gpu_array_buffer.rs's batch size: a 16 KB +/// uniform binding over the 176-byte MeshUniform) +fn per_file_defs(path: &str) -> Vec { + match path { + "bevy_pbr/render/mesh_view_types.wesl" => vec![uint("MAX_DIRECTIONAL_LIGHTS", 10), uint("MAX_CASCADES_PER_LIGHT", 1), uint("MAX_RECT_LIGHTS", 8)], + "bevy_pbr/render/mesh_bindings.wesl" => vec![uint("PER_OBJECT_BUFFER_BATCH_SIZE", 93)], + _ => vec![], + } +} + +/// What every program on a WebGL2 device gets (mesh.rs specialize, view and device parts) +fn webgl_defs() -> Vec { + vec![ + def("WEBGL2"), + def("NO_ARRAY_TEXTURES_SUPPORT"), + def("NO_CUBE_ARRAY_TEXTURES_SUPPORT"), + def("SIXTEEN_BYTE_ALIGNMENT"), + uint("AVAILABLE_STORAGE_BUFFER_BINDINGS", 0), + uint("MAX_DIRECTIONAL_LIGHTS", 10), + uint("MAX_CASCADES_PER_LIGHT", 1), + uint("PER_OBJECT_BUFFER_BATCH_SIZE", 93), + def("MESH_PIPELINE"), + def("VERTEX_OUTPUT_INSTANCE_INDEX"), + def("VERTEX_POSITIONS"), + def("VERTEX_NORMALS"), + def("VERTEX_UVS"), + def("VERTEX_UVS_A"), + def("METADATA_USE_UNIFORM_BUFFERS"), + // no VIEW_PROJECTION_PERSPECTIVE: the shader reads the projection's kind from the view, so an orthographic + // camera shades as it does natively + // material.rs: the material's bind group + uint("MATERIAL_BIND_GROUP", 3), + ] +} + +/// The forward pass of a lit StandardMaterial mesh into an HDR target: Bevy tone-maps after it (the host's tone pass, +/// with Bevy's TonyMcMapface table), as it does natively with an HDR camera. Distance fog is in, off (its mode 0) where +/// the scene has none +fn forward_defs() -> Vec { + let mut d = webgl_defs(); + d.extend([ + def("MULTISAMPLED"), + def("SHADOW_FILTER_METHOD_GAUSSIAN"), + def("DISTANCE_FOG"), + ShaderDefVal::Int("SCREEN_SPACE_SPECULAR_TRANSMISSION_BLUR_TAPS".into(), 4), + uint("RENDER_PHASE_TYPE", 1), + ]); + d +} + +/// A directional light's shadow pass (prepass/mod.rs for a shadow view: depth only, positions, and on WebGL2 the +/// orthographic depth clamp emulated, as it has no unclipped depth) +fn shadow_defs() -> Vec { + let mut d = webgl_defs(); + d.retain(|v| !matches!(v, ShaderDefVal::Bool(n, _) if n == "VERTEX_NORMALS" || n == "VERTEX_UVS" || n == "VERTEX_UVS_A" || n == "VIEW_PROJECTION_PERSPECTIVE")); + d.extend([def("PREPASS_PIPELINE"), def("DEPTH_PREPASS"), def("UNCLIPPED_DEPTH_ORTHO_EMULATION"), def("VIEW_PROJECTION_ORTHOGRAPHIC")]); + d +} + +fn files(root: &Path, under: &Path, out: &mut Vec<(String, PathBuf)>) { + let Ok(rd) = std::fs::read_dir(under) else { return }; + for e in rd.flatten() { + let p = e.path(); + if p.is_dir() { + files(root, &p, out); + } else if p.extension().is_some_and(|x| x == "wesl" || x == "wgsl") { + out.push((p.strip_prefix(root).unwrap().to_string_lossy().replace('\\', "/"), p)); + } + } +} + +/// A type's layout in a uniform block, as naga lays it out (WGSL's uniform rules, std140's) +fn layout(m: &naga::Module, l: &Layouter, ty: naga::Handle) -> Value { + let t = &m.types[ty]; + let size = l[ty].size; + let scalar = |s: naga::Scalar| match s.kind { + naga::ScalarKind::Float => "f32", + naga::ScalarKind::Uint => "u32", + naga::ScalarKind::Sint => "i32", + naga::ScalarKind::Bool => "bool", + _ => "?", + }; + match &t.inner { + TypeInner::Scalar(s) => json!({ "k": scalar(*s), "size": size }), + TypeInner::Atomic(s) => json!({ "k": scalar(*s), "size": size }), + TypeInner::Vector { size: n, scalar: s } => json!({ "k": "vec", "n": *n as u32, "s": scalar(*s), "size": size }), + TypeInner::Matrix { columns, rows, .. } => { + let col = if *rows as u32 == 2 { 8 } else { 16 }; + json!({ "k": "mat", "c": *columns as u32, "r": *rows as u32, "stride": col, "size": size }) + } + TypeInner::Array { base, size: n, stride } => { + let count = match n { + naga::ArraySize::Constant(c) => c.get(), + _ => 0, + }; + json!({ "k": "array", "of": layout(m, l, *base), "count": count, "stride": stride, "size": size }) + } + TypeInner::Struct { members, span } => { + let fields: Vec = members + .iter() + .map(|f| json!({ "name": f.name.clone().unwrap_or_default(), "offset": f.offset, "type": layout(m, l, f.ty) })) + .collect(); + json!({ "k": "struct", "name": t.name.clone().unwrap_or_default(), "fields": fields, "size": span }) + } + other => json!({ "k": format!("{other:?}").split([' ', '{', '(']).next().unwrap_or("?"), "size": size }), + } +} + +/// One entry point in GLSL ES 3.00 for WebGL, and what its names bind to +fn translate(wgsl: &str, stage: ShaderStage, entry: &str) -> Result<(String, Value), String> { + let module = naga::front::wgsl::parse_str(wgsl).map_err(|e| e.emit_to_string(wgsl))?; + let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), naga::valid::Capabilities::all()) + .validate(&module) + .map_err(|e| e.emit_to_string(wgsl))?; + let options = glsl::Options { + version: glsl::Version::Embedded { version: 300, is_webgl: true }, + writer_flags: glsl::WriterFlags::ADJUST_COORDINATE_SPACE | glsl::WriterFlags::FORCE_POINT_SIZE, + binding_map: Default::default(), + zero_initialize_workgroup_memory: false, + }; + let pipeline = glsl::PipelineOptions { shader_stage: stage, entry_point: entry.to_string(), multiview: None }; + let mut out = String::new(); + let mut w = glsl::Writer::new(&mut out, &module, &info, &options, &pipeline, BoundsCheckPolicies::default()).map_err(|e| format!("{e:?}"))?; + let reflection = w.write().map_err(|e| format!("{e:?}"))?; + let mut lay = Layouter::default(); + lay.update(module.to_ctx()).map_err(|e| format!("{e:?}"))?; + let mut uniforms = Map::new(); + for (h, name) in &reflection.uniforms { + let g = &module.global_variables[*h]; + let b = g.binding.as_ref().map(|b| json!({ "group": b.group, "binding": b.binding })).unwrap_or(Value::Null); + let kind = match g.space { + AddressSpace::Uniform => "uniform", + AddressSpace::Storage { .. } => "storage", + _ => "other", + }; + uniforms.insert(name.clone(), json!({ "var": g.name, "space": kind, "at": b, "type": layout(&module, &lay, g.ty) })); + } + let mut textures = Map::new(); + for (name, m) in &reflection.texture_mapping { + let t = &module.global_variables[m.texture]; + let s = m.sampler.map(|s| &module.global_variables[s]); + let at = |g: &naga::GlobalVariable| g.binding.as_ref().map(|b| json!({ "group": b.group, "binding": b.binding })); + textures.insert(name.clone(), json!({ "texture": t.name, "at": at(t), "sampler": s.map(|s| s.name.clone()), "sampler_at": s.and_then(at), "kind": format!("{:?}", module.types[t.ty].inner).split([' ', '{', '(']).next().unwrap_or("?").to_string(), "dim": dim(&module.types[t.ty].inner) })); + } + let varyings: Vec = reflection.varying.keys().cloned().collect(); + Ok((out, json!({ "uniforms": uniforms, "textures": textures, "varyings": varyings }))) +} + +/// A binding's name as Bevy's files give it (`..._bindings__1clustered_lights` -> clustered_lights) +fn short(var: &str) -> String { + var.rsplit("bindings_").next().unwrap_or(var).trim_start_matches('_').trim_start_matches(|c: char| c.is_ascii_digit()).to_string() +} + +/// A block's fields at their offsets by dotted path, each from its own struct's start; an array's stride as `path[]` +fn flatten(t: &Value, prefix: &str, out: &mut Map) { + match t["k"].as_str() { + Some("struct") => { + for f in t["fields"].as_array().into_iter().flatten() { + let name = f["name"].as_str().unwrap_or_default(); + let path = if prefix.is_empty() { name.to_string() } else { format!("{prefix}.{name}") }; + out.insert(path.clone(), f["offset"].clone()); + flatten(&f["type"], &path, out); + } + } + Some("array") => { + out.insert(format!("{prefix}[]"), t["stride"].clone()); + flatten(&t["of"], prefix, out); + } + _ => {} + } +} + +fn dim(t: &TypeInner) -> Value { + match t { + TypeInner::Image { dim, arrayed, class } => json!({ "dim": format!("{dim:?}"), "arrayed": arrayed, "class": format!("{class:?}") }), + _ => Value::Null, + } +} + +fn main() -> Result<(), String> { + let args: Vec = std::env::args().collect(); + let (Some(root), Some(out)) = (args.get(1), args.get(2)) else { + return Err("usage: bevy-glsl RAEA_ROOT OUT_DIR".into()); + }; + let root = PathBuf::from(root); + let reg = std::env::var("CARGO_HOME").map(PathBuf::from).unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".cargo")); + let registry = std::fs::read_dir(reg.join("registry/src")) + .map_err(|e| format!("cargo's registry: {e}"))? + .flatten() + .map(|e| e.path()) + .find(|p| p.join("bevy_render-0.20.0").is_dir()) + .ok_or("bevy_render 0.20.0 isn't in cargo's registry: build raea first")?; + let crates: Vec<(&str, PathBuf)> = vec![ + ("bevy_pbr", root.join("vendor/bevy_pbr/src")), + ("bevy_render", registry.join("bevy_render-0.20.0/src")), + ("bevy_core_pipeline", registry.join("bevy_core_pipeline-0.20.0/src")), + ]; + let mut cache: ShaderCache = ShaderCache::new((), keep); + let mut ids: BTreeMap> = BTreeMap::new(); + for (name, src) in &crates { + let mut fs = Vec::new(); + files(src, src, &mut fs); + for (rel, p) in fs { + let path = format!("{name}/{rel}"); + let text = std::fs::read_to_string(&p).map_err(|e| format!("{}: {e}", p.display()))?; + let mut shader = if rel.ends_with(".wesl") { Shader::from_wesl(text, format!("embedded://{path}")) } else { Shader::from_wgsl(text, format!("embedded://{path}")) }; + shader.shader_defs = per_file_defs(&path); + let id = AssetId::Uuid { uuid: uuid::Uuid::new_v4() }; + cache.set_shader(id, shader); + ids.insert(path, id); + } + } + let id = |p: &str| ids.get(p).copied().ok_or(format!("{p} isn't among Bevy's shaders")); + let out = PathBuf::from(out); + std::fs::create_dir_all(&out).map_err(|e| e.to_string())?; + let programs: [(&str, &str, ShaderStage, &str, Vec); 3] = [ + ("pbr.vert", "bevy_pbr/render/mesh.wesl", ShaderStage::Vertex, "vertex", forward_defs()), + ("pbr.frag", "bevy_pbr/render/pbr.wesl", ShaderStage::Fragment, "fragment", forward_defs()), + ("shadow.vert", "bevy_pbr/prepass/prepass.wesl", ShaderStage::Vertex, "vertex", shadow_defs()), + ]; + let mut meta = Map::new(); + let mut ts = String::from("// Bevy's PBR programs for a playable, as tools/bevy-glsl makes them (docs/playables.feature PA11): generated by\n// sdk/playable/bevy/build.sh, not edited. Each program's GLSL ES 3.00; which of Bevy's bindings each uniform block\n// and sampler is; each binding's fields at their byte offsets (nested fields from their struct's start, an array's\n// stride under `name[]`).\n"); + let (mut blocks, mut samplers, mut layouts) = (Map::new(), Map::new(), Map::new()); + for (name, file, stage, entry, defs) in programs { + let wgsl = cache.get(0, id(file)?, &defs).map_err(|e| format!("{file}: {e}"))?; + std::fs::write(out.join(format!("{name}.wgsl")), wgsl.as_str()).map_err(|e| e.to_string())?; + let (glsl, info) = translate(&wgsl, stage, entry).map_err(|e| format!("{file} ({name}): {e}"))?; + std::fs::write(out.join(format!("{name}.glsl")), &glsl).map_err(|e| e.to_string())?; + eprintln!("{name}: {} lines, {} bytes", glsl.lines().count(), glsl.len()); + // leading spaces and blank lines carry nothing in GLSL + let tight: String = glsl.lines().map(str::trim_start).filter(|l| !l.is_empty()).collect::>().join("\n"); + ts.push_str(&format!("export const {} = {};\n", name.replace('.', "_").to_uppercase(), Value::from(tight))); + for (block, u) in info["uniforms"].as_object().into_iter().flatten() { + let short = short(u["var"].as_str().unwrap_or_default()); + blocks.insert(block.clone(), Value::from(short.clone())); + let mut flat = Map::new(); + flat.insert("$size".into(), u["type"]["size"].clone()); + flatten(&u["type"], "", &mut flat); + layouts.insert(short, Value::Object(flat)); + } + for (sampler, t) in info["textures"].as_object().into_iter().flatten() { + samplers.insert(sampler.clone(), Value::from(short(t["texture"].as_str().unwrap_or_default()))); + } + meta.insert(name.into(), info); + } + ts.push_str(&format!("export const BLOCKS: Record = {};\n", Value::Object(blocks))); + ts.push_str(&format!("export const SAMPLERS: Record = {};\n", Value::Object(samplers))); + ts.push_str(&format!("export const LAYOUT: Record> = {};\n", Value::Object(layouts))); + std::fs::write(out.join("programs.ts"), ts).map_err(|e| e.to_string())?; + std::fs::write(out.join("bevy.json"), serde_json::to_string_pretty(&Value::Object(meta)).unwrap()).map_err(|e| e.to_string())?; + Ok(()) +} diff --git a/tools/layers.toml b/tools/layers.toml index 59a478ff..b8c400df 100644 --- a/tools/layers.toml +++ b/tools/layers.toml @@ -274,6 +274,7 @@ rtools = "tools" skillcheck = "tools" seetool = "tools" raea-hands-audit = "tools" +bevy-glsl = "tools" # Bevy's PBR shaders as WebGL2 GLSL for a playable's light host (docs/playables.feature PA11) # systems that hold only a facility another system may build on (docs/overhaul.md: the mixer graph, ONNX sessions, # Vision requests, K kernels on the GPU)