A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(render): a 2D shadow is drawn, not solved in every pixel
esenginefe3d9f3bb2c5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 70170d36f..a8dd7cd54 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,35 @@ published separately; it ships inside the editor.### Changed+- **2D shadows are drawn, not solved.** A 2D shadow used to be an analytic test inside+ every lit fragment: eight axis-aligned boxes rode in the lighting block, and each one+ was intersected against the segment from the pixel to the light — for every pixel, for+ every light. Eight is a room with two walls in it, and the way to raise the number was+ to make every pixel on the screen pay for it. The engine's own lighting example capped+ the obstacles a player could place at six and said so in its README.++ The shadow is now rasterised. Each frame the engine takes every enabled+ `ShadowCaster2D`, finds the silhouette each casting light sees it by, and draws the+ region behind it into a screen-sized mask that a lit surface reads one texel of. So the+ occluder count is a vertex count rather than a shader constant — a scene may hold as+ many walls as it has — and an occluder's SHAPE stops being a constraint of the test,+ because the shadow is geometry.++ What is capped now is how many lights cast at once: the mask has four channels, so the+ first four casting lights get one each and a light past that lights the scene without+ shadowing it. That is a failure a 2D scene can look at and understand, which "some of+ the walls stopped casting" was not.++ Softness is the same knob and a better shadow: a source with width is sampled across,+ each sample throws the silhouette it sees at its own share of the strength, and the+ shares add — so the penumbra is whole where the whole source is hidden and a fraction+ where only part of it is. A directional light's `shadowDistance` is now how far its+ shadows are CARRIED rather than how far a fragment searched back for an occluder.++ The engine's Lit shaders spend their top texture unit on the mask while one exists,+ which costs a sprite batch one merge slot in a scene that has 2D shadows and nothing at+ all in one that does not.+- **One curve, sampled by everything that has one.** A timeline channel carried keyswith tangents and six interpolations, drawn by an editor that understood them; aparticle's size-over-life carried `{t, v}` pairs joined by straight lines; and thediff --git a/cmake/ESEngineSources.cmake b/cmake/ESEngineSources.cmakeindex c685ff405..8d3648d8c 100644--- a/cmake/ESEngineSources.cmake+++ b/cmake/ESEngineSources.cmake@@ -24,6 +24,7 @@ set(ESENGINE_SOURCES${ESENGINE_ROOT}/src/esengine/renderer/graph/RenderGraph.cpp${ESENGINE_ROOT}/src/esengine/renderer/frame/RenderFrame.cpp${ESENGINE_ROOT}/src/esengine/renderer/frame/RenderFrameMask.cpp+ ${ESENGINE_ROOT}/src/esengine/renderer/frame/RenderFrameShadow2D.cpp${ESENGINE_ROOT}/src/esengine/renderer/frame/RenderFrameOverlay.cpp${ESENGINE_ROOT}/src/esengine/renderer/frame/RenderFrameSubmit.cpp${ESENGINE_ROOT}/src/esengine/renderer/frame/FrameCapture.cppdiff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 44bb190eb..ac587258b 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -211,9 +211,11 @@ Key facts:to migrate by. Shadows are a tiled atlas (`ShadowAtlas`, `MAX_SHADOW_TILES`):a spot resolves one cone, a point light six faces (`SHADOW_CUBE_FACES`), a sunup to `MAX_SHADOW_CASCADES` = 4 cascades, with a real penumbra from- `Light.shadowSoftness` / `sourceAngle`. `MAX_OCCLUDERS_2D` = 8 AABB occluders- (`ShadowCaster2D`) shadow content that has no mesh to rasterize — a sprite —- which is complementary to the maps, not a second strategy.+ `Light.shadowSoftness` / `sourceAngle`. 2D shadows are a second target, not a+ tile: the edges of every `ShadowCaster2D` are drawn as what they hide from each+ casting light into a screen-sized mask, one channel per light+ (`MAX_SHADOW_2D_LIGHTS` = 4), and a lit fragment reads its own channel. Drawn+ rather than solved, so a scene holds as many occluders as it has walls.### Resource pipeline (`resource/`)diff --git a/docs/astro/src/content/docs/graphics/lighting.mdx b/docs/astro/src/content/docs/graphics/lighting.mdxindex 723d8e753..9090938bf 100644--- a/docs/astro/src/content/docs/graphics/lighting.mdx+++ b/docs/astro/src/content/docs/graphics/lighting.mdx@@ -274,6 +274,22 @@ Shadow **quality** is controlled on the light, not the caster:- **`shadowDistance`** — for a **Directional** light, how far its shadows extend; `0`leaves a directional light shadow-free.+### How many, and what it costs++Shadows are **drawn**, not solved per pixel: each frame the engine takes the edges of+every enabled caster, draws what they hide from each casting light into a screen-sized+mask, and a lit surface reads one texel of it. So the number of occluders is a number+of triangles rather than a shader constant — a room may have as many walls as it needs,+and adding one costs a few triangles rather than a test on every pixel of the screen.++What IS capped is how many lights cast at once: the mask has **four channels**, so the+first four casting lights get one each. A light past that still lights the scene and+stops shadowing — the room stays lit, and what is missing is a shadow rather than the+light. A scene with more than four shadow-casting lights in view at once is usually+saying something about its art direction; the fix is to turn shadows off (`shadowDistance`+of 0 on a sun, or a smaller `radius` that takes a light out of view) on the ones whose+shadows nobody looks at.+## Linear color spaceBy default the engine renders **gamma-space** — colors blend as-authored, the way 2Ddiff --git a/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx b/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdxindex 14f57bd3d..d819990f6 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx@@ -258,6 +258,18 @@ cmds.spawn()阴影)。- **`shadowDistance`** — 对 **Directional** 光,阴影延伸多远;`0` 让方向光不产生阴影。+### 能放多少,代价是什么++阴影是**画出来的**,不是逐像素解出来的:每帧引擎取出所有启用的遮挡体的边,把它们对每个投射光遮住的+区域画进一张屏幕大小的遮蔽图,受光表面只读其中一个纹素。于是遮挡体的数量是三角形的数量,而不是一个+着色器常量——一个房间需要多少面墙就能有多少面,多加一面的代价是几个三角形,而不是整屏每个像素多一次+测试。++**有上限的是同时投影的光数**:遮蔽图有**四个通道**,所以前四个投射光各占一个。超出的光仍然照亮场景,+只是不再投影——房间还是亮的,少掉的是影子而不是光。同屏超过四个投影光通常说明美术方向本身有问题;+处理办法是把没人会看那道影子的光关掉阴影(太阳的 `shadowDistance` 设 0,或者用更小的 `radius`+让某个光离开视野)。+## 线性色彩空间引擎默认以**伽马空间**渲染——颜色按作者所写直接混合,这是 2D 管线的经典方式。项目可以切换到diff --git a/examples/lighting-2d/README.md b/examples/lighting-2d/README.mdindex 980fc8fb1..31f2042b8 100644--- a/examples/lighting-2d/README.md+++ b/examples/lighting-2d/README.md@@ -14,9 +14,12 @@ shadows**.| Right-click | Drop a box obstacle that blocks light and casts a shadow || `C` | Clear everything you placed |-Placed lights are capped at 10 and obstacles at 6; when you exceed a cap the-oldest one fades out and is removed, keeping the scene inside the GPU's 16-light-/ 8-occluder budget.+Placed lights are capped at 10 and obstacles at 40; when you exceed a cap the+oldest one fades out and is removed. The light cap is the frame's (16 fit in the+lighting block); the obstacle one is only to keep the demo tidy — occluders are+drawn as geometry, so a scene may hold as many as it has walls. What IS capped+is how many lights cast at once: the first four get a channel of the 2D shadow+mask, and any beyond that light the room without shadowing it.## How it worksdiff --git a/examples/lighting-2d/src/config.ts b/examples/lighting-2d/src/config.tsindex 3d5f94a04..9af558b33 100644--- a/examples/lighting-2d/src/config.ts+++ b/examples/lighting-2d/src/config.ts@@ -17,11 +17,11 @@ export const PLACED_LIGHT_SOFTNESS = 10;// Box occluder placed by a right-click (world units, centered on the cursor).export const OBSTACLE_SIZE = { x: 84, y: 84 };-// The GPU packs at most 16 lights and 8 occluders per frame; the scene already-// spends a torch + ambient + two pillars, so we cap the interactive placements-// well under those limits and fade the oldest out when the cap is reached.+// The frame packs at most 16 lights, and the first four that cast get a channel of+// the 2D shadow mask — past that a light lights the room without shadowing it.+// Occluders are geometry and have no such cap; this limit only keeps the demo tidy.export const MAX_LIGHTS = 10;-export const MAX_OBSTACLES = 6;+export const MAX_OBSTACLES = 40;// Seconds an evicted / cleared entity takes to fade its light and sprite to zero// before it despawns.diff --git a/examples/lighting-2d/src/systems/place.ts b/examples/lighting-2d/src/systems/place.tsindex ab44dd71c..eb2e8e598 100644--- a/examples/lighting-2d/src/systems/place.ts+++ b/examples/lighting-2d/src/systems/place.ts@@ -10,8 +10,7 @@ import {} from '../config';// FIFO records of what the player has placed. When a list exceeds its cap the-// oldest entity is tagged Fading (the fade system dims and despawns it), so the-// scene stays within the GPU's light/occluder budget.+// oldest entity is tagged Fading (the fade system dims and despawns it).const lights: number[] = [];const obstacles: number[] = [];let nextColor = 0;diff --git a/fixtures/scenes/mat-builtin-lit/lit.esshader b/fixtures/scenes/mat-builtin-lit/lit.esshaderindex e70d1be16..ead69ad8f 100644--- a/fixtures/scenes/mat-builtin-lit/lit.esshader+++ b/fixtures/scenes/mat-builtin-lit/lit.esshader@@ -27,7 +27,7 @@ void main() {// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 5330079245724fa2-// assembled-hash: ca1eb542f2c993bf+// assembled-hash: 6d58d9851d30eb16struct gl_PerVertex {@builtin(position) gl_Position: vec4<f32>,gl_PointSize: f32,@@ -108,7 +108,7 @@ fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>,// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 5330079245724fa2-// assembled-hash: ca1eb542f2c993bf+// assembled-hash: 6d58d9851d30eb16struct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -126,8 +126,7 @@ struct Light {struct LightConstants {u_ambient: vec4<f32>,u_lights: array<Light, 16>,- u_occluderCount: vec4<f32>,- u_occluders: array<vec4<f32>, 8>,+ u_shadow2DRect: vec4<f32>,u_shadowMatrix: array<mat4x4<f32>, 16>,u_shadowTile: array<vec4<f32>, 16>,u_shadowParams: vec4<f32>,@@ -149,6 +148,10 @@ struct TimeConstants {var<uniform> unnamed: FrameConstants;@group(0) @binding(2)var<uniform> unnamed_1: LightConstants;+@group(1) @binding(7)+var u_shadow2D_est: texture_2d<f32>;+@group(1) @binding(15)+var u_shadow2D_ess: sampler;@group(1) @binding(0)var es_bt0_est: texture_2d<f32>;@group(1) @binding(8)@@ -208,903 +211,700 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughnessvar param_2: vec3<f32>;var param_3: f32;- let _e97 = unnamed_1.u_envParams[0u];- if (_e97 < 0.5f) {- let _e100 = unnamed_1.u_ambient;- return _e100.xyz;+ let _e96 = unnamed_1.u_envParams[0u];+ if (_e96 < 0.5f) {+ let _e99 = unnamed_1.u_ambient;+ return _e99.xyz;}- let _e102 = (*roughness);- let _e106 = unnamed_1.u_envParams[2u];- lod = (clamp(_e102, 0f, 1f) * _e106);- let _e108 = lod;- lo = floor(_e108);- let _e110 = (*R_1);- param = _e110;- let _e111 = lo;- param_1 = _e111;- let _e112 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));- a = _e112;- let _e113 = lo;- let _e117 = unnamed_1.u_envParams[2u];- let _e119 = (*R_1);- param_2 = _e119;- param_3 = min((_e113 + 1f), _e117);- let _e120 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));- b = _e120;- let _e122 = unnamed_1.u_ambient;- let _e124 = a;- let _e125 = b;- let _e126 = lod;- let _e127 = lo;- let _e132 = unnamed_1.u_envTint;- return (_e122.xyz + (mix(_e124, _e125, vec3((_e126 - _e127))) * _e132.xyz));+ let _e101 = (*roughness);+ let _e105 = unnamed_1.u_envParams[2u];+ lod = (clamp(_e101, 0f, 1f) * _e105);+ let _e107 = lod;+ lo = floor(_e107);+ let _e109 = (*R_1);+ param = _e109;+ let _e110 = lo;+ param_1 = _e110;+ let _e111 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));+ a = _e111;+ let _e112 = lo;+ let _e116 = unnamed_1.u_envParams[2u];+ let _e118 = (*R_1);+ param_2 = _e118;+ param_3 = min((_e112 + 1f), _e116);+ let _e119 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));+ b = _e119;+ let _e121 = unnamed_1.u_ambient;+ let _e123 = a;+ let _e124 = b;+ let _e125 = lod;+ let _e126 = lo;+ let _e131 = unnamed_1.u_envTint;+ return (_e121.xyz + (mix(_e123, _e124, vec3((_e125 - _e126))) * _e131.xyz));}fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {var r: vec4<f32>;var a_1: f32;- let _e89 = (*roughness_1);- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e89) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));- let _e93 = r[0u];- let _e95 = r[0u];- let _e97 = (*NdotV);- let _e102 = r[0u];- let _e105 = r[1u];- a_1 = ((min((_e93 * _e95), exp2((-9.28f * _e97))) * _e102) + _e105);- let _e107 = a_1;- let _e109 = r;- return ((vec2<f32>(-1.04f, 1.04f) * _e107) + _e109.zw);+ let _e88 = (*roughness_1);+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e88) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));+ let _e92 = r[0u];+ let _e94 = r[0u];+ let _e96 = (*NdotV);+ let _e101 = r[0u];+ let _e104 = r[1u];+ a_1 = ((min((_e92 * _e94), exp2((-9.28f * _e96))) * _e101) + _e104);+ let _e106 = a_1;+ let _e108 = r;+ return ((vec2<f32>(-1.04f, 1.04f) * _e106) + _e108.zw);}fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {+ let _e86 = (*F0_);let _e87 = (*F0_);- let _e88 = (*F0_);- let _e90 = (*VdotH);- return (_e87 + ((vec3<f32>(1f, 1f, 1f) - _e88) * pow((1f - _e90), 5f)));+ let _e89 = (*VdotH);+ return (_e86 + ((vec3<f32>(1f, 1f, 1f) - _e87) * pow((1f - _e89), 5f)));}fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {var k: f32;- let _e89 = (*roughness_2);- let _e91 = (*roughness_2);- k = (((_e89 + 1f) * (_e91 + 1f)) * 0.125f);+ let _e88 = (*roughness_2);+ let _e90 = (*roughness_2);+ k = (((_e88 + 1f) * (_e90 + 1f)) * 0.125f);+ let _e94 = (*NdotV_1);let _e95 = (*NdotV_1);- let _e96 = (*NdotV_1);- let _e97 = k;- let _e100 = k;+ let _e96 = k;+ let _e99 = k;+ let _e102 = (*NdotL);let _e103 = (*NdotL);- let _e104 = (*NdotL);- let _e105 = k;- let _e108 = k;- return ((_e95 / ((_e96 * (1f - _e97)) + _e100)) * (_e103 / ((_e104 * (1f - _e105)) + _e108)));+ let _e104 = k;+ let _e107 = k;+ return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));}fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {var a2_: f32;var d: f32;+ let _e88 = (*a_2);let _e89 = (*a_2);- let _e90 = (*a_2);- a2_ = (_e89 * _e90);+ a2_ = (_e88 * _e89);+ let _e91 = (*NdotH);let _e92 = (*NdotH);- let _e93 = (*NdotH);- let _e95 = a2_;- d = (((_e92 * _e93) * (_e95 - 1f)) + 1f);- let _e99 = a2_;- let _e100 = d;- let _e102 = d;- return (_e99 / max(((3.1415927f * _e100) * _e102), 0.0000001f));+ let _e94 = a2_;+ d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);+ let _e98 = a2_;+ let _e99 = d;+ let _e101 = d;+ return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));}fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {return 1f;}-fn segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b(p0_: ptr<function, vec2<f32>>, p1_: ptr<function, vec2<f32>>, box: ptr<function, vec4<f32>>) -> f32 {- var d_1: vec2<f32>;- var tmin: f32;- var tmax: f32;- var a_3: i32;- var da: f32;+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {+ var clip: vec4<f32>;+ var uv: vec2<f32>;+ var m: vec4<f32>;+ var hidden: f32;var local: f32;- var p0a: f32;var local_1: f32;- var lo_1: f32;var local_2: f32;- var hi: f32;- var local_3: f32;- var t1_: f32;- var t2_: f32;var phi_194_: bool;- var phi_203_: bool;- var phi_211_: bool;- let _e103 = (*p0_)[0u];- let _e105 = (*box)[0u];- let _e106 = (_e103 >= _e105);- phi_194_ = _e106;- if _e106 {- let _e108 = (*p0_)[1u];- let _e110 = (*box)[1u];- phi_194_ = (_e108 >= _e110);- }- let _e113 = phi_194_;- phi_203_ = _e113;- if _e113 {- let _e115 = (*p0_)[0u];- let _e117 = (*box)[2u];- phi_203_ = (_e115 <= _e117);- }- let _e120 = phi_203_;- phi_211_ = _e120;- if _e120 {- let _e122 = (*p0_)[1u];- let _e124 = (*box)[3u];- phi_211_ = (_e122 <= _e124);- }- let _e127 = phi_211_;- if _e127 {- return 0f;- }- let _e128 = (*p1_);- let _e129 = (*p0_);- d_1 = (_e128 - _e129);- tmin = 0f;- tmax = 1f;- a_3 = 0i;- loop {- let _e131 = a_3;- if (_e131 < 2i) {- let _e133 = a_3;- if (_e133 == 0i) {- let _e136 = d_1[0u];- local = _e136;- } else {- let _e138 = d_1[1u];- local = _e138;- }- let _e139 = local;- da = _e139;- let _e140 = a_3;- if (_e140 == 0i) {- let _e143 = (*p0_)[0u];- local_1 = _e143;- } else {- let _e145 = (*p0_)[1u];- local_1 = _e145;- }- let _e146 = local_1;- p0a = _e146;- let _e147 = a_3;- if (_e147 == 0i) {- let _e150 = (*box)[0u];- local_2 = _e150;- } else {- let _e152 = (*box)[1u];- local_2 = _e152;- }- let _e153 = local_2;- let _e154 = p0a;- lo_1 = (_e153 - _e154);- let _e156 = a_3;- if (_e156 == 0i) {- let _e159 = (*box)[2u];- local_3 = _e159;- } else {- let _e161 = (*box)[3u];- local_3 = _e161;- }- let _e162 = local_3;- let _e163 = p0a;- hi = (_e162 - _e163);- let _e165 = da;- if (abs(_e165) < 0.00001f) {- let _e168 = lo_1;- let _e170 = hi;- if ((_e168 > 0f) || (_e170 < 0f)) {- return 0f;- }- } else {- let _e173 = lo_1;- let _e174 = da;- t1_ = (_e173 / _e174);- let _e176 = hi;- let _e177 = da;- t2_ = (_e176 / _e177);- let _e179 = tmin;- let _e180 = t1_;- let _e181 = t2_;- tmin = max(_e179, min(_e180, _e181));- let _e184 = tmax;- let _e185 = t1_;- let _e186 = t2_;- tmax = min(_e184, max(_e185, _e186));- let _e189 = tmin;- let _e190 = tmax;- if (_e189 > _e190) {- return 0f;- }- }- continue;- } else {- break;- }- continuing {- let _e192 = a_3;- a_3 = (_e192 + 1i);- }+ let _e93 = (*channel);+ let _e94 = (_e93 < 0f);+ phi_194_ = _e94;+ if !(_e94) {+ let _e98 = unnamed_1.u_shadow2DRect[2u];+ phi_194_ = (_e98 <= 0f);}- return 1f;-}--fn shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b(worldPos_1: ptr<function, vec2<f32>>, target_: ptr<function, vec2<f32>>, softness: ptr<function, f32>) -> f32 {- var n: i32;- var i: i32;- var param_4: vec2<f32>;- var param_5: vec2<f32>;- var param_6: vec4<f32>;- var dir: vec2<f32>;- var dl: f32;- var perp: vec2<f32>;- var local_4: vec2<f32>;- var blocked: f32;- var s: i32;- var t: f32;- var tp: vec2<f32>;- var i_1: i32;- var param_7: vec2<f32>;- var param_8: vec2<f32>;- var param_9: vec4<f32>;-- let _e107 = unnamed_1.u_occluderCount[0u];- n = i32(_e107);- let _e109 = n;- if (_e109 <= 0i) {+ let _e101 = phi_194_;+ if _e101 {return 1f;}- let _e111 = (*softness);- if (_e111 < 0.0001f) {- i = 0i;- loop {- let _e113 = i;- if (_e113 < 8i) {- let _e115 = i;- let _e116 = n;- if (_e115 >= _e116) {- break;- }- let _e118 = i;- let _e119 = (*worldPos_1);- param_4 = _e119;- let _e120 = (*target_);- param_5 = _e120;- let _e123 = unnamed_1.u_occluders[_e118];- param_6 = _e123;- let _e124 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_4), (¶m_5), (¶m_6));- if (_e124 > 0.5f) {- return 0f;- }- continue;- } else {- break;- }- continuing {- let _e126 = i;- i = (_e126 + 1i);- }- }+ let _e103 = unnamed.u_projection;+ let _e104 = (*worldPos_1);+ clip = (_e103 * vec4<f32>(_e104.x, _e104.y, 0f, 1f));+ let _e110 = clip[3u];+ if (_e110 <= 0f) {return 1f;}- let _e128 = (*target_);- let _e129 = (*worldPos_1);- dir = (_e128 - _e129);- let _e131 = dir;- dl = length(_e131);- let _e133 = dl;- if (_e133 > 0.0001f) {- let _e136 = dir[1u];- let _e139 = dir[0u];- let _e141 = dl;- local_4 = (vec2<f32>(-(_e136), _e139) / vec2(_e141));+ let _e113 = unnamed_1.u_shadow2DRect;+ let _e115 = clip;+ let _e118 = clip[3u];+ let _e125 = unnamed_1.u_shadow2DRect;+ uv = (_e113.xy + ((((_e115.xy / vec2(_e118)) * 0.5f) + vec2(0.5f)) * _e125.zw));+ let _e129 = uv;+ let _e130 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e129, 0f);+ m = _e130;+ let _e131 = (*channel);+ if (_e131 < 0.5f) {+ let _e134 = m[0u];+ local = _e134;} else {- local_4 = vec2<f32>(1f, 0f);- }- let _e144 = local_4;- perp = _e144;- blocked = 0f;- s = 0i;- loop {- let _e145 = s;- if (_e145 < 5i) {- let _e147 = s;- t = (((f32(_e147) / 4f) * 2f) - 1f);- let _e152 = (*target_);- let _e153 = perp;- let _e154 = t;- let _e155 = (*softness);- tp = (_e152 + (_e153 * (_e154 * _e155)));- i_1 = 0i;- loop {- let _e159 = i_1;- if (_e159 < 8i) {- let _e161 = i_1;- let _e162 = n;- if (_e161 >= _e162) {- break;- }- let _e164 = i_1;- let _e165 = (*worldPos_1);- param_7 = _e165;- let _e166 = tp;- param_8 = _e166;- let _e169 = unnamed_1.u_occluders[_e164];- param_9 = _e169;- let _e170 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_7), (¶m_8), (¶m_9));- if (_e170 > 0.5f) {- let _e172 = blocked;- blocked = (_e172 + 1f);- break;- }- continue;- } else {- break;- }- continuing {- let _e174 = i_1;- i_1 = (_e174 + 1i);- }- }- continue;+ let _e135 = (*channel);+ if (_e135 < 1.5f) {+ let _e138 = m[1u];+ local_1 = _e138;} else {- break;- }- continuing {- let _e176 = s;- s = (_e176 + 1i);+ let _e139 = (*channel);+ if (_e139 < 2.5f) {+ let _e142 = m[2u];+ local_2 = _e142;+ } else {+ let _e144 = m[3u];+ local_2 = _e144;+ }+ let _e145 = local_2;+ local_1 = _e145;}+ let _e146 = local_1;+ local = _e146;}- let _e178 = blocked;- return (1f - (_e178 / 5f));+ let _e147 = local;+ hidden = _e147;+ let _e148 = hidden;+ return (1f - min(_e148, 1f));}fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {var axis: vec2<f32>;- var local_5: vec2<f32>;+ var local_3: vec2<f32>;var toFrag: vec2<f32>;- var local_6: vec2<f32>;+ var local_4: vec2<f32>;- let _e93 = (*sp);- let _e95 = (*sp);- if (dot(_e93.xy, _e95.xy) > 0.00000001f) {- let _e99 = (*sp);- local_5 = normalize(_e99.xy);+ let _e92 = (*sp);+ let _e94 = (*sp);+ if (dot(_e92.xy, _e94.xy) > 0.00000001f) {+ let _e98 = (*sp);+ local_3 = normalize(_e98.xy);} else {- local_5 = vec2<f32>(0f, -1f);+ local_3 = vec2<f32>(0f, -1f);}- let _e102 = local_5;- axis = _e102;- let _e103 = (*dist);- if (_e103 > 0.0001f) {- let _e105 = (*toLight);- let _e108 = (*dist);- local_6 = (-(_e105.xy) / vec2(_e108));+ let _e101 = local_3;+ axis = _e101;+ let _e102 = (*dist);+ if (_e102 > 0.0001f) {+ let _e104 = (*toLight);+ let _e107 = (*dist);+ local_4 = (-(_e104.xy) / vec2(_e107));} else {- let _e111 = axis;- local_6 = _e111;+ let _e110 = axis;+ local_4 = _e110;}- let _e112 = local_6;- toFrag = _e112;- let _e114 = (*sp)[3u];- let _e116 = (*sp)[2u];- let _e117 = axis;- let _e118 = toFrag;- return smoothstep(_e114, _e116, dot(_e117, _e118));+ let _e111 = local_4;+ toFrag = _e111;+ let _e113 = (*sp)[3u];+ let _e115 = (*sp)[2u];+ let _e116 = axis;+ let _e117 = toFrag;+ return smoothstep(_e113, _e115, dot(_e116, _e117));}fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_7: vec3<f32>;+ var local_5: vec3<f32>;+ let _e87 = (*toLight_1);let _e88 = (*toLight_1);- let _e89 = (*toLight_1);- if (dot(_e88, _e89) > 0.00000001f) {- let _e92 = (*toLight_1);- local_7 = normalize(_e92);+ if (dot(_e87, _e88) > 0.00000001f) {+ let _e91 = (*toLight_1);+ local_5 = normalize(_e91);} else {- let _e94 = (*N_1);- local_7 = _e94;+ let _e93 = (*N_1);+ local_5 = _e93;}- let _e95 = local_7;- return _e95;+ let _e94 = local_5;+ return _e94;}fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {- let _e86 = (*toLight_2);- return length(_e86.xy);+ let _e85 = (*toLight_2);+ return length(_e85.xy);}fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {- let _e88 = (*pd);- let _e90 = (*worldPos_2);- let _e92 = (_e88.xy - _e90.xy);- let _e94 = (*pd)[3u];- return vec3<f32>(_e92.x, _e92.y, max(_e94, 1f));+ let _e87 = (*pd);+ let _e89 = (*worldPos_2);+ let _e91 = (_e87.xy - _e89.xy);+ let _e93 = (*pd)[3u];+ return vec3<f32>(_e91.x, _e91.y, max(_e93, 1f));}-fn envDirection_u0028_vf3_u003b(d_2: ptr<function, vec3<f32>>) -> vec3<f32> {- var a_4: f32;- var s_1: f32;+fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {+ var a_3: f32;+ var s: f32;var c: f32;- let _e91 = unnamed_1.u_envTint[3u];- a_4 = -(_e91);- let _e93 = a_4;- s_1 = sin(_e93);- let _e95 = a_4;- c = cos(_e95);- let _e97 = c;- let _e99 = (*d_2)[0u];- let _e101 = s_1;- let _e103 = (*d_2)[2u];- let _e107 = (*d_2)[1u];- let _e108 = s_1;- let _e111 = (*d_2)[0u];- let _e113 = c;- let _e115 = (*d_2)[2u];- return vec3<f32>(((_e97 * _e99) + (_e101 * _e103)), _e107, ((-(_e108) * _e111) + (_e113 * _e115)));+ let _e90 = unnamed_1.u_envTint[3u];+ a_3 = -(_e90);+ let _e92 = a_3;+ s = sin(_e92);+ let _e94 = a_3;+ c = cos(_e94);+ let _e96 = c;+ let _e98 = (*d_1)[0u];+ let _e100 = s;+ let _e102 = (*d_1)[2u];+ let _e106 = (*d_1)[1u];+ let _e107 = s;+ let _e110 = (*d_1)[0u];+ let _e112 = c;+ let _e114 = (*d_1)[2u];+ return vec3<f32>(((_e96 * _e98) + (_e100 * _e102)), _e106, ((-(_e107) * _e110) + (_e112 * _e114)));}fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {var N_2: vec3<f32>;- var param_10: vec3<f32>;+ var param_4: vec3<f32>;var sh_2: vec3<f32>;- let _e89 = (*Nw);- param_10 = _e89;- let _e90 = envDirection_u0028_vf3_u003b((¶m_10));- N_2 = _e90;- let _e93 = unnamed_1.u_envIrradiance[0i];- let _e98 = unnamed_1.u_envIrradiance[1i];- let _e101 = N_2[1u];- let _e107 = unnamed_1.u_envIrradiance[2i];- let _e110 = N_2[2u];- let _e116 = unnamed_1.u_envIrradiance[3i];- let _e119 = N_2[0u];- let _e125 = unnamed_1.u_envIrradiance[4i];- let _e128 = N_2[0u];- let _e131 = N_2[1u];- let _e137 = unnamed_1.u_envIrradiance[5i];- let _e140 = N_2[1u];- let _e143 = N_2[2u];- let _e149 = unnamed_1.u_envIrradiance[6i];- let _e152 = N_2[2u];- let _e155 = N_2[2u];- let _e163 = unnamed_1.u_envIrradiance[7i];- let _e166 = N_2[0u];- let _e169 = N_2[2u];- let _e175 = unnamed_1.u_envIrradiance[8i];- let _e178 = N_2[0u];- let _e180 = N_2[0u];- let _e183 = N_2[1u];- let _e185 = N_2[1u];- sh_2 = (((((((((_e93.xyz * 0.282095f) + (_e98.xyz * (0.488603f * _e101))) + (_e107.xyz * (0.488603f * _e110))) + (_e116.xyz * (0.488603f * _e119))) + (_e125.xyz * ((1.092548f * _e128) * _e131))) + (_e137.xyz * ((1.092548f * _e140) * _e143))) + (_e149.xyz * (0.315392f * (((3f * _e152) * _e155) - 1f)))) + (_e163.xyz * ((1.092548f * _e166) * _e169))) + (_e175.xyz * (0.546274f * ((_e178 * _e180) - (_e183 * _e185)))));- let _e192 = unnamed_1.u_ambient;- let _e194 = sh_2;- let _e197 = unnamed_1.u_envTint;- return (_e192.xyz + (max(_e194, vec3<f32>(0f, 0f, 0f)) * _e197.xyz));+ let _e88 = (*Nw);+ param_4 = _e88;+ let _e89 = envDirection_u0028_vf3_u003b((¶m_4));+ N_2 = _e89;+ let _e92 = unnamed_1.u_envIrradiance[0i];+ let _e97 = unnamed_1.u_envIrradiance[1i];+ let _e100 = N_2[1u];+ let _e106 = unnamed_1.u_envIrradiance[2i];+ let _e109 = N_2[2u];+ let _e115 = unnamed_1.u_envIrradiance[3i];+ let _e118 = N_2[0u];+ let _e124 = unnamed_1.u_envIrradiance[4i];+ let _e127 = N_2[0u];+ let _e130 = N_2[1u];+ let _e136 = unnamed_1.u_envIrradiance[5i];+ let _e139 = N_2[1u];+ let _e142 = N_2[2u];+ let _e148 = unnamed_1.u_envIrradiance[6i];+ let _e151 = N_2[2u];+ let _e154 = N_2[2u];+ let _e162 = unnamed_1.u_envIrradiance[7i];+ let _e165 = N_2[0u];+ let _e168 = N_2[2u];+ let _e174 = unnamed_1.u_envIrradiance[8i];+ let _e177 = N_2[0u];+ let _e179 = N_2[0u];+ let _e182 = N_2[1u];+ let _e184 = N_2[1u];+ sh_2 = (((((((((_e92.xyz * 0.282095f) + (_e97.xyz * (0.488603f * _e100))) + (_e106.xyz * (0.488603f * _e109))) + (_e115.xyz * (0.488603f * _e118))) + (_e124.xyz * ((1.092548f * _e127) * _e130))) + (_e136.xyz * ((1.092548f * _e139) * _e142))) + (_e148.xyz * (0.315392f * (((3f * _e151) * _e154) - 1f)))) + (_e162.xyz * ((1.092548f * _e165) * _e168))) + (_e174.xyz * (0.546274f * ((_e177 * _e179) - (_e182 * _e184)))));+ let _e191 = unnamed_1.u_ambient;+ let _e193 = sh_2;+ let _e196 = unnamed_1.u_envTint;+ return (_e191.xyz + (max(_e193, vec3<f32>(0f, 0f, 0f)) * _e196.xyz));}fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {var F0_1: vec3<f32>;- var a_5: f32;+ var a_4: f32;var NdotV_2: f32;var lit: vec3<f32>;- var param_11: vec3<f32>;+ var param_5: vec3<f32>;var gloss: vec3<f32>;- var i_2: i32;+ var i: i32;var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;- var target_1: vec2<f32>;+ var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;- var param_12: vec4<f32>;- var param_13: vec4<f32>;- var param_14: vec3<f32>;+ var param_6: vec4<f32>;+ var param_7: vec4<f32>;+ var param_8: vec3<f32>;var dist_1: f32;- var param_15: vec3<f32>;+ var param_9: vec3<f32>;var atten: f32;var L_1: vec3<f32>;- var param_16: vec3<f32>;- var param_17: vec3<f32>;+ var param_10: vec3<f32>;+ var param_11: vec3<f32>;var toLight_3: vec2<f32>;- var local_8: vec2<f32>;+ var local_6: vec2<f32>;var sp_1: vec4<f32>;var toL_1: vec3<f32>;+ var param_12: vec4<f32>;+ var param_13: vec4<f32>;+ var param_14: vec3<f32>;+ var dist_2: f32;+ var param_15: vec3<f32>;+ var param_16: vec3<f32>;+ var param_17: vec3<f32>;var param_18: vec4<f32>;var param_19: vec4<f32>;var param_20: vec3<f32>;- var dist_2: f32;- var param_21: vec3<f32>;- var param_22: vec3<f32>;- var param_23: vec3<f32>;- var param_24: vec4<f32>;- var param_25: vec4<f32>;- var param_26: vec3<f32>;- var param_27: f32;- var param_28: vec2<f32>;- var param_29: vec2<f32>;- var param_30: f32;+ var param_21: f32;+ var param_22: f32;+ var param_23: vec2<f32>;var sm: vec4<f32>;- var param_31: vec3<f32>;- var param_32: vec3<f32>;- var param_33: vec3<f32>;- var param_34: vec2<f32>;- var param_35: i32;- var param_36: i32;+ var param_24: vec3<f32>;+ var param_25: vec3<f32>;+ var param_26: vec3<f32>;+ var param_27: vec2<f32>;+ var param_28: i32;+ var param_29: i32;var ndotl: f32;var radiance: vec3<f32>;var H: vec3<f32>;var brdf: f32;+ var param_30: f32;+ var param_31: f32;+ var param_32: f32;+ var param_33: f32;+ var param_34: f32;+ var param_35: f32;+ var param_36: vec3<f32>;+ var ab: vec2<f32>;var param_37: f32;var param_38: f32;- var param_39: f32;+ var param_39: vec3<f32>;var param_40: f32;- var param_41: f32;- var param_42: f32;- var param_43: vec3<f32>;- var ab: vec2<f32>;- var param_44: f32;- var param_45: f32;- var param_46: vec3<f32>;- var param_47: f32;- var phi_979_: bool;- var phi_1033_: bool;-- let _e156 = (*albedo);- let _e157 = (*metallic);- F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e156, vec3(_e157));- let _e160 = (*roughness_3);- let _e161 = (*roughness_3);- a_5 = max((_e160 * _e161), 0.001f);- let _e164 = (*N_3);- let _e165 = (*V);- NdotV_2 = max(dot(_e164, _e165), 0.0001f);- let _e168 = (*N_3);- param_11 = _e168;- let _e169 = envIrradiance_u0028_vf3_u003b((¶m_11));- let _e170 = (*ao);- lit = (_e169 * _e170);+ var phi_787_: bool;+ var phi_841_: bool;++ let _e154 = (*albedo);+ let _e155 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e154, vec3(_e155));+ let _e158 = (*roughness_3);+ let _e159 = (*roughness_3);+ a_4 = max((_e158 * _e159), 0.001f);+ let _e162 = (*N_3);+ let _e163 = (*V);+ NdotV_2 = max(dot(_e162, _e163), 0.0001f);+ let _e166 = (*N_3);+ param_5 = _e166;+ let _e167 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e168 = (*ao);+ lit = (_e167 * _e168);gloss = vec3<f32>(0f, 0f, 0f);- i_2 = 0i;+ i = 0i;loop {- let _e172 = i_2;- if (_e172 < 16i) {- let _e174 = i_2;- let _e178 = unnamed_1.u_lights[_e174].posDir;- pd_1 = _e178;- let _e179 = i_2;- let _e183 = unnamed_1.u_lights[_e179].color;- col = _e183;- let _e184 = i_2;- let _e188 = unnamed_1.u_lights[_e184].shadow;- sh_3 = _e188;- let _e189 = pd_1;- target_1 = _e189.xy;+ let _e170 = i;+ if (_e170 < 16i) {+ let _e172 = i;+ let _e176 = unnamed_1.u_lights[_e172].posDir;+ pd_1 = _e176;+ let _e177 = i;+ let _e181 = unnamed_1.u_lights[_e177].color;+ col = _e181;+ let _e182 = i;+ let _e186 = unnamed_1.u_lights[_e182].shadow;+ sh_3 = _e186;+ let _e187 = pd_1;+ target_ = _e187.xy;castShadow = true;- let _e192 = pd_1[2u];- if (_e192 < 0.5f) {- let _e194 = pd_1;- param_12 = _e194;- let _e195 = sh_3;- param_13 = _e195;- let _e196 = (*worldPos_3);- param_14 = _e196;- let _e197 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));- toL = _e197;- let _e198 = toL;- param_15 = _e198;- let _e199 = lightDistance_u0028_vf3_u003b((¶m_15));- dist_1 = _e199;- let _e200 = dist_1;- let _e202 = pd_1[3u];- atten = max(0f, (1f - (_e200 / max(_e202, 0.0001f))));- let _e207 = toL;- param_16 = _e207;- let _e208 = (*N_3);- param_17 = _e208;- let _e209 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));- L_1 = _e209;+ let _e190 = pd_1[2u];+ if (_e190 < 0.5f) {+ let _e192 = pd_1;+ param_6 = _e192;+ let _e193 = sh_3;+ param_7 = _e193;+ let _e194 = (*worldPos_3);+ param_8 = _e194;+ let _e195 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e195;+ let _e196 = toL;+ param_9 = _e196;+ let _e197 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_1 = _e197;+ let _e198 = dist_1;+ let _e200 = pd_1[3u];+ atten = max(0f, (1f - (_e198 / max(_e200, 0.0001f))));+ let _e205 = toL;+ param_10 = _e205;+ let _e206 = (*N_3);+ param_11 = _e206;+ let _e207 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_10), (¶m_11));+ L_1 = _e207;} else {- let _e211 = pd_1[2u];- if (_e211 < 1.5f) {+ let _e209 = pd_1[2u];+ if (_e209 < 1.5f) {atten = 1f;- let _e213 = pd_1;- let _e214 = _e213.xy;- let _e216 = pd_1[3u];- L_1 = normalize(-(vec3<f32>(_e214.x, _e214.y, _e216)));+ let _e211 = pd_1;+ let _e212 = _e211.xy;+ let _e214 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e212.x, _e212.y, _e214)));+ let _e220 = pd_1;let _e222 = pd_1;- let _e224 = pd_1;- if (dot(_e222.xy, _e224.xy) > 0.00000001f) {- let _e228 = pd_1;- local_8 = normalize(-(_e228.xy));+ if (dot(_e220.xy, _e222.xy) > 0.00000001f) {+ let _e226 = pd_1;+ local_6 = normalize(-(_e226.xy));} else {- local_8 = vec2<f32>(0f, 0f);+ local_6 = vec2<f32>(0f, 0f);}- let _e232 = local_8;- toLight_3 = _e232;- let _e234 = sh_3[1u];- let _e235 = (_e234 > 0f);- phi_979_ = _e235;- if _e235 {- let _e236 = toLight_3;- let _e237 = toLight_3;- phi_979_ = (dot(_e236, _e237) > 0.5f);+ let _e230 = local_6;+ toLight_3 = _e230;+ let _e232 = sh_3[1u];+ let _e233 = (_e232 > 0f);+ phi_787_ = _e233;+ if _e233 {+ let _e234 = toLight_3;+ let _e235 = toLight_3;+ phi_787_ = (dot(_e234, _e235) > 0.5f);}- let _e241 = phi_979_;- castShadow = _e241;- let _e242 = (*worldPos_3);- let _e244 = toLight_3;- let _e246 = sh_3[1u];- target_1 = (_e242.xy + (_e244 * _e246));+ let _e239 = phi_787_;+ castShadow = _e239;+ let _e240 = (*worldPos_3);+ let _e242 = toLight_3;+ let _e244 = sh_3[1u];+ target_ = (_e240.xy + (_e242 * _e244));} else {- let _e249 = i_2;- let _e253 = unnamed_1.u_lights[_e249].spot;- sp_1 = _e253;- let _e254 = pd_1;- param_18 = _e254;- let _e255 = sh_3;- param_19 = _e255;- let _e256 = (*worldPos_3);- param_20 = _e256;- let _e257 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_18), (¶m_19), (¶m_20));- toL_1 = _e257;- let _e258 = toL_1;- param_21 = _e258;- let _e259 = lightDistance_u0028_vf3_u003b((¶m_21));- dist_2 = _e259;- let _e260 = dist_2;- let _e262 = pd_1[3u];- atten = max(0f, (1f - (_e260 / max(_e262, 0.0001f))));- let _e267 = toL_1;- param_22 = _e267;- let _e268 = (*N_3);- param_23 = _e268;- let _e269 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));- L_1 = _e269;- let _e270 = sp_1;- param_24 = _e270;- let _e271 = sh_3;- param_25 = _e271;- let _e272 = toL_1;- param_26 = _e272;- let _e273 = dist_2;- param_27 = _e273;- let _e274 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));- let _e275 = atten;- atten = (_e275 * _e274);+ let _e247 = i;+ let _e251 = unnamed_1.u_lights[_e247].spot;+ sp_1 = _e251;+ let _e252 = pd_1;+ param_12 = _e252;+ let _e253 = sh_3;+ param_13 = _e253;+ let _e254 = (*worldPos_3);+ param_14 = _e254;+ let _e255 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));+ toL_1 = _e255;+ let _e256 = toL_1;+ param_15 = _e256;+ let _e257 = lightDistance_u0028_vf3_u003b((¶m_15));+ dist_2 = _e257;+ let _e258 = dist_2;+ let _e260 = pd_1[3u];+ atten = max(0f, (1f - (_e258 / max(_e260, 0.0001f))));+ let _e265 = toL_1;+ param_16 = _e265;+ let _e266 = (*N_3);+ param_17 = _e266;+ let _e267 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));+ L_1 = _e267;+ let _e268 = sp_1;+ param_18 = _e268;+ let _e269 = sh_3;+ param_19 = _e269;+ let _e270 = toL_1;+ param_20 = _e270;+ let _e271 = dist_2;+ param_21 = _e271;+ let _e272 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_18), (¶m_19), (¶m_20), (¶m_21));+ let _e273 = atten;+ atten = (_e273 * _e272);}}- let _e277 = castShadow;- phi_1033_ = _e277;- if _e277 {- let _e279 = col[3u];- phi_1033_ = (_e279 > 0f);+ let _e275 = castShadow;+ phi_841_ = _e275;+ if _e275 {+ let _e277 = col[3u];+ phi_841_ = (_e277 > 0f);}- let _e282 = phi_1033_;- let _e283 = atten;- if (_e282 && (_e283 > 0f)) {- let _e286 = (*worldPos_3);- param_28 = _e286.xy;- let _e288 = target_1;- param_29 = _e288;- let _e290 = sh_3[0u];- param_30 = _e290;- let _e291 = shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b((¶m_28), (¶m_29), (¶m_30));- let _e292 = atten;- atten = (_e292 * _e291);+ let _e280 = phi_841_;+ let _e281 = atten;+ if (_e280 && (_e281 > 0f)) {+ let _e284 = i;+ let _e289 = unnamed_1.u_lights[_e284].shadowMap[3u];+ param_22 = _e289;+ let _e290 = (*worldPos_3);+ param_23 = _e290.xy;+ let _e292 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_22), (¶m_23));+ let _e293 = atten;+ atten = (_e293 * _e292);}- let _e294 = i_2;- let _e298 = unnamed_1.u_lights[_e294].shadowMap;- sm = _e298;- let _e300 = sm[1u];- let _e302 = atten;- if ((_e300 > 0f) && (_e302 > 0f)) {- let _e306 = sh_3[0u];- let _e308 = sm[2u];- let _e311 = sm[0u];- let _e314 = sm[1u];- let _e316 = (*worldPos_3);- param_31 = _e316;- let _e317 = (*N_3);- param_32 = _e317;- let _e318 = L_1;- param_33 = _e318;- param_34 = vec2<f32>(_e306, _e308);- param_35 = i32(_e311);- param_36 = i32(_e314);- let _e319 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35), (¶m_36));- let _e320 = atten;- atten = (_e320 * _e319);+ let _e295 = i;+ let _e299 = unnamed_1.u_lights[_e295].shadowMap;+ sm = _e299;+ let _e301 = sm[1u];+ let _e303 = atten;+ if ((_e301 > 0f) && (_e303 > 0f)) {+ let _e307 = sh_3[0u];+ let _e309 = sm[2u];+ let _e312 = sm[0u];+ let _e315 = sm[1u];+ let _e317 = (*worldPos_3);+ param_24 = _e317;+ let _e318 = (*N_3);+ param_25 = _e318;+ let _e319 = L_1;+ param_26 = _e319;+ param_27 = vec2<f32>(_e307, _e309);+ param_28 = i32(_e312);+ param_29 = i32(_e315);+ let _e320 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27), (¶m_28), (¶m_29));+ let _e321 = atten;+ atten = (_e321 * _e320);}- let _e322 = (*N_3);- let _e323 = L_1;- ndotl = max(dot(_e322, _e323), 0f);- let _e326 = col;- let _e329 = col[3u];- let _e330 = ndotl;- let _e332 = atten;- radiance = (_e326.xyz * ((_e329 * _e330) * _e332));- let _e335 = radiance;- let _e336 = lit;- lit = (_e336 + _e335);- let _e338 = (*specular);- if (_e338 > 0f) {- let _e340 = L_1;- let _e341 = (*V);- H = normalize((_e340 + _e341));- let _e344 = (*N_3);- let _e345 = H;- param_37 = max(dot(_e344, _e345), 0f);- let _e348 = a_5;- param_38 = _e348;- let _e349 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));- let _e350 = NdotV_2;- param_39 = _e350;- let _e351 = ndotl;- param_40 = _e351;- let _e352 = (*roughness_3);- param_41 = _e352;- let _e353 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_39), (¶m_40), (¶m_41));- let _e355 = NdotV_2;- let _e357 = ndotl;- brdf = ((_e349 * _e353) / max(((4f * _e355) * _e357), 0.0001f));- let _e361 = radiance;- let _e362 = (*V);- let _e363 = H;- param_42 = max(dot(_e362, _e363), 0f);- let _e366 = F0_1;- param_43 = _e366;- let _e367 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_42), (¶m_43));- let _e369 = brdf;- let _e371 = (*specular);- let _e374 = gloss;- gloss = (_e374 + ((_e361 * _e367) * ((_e369 * 3.1415927f) * _e371)));+ let _e323 = (*N_3);+ let _e324 = L_1;+ ndotl = max(dot(_e323, _e324), 0f);+ let _e327 = col;+ let _e330 = col[3u];+ let _e331 = ndotl;+ let _e333 = atten;+ radiance = (_e327.xyz * ((_e330 * _e331) * _e333));+ let _e336 = radiance;+ let _e337 = lit;+ lit = (_e337 + _e336);+ let _e339 = (*specular);+ if (_e339 > 0f) {+ let _e341 = L_1;+ let _e342 = (*V);+ H = normalize((_e341 + _e342));+ let _e345 = (*N_3);+ let _e346 = H;+ param_30 = max(dot(_e345, _e346), 0f);+ let _e349 = a_4;+ param_31 = _e349;+ let _e350 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_30), (¶m_31));+ let _e351 = NdotV_2;+ param_32 = _e351;+ let _e352 = ndotl;+ param_33 = _e352;+ let _e353 = (*roughness_3);+ param_34 = _e353;+ let _e354 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_32), (¶m_33), (¶m_34));+ let _e356 = NdotV_2;+ let _e358 = ndotl;+ brdf = ((_e350 * _e354) / max(((4f * _e356) * _e358), 0.0001f));+ let _e362 = radiance;+ let _e363 = (*V);+ let _e364 = H;+ param_35 = max(dot(_e363, _e364), 0f);+ let _e367 = F0_1;+ param_36 = _e367;+ let _e368 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_35), (¶m_36));+ let _e370 = brdf;+ let _e372 = (*specular);+ let _e375 = gloss;+ gloss = (_e375 + ((_e362 * _e368) * ((_e370 * 3.1415927f) * _e372)));}continue;} else {break;}continuing {- let _e376 = i_2;- i_2 = (_e376 + 1i);+ let _e377 = i;+ i = (_e377 + 1i);}}- let _e378 = NdotV_2;- param_44 = _e378;- let _e379 = (*roughness_3);- param_45 = _e379;- let _e380 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_44), (¶m_45));- ab = _e380;- let _e381 = (*V);- let _e383 = (*N_3);- param_46 = reflect(-(_e381), _e383);- let _e385 = (*roughness_3);- param_47 = _e385;- let _e386 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_46), (¶m_47));- let _e387 = (*ao);- let _e388 = (*specular);- let _e391 = F0_1;- let _e393 = ab[0u];- let _e396 = ab[1u];- let _e400 = gloss;- gloss = (_e400 + ((_e386 * (_e387 * _e388)) * ((_e391 * _e393) + vec3(_e396))));- let _e402 = (*albedo);- let _e403 = (*metallic);- let _e406 = lit;- let _e408 = gloss;- return (((_e402 * (1f - _e403)) * _e406) + _e408);+ let _e379 = NdotV_2;+ param_37 = _e379;+ let _e380 = (*roughness_3);+ param_38 = _e380;+ let _e381 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));+ ab = _e381;+ let _e382 = (*V);+ let _e384 = (*N_3);+ param_39 = reflect(-(_e382), _e384);+ let _e386 = (*roughness_3);+ param_40 = _e386;+ let _e387 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_39), (¶m_40));+ let _e388 = (*ao);+ let _e389 = (*specular);+ let _e392 = F0_1;+ let _e394 = ab[0u];+ let _e397 = ab[1u];+ let _e401 = gloss;+ gloss = (_e401 + ((_e387 * (_e388 * _e389)) * ((_e392 * _e394) + vec3(_e397))));+ let _e403 = (*albedo);+ let _e404 = (*metallic);+ let _e407 = lit;+ let _e409 = gloss;+ return (((_e403 * (1f - _e404)) * _e407) + _e409);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_9: vec3<f32>;+ var local_7: vec3<f32>;- let _e89 = unnamed.u_camera[3u];- if (_e89 > 0.5f) {- let _e92 = unnamed.u_camera;- let _e94 = (*worldPos_4);- local_9 = normalize((_e92.xyz - _e94));+ let _e88 = unnamed.u_camera[3u];+ if (_e88 > 0.5f) {+ let _e91 = unnamed.u_camera;+ let _e93 = (*worldPos_4);+ local_7 = normalize((_e91.xyz - _e93));} else {- let _e98 = unnamed.u_camera;- local_9 = _e98.xyz;+ let _e97 = unnamed.u_camera;+ local_7 = _e97.xyz;}- let _e100 = local_9;- return _e100;+ let _e99 = local_7;+ return _e99;}fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {var P: vec3<f32>;- var param_48: vec3<f32>;- var param_49: vec3<f32>;- var param_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec3<f32>;- var param_53: f32;- var param_54: f32;- var param_55: f32;- var param_56: f32;-- let _e99 = (*worldPos_5);- P = vec3<f32>(_e99.x, _e99.y, 0f);- let _e103 = P;- param_48 = _e103;- let _e104 = viewDirection_u0028_vf3_u003b((¶m_48));- let _e105 = (*albedo_1);- param_49 = _e105;- let _e106 = (*N_4);- param_50 = _e106;- let _e107 = P;- param_51 = _e107;- param_52 = _e104;- param_53 = 0f;- param_54 = 1f;- param_55 = 0f;- let _e108 = (*ao_1);- param_56 = _e108;- let _e109 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55), (¶m_56));- return _e109;+ var param_41: vec3<f32>;+ var param_42: vec3<f32>;+ var param_43: vec3<f32>;+ var param_44: vec3<f32>;+ var param_45: vec3<f32>;+ var param_46: f32;+ var param_47: f32;+ var param_48: f32;+ var param_49: f32;++ let _e98 = (*worldPos_5);+ P = vec3<f32>(_e98.x, _e98.y, 0f);+ let _e102 = P;+ param_41 = _e102;+ let _e103 = viewDirection_u0028_vf3_u003b((¶m_41));+ let _e104 = (*albedo_1);+ param_42 = _e104;+ let _e105 = (*N_4);+ param_43 = _e105;+ let _e106 = P;+ param_44 = _e106;+ param_45 = _e103;+ param_46 = 0f;+ param_47 = 1f;+ param_48 = 0f;+ let _e107 = (*ao_1);+ param_49 = _e107;+ let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_42), (¶m_43), (¶m_44), (¶m_45), (¶m_46), (¶m_47), (¶m_48), (¶m_49));+ return _e108;}fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_6: ptr<function, vec2<f32>>) -> vec3<f32> {- var param_57: vec3<f32>;- var param_58: vec3<f32>;- var param_59: vec2<f32>;- var param_60: f32;+ var param_50: vec3<f32>;+ var param_51: vec3<f32>;+ var param_52: vec2<f32>;+ var param_53: f32;- let _e92 = (*albedo_2);- param_57 = _e92;- let _e93 = (*N_5);- param_58 = _e93;- let _e94 = (*worldPos_6);- param_59 = _e94;- param_60 = 1f;- let _e95 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_57), (¶m_58), (¶m_59), (¶m_60));- return _e95;+ let _e91 = (*albedo_2);+ param_50 = _e91;+ let _e92 = (*N_5);+ param_51 = _e92;+ let _e93 = (*worldPos_6);+ param_52 = _e93;+ param_53 = 1f;+ let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_50), (¶m_51), (¶m_52), (¶m_53));+ return _e94;}-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv: ptr<function, vec2<f32>>) -> vec3<f32> {- let _e88 = (*uv);- let _e89 = textureSample(map_est, map_ess, _e88);- return normalize(((_e89.xyz * 2f) - vec3(1f)));+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {+ let _e87 = (*uv_1);+ let _e88 = textureSample(map_est, map_ess, _e87);+ return normalize(((_e88.xyz * 2f) - vec3(1f)));}fn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_61: vec2<f32>;- var param_62: vec3<f32>;- var param_63: vec3<f32>;- var param_64: vec2<f32>;-- let _e91 = v_texCoord_1;- let _e92 = textureSample(es_bt0_est, es_bt0_ess, _e91);- let _e93 = v_color_1;- let _e96 = unnamed_2.u_tint;- base = ((_e92 * _e93) * _e96);- let _e98 = v_texCoord_1;- param_61 = _e98;- let _e99 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (¶m_61));- N_6 = _e99;- let _e100 = base;- param_62 = _e100.xyz;- let _e102 = N_6;- param_63 = _e102;- let _e103 = v_worldPos_1;- param_64 = _e103;- let _e104 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_62), (¶m_63), (¶m_64));- let _e106 = base[3u];- fragColor = vec4<f32>(_e104.x, _e104.y, _e104.z, _e106);+ var param_54: vec2<f32>;+ var param_55: vec3<f32>;+ var param_56: vec3<f32>;+ var param_57: vec2<f32>;++ let _e90 = v_texCoord_1;+ let _e91 = textureSample(es_bt0_est, es_bt0_ess, _e90);+ let _e92 = v_color_1;+ let _e95 = unnamed_2.u_tint;+ base = ((_e91 * _e92) * _e95);+ let _e97 = v_texCoord_1;+ param_54 = _e97;+ let _e98 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (¶m_54));+ N_6 = _e98;+ let _e99 = base;+ param_55 = _e99.xyz;+ let _e101 = N_6;+ param_56 = _e101;+ let _e102 = v_worldPos_1;+ param_57 = _e102;+ let _e103 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_55), (¶m_56), (¶m_57));+ let _e105 = base[3u];+ fragColor = vec4<f32>(_e103.x, _e103.y, _e103.z, _e105);return;}diff --git a/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader b/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshaderindex 96c51e60b..6c733423d 100644--- a/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader+++ b/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader@@ -47,7 +47,7 @@ void main() {// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: a8853729e0f76d55-// assembled-hash: 16b98c0f8747453a+// assembled-hash: ec80a65441a56f13struct gl_PerVertex {@builtin(position) gl_Position: vec4<f32>,gl_PointSize: f32,@@ -120,7 +120,7 @@ fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>,// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: a8853729e0f76d55-// assembled-hash: 16b98c0f8747453a+// assembled-hash: ec80a65441a56f13struct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -138,8 +138,7 @@ struct Light {struct LightConstants {u_ambient: vec4<f32>,u_lights: array<Light, 16>,- u_occluderCount: vec4<f32>,- u_occluders: array<vec4<f32>, 8>,+ u_shadow2DRect: vec4<f32>,u_shadowMatrix: array<mat4x4<f32>, 16>,u_shadowTile: array<vec4<f32>, 16>,u_shadowParams: vec4<f32>,@@ -157,6 +156,10 @@ struct TimeConstants {var<uniform> unnamed: FrameConstants;@group(0) @binding(2)var<uniform> unnamed_1: LightConstants;+@group(1) @binding(7)+var u_shadow2D_est: texture_2d<f32>;+@group(1) @binding(15)+var u_shadow2D_ess: sampler;@group(1) @binding(0)var es_bt0_est: texture_2d<f32>;@group(1) @binding(8)@@ -214,905 +217,702 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughnessvar param_2: vec3<f32>;var param_3: f32;- let _e96 = unnamed_1.u_envParams[0u];- if (_e96 < 0.5f) {- let _e99 = unnamed_1.u_ambient;- return _e99.xyz;+ let _e95 = unnamed_1.u_envParams[0u];+ if (_e95 < 0.5f) {+ let _e98 = unnamed_1.u_ambient;+ return _e98.xyz;}- let _e101 = (*roughness);- let _e105 = unnamed_1.u_envParams[2u];- lod = (clamp(_e101, 0f, 1f) * _e105);- let _e107 = lod;- lo = floor(_e107);- let _e109 = (*R_1);- param = _e109;- let _e110 = lo;- param_1 = _e110;- let _e111 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));- a = _e111;- let _e112 = lo;- let _e116 = unnamed_1.u_envParams[2u];- let _e118 = (*R_1);- param_2 = _e118;- param_3 = min((_e112 + 1f), _e116);- let _e119 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));- b = _e119;- let _e121 = unnamed_1.u_ambient;- let _e123 = a;- let _e124 = b;- let _e125 = lod;- let _e126 = lo;- let _e131 = unnamed_1.u_envTint;- return (_e121.xyz + (mix(_e123, _e124, vec3((_e125 - _e126))) * _e131.xyz));+ let _e100 = (*roughness);+ let _e104 = unnamed_1.u_envParams[2u];+ lod = (clamp(_e100, 0f, 1f) * _e104);+ let _e106 = lod;+ lo = floor(_e106);+ let _e108 = (*R_1);+ param = _e108;+ let _e109 = lo;+ param_1 = _e109;+ let _e110 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));+ a = _e110;+ let _e111 = lo;+ let _e115 = unnamed_1.u_envParams[2u];+ let _e117 = (*R_1);+ param_2 = _e117;+ param_3 = min((_e111 + 1f), _e115);+ let _e118 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));+ b = _e118;+ let _e120 = unnamed_1.u_ambient;+ let _e122 = a;+ let _e123 = b;+ let _e124 = lod;+ let _e125 = lo;+ let _e130 = unnamed_1.u_envTint;+ return (_e120.xyz + (mix(_e122, _e123, vec3((_e124 - _e125))) * _e130.xyz));}fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {var r: vec4<f32>;var a_1: f32;- let _e88 = (*roughness_1);- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e88) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));- let _e92 = r[0u];- let _e94 = r[0u];- let _e96 = (*NdotV);- let _e101 = r[0u];- let _e104 = r[1u];- a_1 = ((min((_e92 * _e94), exp2((-9.28f * _e96))) * _e101) + _e104);- let _e106 = a_1;- let _e108 = r;- return ((vec2<f32>(-1.04f, 1.04f) * _e106) + _e108.zw);+ let _e87 = (*roughness_1);+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e87) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));+ let _e91 = r[0u];+ let _e93 = r[0u];+ let _e95 = (*NdotV);+ let _e100 = r[0u];+ let _e103 = r[1u];+ a_1 = ((min((_e91 * _e93), exp2((-9.28f * _e95))) * _e100) + _e103);+ let _e105 = a_1;+ let _e107 = r;+ return ((vec2<f32>(-1.04f, 1.04f) * _e105) + _e107.zw);}fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {+ let _e85 = (*F0_);let _e86 = (*F0_);- let _e87 = (*F0_);- let _e89 = (*VdotH);- return (_e86 + ((vec3<f32>(1f, 1f, 1f) - _e87) * pow((1f - _e89), 5f)));+ let _e88 = (*VdotH);+ return (_e85 + ((vec3<f32>(1f, 1f, 1f) - _e86) * pow((1f - _e88), 5f)));}fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {var k: f32;- let _e88 = (*roughness_2);- let _e90 = (*roughness_2);- k = (((_e88 + 1f) * (_e90 + 1f)) * 0.125f);+ let _e87 = (*roughness_2);+ let _e89 = (*roughness_2);+ k = (((_e87 + 1f) * (_e89 + 1f)) * 0.125f);+ let _e93 = (*NdotV_1);let _e94 = (*NdotV_1);- let _e95 = (*NdotV_1);- let _e96 = k;- let _e99 = k;+ let _e95 = k;+ let _e98 = k;+ let _e101 = (*NdotL);let _e102 = (*NdotL);- let _e103 = (*NdotL);- let _e104 = k;- let _e107 = k;- return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));+ let _e103 = k;+ let _e106 = k;+ return ((_e93 / ((_e94 * (1f - _e95)) + _e98)) * (_e101 / ((_e102 * (1f - _e103)) + _e106)));}fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {var a2_: f32;var d: f32;+ let _e87 = (*a_2);let _e88 = (*a_2);- let _e89 = (*a_2);- a2_ = (_e88 * _e89);+ a2_ = (_e87 * _e88);+ let _e90 = (*NdotH);let _e91 = (*NdotH);- let _e92 = (*NdotH);- let _e94 = a2_;- d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);- let _e98 = a2_;- let _e99 = d;- let _e101 = d;- return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));+ let _e93 = a2_;+ d = (((_e90 * _e91) * (_e93 - 1f)) + 1f);+ let _e97 = a2_;+ let _e98 = d;+ let _e100 = d;+ return (_e97 / max(((3.1415927f * _e98) * _e100), 0.0000001f));}fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {return 1f;}-fn segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b(p0_: ptr<function, vec2<f32>>, p1_: ptr<function, vec2<f32>>, box: ptr<function, vec4<f32>>) -> f32 {- var d_1: vec2<f32>;- var tmin: f32;- var tmax: f32;- var a_3: i32;- var da: f32;+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {+ var clip: vec4<f32>;+ var uv: vec2<f32>;+ var m: vec4<f32>;+ var hidden: f32;var local: f32;- var p0a: f32;var local_1: f32;- var lo_1: f32;var local_2: f32;- var hi: f32;- var local_3: f32;- var t1_: f32;- var t2_: f32;var phi_194_: bool;- var phi_203_: bool;- var phi_211_: bool;- let _e102 = (*p0_)[0u];- let _e104 = (*box)[0u];- let _e105 = (_e102 >= _e104);- phi_194_ = _e105;- if _e105 {- let _e107 = (*p0_)[1u];- let _e109 = (*box)[1u];- phi_194_ = (_e107 >= _e109);- }- let _e112 = phi_194_;- phi_203_ = _e112;- if _e112 {- let _e114 = (*p0_)[0u];- let _e116 = (*box)[2u];- phi_203_ = (_e114 <= _e116);- }- let _e119 = phi_203_;- phi_211_ = _e119;- if _e119 {- let _e121 = (*p0_)[1u];- let _e123 = (*box)[3u];- phi_211_ = (_e121 <= _e123);- }- let _e126 = phi_211_;- if _e126 {- return 0f;- }- let _e127 = (*p1_);- let _e128 = (*p0_);- d_1 = (_e127 - _e128);- tmin = 0f;- tmax = 1f;- a_3 = 0i;- loop {- let _e130 = a_3;- if (_e130 < 2i) {- let _e132 = a_3;- if (_e132 == 0i) {- let _e135 = d_1[0u];- local = _e135;- } else {- let _e137 = d_1[1u];- local = _e137;- }- let _e138 = local;- da = _e138;- let _e139 = a_3;- if (_e139 == 0i) {- let _e142 = (*p0_)[0u];- local_1 = _e142;- } else {- let _e144 = (*p0_)[1u];- local_1 = _e144;- }- let _e145 = local_1;- p0a = _e145;- let _e146 = a_3;- if (_e146 == 0i) {- let _e149 = (*box)[0u];- local_2 = _e149;- } else {- let _e151 = (*box)[1u];- local_2 = _e151;- }- let _e152 = local_2;- let _e153 = p0a;- lo_1 = (_e152 - _e153);- let _e155 = a_3;- if (_e155 == 0i) {- let _e158 = (*box)[2u];- local_3 = _e158;- } else {- let _e160 = (*box)[3u];- local_3 = _e160;- }- let _e161 = local_3;- let _e162 = p0a;- hi = (_e161 - _e162);- let _e164 = da;- if (abs(_e164) < 0.00001f) {- let _e167 = lo_1;- let _e169 = hi;- if ((_e167 > 0f) || (_e169 < 0f)) {- return 0f;- }- } else {- let _e172 = lo_1;- let _e173 = da;- t1_ = (_e172 / _e173);- let _e175 = hi;- let _e176 = da;- t2_ = (_e175 / _e176);- let _e178 = tmin;- let _e179 = t1_;- let _e180 = t2_;- tmin = max(_e178, min(_e179, _e180));- let _e183 = tmax;- let _e184 = t1_;- let _e185 = t2_;- tmax = min(_e183, max(_e184, _e185));- let _e188 = tmin;- let _e189 = tmax;- if (_e188 > _e189) {- return 0f;- }- }- continue;- } else {- break;- }- continuing {- let _e191 = a_3;- a_3 = (_e191 + 1i);- }+ let _e92 = (*channel);+ let _e93 = (_e92 < 0f);+ phi_194_ = _e93;+ if !(_e93) {+ let _e97 = unnamed_1.u_shadow2DRect[2u];+ phi_194_ = (_e97 <= 0f);}- return 1f;-}--fn shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b(worldPos_1: ptr<function, vec2<f32>>, target_: ptr<function, vec2<f32>>, softness: ptr<function, f32>) -> f32 {- var n: i32;- var i: i32;- var param_4: vec2<f32>;- var param_5: vec2<f32>;- var param_6: vec4<f32>;- var dir: vec2<f32>;- var dl: f32;- var perp: vec2<f32>;- var local_4: vec2<f32>;- var blocked: f32;- var s: i32;- var t: f32;- var tp: vec2<f32>;- var i_1: i32;- var param_7: vec2<f32>;- var param_8: vec2<f32>;- var param_9: vec4<f32>;-- let _e106 = unnamed_1.u_occluderCount[0u];- n = i32(_e106);- let _e108 = n;- if (_e108 <= 0i) {+ let _e100 = phi_194_;+ if _e100 {return 1f;}- let _e110 = (*softness);- if (_e110 < 0.0001f) {- i = 0i;- loop {- let _e112 = i;- if (_e112 < 8i) {- let _e114 = i;- let _e115 = n;- if (_e114 >= _e115) {- break;- }- let _e117 = i;- let _e118 = (*worldPos_1);- param_4 = _e118;- let _e119 = (*target_);- param_5 = _e119;- let _e122 = unnamed_1.u_occluders[_e117];- param_6 = _e122;- let _e123 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_4), (¶m_5), (¶m_6));- if (_e123 > 0.5f) {- return 0f;- }- continue;- } else {- break;- }- continuing {- let _e125 = i;- i = (_e125 + 1i);- }- }+ let _e102 = unnamed.u_projection;+ let _e103 = (*worldPos_1);+ clip = (_e102 * vec4<f32>(_e103.x, _e103.y, 0f, 1f));+ let _e109 = clip[3u];+ if (_e109 <= 0f) {return 1f;}- let _e127 = (*target_);- let _e128 = (*worldPos_1);- dir = (_e127 - _e128);- let _e130 = dir;- dl = length(_e130);- let _e132 = dl;- if (_e132 > 0.0001f) {- let _e135 = dir[1u];- let _e138 = dir[0u];- let _e140 = dl;- local_4 = (vec2<f32>(-(_e135), _e138) / vec2(_e140));+ let _e112 = unnamed_1.u_shadow2DRect;+ let _e114 = clip;+ let _e117 = clip[3u];+ let _e124 = unnamed_1.u_shadow2DRect;+ uv = (_e112.xy + ((((_e114.xy / vec2(_e117)) * 0.5f) + vec2(0.5f)) * _e124.zw));+ let _e128 = uv;+ let _e129 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e128, 0f);+ m = _e129;+ let _e130 = (*channel);+ if (_e130 < 0.5f) {+ let _e133 = m[0u];+ local = _e133;} else {- local_4 = vec2<f32>(1f, 0f);- }- let _e143 = local_4;- perp = _e143;- blocked = 0f;- s = 0i;- loop {- let _e144 = s;- if (_e144 < 5i) {- let _e146 = s;- t = (((f32(_e146) / 4f) * 2f) - 1f);- let _e151 = (*target_);- let _e152 = perp;- let _e153 = t;- let _e154 = (*softness);- tp = (_e151 + (_e152 * (_e153 * _e154)));- i_1 = 0i;- loop {- let _e158 = i_1;- if (_e158 < 8i) {- let _e160 = i_1;- let _e161 = n;- if (_e160 >= _e161) {- break;- }- let _e163 = i_1;- let _e164 = (*worldPos_1);- param_7 = _e164;- let _e165 = tp;- param_8 = _e165;- let _e168 = unnamed_1.u_occluders[_e163];- param_9 = _e168;- let _e169 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_7), (¶m_8), (¶m_9));- if (_e169 > 0.5f) {- let _e171 = blocked;- blocked = (_e171 + 1f);- break;- }- continue;- } else {- break;- }- continuing {- let _e173 = i_1;- i_1 = (_e173 + 1i);- }- }- continue;+ let _e134 = (*channel);+ if (_e134 < 1.5f) {+ let _e137 = m[1u];+ local_1 = _e137;} else {- break;- }- continuing {- let _e175 = s;- s = (_e175 + 1i);+ let _e138 = (*channel);+ if (_e138 < 2.5f) {+ let _e141 = m[2u];+ local_2 = _e141;+ } else {+ let _e143 = m[3u];+ local_2 = _e143;+ }+ let _e144 = local_2;+ local_1 = _e144;}+ let _e145 = local_1;+ local = _e145;}- let _e177 = blocked;- return (1f - (_e177 / 5f));+ let _e146 = local;+ hidden = _e146;+ let _e147 = hidden;+ return (1f - min(_e147, 1f));}fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {var axis: vec2<f32>;- var local_5: vec2<f32>;+ var local_3: vec2<f32>;var toFrag: vec2<f32>;- var local_6: vec2<f32>;+ var local_4: vec2<f32>;- let _e92 = (*sp);- let _e94 = (*sp);- if (dot(_e92.xy, _e94.xy) > 0.00000001f) {- let _e98 = (*sp);- local_5 = normalize(_e98.xy);+ let _e91 = (*sp);+ let _e93 = (*sp);+ if (dot(_e91.xy, _e93.xy) > 0.00000001f) {+ let _e97 = (*sp);+ local_3 = normalize(_e97.xy);} else {- local_5 = vec2<f32>(0f, -1f);+ local_3 = vec2<f32>(0f, -1f);}- let _e101 = local_5;- axis = _e101;- let _e102 = (*dist);- if (_e102 > 0.0001f) {- let _e104 = (*toLight);- let _e107 = (*dist);- local_6 = (-(_e104.xy) / vec2(_e107));+ let _e100 = local_3;+ axis = _e100;+ let _e101 = (*dist);+ if (_e101 > 0.0001f) {+ let _e103 = (*toLight);+ let _e106 = (*dist);+ local_4 = (-(_e103.xy) / vec2(_e106));} else {- let _e110 = axis;- local_6 = _e110;+ let _e109 = axis;+ local_4 = _e109;}- let _e111 = local_6;- toFrag = _e111;- let _e113 = (*sp)[3u];- let _e115 = (*sp)[2u];- let _e116 = axis;- let _e117 = toFrag;- return smoothstep(_e113, _e115, dot(_e116, _e117));+ let _e110 = local_4;+ toFrag = _e110;+ let _e112 = (*sp)[3u];+ let _e114 = (*sp)[2u];+ let _e115 = axis;+ let _e116 = toFrag;+ return smoothstep(_e112, _e114, dot(_e115, _e116));}fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_7: vec3<f32>;+ var local_5: vec3<f32>;+ let _e86 = (*toLight_1);let _e87 = (*toLight_1);- let _e88 = (*toLight_1);- if (dot(_e87, _e88) > 0.00000001f) {- let _e91 = (*toLight_1);- local_7 = normalize(_e91);+ if (dot(_e86, _e87) > 0.00000001f) {+ let _e90 = (*toLight_1);+ local_5 = normalize(_e90);} else {- let _e93 = (*N_1);- local_7 = _e93;+ let _e92 = (*N_1);+ local_5 = _e92;}- let _e94 = local_7;- return _e94;+ let _e93 = local_5;+ return _e93;}fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {- let _e85 = (*toLight_2);- return length(_e85.xy);+ let _e84 = (*toLight_2);+ return length(_e84.xy);}fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {- let _e87 = (*pd);- let _e89 = (*worldPos_2);- let _e91 = (_e87.xy - _e89.xy);- let _e93 = (*pd)[3u];- return vec3<f32>(_e91.x, _e91.y, max(_e93, 1f));+ let _e86 = (*pd);+ let _e88 = (*worldPos_2);+ let _e90 = (_e86.xy - _e88.xy);+ let _e92 = (*pd)[3u];+ return vec3<f32>(_e90.x, _e90.y, max(_e92, 1f));}-fn envDirection_u0028_vf3_u003b(d_2: ptr<function, vec3<f32>>) -> vec3<f32> {- var a_4: f32;- var s_1: f32;+fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {+ var a_3: f32;+ var s: f32;var c: f32;- let _e90 = unnamed_1.u_envTint[3u];- a_4 = -(_e90);- let _e92 = a_4;- s_1 = sin(_e92);- let _e94 = a_4;- c = cos(_e94);- let _e96 = c;- let _e98 = (*d_2)[0u];- let _e100 = s_1;- let _e102 = (*d_2)[2u];- let _e106 = (*d_2)[1u];- let _e107 = s_1;- let _e110 = (*d_2)[0u];- let _e112 = c;- let _e114 = (*d_2)[2u];- return vec3<f32>(((_e96 * _e98) + (_e100 * _e102)), _e106, ((-(_e107) * _e110) + (_e112 * _e114)));+ let _e89 = unnamed_1.u_envTint[3u];+ a_3 = -(_e89);+ let _e91 = a_3;+ s = sin(_e91);+ let _e93 = a_3;+ c = cos(_e93);+ let _e95 = c;+ let _e97 = (*d_1)[0u];+ let _e99 = s;+ let _e101 = (*d_1)[2u];+ let _e105 = (*d_1)[1u];+ let _e106 = s;+ let _e109 = (*d_1)[0u];+ let _e111 = c;+ let _e113 = (*d_1)[2u];+ return vec3<f32>(((_e95 * _e97) + (_e99 * _e101)), _e105, ((-(_e106) * _e109) + (_e111 * _e113)));}fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {var N_2: vec3<f32>;- var param_10: vec3<f32>;+ var param_4: vec3<f32>;var sh_2: vec3<f32>;- let _e88 = (*Nw);- param_10 = _e88;- let _e89 = envDirection_u0028_vf3_u003b((¶m_10));- N_2 = _e89;- let _e92 = unnamed_1.u_envIrradiance[0i];- let _e97 = unnamed_1.u_envIrradiance[1i];- let _e100 = N_2[1u];- let _e106 = unnamed_1.u_envIrradiance[2i];- let _e109 = N_2[2u];- let _e115 = unnamed_1.u_envIrradiance[3i];- let _e118 = N_2[0u];- let _e124 = unnamed_1.u_envIrradiance[4i];- let _e127 = N_2[0u];- let _e130 = N_2[1u];- let _e136 = unnamed_1.u_envIrradiance[5i];- let _e139 = N_2[1u];- let _e142 = N_2[2u];- let _e148 = unnamed_1.u_envIrradiance[6i];- let _e151 = N_2[2u];- let _e154 = N_2[2u];- let _e162 = unnamed_1.u_envIrradiance[7i];- let _e165 = N_2[0u];- let _e168 = N_2[2u];- let _e174 = unnamed_1.u_envIrradiance[8i];- let _e177 = N_2[0u];- let _e179 = N_2[0u];- let _e182 = N_2[1u];- let _e184 = N_2[1u];- sh_2 = (((((((((_e92.xyz * 0.282095f) + (_e97.xyz * (0.488603f * _e100))) + (_e106.xyz * (0.488603f * _e109))) + (_e115.xyz * (0.488603f * _e118))) + (_e124.xyz * ((1.092548f * _e127) * _e130))) + (_e136.xyz * ((1.092548f * _e139) * _e142))) + (_e148.xyz * (0.315392f * (((3f * _e151) * _e154) - 1f)))) + (_e162.xyz * ((1.092548f * _e165) * _e168))) + (_e174.xyz * (0.546274f * ((_e177 * _e179) - (_e182 * _e184)))));- let _e191 = unnamed_1.u_ambient;- let _e193 = sh_2;- let _e196 = unnamed_1.u_envTint;- return (_e191.xyz + (max(_e193, vec3<f32>(0f, 0f, 0f)) * _e196.xyz));+ let _e87 = (*Nw);+ param_4 = _e87;+ let _e88 = envDirection_u0028_vf3_u003b((¶m_4));+ N_2 = _e88;+ let _e91 = unnamed_1.u_envIrradiance[0i];+ let _e96 = unnamed_1.u_envIrradiance[1i];+ let _e99 = N_2[1u];+ let _e105 = unnamed_1.u_envIrradiance[2i];+ let _e108 = N_2[2u];+ let _e114 = unnamed_1.u_envIrradiance[3i];+ let _e117 = N_2[0u];+ let _e123 = unnamed_1.u_envIrradiance[4i];+ let _e126 = N_2[0u];+ let _e129 = N_2[1u];+ let _e135 = unnamed_1.u_envIrradiance[5i];+ let _e138 = N_2[1u];+ let _e141 = N_2[2u];+ let _e147 = unnamed_1.u_envIrradiance[6i];+ let _e150 = N_2[2u];+ let _e153 = N_2[2u];+ let _e161 = unnamed_1.u_envIrradiance[7i];+ let _e164 = N_2[0u];+ let _e167 = N_2[2u];+ let _e173 = unnamed_1.u_envIrradiance[8i];+ let _e176 = N_2[0u];+ let _e178 = N_2[0u];+ let _e181 = N_2[1u];+ let _e183 = N_2[1u];+ sh_2 = (((((((((_e91.xyz * 0.282095f) + (_e96.xyz * (0.488603f * _e99))) + (_e105.xyz * (0.488603f * _e108))) + (_e114.xyz * (0.488603f * _e117))) + (_e123.xyz * ((1.092548f * _e126) * _e129))) + (_e135.xyz * ((1.092548f * _e138) * _e141))) + (_e147.xyz * (0.315392f * (((3f * _e150) * _e153) - 1f)))) + (_e161.xyz * ((1.092548f * _e164) * _e167))) + (_e173.xyz * (0.546274f * ((_e176 * _e178) - (_e181 * _e183)))));+ let _e190 = unnamed_1.u_ambient;+ let _e192 = sh_2;+ let _e195 = unnamed_1.u_envTint;+ return (_e190.xyz + (max(_e192, vec3<f32>(0f, 0f, 0f)) * _e195.xyz));}fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {var F0_1: vec3<f32>;- var a_5: f32;+ var a_4: f32;var NdotV_2: f32;var lit: vec3<f32>;- var param_11: vec3<f32>;+ var param_5: vec3<f32>;var gloss: vec3<f32>;- var i_2: i32;+ var i: i32;var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;- var target_1: vec2<f32>;+ var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;- var param_12: vec4<f32>;- var param_13: vec4<f32>;- var param_14: vec3<f32>;+ var param_6: vec4<f32>;+ var param_7: vec4<f32>;+ var param_8: vec3<f32>;var dist_1: f32;- var param_15: vec3<f32>;+ var param_9: vec3<f32>;var atten: f32;var L_1: vec3<f32>;- var param_16: vec3<f32>;- var param_17: vec3<f32>;+ var param_10: vec3<f32>;+ var param_11: vec3<f32>;var toLight_3: vec2<f32>;- var local_8: vec2<f32>;+ var local_6: vec2<f32>;var sp_1: vec4<f32>;var toL_1: vec3<f32>;+ var param_12: vec4<f32>;+ var param_13: vec4<f32>;+ var param_14: vec3<f32>;+ var dist_2: f32;+ var param_15: vec3<f32>;+ var param_16: vec3<f32>;+ var param_17: vec3<f32>;var param_18: vec4<f32>;var param_19: vec4<f32>;var param_20: vec3<f32>;- var dist_2: f32;- var param_21: vec3<f32>;- var param_22: vec3<f32>;- var param_23: vec3<f32>;- var param_24: vec4<f32>;- var param_25: vec4<f32>;- var param_26: vec3<f32>;- var param_27: f32;- var param_28: vec2<f32>;- var param_29: vec2<f32>;- var param_30: f32;+ var param_21: f32;+ var param_22: f32;+ var param_23: vec2<f32>;var sm: vec4<f32>;- var param_31: vec3<f32>;- var param_32: vec3<f32>;- var param_33: vec3<f32>;- var param_34: vec2<f32>;- var param_35: i32;- var param_36: i32;+ var param_24: vec3<f32>;+ var param_25: vec3<f32>;+ var param_26: vec3<f32>;+ var param_27: vec2<f32>;+ var param_28: i32;+ var param_29: i32;var ndotl: f32;var radiance: vec3<f32>;var H: vec3<f32>;var brdf: f32;+ var param_30: f32;+ var param_31: f32;+ var param_32: f32;+ var param_33: f32;+ var param_34: f32;+ var param_35: f32;+ var param_36: vec3<f32>;+ var ab: vec2<f32>;var param_37: f32;var param_38: f32;- var param_39: f32;+ var param_39: vec3<f32>;var param_40: f32;- var param_41: f32;- var param_42: f32;- var param_43: vec3<f32>;- var ab: vec2<f32>;- var param_44: f32;- var param_45: f32;- var param_46: vec3<f32>;- var param_47: f32;- var phi_979_: bool;- var phi_1033_: bool;-- let _e155 = (*albedo);- let _e156 = (*metallic);- F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e155, vec3(_e156));- let _e159 = (*roughness_3);- let _e160 = (*roughness_3);- a_5 = max((_e159 * _e160), 0.001f);- let _e163 = (*N_3);- let _e164 = (*V);- NdotV_2 = max(dot(_e163, _e164), 0.0001f);- let _e167 = (*N_3);- param_11 = _e167;- let _e168 = envIrradiance_u0028_vf3_u003b((¶m_11));- let _e169 = (*ao);- lit = (_e168 * _e169);+ var phi_787_: bool;+ var phi_841_: bool;++ let _e153 = (*albedo);+ let _e154 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e153, vec3(_e154));+ let _e157 = (*roughness_3);+ let _e158 = (*roughness_3);+ a_4 = max((_e157 * _e158), 0.001f);+ let _e161 = (*N_3);+ let _e162 = (*V);+ NdotV_2 = max(dot(_e161, _e162), 0.0001f);+ let _e165 = (*N_3);+ param_5 = _e165;+ let _e166 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e167 = (*ao);+ lit = (_e166 * _e167);gloss = vec3<f32>(0f, 0f, 0f);- i_2 = 0i;+ i = 0i;loop {- let _e171 = i_2;- if (_e171 < 16i) {- let _e173 = i_2;- let _e177 = unnamed_1.u_lights[_e173].posDir;- pd_1 = _e177;- let _e178 = i_2;- let _e182 = unnamed_1.u_lights[_e178].color;- col = _e182;- let _e183 = i_2;- let _e187 = unnamed_1.u_lights[_e183].shadow;- sh_3 = _e187;- let _e188 = pd_1;- target_1 = _e188.xy;+ let _e169 = i;+ if (_e169 < 16i) {+ let _e171 = i;+ let _e175 = unnamed_1.u_lights[_e171].posDir;+ pd_1 = _e175;+ let _e176 = i;+ let _e180 = unnamed_1.u_lights[_e176].color;+ col = _e180;+ let _e181 = i;+ let _e185 = unnamed_1.u_lights[_e181].shadow;+ sh_3 = _e185;+ let _e186 = pd_1;+ target_ = _e186.xy;castShadow = true;- let _e191 = pd_1[2u];- if (_e191 < 0.5f) {- let _e193 = pd_1;- param_12 = _e193;- let _e194 = sh_3;- param_13 = _e194;- let _e195 = (*worldPos_3);- param_14 = _e195;- let _e196 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));- toL = _e196;- let _e197 = toL;- param_15 = _e197;- let _e198 = lightDistance_u0028_vf3_u003b((¶m_15));- dist_1 = _e198;- let _e199 = dist_1;- let _e201 = pd_1[3u];- atten = max(0f, (1f - (_e199 / max(_e201, 0.0001f))));- let _e206 = toL;- param_16 = _e206;- let _e207 = (*N_3);- param_17 = _e207;- let _e208 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));- L_1 = _e208;+ let _e189 = pd_1[2u];+ if (_e189 < 0.5f) {+ let _e191 = pd_1;+ param_6 = _e191;+ let _e192 = sh_3;+ param_7 = _e192;+ let _e193 = (*worldPos_3);+ param_8 = _e193;+ let _e194 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e194;+ let _e195 = toL;+ param_9 = _e195;+ let _e196 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_1 = _e196;+ let _e197 = dist_1;+ let _e199 = pd_1[3u];+ atten = max(0f, (1f - (_e197 / max(_e199, 0.0001f))));+ let _e204 = toL;+ param_10 = _e204;+ let _e205 = (*N_3);+ param_11 = _e205;+ let _e206 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_10), (¶m_11));+ L_1 = _e206;} else {- let _e210 = pd_1[2u];- if (_e210 < 1.5f) {+ let _e208 = pd_1[2u];+ if (_e208 < 1.5f) {atten = 1f;- let _e212 = pd_1;- let _e213 = _e212.xy;- let _e215 = pd_1[3u];- L_1 = normalize(-(vec3<f32>(_e213.x, _e213.y, _e215)));+ let _e210 = pd_1;+ let _e211 = _e210.xy;+ let _e213 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e211.x, _e211.y, _e213)));+ let _e219 = pd_1;let _e221 = pd_1;- let _e223 = pd_1;- if (dot(_e221.xy, _e223.xy) > 0.00000001f) {- let _e227 = pd_1;- local_8 = normalize(-(_e227.xy));+ if (dot(_e219.xy, _e221.xy) > 0.00000001f) {+ let _e225 = pd_1;+ local_6 = normalize(-(_e225.xy));} else {- local_8 = vec2<f32>(0f, 0f);+ local_6 = vec2<f32>(0f, 0f);}- let _e231 = local_8;- toLight_3 = _e231;- let _e233 = sh_3[1u];- let _e234 = (_e233 > 0f);- phi_979_ = _e234;- if _e234 {- let _e235 = toLight_3;- let _e236 = toLight_3;- phi_979_ = (dot(_e235, _e236) > 0.5f);+ let _e229 = local_6;+ toLight_3 = _e229;+ let _e231 = sh_3[1u];+ let _e232 = (_e231 > 0f);+ phi_787_ = _e232;+ if _e232 {+ let _e233 = toLight_3;+ let _e234 = toLight_3;+ phi_787_ = (dot(_e233, _e234) > 0.5f);}- let _e240 = phi_979_;- castShadow = _e240;- let _e241 = (*worldPos_3);- let _e243 = toLight_3;- let _e245 = sh_3[1u];- target_1 = (_e241.xy + (_e243 * _e245));+ let _e238 = phi_787_;+ castShadow = _e238;+ let _e239 = (*worldPos_3);+ let _e241 = toLight_3;+ let _e243 = sh_3[1u];+ target_ = (_e239.xy + (_e241 * _e243));} else {- let _e248 = i_2;- let _e252 = unnamed_1.u_lights[_e248].spot;- sp_1 = _e252;- let _e253 = pd_1;- param_18 = _e253;- let _e254 = sh_3;- param_19 = _e254;- let _e255 = (*worldPos_3);- param_20 = _e255;- let _e256 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_18), (¶m_19), (¶m_20));- toL_1 = _e256;- let _e257 = toL_1;- param_21 = _e257;- let _e258 = lightDistance_u0028_vf3_u003b((¶m_21));- dist_2 = _e258;- let _e259 = dist_2;- let _e261 = pd_1[3u];- atten = max(0f, (1f - (_e259 / max(_e261, 0.0001f))));- let _e266 = toL_1;- param_22 = _e266;- let _e267 = (*N_3);- param_23 = _e267;- let _e268 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));- L_1 = _e268;- let _e269 = sp_1;- param_24 = _e269;- let _e270 = sh_3;- param_25 = _e270;- let _e271 = toL_1;- param_26 = _e271;- let _e272 = dist_2;- param_27 = _e272;- let _e273 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));- let _e274 = atten;- atten = (_e274 * _e273);+ let _e246 = i;+ let _e250 = unnamed_1.u_lights[_e246].spot;+ sp_1 = _e250;+ let _e251 = pd_1;+ param_12 = _e251;+ let _e252 = sh_3;+ param_13 = _e252;+ let _e253 = (*worldPos_3);+ param_14 = _e253;+ let _e254 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));+ toL_1 = _e254;+ let _e255 = toL_1;+ param_15 = _e255;+ let _e256 = lightDistance_u0028_vf3_u003b((¶m_15));+ dist_2 = _e256;+ let _e257 = dist_2;+ let _e259 = pd_1[3u];+ atten = max(0f, (1f - (_e257 / max(_e259, 0.0001f))));+ let _e264 = toL_1;+ param_16 = _e264;+ let _e265 = (*N_3);+ param_17 = _e265;+ let _e266 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));+ L_1 = _e266;+ let _e267 = sp_1;+ param_18 = _e267;+ let _e268 = sh_3;+ param_19 = _e268;+ let _e269 = toL_1;+ param_20 = _e269;+ let _e270 = dist_2;+ param_21 = _e270;+ let _e271 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_18), (¶m_19), (¶m_20), (¶m_21));+ let _e272 = atten;+ atten = (_e272 * _e271);}}- let _e276 = castShadow;- phi_1033_ = _e276;- if _e276 {- let _e278 = col[3u];- phi_1033_ = (_e278 > 0f);+ let _e274 = castShadow;+ phi_841_ = _e274;+ if _e274 {+ let _e276 = col[3u];+ phi_841_ = (_e276 > 0f);}- let _e281 = phi_1033_;- let _e282 = atten;- if (_e281 && (_e282 > 0f)) {- let _e285 = (*worldPos_3);- param_28 = _e285.xy;- let _e287 = target_1;- param_29 = _e287;- let _e289 = sh_3[0u];- param_30 = _e289;- let _e290 = shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b((¶m_28), (¶m_29), (¶m_30));- let _e291 = atten;- atten = (_e291 * _e290);+ let _e279 = phi_841_;+ let _e280 = atten;+ if (_e279 && (_e280 > 0f)) {+ let _e283 = i;+ let _e288 = unnamed_1.u_lights[_e283].shadowMap[3u];+ param_22 = _e288;+ let _e289 = (*worldPos_3);+ param_23 = _e289.xy;+ let _e291 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_22), (¶m_23));+ let _e292 = atten;+ atten = (_e292 * _e291);}- let _e293 = i_2;- let _e297 = unnamed_1.u_lights[_e293].shadowMap;- sm = _e297;- let _e299 = sm[1u];- let _e301 = atten;- if ((_e299 > 0f) && (_e301 > 0f)) {- let _e305 = sh_3[0u];- let _e307 = sm[2u];- let _e310 = sm[0u];- let _e313 = sm[1u];- let _e315 = (*worldPos_3);- param_31 = _e315;- let _e316 = (*N_3);- param_32 = _e316;- let _e317 = L_1;- param_33 = _e317;- param_34 = vec2<f32>(_e305, _e307);- param_35 = i32(_e310);- param_36 = i32(_e313);- let _e318 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35), (¶m_36));- let _e319 = atten;- atten = (_e319 * _e318);+ let _e294 = i;+ let _e298 = unnamed_1.u_lights[_e294].shadowMap;+ sm = _e298;+ let _e300 = sm[1u];+ let _e302 = atten;+ if ((_e300 > 0f) && (_e302 > 0f)) {+ let _e306 = sh_3[0u];+ let _e308 = sm[2u];+ let _e311 = sm[0u];+ let _e314 = sm[1u];+ let _e316 = (*worldPos_3);+ param_24 = _e316;+ let _e317 = (*N_3);+ param_25 = _e317;+ let _e318 = L_1;+ param_26 = _e318;+ param_27 = vec2<f32>(_e306, _e308);+ param_28 = i32(_e311);+ param_29 = i32(_e314);+ let _e319 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27), (¶m_28), (¶m_29));+ let _e320 = atten;+ atten = (_e320 * _e319);}- let _e321 = (*N_3);- let _e322 = L_1;- ndotl = max(dot(_e321, _e322), 0f);- let _e325 = col;- let _e328 = col[3u];- let _e329 = ndotl;- let _e331 = atten;- radiance = (_e325.xyz * ((_e328 * _e329) * _e331));- let _e334 = radiance;- let _e335 = lit;- lit = (_e335 + _e334);- let _e337 = (*specular);- if (_e337 > 0f) {- let _e339 = L_1;- let _e340 = (*V);- H = normalize((_e339 + _e340));- let _e343 = (*N_3);- let _e344 = H;- param_37 = max(dot(_e343, _e344), 0f);- let _e347 = a_5;- param_38 = _e347;- let _e348 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));- let _e349 = NdotV_2;- param_39 = _e349;- let _e350 = ndotl;- param_40 = _e350;- let _e351 = (*roughness_3);- param_41 = _e351;- let _e352 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_39), (¶m_40), (¶m_41));- let _e354 = NdotV_2;- let _e356 = ndotl;- brdf = ((_e348 * _e352) / max(((4f * _e354) * _e356), 0.0001f));- let _e360 = radiance;- let _e361 = (*V);- let _e362 = H;- param_42 = max(dot(_e361, _e362), 0f);- let _e365 = F0_1;- param_43 = _e365;- let _e366 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_42), (¶m_43));- let _e368 = brdf;- let _e370 = (*specular);- let _e373 = gloss;- gloss = (_e373 + ((_e360 * _e366) * ((_e368 * 3.1415927f) * _e370)));+ let _e322 = (*N_3);+ let _e323 = L_1;+ ndotl = max(dot(_e322, _e323), 0f);+ let _e326 = col;+ let _e329 = col[3u];+ let _e330 = ndotl;+ let _e332 = atten;+ radiance = (_e326.xyz * ((_e329 * _e330) * _e332));+ let _e335 = radiance;+ let _e336 = lit;+ lit = (_e336 + _e335);+ let _e338 = (*specular);+ if (_e338 > 0f) {+ let _e340 = L_1;+ let _e341 = (*V);+ H = normalize((_e340 + _e341));+ let _e344 = (*N_3);+ let _e345 = H;+ param_30 = max(dot(_e344, _e345), 0f);+ let _e348 = a_4;+ param_31 = _e348;+ let _e349 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_30), (¶m_31));+ let _e350 = NdotV_2;+ param_32 = _e350;+ let _e351 = ndotl;+ param_33 = _e351;+ let _e352 = (*roughness_3);+ param_34 = _e352;+ let _e353 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_32), (¶m_33), (¶m_34));+ let _e355 = NdotV_2;+ let _e357 = ndotl;+ brdf = ((_e349 * _e353) / max(((4f * _e355) * _e357), 0.0001f));+ let _e361 = radiance;+ let _e362 = (*V);+ let _e363 = H;+ param_35 = max(dot(_e362, _e363), 0f);+ let _e366 = F0_1;+ param_36 = _e366;+ let _e367 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_35), (¶m_36));+ let _e369 = brdf;+ let _e371 = (*specular);+ let _e374 = gloss;+ gloss = (_e374 + ((_e361 * _e367) * ((_e369 * 3.1415927f) * _e371)));}continue;} else {break;}continuing {- let _e375 = i_2;- i_2 = (_e375 + 1i);+ let _e376 = i;+ i = (_e376 + 1i);}}- let _e377 = NdotV_2;- param_44 = _e377;- let _e378 = (*roughness_3);- param_45 = _e378;- let _e379 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_44), (¶m_45));- ab = _e379;- let _e380 = (*V);- let _e382 = (*N_3);- param_46 = reflect(-(_e380), _e382);- let _e384 = (*roughness_3);- param_47 = _e384;- let _e385 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_46), (¶m_47));- let _e386 = (*ao);- let _e387 = (*specular);- let _e390 = F0_1;- let _e392 = ab[0u];- let _e395 = ab[1u];- let _e399 = gloss;- gloss = (_e399 + ((_e385 * (_e386 * _e387)) * ((_e390 * _e392) + vec3(_e395))));- let _e401 = (*albedo);- let _e402 = (*metallic);- let _e405 = lit;- let _e407 = gloss;- return (((_e401 * (1f - _e402)) * _e405) + _e407);+ let _e378 = NdotV_2;+ param_37 = _e378;+ let _e379 = (*roughness_3);+ param_38 = _e379;+ let _e380 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));+ ab = _e380;+ let _e381 = (*V);+ let _e383 = (*N_3);+ param_39 = reflect(-(_e381), _e383);+ let _e385 = (*roughness_3);+ param_40 = _e385;+ let _e386 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_39), (¶m_40));+ let _e387 = (*ao);+ let _e388 = (*specular);+ let _e391 = F0_1;+ let _e393 = ab[0u];+ let _e396 = ab[1u];+ let _e400 = gloss;+ gloss = (_e400 + ((_e386 * (_e387 * _e388)) * ((_e391 * _e393) + vec3(_e396))));+ let _e402 = (*albedo);+ let _e403 = (*metallic);+ let _e406 = lit;+ let _e408 = gloss;+ return (((_e402 * (1f - _e403)) * _e406) + _e408);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_9: vec3<f32>;+ var local_7: vec3<f32>;- let _e88 = unnamed.u_camera[3u];- if (_e88 > 0.5f) {- let _e91 = unnamed.u_camera;- let _e93 = (*worldPos_4);- local_9 = normalize((_e91.xyz - _e93));+ let _e87 = unnamed.u_camera[3u];+ if (_e87 > 0.5f) {+ let _e90 = unnamed.u_camera;+ let _e92 = (*worldPos_4);+ local_7 = normalize((_e90.xyz - _e92));} else {- let _e97 = unnamed.u_camera;- local_9 = _e97.xyz;+ let _e96 = unnamed.u_camera;+ local_7 = _e96.xyz;}- let _e99 = local_9;- return _e99;+ let _e98 = local_7;+ return _e98;}fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {var P: vec3<f32>;- var param_48: vec3<f32>;- var param_49: vec3<f32>;- var param_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec3<f32>;- var param_53: f32;- var param_54: f32;- var param_55: f32;- var param_56: f32;-- let _e98 = (*worldPos_5);- P = vec3<f32>(_e98.x, _e98.y, 0f);- let _e102 = P;- param_48 = _e102;- let _e103 = viewDirection_u0028_vf3_u003b((¶m_48));- let _e104 = (*albedo_1);- param_49 = _e104;- let _e105 = (*N_4);- param_50 = _e105;- let _e106 = P;- param_51 = _e106;- param_52 = _e103;- param_53 = 0f;- param_54 = 1f;- param_55 = 0f;- let _e107 = (*ao_1);- param_56 = _e107;- let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55), (¶m_56));- return _e108;+ var param_41: vec3<f32>;+ var param_42: vec3<f32>;+ var param_43: vec3<f32>;+ var param_44: vec3<f32>;+ var param_45: vec3<f32>;+ var param_46: f32;+ var param_47: f32;+ var param_48: f32;+ var param_49: f32;++ let _e97 = (*worldPos_5);+ P = vec3<f32>(_e97.x, _e97.y, 0f);+ let _e101 = P;+ param_41 = _e101;+ let _e102 = viewDirection_u0028_vf3_u003b((¶m_41));+ let _e103 = (*albedo_1);+ param_42 = _e103;+ let _e104 = (*N_4);+ param_43 = _e104;+ let _e105 = P;+ param_44 = _e105;+ param_45 = _e102;+ param_46 = 0f;+ param_47 = 1f;+ param_48 = 0f;+ let _e106 = (*ao_1);+ param_49 = _e106;+ let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_42), (¶m_43), (¶m_44), (¶m_45), (¶m_46), (¶m_47), (¶m_48), (¶m_49));+ return _e107;}fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_6: ptr<function, vec2<f32>>) -> vec3<f32> {- var param_57: vec3<f32>;- var param_58: vec3<f32>;- var param_59: vec2<f32>;- var param_60: f32;+ var param_50: vec3<f32>;+ var param_51: vec3<f32>;+ var param_52: vec2<f32>;+ var param_53: f32;- let _e91 = (*albedo_2);- param_57 = _e91;- let _e92 = (*N_5);- param_58 = _e92;- let _e93 = (*worldPos_6);- param_59 = _e93;- param_60 = 1f;- let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_57), (¶m_58), (¶m_59), (¶m_60));- return _e94;+ let _e90 = (*albedo_2);+ param_50 = _e90;+ let _e91 = (*N_5);+ param_51 = _e91;+ let _e92 = (*worldPos_6);+ param_52 = _e92;+ param_53 = 1f;+ let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_50), (¶m_51), (¶m_52), (¶m_53));+ return _e93;}-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv: ptr<function, vec2<f32>>) -> vec3<f32> {- let _e87 = (*uv);- let _e88 = textureSample(map_est, map_ess, _e87);- return normalize(((_e88.xyz * 2f) - vec3(1f)));+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {+ let _e86 = (*uv_1);+ let _e87 = textureSample(map_est, map_ess, _e86);+ return normalize(((_e87.xyz * 2f) - vec3(1f)));}fn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_61: vec2<f32>;+ var param_54: vec2<f32>;var lit_1: vec3<f32>;- var param_62: vec3<f32>;- var param_63: vec3<f32>;- var param_64: vec2<f32>;-- let _e91 = v_texCoord_1;- let _e92 = textureSample(es_bt0_est, es_bt0_ess, _e91);- let _e93 = v_color_1;- base = (_e92 * _e93);- let _e95 = v_texCoord_1;- param_61 = _e95;- let _e96 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_61));- N_6 = _e96;- let _e97 = base;- param_62 = _e97.xyz;- let _e99 = N_6;- param_63 = _e99;- let _e100 = v_worldPos_1;- param_64 = _e100;- let _e101 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_62), (¶m_63), (¶m_64));- lit_1 = _e101;- let _e102 = lit_1;- let _e104 = base[3u];- fragColor = vec4<f32>(_e102.x, _e102.y, _e102.z, _e104);+ var param_55: vec3<f32>;+ var param_56: vec3<f32>;+ var param_57: vec2<f32>;++ let _e90 = v_texCoord_1;+ let _e91 = textureSample(es_bt0_est, es_bt0_ess, _e90);+ let _e92 = v_color_1;+ base = (_e91 * _e92);+ let _e94 = v_texCoord_1;+ param_54 = _e94;+ let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_54));+ N_6 = _e95;+ let _e96 = base;+ param_55 = _e96.xyz;+ let _e98 = N_6;+ param_56 = _e98;+ let _e99 = v_worldPos_1;+ param_57 = _e99;+ let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_55), (¶m_56), (¶m_57));+ lit_1 = _e100;+ let _e101 = lit_1;+ let _e103 = base[3u];+ fragColor = vec4<f32>(_e101.x, _e101.y, _e101.z, _e103);return;}diff --git a/fixtures/scenes/mat-lit-normal/lit-normal.esshader b/fixtures/scenes/mat-lit-normal/lit-normal.esshaderindex 9f1ad5bb4..2a233b336 100644--- a/fixtures/scenes/mat-lit-normal/lit-normal.esshader+++ b/fixtures/scenes/mat-lit-normal/lit-normal.esshader@@ -47,7 +47,7 @@ void main() {// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 577c1ff7b66006ff-// assembled-hash: b8931a8c9162b07d+// assembled-hash: df25379d17a5c76astruct gl_PerVertex {@builtin(position) gl_Position: vec4<f32>,gl_PointSize: f32,@@ -120,7 +120,7 @@ fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>,// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 577c1ff7b66006ff-// assembled-hash: b8931a8c9162b07d+// assembled-hash: df25379d17a5c76astruct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -138,8 +138,7 @@ struct Light {struct LightConstants {u_ambient: vec4<f32>,u_lights: array<Light, 16>,- u_occluderCount: vec4<f32>,- u_occluders: array<vec4<f32>, 8>,+ u_shadow2DRect: vec4<f32>,u_shadowMatrix: array<mat4x4<f32>, 16>,u_shadowTile: array<vec4<f32>, 16>,u_shadowParams: vec4<f32>,@@ -157,6 +156,10 @@ struct TimeConstants {var<uniform> unnamed: FrameConstants;@group(0) @binding(2)var<uniform> unnamed_1: LightConstants;+@group(1) @binding(7)+var u_shadow2D_est: texture_2d<f32>;+@group(1) @binding(15)+var u_shadow2D_ess: sampler;@group(1) @binding(0)var es_bt0_est: texture_2d<f32>;@group(1) @binding(8)@@ -214,905 +217,702 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughnessvar param_2: vec3<f32>;var param_3: f32;- let _e96 = unnamed_1.u_envParams[0u];- if (_e96 < 0.5f) {- let _e99 = unnamed_1.u_ambient;- return _e99.xyz;+ let _e95 = unnamed_1.u_envParams[0u];+ if (_e95 < 0.5f) {+ let _e98 = unnamed_1.u_ambient;+ return _e98.xyz;}- let _e101 = (*roughness);- let _e105 = unnamed_1.u_envParams[2u];- lod = (clamp(_e101, 0f, 1f) * _e105);- let _e107 = lod;- lo = floor(_e107);- let _e109 = (*R_1);- param = _e109;- let _e110 = lo;- param_1 = _e110;- let _e111 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));- a = _e111;- let _e112 = lo;- let _e116 = unnamed_1.u_envParams[2u];- let _e118 = (*R_1);- param_2 = _e118;- param_3 = min((_e112 + 1f), _e116);- let _e119 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));- b = _e119;- let _e121 = unnamed_1.u_ambient;- let _e123 = a;- let _e124 = b;- let _e125 = lod;- let _e126 = lo;- let _e131 = unnamed_1.u_envTint;- return (_e121.xyz + (mix(_e123, _e124, vec3((_e125 - _e126))) * _e131.xyz));+ let _e100 = (*roughness);+ let _e104 = unnamed_1.u_envParams[2u];+ lod = (clamp(_e100, 0f, 1f) * _e104);+ let _e106 = lod;+ lo = floor(_e106);+ let _e108 = (*R_1);+ param = _e108;+ let _e109 = lo;+ param_1 = _e109;+ let _e110 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));+ a = _e110;+ let _e111 = lo;+ let _e115 = unnamed_1.u_envParams[2u];+ let _e117 = (*R_1);+ param_2 = _e117;+ param_3 = min((_e111 + 1f), _e115);+ let _e118 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));+ b = _e118;+ let _e120 = unnamed_1.u_ambient;+ let _e122 = a;+ let _e123 = b;+ let _e124 = lod;+ let _e125 = lo;+ let _e130 = unnamed_1.u_envTint;+ return (_e120.xyz + (mix(_e122, _e123, vec3((_e124 - _e125))) * _e130.xyz));}fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {var r: vec4<f32>;var a_1: f32;- let _e88 = (*roughness_1);- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e88) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));- let _e92 = r[0u];- let _e94 = r[0u];- let _e96 = (*NdotV);- let _e101 = r[0u];- let _e104 = r[1u];- a_1 = ((min((_e92 * _e94), exp2((-9.28f * _e96))) * _e101) + _e104);- let _e106 = a_1;- let _e108 = r;- return ((vec2<f32>(-1.04f, 1.04f) * _e106) + _e108.zw);+ let _e87 = (*roughness_1);+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e87) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));+ let _e91 = r[0u];+ let _e93 = r[0u];+ let _e95 = (*NdotV);+ let _e100 = r[0u];+ let _e103 = r[1u];+ a_1 = ((min((_e91 * _e93), exp2((-9.28f * _e95))) * _e100) + _e103);+ let _e105 = a_1;+ let _e107 = r;+ return ((vec2<f32>(-1.04f, 1.04f) * _e105) + _e107.zw);}fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {+ let _e85 = (*F0_);let _e86 = (*F0_);- let _e87 = (*F0_);- let _e89 = (*VdotH);- return (_e86 + ((vec3<f32>(1f, 1f, 1f) - _e87) * pow((1f - _e89), 5f)));+ let _e88 = (*VdotH);+ return (_e85 + ((vec3<f32>(1f, 1f, 1f) - _e86) * pow((1f - _e88), 5f)));}fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {var k: f32;- let _e88 = (*roughness_2);- let _e90 = (*roughness_2);- k = (((_e88 + 1f) * (_e90 + 1f)) * 0.125f);+ let _e87 = (*roughness_2);+ let _e89 = (*roughness_2);+ k = (((_e87 + 1f) * (_e89 + 1f)) * 0.125f);+ let _e93 = (*NdotV_1);let _e94 = (*NdotV_1);- let _e95 = (*NdotV_1);- let _e96 = k;- let _e99 = k;+ let _e95 = k;+ let _e98 = k;+ let _e101 = (*NdotL);let _e102 = (*NdotL);- let _e103 = (*NdotL);- let _e104 = k;- let _e107 = k;- return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));+ let _e103 = k;+ let _e106 = k;+ return ((_e93 / ((_e94 * (1f - _e95)) + _e98)) * (_e101 / ((_e102 * (1f - _e103)) + _e106)));}fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {var a2_: f32;var d: f32;+ let _e87 = (*a_2);let _e88 = (*a_2);- let _e89 = (*a_2);- a2_ = (_e88 * _e89);+ a2_ = (_e87 * _e88);+ let _e90 = (*NdotH);let _e91 = (*NdotH);- let _e92 = (*NdotH);- let _e94 = a2_;- d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);- let _e98 = a2_;- let _e99 = d;- let _e101 = d;- return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));+ let _e93 = a2_;+ d = (((_e90 * _e91) * (_e93 - 1f)) + 1f);+ let _e97 = a2_;+ let _e98 = d;+ let _e100 = d;+ return (_e97 / max(((3.1415927f * _e98) * _e100), 0.0000001f));}fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {return 1f;}-fn segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b(p0_: ptr<function, vec2<f32>>, p1_: ptr<function, vec2<f32>>, box: ptr<function, vec4<f32>>) -> f32 {- var d_1: vec2<f32>;- var tmin: f32;- var tmax: f32;- var a_3: i32;- var da: f32;+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {+ var clip: vec4<f32>;+ var uv: vec2<f32>;+ var m: vec4<f32>;+ var hidden: f32;var local: f32;- var p0a: f32;var local_1: f32;- var lo_1: f32;var local_2: f32;- var hi: f32;- var local_3: f32;- var t1_: f32;- var t2_: f32;var phi_194_: bool;- var phi_203_: bool;- var phi_211_: bool;- let _e102 = (*p0_)[0u];- let _e104 = (*box)[0u];- let _e105 = (_e102 >= _e104);- phi_194_ = _e105;- if _e105 {- let _e107 = (*p0_)[1u];- let _e109 = (*box)[1u];- phi_194_ = (_e107 >= _e109);- }- let _e112 = phi_194_;- phi_203_ = _e112;- if _e112 {- let _e114 = (*p0_)[0u];- let _e116 = (*box)[2u];- phi_203_ = (_e114 <= _e116);- }- let _e119 = phi_203_;- phi_211_ = _e119;- if _e119 {- let _e121 = (*p0_)[1u];- let _e123 = (*box)[3u];- phi_211_ = (_e121 <= _e123);- }- let _e126 = phi_211_;- if _e126 {- return 0f;- }- let _e127 = (*p1_);- let _e128 = (*p0_);- d_1 = (_e127 - _e128);- tmin = 0f;- tmax = 1f;- a_3 = 0i;- loop {- let _e130 = a_3;- if (_e130 < 2i) {- let _e132 = a_3;- if (_e132 == 0i) {- let _e135 = d_1[0u];- local = _e135;- } else {- let _e137 = d_1[1u];- local = _e137;- }- let _e138 = local;- da = _e138;- let _e139 = a_3;- if (_e139 == 0i) {- let _e142 = (*p0_)[0u];- local_1 = _e142;- } else {- let _e144 = (*p0_)[1u];- local_1 = _e144;- }- let _e145 = local_1;- p0a = _e145;- let _e146 = a_3;- if (_e146 == 0i) {- let _e149 = (*box)[0u];- local_2 = _e149;- } else {- let _e151 = (*box)[1u];- local_2 = _e151;- }- let _e152 = local_2;- let _e153 = p0a;- lo_1 = (_e152 - _e153);- let _e155 = a_3;- if (_e155 == 0i) {- let _e158 = (*box)[2u];- local_3 = _e158;- } else {- let _e160 = (*box)[3u];- local_3 = _e160;- }- let _e161 = local_3;- let _e162 = p0a;- hi = (_e161 - _e162);- let _e164 = da;- if (abs(_e164) < 0.00001f) {- let _e167 = lo_1;- let _e169 = hi;- if ((_e167 > 0f) || (_e169 < 0f)) {- return 0f;- }- } else {- let _e172 = lo_1;- let _e173 = da;- t1_ = (_e172 / _e173);- let _e175 = hi;- let _e176 = da;- t2_ = (_e175 / _e176);- let _e178 = tmin;- let _e179 = t1_;- let _e180 = t2_;- tmin = max(_e178, min(_e179, _e180));- let _e183 = tmax;- let _e184 = t1_;- let _e185 = t2_;- tmax = min(_e183, max(_e184, _e185));- let _e188 = tmin;- let _e189 = tmax;- if (_e188 > _e189) {- return 0f;- }- }- continue;- } else {- break;- }- continuing {- let _e191 = a_3;- a_3 = (_e191 + 1i);- }+ let _e92 = (*channel);+ let _e93 = (_e92 < 0f);+ phi_194_ = _e93;+ if !(_e93) {+ let _e97 = unnamed_1.u_shadow2DRect[2u];+ phi_194_ = (_e97 <= 0f);}- return 1f;-}--fn shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b(worldPos_1: ptr<function, vec2<f32>>, target_: ptr<function, vec2<f32>>, softness: ptr<function, f32>) -> f32 {- var n: i32;- var i: i32;- var param_4: vec2<f32>;- var param_5: vec2<f32>;- var param_6: vec4<f32>;- var dir: vec2<f32>;- var dl: f32;- var perp: vec2<f32>;- var local_4: vec2<f32>;- var blocked: f32;- var s: i32;- var t: f32;- var tp: vec2<f32>;- var i_1: i32;- var param_7: vec2<f32>;- var param_8: vec2<f32>;- var param_9: vec4<f32>;-- let _e106 = unnamed_1.u_occluderCount[0u];- n = i32(_e106);- let _e108 = n;- if (_e108 <= 0i) {+ let _e100 = phi_194_;+ if _e100 {return 1f;}- let _e110 = (*softness);- if (_e110 < 0.0001f) {- i = 0i;- loop {- let _e112 = i;- if (_e112 < 8i) {- let _e114 = i;- let _e115 = n;- if (_e114 >= _e115) {- break;- }- let _e117 = i;- let _e118 = (*worldPos_1);- param_4 = _e118;- let _e119 = (*target_);- param_5 = _e119;- let _e122 = unnamed_1.u_occluders[_e117];- param_6 = _e122;- let _e123 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_4), (¶m_5), (¶m_6));- if (_e123 > 0.5f) {- return 0f;- }- continue;- } else {- break;- }- continuing {- let _e125 = i;- i = (_e125 + 1i);- }- }+ let _e102 = unnamed.u_projection;+ let _e103 = (*worldPos_1);+ clip = (_e102 * vec4<f32>(_e103.x, _e103.y, 0f, 1f));+ let _e109 = clip[3u];+ if (_e109 <= 0f) {return 1f;}- let _e127 = (*target_);- let _e128 = (*worldPos_1);- dir = (_e127 - _e128);- let _e130 = dir;- dl = length(_e130);- let _e132 = dl;- if (_e132 > 0.0001f) {- let _e135 = dir[1u];- let _e138 = dir[0u];- let _e140 = dl;- local_4 = (vec2<f32>(-(_e135), _e138) / vec2(_e140));+ let _e112 = unnamed_1.u_shadow2DRect;+ let _e114 = clip;+ let _e117 = clip[3u];+ let _e124 = unnamed_1.u_shadow2DRect;+ uv = (_e112.xy + ((((_e114.xy / vec2(_e117)) * 0.5f) + vec2(0.5f)) * _e124.zw));+ let _e128 = uv;+ let _e129 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e128, 0f);+ m = _e129;+ let _e130 = (*channel);+ if (_e130 < 0.5f) {+ let _e133 = m[0u];+ local = _e133;} else {- local_4 = vec2<f32>(1f, 0f);- }- let _e143 = local_4;- perp = _e143;- blocked = 0f;- s = 0i;- loop {- let _e144 = s;- if (_e144 < 5i) {- let _e146 = s;- t = (((f32(_e146) / 4f) * 2f) - 1f);- let _e151 = (*target_);- let _e152 = perp;- let _e153 = t;- let _e154 = (*softness);- tp = (_e151 + (_e152 * (_e153 * _e154)));- i_1 = 0i;- loop {- let _e158 = i_1;- if (_e158 < 8i) {- let _e160 = i_1;- let _e161 = n;- if (_e160 >= _e161) {- break;- }- let _e163 = i_1;- let _e164 = (*worldPos_1);- param_7 = _e164;- let _e165 = tp;- param_8 = _e165;- let _e168 = unnamed_1.u_occluders[_e163];- param_9 = _e168;- let _e169 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_7), (¶m_8), (¶m_9));- if (_e169 > 0.5f) {- let _e171 = blocked;- blocked = (_e171 + 1f);- break;- }- continue;- } else {- break;- }- continuing {- let _e173 = i_1;- i_1 = (_e173 + 1i);- }- }- continue;+ let _e134 = (*channel);+ if (_e134 < 1.5f) {+ let _e137 = m[1u];+ local_1 = _e137;} else {- break;- }- continuing {- let _e175 = s;- s = (_e175 + 1i);+ let _e138 = (*channel);+ if (_e138 < 2.5f) {+ let _e141 = m[2u];+ local_2 = _e141;+ } else {+ let _e143 = m[3u];+ local_2 = _e143;+ }+ let _e144 = local_2;+ local_1 = _e144;}+ let _e145 = local_1;+ local = _e145;}- let _e177 = blocked;- return (1f - (_e177 / 5f));+ let _e146 = local;+ hidden = _e146;+ let _e147 = hidden;+ return (1f - min(_e147, 1f));}fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {var axis: vec2<f32>;- var local_5: vec2<f32>;+ var local_3: vec2<f32>;var toFrag: vec2<f32>;- var local_6: vec2<f32>;+ var local_4: vec2<f32>;- let _e92 = (*sp);- let _e94 = (*sp);- if (dot(_e92.xy, _e94.xy) > 0.00000001f) {- let _e98 = (*sp);- local_5 = normalize(_e98.xy);+ let _e91 = (*sp);+ let _e93 = (*sp);+ if (dot(_e91.xy, _e93.xy) > 0.00000001f) {+ let _e97 = (*sp);+ local_3 = normalize(_e97.xy);} else {- local_5 = vec2<f32>(0f, -1f);+ local_3 = vec2<f32>(0f, -1f);}- let _e101 = local_5;- axis = _e101;- let _e102 = (*dist);- if (_e102 > 0.0001f) {- let _e104 = (*toLight);- let _e107 = (*dist);- local_6 = (-(_e104.xy) / vec2(_e107));+ let _e100 = local_3;+ axis = _e100;+ let _e101 = (*dist);+ if (_e101 > 0.0001f) {+ let _e103 = (*toLight);+ let _e106 = (*dist);+ local_4 = (-(_e103.xy) / vec2(_e106));} else {- let _e110 = axis;- local_6 = _e110;+ let _e109 = axis;+ local_4 = _e109;}- let _e111 = local_6;- toFrag = _e111;- let _e113 = (*sp)[3u];- let _e115 = (*sp)[2u];- let _e116 = axis;- let _e117 = toFrag;- return smoothstep(_e113, _e115, dot(_e116, _e117));+ let _e110 = local_4;+ toFrag = _e110;+ let _e112 = (*sp)[3u];+ let _e114 = (*sp)[2u];+ let _e115 = axis;+ let _e116 = toFrag;+ return smoothstep(_e112, _e114, dot(_e115, _e116));}fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_7: vec3<f32>;+ var local_5: vec3<f32>;+ let _e86 = (*toLight_1);let _e87 = (*toLight_1);- let _e88 = (*toLight_1);- if (dot(_e87, _e88) > 0.00000001f) {- let _e91 = (*toLight_1);- local_7 = normalize(_e91);+ if (dot(_e86, _e87) > 0.00000001f) {+ let _e90 = (*toLight_1);+ local_5 = normalize(_e90);} else {- let _e93 = (*N_1);- local_7 = _e93;+ let _e92 = (*N_1);+ local_5 = _e92;}- let _e94 = local_7;- return _e94;+ let _e93 = local_5;+ return _e93;}fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {- let _e85 = (*toLight_2);- return length(_e85.xy);+ let _e84 = (*toLight_2);+ return length(_e84.xy);}fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {- let _e87 = (*pd);- let _e89 = (*worldPos_2);- let _e91 = (_e87.xy - _e89.xy);- let _e93 = (*pd)[3u];- return vec3<f32>(_e91.x, _e91.y, max(_e93, 1f));+ let _e86 = (*pd);+ let _e88 = (*worldPos_2);+ let _e90 = (_e86.xy - _e88.xy);+ let _e92 = (*pd)[3u];+ return vec3<f32>(_e90.x, _e90.y, max(_e92, 1f));}-fn envDirection_u0028_vf3_u003b(d_2: ptr<function, vec3<f32>>) -> vec3<f32> {- var a_4: f32;- var s_1: f32;+fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {+ var a_3: f32;+ var s: f32;var c: f32;- let _e90 = unnamed_1.u_envTint[3u];- a_4 = -(_e90);- let _e92 = a_4;- s_1 = sin(_e92);- let _e94 = a_4;- c = cos(_e94);- let _e96 = c;- let _e98 = (*d_2)[0u];- let _e100 = s_1;- let _e102 = (*d_2)[2u];- let _e106 = (*d_2)[1u];- let _e107 = s_1;- let _e110 = (*d_2)[0u];- let _e112 = c;- let _e114 = (*d_2)[2u];- return vec3<f32>(((_e96 * _e98) + (_e100 * _e102)), _e106, ((-(_e107) * _e110) + (_e112 * _e114)));+ let _e89 = unnamed_1.u_envTint[3u];+ a_3 = -(_e89);+ let _e91 = a_3;+ s = sin(_e91);+ let _e93 = a_3;+ c = cos(_e93);+ let _e95 = c;+ let _e97 = (*d_1)[0u];+ let _e99 = s;+ let _e101 = (*d_1)[2u];+ let _e105 = (*d_1)[1u];+ let _e106 = s;+ let _e109 = (*d_1)[0u];+ let _e111 = c;+ let _e113 = (*d_1)[2u];+ return vec3<f32>(((_e95 * _e97) + (_e99 * _e101)), _e105, ((-(_e106) * _e109) + (_e111 * _e113)));}fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {var N_2: vec3<f32>;- var param_10: vec3<f32>;+ var param_4: vec3<f32>;var sh_2: vec3<f32>;- let _e88 = (*Nw);- param_10 = _e88;- let _e89 = envDirection_u0028_vf3_u003b((¶m_10));- N_2 = _e89;- let _e92 = unnamed_1.u_envIrradiance[0i];- let _e97 = unnamed_1.u_envIrradiance[1i];- let _e100 = N_2[1u];- let _e106 = unnamed_1.u_envIrradiance[2i];- let _e109 = N_2[2u];- let _e115 = unnamed_1.u_envIrradiance[3i];- let _e118 = N_2[0u];- let _e124 = unnamed_1.u_envIrradiance[4i];- let _e127 = N_2[0u];- let _e130 = N_2[1u];- let _e136 = unnamed_1.u_envIrradiance[5i];- let _e139 = N_2[1u];- let _e142 = N_2[2u];- let _e148 = unnamed_1.u_envIrradiance[6i];- let _e151 = N_2[2u];- let _e154 = N_2[2u];- let _e162 = unnamed_1.u_envIrradiance[7i];- let _e165 = N_2[0u];- let _e168 = N_2[2u];- let _e174 = unnamed_1.u_envIrradiance[8i];- let _e177 = N_2[0u];- let _e179 = N_2[0u];- let _e182 = N_2[1u];- let _e184 = N_2[1u];- sh_2 = (((((((((_e92.xyz * 0.282095f) + (_e97.xyz * (0.488603f * _e100))) + (_e106.xyz * (0.488603f * _e109))) + (_e115.xyz * (0.488603f * _e118))) + (_e124.xyz * ((1.092548f * _e127) * _e130))) + (_e136.xyz * ((1.092548f * _e139) * _e142))) + (_e148.xyz * (0.315392f * (((3f * _e151) * _e154) - 1f)))) + (_e162.xyz * ((1.092548f * _e165) * _e168))) + (_e174.xyz * (0.546274f * ((_e177 * _e179) - (_e182 * _e184)))));- let _e191 = unnamed_1.u_ambient;- let _e193 = sh_2;- let _e196 = unnamed_1.u_envTint;- return (_e191.xyz + (max(_e193, vec3<f32>(0f, 0f, 0f)) * _e196.xyz));+ let _e87 = (*Nw);+ param_4 = _e87;+ let _e88 = envDirection_u0028_vf3_u003b((¶m_4));+ N_2 = _e88;+ let _e91 = unnamed_1.u_envIrradiance[0i];+ let _e96 = unnamed_1.u_envIrradiance[1i];+ let _e99 = N_2[1u];+ let _e105 = unnamed_1.u_envIrradiance[2i];+ let _e108 = N_2[2u];+ let _e114 = unnamed_1.u_envIrradiance[3i];+ let _e117 = N_2[0u];+ let _e123 = unnamed_1.u_envIrradiance[4i];+ let _e126 = N_2[0u];+ let _e129 = N_2[1u];+ let _e135 = unnamed_1.u_envIrradiance[5i];+ let _e138 = N_2[1u];+ let _e141 = N_2[2u];+ let _e147 = unnamed_1.u_envIrradiance[6i];+ let _e150 = N_2[2u];+ let _e153 = N_2[2u];+ let _e161 = unnamed_1.u_envIrradiance[7i];+ let _e164 = N_2[0u];+ let _e167 = N_2[2u];+ let _e173 = unnamed_1.u_envIrradiance[8i];+ let _e176 = N_2[0u];+ let _e178 = N_2[0u];+ let _e181 = N_2[1u];+ let _e183 = N_2[1u];+ sh_2 = (((((((((_e91.xyz * 0.282095f) + (_e96.xyz * (0.488603f * _e99))) + (_e105.xyz * (0.488603f * _e108))) + (_e114.xyz * (0.488603f * _e117))) + (_e123.xyz * ((1.092548f * _e126) * _e129))) + (_e135.xyz * ((1.092548f * _e138) * _e141))) + (_e147.xyz * (0.315392f * (((3f * _e150) * _e153) - 1f)))) + (_e161.xyz * ((1.092548f * _e164) * _e167))) + (_e173.xyz * (0.546274f * ((_e176 * _e178) - (_e181 * _e183)))));+ let _e190 = unnamed_1.u_ambient;+ let _e192 = sh_2;+ let _e195 = unnamed_1.u_envTint;+ return (_e190.xyz + (max(_e192, vec3<f32>(0f, 0f, 0f)) * _e195.xyz));}fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {var F0_1: vec3<f32>;- var a_5: f32;+ var a_4: f32;var NdotV_2: f32;var lit: vec3<f32>;- var param_11: vec3<f32>;+ var param_5: vec3<f32>;var gloss: vec3<f32>;- var i_2: i32;+ var i: i32;var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;- var target_1: vec2<f32>;+ var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;- var param_12: vec4<f32>;- var param_13: vec4<f32>;- var param_14: vec3<f32>;+ var param_6: vec4<f32>;+ var param_7: vec4<f32>;+ var param_8: vec3<f32>;var dist_1: f32;- var param_15: vec3<f32>;+ var param_9: vec3<f32>;var atten: f32;var L_1: vec3<f32>;- var param_16: vec3<f32>;- var param_17: vec3<f32>;+ var param_10: vec3<f32>;+ var param_11: vec3<f32>;var toLight_3: vec2<f32>;- var local_8: vec2<f32>;+ var local_6: vec2<f32>;var sp_1: vec4<f32>;var toL_1: vec3<f32>;+ var param_12: vec4<f32>;+ var param_13: vec4<f32>;+ var param_14: vec3<f32>;+ var dist_2: f32;+ var param_15: vec3<f32>;+ var param_16: vec3<f32>;+ var param_17: vec3<f32>;var param_18: vec4<f32>;var param_19: vec4<f32>;var param_20: vec3<f32>;- var dist_2: f32;- var param_21: vec3<f32>;- var param_22: vec3<f32>;- var param_23: vec3<f32>;- var param_24: vec4<f32>;- var param_25: vec4<f32>;- var param_26: vec3<f32>;- var param_27: f32;- var param_28: vec2<f32>;- var param_29: vec2<f32>;- var param_30: f32;+ var param_21: f32;+ var param_22: f32;+ var param_23: vec2<f32>;var sm: vec4<f32>;- var param_31: vec3<f32>;- var param_32: vec3<f32>;- var param_33: vec3<f32>;- var param_34: vec2<f32>;- var param_35: i32;- var param_36: i32;+ var param_24: vec3<f32>;+ var param_25: vec3<f32>;+ var param_26: vec3<f32>;+ var param_27: vec2<f32>;+ var param_28: i32;+ var param_29: i32;var ndotl: f32;var radiance: vec3<f32>;var H: vec3<f32>;var brdf: f32;+ var param_30: f32;+ var param_31: f32;+ var param_32: f32;+ var param_33: f32;+ var param_34: f32;+ var param_35: f32;+ var param_36: vec3<f32>;+ var ab: vec2<f32>;var param_37: f32;var param_38: f32;- var param_39: f32;+ var param_39: vec3<f32>;var param_40: f32;- var param_41: f32;- var param_42: f32;- var param_43: vec3<f32>;- var ab: vec2<f32>;- var param_44: f32;- var param_45: f32;- var param_46: vec3<f32>;- var param_47: f32;- var phi_979_: bool;- var phi_1033_: bool;-- let _e155 = (*albedo);- let _e156 = (*metallic);- F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e155, vec3(_e156));- let _e159 = (*roughness_3);- let _e160 = (*roughness_3);- a_5 = max((_e159 * _e160), 0.001f);- let _e163 = (*N_3);- let _e164 = (*V);- NdotV_2 = max(dot(_e163, _e164), 0.0001f);- let _e167 = (*N_3);- param_11 = _e167;- let _e168 = envIrradiance_u0028_vf3_u003b((¶m_11));- let _e169 = (*ao);- lit = (_e168 * _e169);+ var phi_787_: bool;+ var phi_841_: bool;++ let _e153 = (*albedo);+ let _e154 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e153, vec3(_e154));+ let _e157 = (*roughness_3);+ let _e158 = (*roughness_3);+ a_4 = max((_e157 * _e158), 0.001f);+ let _e161 = (*N_3);+ let _e162 = (*V);+ NdotV_2 = max(dot(_e161, _e162), 0.0001f);+ let _e165 = (*N_3);+ param_5 = _e165;+ let _e166 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e167 = (*ao);+ lit = (_e166 * _e167);gloss = vec3<f32>(0f, 0f, 0f);- i_2 = 0i;+ i = 0i;loop {- let _e171 = i_2;- if (_e171 < 16i) {- let _e173 = i_2;- let _e177 = unnamed_1.u_lights[_e173].posDir;- pd_1 = _e177;- let _e178 = i_2;- let _e182 = unnamed_1.u_lights[_e178].color;- col = _e182;- let _e183 = i_2;- let _e187 = unnamed_1.u_lights[_e183].shadow;- sh_3 = _e187;- let _e188 = pd_1;- target_1 = _e188.xy;+ let _e169 = i;+ if (_e169 < 16i) {+ let _e171 = i;+ let _e175 = unnamed_1.u_lights[_e171].posDir;+ pd_1 = _e175;+ let _e176 = i;+ let _e180 = unnamed_1.u_lights[_e176].color;+ col = _e180;+ let _e181 = i;+ let _e185 = unnamed_1.u_lights[_e181].shadow;+ sh_3 = _e185;+ let _e186 = pd_1;+ target_ = _e186.xy;castShadow = true;- let _e191 = pd_1[2u];- if (_e191 < 0.5f) {- let _e193 = pd_1;- param_12 = _e193;- let _e194 = sh_3;- param_13 = _e194;- let _e195 = (*worldPos_3);- param_14 = _e195;- let _e196 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));- toL = _e196;- let _e197 = toL;- param_15 = _e197;- let _e198 = lightDistance_u0028_vf3_u003b((¶m_15));- dist_1 = _e198;- let _e199 = dist_1;- let _e201 = pd_1[3u];- atten = max(0f, (1f - (_e199 / max(_e201, 0.0001f))));- let _e206 = toL;- param_16 = _e206;- let _e207 = (*N_3);- param_17 = _e207;- let _e208 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));- L_1 = _e208;+ let _e189 = pd_1[2u];+ if (_e189 < 0.5f) {+ let _e191 = pd_1;+ param_6 = _e191;+ let _e192 = sh_3;+ param_7 = _e192;+ let _e193 = (*worldPos_3);+ param_8 = _e193;+ let _e194 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e194;+ let _e195 = toL;+ param_9 = _e195;+ let _e196 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_1 = _e196;+ let _e197 = dist_1;+ let _e199 = pd_1[3u];+ atten = max(0f, (1f - (_e197 / max(_e199, 0.0001f))));+ let _e204 = toL;+ param_10 = _e204;+ let _e205 = (*N_3);+ param_11 = _e205;+ let _e206 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_10), (¶m_11));+ L_1 = _e206;} else {- let _e210 = pd_1[2u];- if (_e210 < 1.5f) {+ let _e208 = pd_1[2u];+ if (_e208 < 1.5f) {atten = 1f;- let _e212 = pd_1;- let _e213 = _e212.xy;- let _e215 = pd_1[3u];- L_1 = normalize(-(vec3<f32>(_e213.x, _e213.y, _e215)));+ let _e210 = pd_1;+ let _e211 = _e210.xy;+ let _e213 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e211.x, _e211.y, _e213)));+ let _e219 = pd_1;let _e221 = pd_1;- let _e223 = pd_1;- if (dot(_e221.xy, _e223.xy) > 0.00000001f) {- let _e227 = pd_1;- local_8 = normalize(-(_e227.xy));+ if (dot(_e219.xy, _e221.xy) > 0.00000001f) {+ let _e225 = pd_1;+ local_6 = normalize(-(_e225.xy));} else {- local_8 = vec2<f32>(0f, 0f);+ local_6 = vec2<f32>(0f, 0f);}- let _e231 = local_8;- toLight_3 = _e231;- let _e233 = sh_3[1u];- let _e234 = (_e233 > 0f);- phi_979_ = _e234;- if _e234 {- let _e235 = toLight_3;- let _e236 = toLight_3;- phi_979_ = (dot(_e235, _e236) > 0.5f);+ let _e229 = local_6;+ toLight_3 = _e229;+ let _e231 = sh_3[1u];+ let _e232 = (_e231 > 0f);+ phi_787_ = _e232;+ if _e232 {+ let _e233 = toLight_3;+ let _e234 = toLight_3;+ phi_787_ = (dot(_e233, _e234) > 0.5f);}- let _e240 = phi_979_;- castShadow = _e240;- let _e241 = (*worldPos_3);- let _e243 = toLight_3;- let _e245 = sh_3[1u];- target_1 = (_e241.xy + (_e243 * _e245));+ let _e238 = phi_787_;+ castShadow = _e238;+ let _e239 = (*worldPos_3);+ let _e241 = toLight_3;+ let _e243 = sh_3[1u];+ target_ = (_e239.xy + (_e241 * _e243));} else {- let _e248 = i_2;- let _e252 = unnamed_1.u_lights[_e248].spot;- sp_1 = _e252;- let _e253 = pd_1;- param_18 = _e253;- let _e254 = sh_3;- param_19 = _e254;- let _e255 = (*worldPos_3);- param_20 = _e255;- let _e256 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_18), (¶m_19), (¶m_20));- toL_1 = _e256;- let _e257 = toL_1;- param_21 = _e257;- let _e258 = lightDistance_u0028_vf3_u003b((¶m_21));- dist_2 = _e258;- let _e259 = dist_2;- let _e261 = pd_1[3u];- atten = max(0f, (1f - (_e259 / max(_e261, 0.0001f))));- let _e266 = toL_1;- param_22 = _e266;- let _e267 = (*N_3);- param_23 = _e267;- let _e268 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));- L_1 = _e268;- let _e269 = sp_1;- param_24 = _e269;- let _e270 = sh_3;- param_25 = _e270;- let _e271 = toL_1;- param_26 = _e271;- let _e272 = dist_2;- param_27 = _e272;- let _e273 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));- let _e274 = atten;- atten = (_e274 * _e273);+ let _e246 = i;+ let _e250 = unnamed_1.u_lights[_e246].spot;+ sp_1 = _e250;+ let _e251 = pd_1;+ param_12 = _e251;+ let _e252 = sh_3;+ param_13 = _e252;+ let _e253 = (*worldPos_3);+ param_14 = _e253;+ let _e254 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));+ toL_1 = _e254;+ let _e255 = toL_1;+ param_15 = _e255;+ let _e256 = lightDistance_u0028_vf3_u003b((¶m_15));+ dist_2 = _e256;+ let _e257 = dist_2;+ let _e259 = pd_1[3u];+ atten = max(0f, (1f - (_e257 / max(_e259, 0.0001f))));+ let _e264 = toL_1;+ param_16 = _e264;+ let _e265 = (*N_3);+ param_17 = _e265;+ let _e266 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));+ L_1 = _e266;+ let _e267 = sp_1;+ param_18 = _e267;+ let _e268 = sh_3;+ param_19 = _e268;+ let _e269 = toL_1;+ param_20 = _e269;+ let _e270 = dist_2;+ param_21 = _e270;+ let _e271 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_18), (¶m_19), (¶m_20), (¶m_21));+ let _e272 = atten;+ atten = (_e272 * _e271);}}- let _e276 = castShadow;- phi_1033_ = _e276;- if _e276 {- let _e278 = col[3u];- phi_1033_ = (_e278 > 0f);+ let _e274 = castShadow;+ phi_841_ = _e274;+ if _e274 {+ let _e276 = col[3u];+ phi_841_ = (_e276 > 0f);}- let _e281 = phi_1033_;- let _e282 = atten;- if (_e281 && (_e282 > 0f)) {- let _e285 = (*worldPos_3);- param_28 = _e285.xy;- let _e287 = target_1;- param_29 = _e287;- let _e289 = sh_3[0u];- param_30 = _e289;- let _e290 = shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b((¶m_28), (¶m_29), (¶m_30));- let _e291 = atten;- atten = (_e291 * _e290);+ let _e279 = phi_841_;+ let _e280 = atten;+ if (_e279 && (_e280 > 0f)) {+ let _e283 = i;+ let _e288 = unnamed_1.u_lights[_e283].shadowMap[3u];+ param_22 = _e288;+ let _e289 = (*worldPos_3);+ param_23 = _e289.xy;+ let _e291 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_22), (¶m_23));+ let _e292 = atten;+ atten = (_e292 * _e291);}- let _e293 = i_2;- let _e297 = unnamed_1.u_lights[_e293].shadowMap;- sm = _e297;- let _e299 = sm[1u];- let _e301 = atten;- if ((_e299 > 0f) && (_e301 > 0f)) {- let _e305 = sh_3[0u];- let _e307 = sm[2u];- let _e310 = sm[0u];- let _e313 = sm[1u];- let _e315 = (*worldPos_3);- param_31 = _e315;- let _e316 = (*N_3);- param_32 = _e316;- let _e317 = L_1;- param_33 = _e317;- param_34 = vec2<f32>(_e305, _e307);- param_35 = i32(_e310);- param_36 = i32(_e313);- let _e318 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35), (¶m_36));- let _e319 = atten;- atten = (_e319 * _e318);+ let _e294 = i;+ let _e298 = unnamed_1.u_lights[_e294].shadowMap;+ sm = _e298;+ let _e300 = sm[1u];+ let _e302 = atten;+ if ((_e300 > 0f) && (_e302 > 0f)) {+ let _e306 = sh_3[0u];+ let _e308 = sm[2u];+ let _e311 = sm[0u];+ let _e314 = sm[1u];+ let _e316 = (*worldPos_3);+ param_24 = _e316;+ let _e317 = (*N_3);+ param_25 = _e317;+ let _e318 = L_1;+ param_26 = _e318;+ param_27 = vec2<f32>(_e306, _e308);+ param_28 = i32(_e311);+ param_29 = i32(_e314);+ let _e319 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27), (¶m_28), (¶m_29));+ let _e320 = atten;+ atten = (_e320 * _e319);}- let _e321 = (*N_3);- let _e322 = L_1;- ndotl = max(dot(_e321, _e322), 0f);- let _e325 = col;- let _e328 = col[3u];- let _e329 = ndotl;- let _e331 = atten;- radiance = (_e325.xyz * ((_e328 * _e329) * _e331));- let _e334 = radiance;- let _e335 = lit;- lit = (_e335 + _e334);- let _e337 = (*specular);- if (_e337 > 0f) {- let _e339 = L_1;- let _e340 = (*V);- H = normalize((_e339 + _e340));- let _e343 = (*N_3);- let _e344 = H;- param_37 = max(dot(_e343, _e344), 0f);- let _e347 = a_5;- param_38 = _e347;- let _e348 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));- let _e349 = NdotV_2;- param_39 = _e349;- let _e350 = ndotl;- param_40 = _e350;- let _e351 = (*roughness_3);- param_41 = _e351;- let _e352 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_39), (¶m_40), (¶m_41));- let _e354 = NdotV_2;- let _e356 = ndotl;- brdf = ((_e348 * _e352) / max(((4f * _e354) * _e356), 0.0001f));- let _e360 = radiance;- let _e361 = (*V);- let _e362 = H;- param_42 = max(dot(_e361, _e362), 0f);- let _e365 = F0_1;- param_43 = _e365;- let _e366 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_42), (¶m_43));- let _e368 = brdf;- let _e370 = (*specular);- let _e373 = gloss;- gloss = (_e373 + ((_e360 * _e366) * ((_e368 * 3.1415927f) * _e370)));+ let _e322 = (*N_3);+ let _e323 = L_1;+ ndotl = max(dot(_e322, _e323), 0f);+ let _e326 = col;+ let _e329 = col[3u];+ let _e330 = ndotl;+ let _e332 = atten;+ radiance = (_e326.xyz * ((_e329 * _e330) * _e332));+ let _e335 = radiance;+ let _e336 = lit;+ lit = (_e336 + _e335);+ let _e338 = (*specular);+ if (_e338 > 0f) {+ let _e340 = L_1;+ let _e341 = (*V);+ H = normalize((_e340 + _e341));+ let _e344 = (*N_3);+ let _e345 = H;+ param_30 = max(dot(_e344, _e345), 0f);+ let _e348 = a_4;+ param_31 = _e348;+ let _e349 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_30), (¶m_31));+ let _e350 = NdotV_2;+ param_32 = _e350;+ let _e351 = ndotl;+ param_33 = _e351;+ let _e352 = (*roughness_3);+ param_34 = _e352;+ let _e353 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_32), (¶m_33), (¶m_34));+ let _e355 = NdotV_2;+ let _e357 = ndotl;+ brdf = ((_e349 * _e353) / max(((4f * _e355) * _e357), 0.0001f));+ let _e361 = radiance;+ let _e362 = (*V);+ let _e363 = H;+ param_35 = max(dot(_e362, _e363), 0f);+ let _e366 = F0_1;+ param_36 = _e366;+ let _e367 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_35), (¶m_36));+ let _e369 = brdf;+ let _e371 = (*specular);+ let _e374 = gloss;+ gloss = (_e374 + ((_e361 * _e367) * ((_e369 * 3.1415927f) * _e371)));}continue;} else {break;}continuing {- let _e375 = i_2;- i_2 = (_e375 + 1i);+ let _e376 = i;+ i = (_e376 + 1i);}}- let _e377 = NdotV_2;- param_44 = _e377;- let _e378 = (*roughness_3);- param_45 = _e378;- let _e379 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_44), (¶m_45));- ab = _e379;- let _e380 = (*V);- let _e382 = (*N_3);- param_46 = reflect(-(_e380), _e382);- let _e384 = (*roughness_3);- param_47 = _e384;- let _e385 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_46), (¶m_47));- let _e386 = (*ao);- let _e387 = (*specular);- let _e390 = F0_1;- let _e392 = ab[0u];- let _e395 = ab[1u];- let _e399 = gloss;- gloss = (_e399 + ((_e385 * (_e386 * _e387)) * ((_e390 * _e392) + vec3(_e395))));- let _e401 = (*albedo);- let _e402 = (*metallic);- let _e405 = lit;- let _e407 = gloss;- return (((_e401 * (1f - _e402)) * _e405) + _e407);+ let _e378 = NdotV_2;+ param_37 = _e378;+ let _e379 = (*roughness_3);+ param_38 = _e379;+ let _e380 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));+ ab = _e380;+ let _e381 = (*V);+ let _e383 = (*N_3);+ param_39 = reflect(-(_e381), _e383);+ let _e385 = (*roughness_3);+ param_40 = _e385;+ let _e386 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_39), (¶m_40));+ let _e387 = (*ao);+ let _e388 = (*specular);+ let _e391 = F0_1;+ let _e393 = ab[0u];+ let _e396 = ab[1u];+ let _e400 = gloss;+ gloss = (_e400 + ((_e386 * (_e387 * _e388)) * ((_e391 * _e393) + vec3(_e396))));+ let _e402 = (*albedo);+ let _e403 = (*metallic);+ let _e406 = lit;+ let _e408 = gloss;+ return (((_e402 * (1f - _e403)) * _e406) + _e408);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_9: vec3<f32>;+ var local_7: vec3<f32>;- let _e88 = unnamed.u_camera[3u];- if (_e88 > 0.5f) {- let _e91 = unnamed.u_camera;- let _e93 = (*worldPos_4);- local_9 = normalize((_e91.xyz - _e93));+ let _e87 = unnamed.u_camera[3u];+ if (_e87 > 0.5f) {+ let _e90 = unnamed.u_camera;+ let _e92 = (*worldPos_4);+ local_7 = normalize((_e90.xyz - _e92));} else {- let _e97 = unnamed.u_camera;- local_9 = _e97.xyz;+ let _e96 = unnamed.u_camera;+ local_7 = _e96.xyz;}- let _e99 = local_9;- return _e99;+ let _e98 = local_7;+ return _e98;}fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {var P: vec3<f32>;- var param_48: vec3<f32>;- var param_49: vec3<f32>;- var param_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec3<f32>;- var param_53: f32;- var param_54: f32;- var param_55: f32;- var param_56: f32;-- let _e98 = (*worldPos_5);- P = vec3<f32>(_e98.x, _e98.y, 0f);- let _e102 = P;- param_48 = _e102;- let _e103 = viewDirection_u0028_vf3_u003b((¶m_48));- let _e104 = (*albedo_1);- param_49 = _e104;- let _e105 = (*N_4);- param_50 = _e105;- let _e106 = P;- param_51 = _e106;- param_52 = _e103;- param_53 = 0f;- param_54 = 1f;- param_55 = 0f;- let _e107 = (*ao_1);- param_56 = _e107;- let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55), (¶m_56));- return _e108;+ var param_41: vec3<f32>;+ var param_42: vec3<f32>;+ var param_43: vec3<f32>;+ var param_44: vec3<f32>;+ var param_45: vec3<f32>;+ var param_46: f32;+ var param_47: f32;+ var param_48: f32;+ var param_49: f32;++ let _e97 = (*worldPos_5);+ P = vec3<f32>(_e97.x, _e97.y, 0f);+ let _e101 = P;+ param_41 = _e101;+ let _e102 = viewDirection_u0028_vf3_u003b((¶m_41));+ let _e103 = (*albedo_1);+ param_42 = _e103;+ let _e104 = (*N_4);+ param_43 = _e104;+ let _e105 = P;+ param_44 = _e105;+ param_45 = _e102;+ param_46 = 0f;+ param_47 = 1f;+ param_48 = 0f;+ let _e106 = (*ao_1);+ param_49 = _e106;+ let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_42), (¶m_43), (¶m_44), (¶m_45), (¶m_46), (¶m_47), (¶m_48), (¶m_49));+ return _e107;}fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_6: ptr<function, vec2<f32>>) -> vec3<f32> {- var param_57: vec3<f32>;- var param_58: vec3<f32>;- var param_59: vec2<f32>;- var param_60: f32;+ var param_50: vec3<f32>;+ var param_51: vec3<f32>;+ var param_52: vec2<f32>;+ var param_53: f32;- let _e91 = (*albedo_2);- param_57 = _e91;- let _e92 = (*N_5);- param_58 = _e92;- let _e93 = (*worldPos_6);- param_59 = _e93;- param_60 = 1f;- let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_57), (¶m_58), (¶m_59), (¶m_60));- return _e94;+ let _e90 = (*albedo_2);+ param_50 = _e90;+ let _e91 = (*N_5);+ param_51 = _e91;+ let _e92 = (*worldPos_6);+ param_52 = _e92;+ param_53 = 1f;+ let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_50), (¶m_51), (¶m_52), (¶m_53));+ return _e93;}-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv: ptr<function, vec2<f32>>) -> vec3<f32> {- let _e87 = (*uv);- let _e88 = textureSample(map_est, map_ess, _e87);- return normalize(((_e88.xyz * 2f) - vec3(1f)));+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {+ let _e86 = (*uv_1);+ let _e87 = textureSample(map_est, map_ess, _e86);+ return normalize(((_e87.xyz * 2f) - vec3(1f)));}fn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_61: vec2<f32>;+ var param_54: vec2<f32>;var lit_1: vec3<f32>;- var param_62: vec3<f32>;- var param_63: vec3<f32>;- var param_64: vec2<f32>;-- let _e91 = v_texCoord_1;- let _e92 = textureSample(es_bt0_est, es_bt0_ess, _e91);- let _e93 = v_color_1;- base = (_e92 * _e93);- let _e95 = v_texCoord_1;- param_61 = _e95;- let _e96 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_61));- N_6 = _e96;- let _e97 = base;- param_62 = _e97.xyz;- let _e99 = N_6;- param_63 = _e99;- let _e100 = v_worldPos_1;- param_64 = _e100;- let _e101 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_62), (¶m_63), (¶m_64));- lit_1 = _e101;- let _e102 = lit_1;- let _e104 = base[3u];- fragColor = vec4<f32>(_e102.x, _e102.y, _e102.z, _e104);+ var param_55: vec3<f32>;+ var param_56: vec3<f32>;+ var param_57: vec2<f32>;++ let _e90 = v_texCoord_1;+ let _e91 = textureSample(es_bt0_est, es_bt0_ess, _e90);+ let _e92 = v_color_1;+ base = (_e91 * _e92);+ let _e94 = v_texCoord_1;+ param_54 = _e94;+ let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_54));+ N_6 = _e95;+ let _e96 = base;+ param_55 = _e96.xyz;+ let _e98 = N_6;+ param_56 = _e98;+ let _e99 = v_worldPos_1;+ param_57 = _e99;+ let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_55), (¶m_56), (¶m_57));+ lit_1 = _e100;+ let _e101 = lit_1;+ let _e103 = base[3u];+ fragColor = vec4<f32>(_e101.x, _e101.y, _e101.z, _e103);return;}diff --git a/fixtures/scenes/mat-lit-shadow-dir.esscene b/fixtures/scenes/mat-lit-shadow-dir.essceneindex 0a6f65bc2..7aff12374 100644--- a/fixtures/scenes/mat-lit-shadow-dir.esscene+++ b/fixtures/scenes/mat-lit-shadow-dir.esscene@@ -8,8 +8,25 @@"parent": null,"children": [],"components": [- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },- { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 300, "isActive": true, "priority": 0 } }+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 10+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 1,+ "orthoSize": 300,+ "isActive": true,+ "priority": 0+ }+ }],"visible": true},@@ -19,12 +36,29 @@"parent": null,"children": [],"components": [- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },{"type": "Sprite","data": {- "size": { "x": 400, "y": 400 },- "color": { "r": 1, "g": 1, "b": 1, "a": 1 },+ "size": {+ "x": 400,+ "y": 400+ },+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },"material": "/scenes/mat-lit/lit.esmaterial"}}@@ -37,14 +71,33 @@"parent": null,"children": [],"components": [- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "rotation": {+ "x": 0,+ "y": -0.3826834,+ "z": 0,+ "w": 0.9238795+ }+ }+ },{"type": "Light","data": {"type": 1,- "color": { "r": 0, "g": 1, "b": 0, "a": 1 },+ "color": {+ "r": 0,+ "g": 1,+ "b": 0,+ "a": 1+ },"intensity": 1,- "direction": { "x": 1, "y": 0 },"shadowDistance": 600,"shadowSoftness": 0}@@ -58,8 +111,26 @@"parent": null,"children": [],"components": [- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },- { "type": "ShadowCaster2D", "data": { "size": { "x": 40, "y": 120 }, "enabled": true } }+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 40,+ "y": 120+ },+ "enabled": true+ }+ }],"visible": true}diff --git a/fixtures/scenes/mat-lit-shadow-many.esscene b/fixtures/scenes/mat-lit-shadow-many.esscenenew file mode 100644index 000000000..5f642846e--- /dev/null+++ b/fixtures/scenes/mat-lit-shadow-many.esscene@@ -0,0 +1,451 @@+{+ "version": 4,+ "name": "Main",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 10+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 1,+ "orthoSize": 300,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Lit",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Sprite",+ "data": {+ "size": {+ "x": 400,+ "y": 400+ },+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "material": "/scenes/mat-lit/lit.esmaterial"+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "GreenPointLight",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -250,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 0,+ "color": {+ "r": 0,+ "g": 1,+ "b": 0,+ "a": 1+ },+ "intensity": 1,+ "radius": 900,+ "shadowSoftness": 0+ }+ }+ ]+ },+ {+ "id": 3,+ "name": "Filler1",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 170,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 4,+ "name": "Filler2",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 182,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 5,+ "name": "Filler3",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 194,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 6,+ "name": "Filler4",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 206,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 7,+ "name": "Filler5",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 218,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 8,+ "name": "Filler6",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 230,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 9,+ "name": "Filler7",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 242,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 10,+ "name": "Filler8",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 254,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 11,+ "name": "Filler9",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 266,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 12,+ "name": "Filler10",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 278,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 13,+ "name": "Filler11",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 290,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 8,+ "y": 8+ },+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 14,+ "name": "Wall",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "ShadowCaster2D",+ "data": {+ "size": {+ "x": 40,+ "y": 120+ },+ "enabled": true+ }+ }+ ]+ }+ ]+}diff --git a/fixtures/scenes/mat-lit-shadow-many.textures.json b/fixtures/scenes/mat-lit-shadow-many.textures.jsonnew file mode 100644index 000000000..0967ef424--- /dev/null+++ b/fixtures/scenes/mat-lit-shadow-many.textures.json@@ -0,0 +1 @@+{}diff --git a/fixtures/scenes/mat-lit/lit.esshader b/fixtures/scenes/mat-lit/lit.esshaderindex 56f62fa92..6971ea43e 100644--- a/fixtures/scenes/mat-lit/lit.esshader+++ b/fixtures/scenes/mat-lit/lit.esshader@@ -53,7 +53,7 @@ void main() {// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 8c118f2b442c055e-// assembled-hash: 5c7e77cef9746685+// assembled-hash: 5d4306ee1d4d91ecstruct gl_PerVertex {@builtin(position) gl_Position: vec4<f32>,gl_PointSize: f32,@@ -122,7 +122,7 @@ fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>,// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.// Regenerate after changing the GLSL stages above.// source-hash: 8c118f2b442c055e-// assembled-hash: 5c7e77cef9746685+// assembled-hash: 5d4306ee1d4d91ecstruct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -140,8 +140,7 @@ struct Light {struct LightConstants {u_ambient: vec4<f32>,u_lights: array<Light, 16>,- u_occluderCount: vec4<f32>,- u_occluders: array<vec4<f32>, 8>,+ u_shadow2DRect: vec4<f32>,u_shadowMatrix: array<mat4x4<f32>, 16>,u_shadowTile: array<vec4<f32>, 16>,u_shadowParams: vec4<f32>,@@ -159,6 +158,10 @@ struct TimeConstants {var<uniform> unnamed: FrameConstants;@group(0) @binding(2)var<uniform> unnamed_1: LightConstants;+@group(1) @binding(7)+var u_shadow2D_est: texture_2d<f32>;+@group(1) @binding(15)+var u_shadow2D_ess: sampler;@group(1) @binding(0)var es_bt0_est: texture_2d<f32>;@group(1) @binding(8)@@ -212,704 +215,501 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughnessvar param_2: vec3<f32>;var param_3: f32;- let _e95 = unnamed_1.u_envParams[0u];- if (_e95 < 0.5f) {- let _e98 = unnamed_1.u_ambient;- return _e98.xyz;+ let _e93 = unnamed_1.u_envParams[0u];+ if (_e93 < 0.5f) {+ let _e96 = unnamed_1.u_ambient;+ return _e96.xyz;}- let _e100 = (*roughness);- let _e104 = unnamed_1.u_envParams[2u];- lod = (clamp(_e100, 0f, 1f) * _e104);- let _e106 = lod;- lo = floor(_e106);- let _e108 = (*R_1);- param = _e108;+ let _e98 = (*roughness);+ let _e102 = unnamed_1.u_envParams[2u];+ lod = (clamp(_e98, 0f, 1f) * _e102);+ let _e104 = lod;+ lo = floor(_e104);+ let _e106 = (*R_1);+ param = _e106;+ let _e107 = lo;+ param_1 = _e107;+ let _e108 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));+ a = _e108;let _e109 = lo;- param_1 = _e109;- let _e110 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m), (¶m_1));- a = _e110;- let _e111 = lo;- let _e115 = unnamed_1.u_envParams[2u];- let _e117 = (*R_1);- param_2 = _e117;- param_3 = min((_e111 + 1f), _e115);- let _e118 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));- b = _e118;- let _e120 = unnamed_1.u_ambient;- let _e122 = a;- let _e123 = b;- let _e124 = lod;- let _e125 = lo;- let _e130 = unnamed_1.u_envTint;- return (_e120.xyz + (mix(_e122, _e123, vec3((_e124 - _e125))) * _e130.xyz));+ let _e113 = unnamed_1.u_envParams[2u];+ let _e115 = (*R_1);+ param_2 = _e115;+ param_3 = min((_e109 + 1f), _e113);+ let _e116 = envSampleMip_u0028_vf3_u003b_f1_u003b((¶m_2), (¶m_3));+ b = _e116;+ let _e118 = unnamed_1.u_ambient;+ let _e120 = a;+ let _e121 = b;+ let _e122 = lod;+ let _e123 = lo;+ let _e128 = unnamed_1.u_envTint;+ return (_e118.xyz + (mix(_e120, _e121, vec3((_e122 - _e123))) * _e128.xyz));}fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {var r: vec4<f32>;var a_1: f32;- let _e87 = (*roughness_1);- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e87) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));+ let _e85 = (*roughness_1);+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e85) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));+ let _e89 = r[0u];let _e91 = r[0u];- let _e93 = r[0u];- let _e95 = (*NdotV);- let _e100 = r[0u];- let _e103 = r[1u];- a_1 = ((min((_e91 * _e93), exp2((-9.28f * _e95))) * _e100) + _e103);- let _e105 = a_1;- let _e107 = r;- return ((vec2<f32>(-1.04f, 1.04f) * _e105) + _e107.zw);+ let _e93 = (*NdotV);+ let _e98 = r[0u];+ let _e101 = r[1u];+ a_1 = ((min((_e89 * _e91), exp2((-9.28f * _e93))) * _e98) + _e101);+ let _e103 = a_1;+ let _e105 = r;+ return ((vec2<f32>(-1.04f, 1.04f) * _e103) + _e105.zw);}fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {- let _e85 = (*F0_);- let _e86 = (*F0_);- let _e88 = (*VdotH);- return (_e85 + ((vec3<f32>(1f, 1f, 1f) - _e86) * pow((1f - _e88), 5f)));+ let _e83 = (*F0_);+ let _e84 = (*F0_);+ let _e86 = (*VdotH);+ return (_e83 + ((vec3<f32>(1f, 1f, 1f) - _e84) * pow((1f - _e86), 5f)));}fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {var k: f32;+ let _e85 = (*roughness_2);let _e87 = (*roughness_2);- let _e89 = (*roughness_2);- k = (((_e87 + 1f) * (_e89 + 1f)) * 0.125f);- let _e93 = (*NdotV_1);- let _e94 = (*NdotV_1);- let _e95 = k;- let _e98 = k;- let _e101 = (*NdotL);- let _e102 = (*NdotL);- let _e103 = k;- let _e106 = k;- return ((_e93 / ((_e94 * (1f - _e95)) + _e98)) * (_e101 / ((_e102 * (1f - _e103)) + _e106)));+ k = (((_e85 + 1f) * (_e87 + 1f)) * 0.125f);+ let _e91 = (*NdotV_1);+ let _e92 = (*NdotV_1);+ let _e93 = k;+ let _e96 = k;+ let _e99 = (*NdotL);+ let _e100 = (*NdotL);+ let _e101 = k;+ let _e104 = k;+ return ((_e91 / ((_e92 * (1f - _e93)) + _e96)) * (_e99 / ((_e100 * (1f - _e101)) + _e104)));}fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {var a2_: f32;var d: f32;- let _e87 = (*a_2);- let _e88 = (*a_2);- a2_ = (_e87 * _e88);- let _e90 = (*NdotH);- let _e91 = (*NdotH);- let _e93 = a2_;- d = (((_e90 * _e91) * (_e93 - 1f)) + 1f);- let _e97 = a2_;+ let _e85 = (*a_2);+ let _e86 = (*a_2);+ a2_ = (_e85 * _e86);+ let _e88 = (*NdotH);+ let _e89 = (*NdotH);+ let _e91 = a2_;+ d = (((_e88 * _e89) * (_e91 - 1f)) + 1f);+ let _e95 = a2_;+ let _e96 = d;let _e98 = d;- let _e100 = d;- return (_e97 / max(((3.1415927f * _e98) * _e100), 0.0000001f));+ return (_e95 / max(((3.1415927f * _e96) * _e98), 0.0000001f));}fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {return 1f;}-fn segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b(p0_: ptr<function, vec2<f32>>, p1_: ptr<function, vec2<f32>>, box: ptr<function, vec4<f32>>) -> f32 {- var d_1: vec2<f32>;- var tmin: f32;- var tmax: f32;- var a_3: i32;- var da: f32;+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {+ var clip: vec4<f32>;+ var uv: vec2<f32>;+ var m: vec4<f32>;+ var hidden: f32;var local: f32;- var p0a: f32;var local_1: f32;- var lo_1: f32;var local_2: f32;- var hi: f32;- var local_3: f32;- var t1_: f32;- var t2_: f32;var phi_170_: bool;- var phi_179_: bool;- var phi_187_: bool;- let _e101 = (*p0_)[0u];- let _e103 = (*box)[0u];- let _e104 = (_e101 >= _e103);- phi_170_ = _e104;- if _e104 {- let _e106 = (*p0_)[1u];- let _e108 = (*box)[1u];- phi_170_ = (_e106 >= _e108);- }- let _e111 = phi_170_;- phi_179_ = _e111;- if _e111 {- let _e113 = (*p0_)[0u];- let _e115 = (*box)[2u];- phi_179_ = (_e113 <= _e115);- }- let _e118 = phi_179_;- phi_187_ = _e118;- if _e118 {- let _e120 = (*p0_)[1u];- let _e122 = (*box)[3u];- phi_187_ = (_e120 <= _e122);- }- let _e125 = phi_187_;- if _e125 {- return 0f;- }- let _e126 = (*p1_);- let _e127 = (*p0_);- d_1 = (_e126 - _e127);- tmin = 0f;- tmax = 1f;- a_3 = 0i;- loop {- let _e129 = a_3;- if (_e129 < 2i) {- let _e131 = a_3;- if (_e131 == 0i) {- let _e134 = d_1[0u];- local = _e134;- } else {- let _e136 = d_1[1u];- local = _e136;- }- let _e137 = local;- da = _e137;- let _e138 = a_3;- if (_e138 == 0i) {- let _e141 = (*p0_)[0u];- local_1 = _e141;- } else {- let _e143 = (*p0_)[1u];- local_1 = _e143;- }- let _e144 = local_1;- p0a = _e144;- let _e145 = a_3;- if (_e145 == 0i) {- let _e148 = (*box)[0u];- local_2 = _e148;- } else {- let _e150 = (*box)[1u];- local_2 = _e150;- }- let _e151 = local_2;- let _e152 = p0a;- lo_1 = (_e151 - _e152);- let _e154 = a_3;- if (_e154 == 0i) {- let _e157 = (*box)[2u];- local_3 = _e157;- } else {- let _e159 = (*box)[3u];- local_3 = _e159;- }- let _e160 = local_3;- let _e161 = p0a;- hi = (_e160 - _e161);- let _e163 = da;- if (abs(_e163) < 0.00001f) {- let _e166 = lo_1;- let _e168 = hi;- if ((_e166 > 0f) || (_e168 < 0f)) {- return 0f;- }- } else {- let _e171 = lo_1;- let _e172 = da;- t1_ = (_e171 / _e172);- let _e174 = hi;- let _e175 = da;- t2_ = (_e174 / _e175);- let _e177 = tmin;- let _e178 = t1_;- let _e179 = t2_;- tmin = max(_e177, min(_e178, _e179));- let _e182 = tmax;- let _e183 = t1_;- let _e184 = t2_;- tmax = min(_e182, max(_e183, _e184));- let _e187 = tmin;- let _e188 = tmax;- if (_e187 > _e188) {- return 0f;- }- }- continue;- } else {- break;- }- continuing {- let _e190 = a_3;- a_3 = (_e190 + 1i);- }+ let _e90 = (*channel);+ let _e91 = (_e90 < 0f);+ phi_170_ = _e91;+ if !(_e91) {+ let _e95 = unnamed_1.u_shadow2DRect[2u];+ phi_170_ = (_e95 <= 0f);}- return 1f;-}--fn shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b(worldPos_1: ptr<function, vec2<f32>>, target_: ptr<function, vec2<f32>>, softness: ptr<function, f32>) -> f32 {- var n: i32;- var i: i32;- var param_4: vec2<f32>;- var param_5: vec2<f32>;- var param_6: vec4<f32>;- var dir: vec2<f32>;- var dl: f32;- var perp: vec2<f32>;- var local_4: vec2<f32>;- var blocked: f32;- var s: i32;- var t: f32;- var tp: vec2<f32>;- var i_1: i32;- var param_7: vec2<f32>;- var param_8: vec2<f32>;- var param_9: vec4<f32>;-- let _e105 = unnamed_1.u_occluderCount[0u];- n = i32(_e105);- let _e107 = n;- if (_e107 <= 0i) {+ let _e98 = phi_170_;+ if _e98 {return 1f;}- let _e109 = (*softness);- if (_e109 < 0.0001f) {- i = 0i;- loop {- let _e111 = i;- if (_e111 < 8i) {- let _e113 = i;- let _e114 = n;- if (_e113 >= _e114) {- break;- }- let _e116 = i;- let _e117 = (*worldPos_1);- param_4 = _e117;- let _e118 = (*target_);- param_5 = _e118;- let _e121 = unnamed_1.u_occluders[_e116];- param_6 = _e121;- let _e122 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_4), (¶m_5), (¶m_6));- if (_e122 > 0.5f) {- return 0f;- }- continue;- } else {- break;- }- continuing {- let _e124 = i;- i = (_e124 + 1i);- }- }+ let _e100 = unnamed.u_projection;+ let _e101 = (*worldPos_1);+ clip = (_e100 * vec4<f32>(_e101.x, _e101.y, 0f, 1f));+ let _e107 = clip[3u];+ if (_e107 <= 0f) {return 1f;}- let _e126 = (*target_);- let _e127 = (*worldPos_1);- dir = (_e126 - _e127);- let _e129 = dir;- dl = length(_e129);- let _e131 = dl;- if (_e131 > 0.0001f) {- let _e134 = dir[1u];- let _e137 = dir[0u];- let _e139 = dl;- local_4 = (vec2<f32>(-(_e134), _e137) / vec2(_e139));+ let _e110 = unnamed_1.u_shadow2DRect;+ let _e112 = clip;+ let _e115 = clip[3u];+ let _e122 = unnamed_1.u_shadow2DRect;+ uv = (_e110.xy + ((((_e112.xy / vec2(_e115)) * 0.5f) + vec2(0.5f)) * _e122.zw));+ let _e126 = uv;+ let _e127 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e126, 0f);+ m = _e127;+ let _e128 = (*channel);+ if (_e128 < 0.5f) {+ let _e131 = m[0u];+ local = _e131;} else {- local_4 = vec2<f32>(1f, 0f);- }- let _e142 = local_4;- perp = _e142;- blocked = 0f;- s = 0i;- loop {- let _e143 = s;- if (_e143 < 5i) {- let _e145 = s;- t = (((f32(_e145) / 4f) * 2f) - 1f);- let _e150 = (*target_);- let _e151 = perp;- let _e152 = t;- let _e153 = (*softness);- tp = (_e150 + (_e151 * (_e152 * _e153)));- i_1 = 0i;- loop {- let _e157 = i_1;- if (_e157 < 8i) {- let _e159 = i_1;- let _e160 = n;- if (_e159 >= _e160) {- break;- }- let _e162 = i_1;- let _e163 = (*worldPos_1);- param_7 = _e163;- let _e164 = tp;- param_8 = _e164;- let _e167 = unnamed_1.u_occluders[_e162];- param_9 = _e167;- let _e168 = segHitsBox_u0028_vf2_u003b_vf2_u003b_vf4_u003b((¶m_7), (¶m_8), (¶m_9));- if (_e168 > 0.5f) {- let _e170 = blocked;- blocked = (_e170 + 1f);- break;- }- continue;- } else {- break;- }- continuing {- let _e172 = i_1;- i_1 = (_e172 + 1i);- }- }- continue;+ let _e132 = (*channel);+ if (_e132 < 1.5f) {+ let _e135 = m[1u];+ local_1 = _e135;} else {- break;- }- continuing {- let _e174 = s;- s = (_e174 + 1i);+ let _e136 = (*channel);+ if (_e136 < 2.5f) {+ let _e139 = m[2u];+ local_2 = _e139;+ } else {+ let _e141 = m[3u];+ local_2 = _e141;+ }+ let _e142 = local_2;+ local_1 = _e142;}+ let _e143 = local_1;+ local = _e143;}- let _e176 = blocked;- return (1f - (_e176 / 5f));+ let _e144 = local;+ hidden = _e144;+ let _e145 = hidden;+ return (1f - min(_e145, 1f));}fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {var axis: vec2<f32>;- var local_5: vec2<f32>;+ var local_3: vec2<f32>;var toFrag: vec2<f32>;- var local_6: vec2<f32>;+ var local_4: vec2<f32>;+ let _e89 = (*sp);let _e91 = (*sp);- let _e93 = (*sp);- if (dot(_e91.xy, _e93.xy) > 0.00000001f) {- let _e97 = (*sp);- local_5 = normalize(_e97.xy);+ if (dot(_e89.xy, _e91.xy) > 0.00000001f) {+ let _e95 = (*sp);+ local_3 = normalize(_e95.xy);} else {- local_5 = vec2<f32>(0f, -1f);+ local_3 = vec2<f32>(0f, -1f);}- let _e100 = local_5;- axis = _e100;- let _e101 = (*dist);- if (_e101 > 0.0001f) {- let _e103 = (*toLight);- let _e106 = (*dist);- local_6 = (-(_e103.xy) / vec2(_e106));+ let _e98 = local_3;+ axis = _e98;+ let _e99 = (*dist);+ if (_e99 > 0.0001f) {+ let _e101 = (*toLight);+ let _e104 = (*dist);+ local_4 = (-(_e101.xy) / vec2(_e104));} else {- let _e109 = axis;- local_6 = _e109;+ let _e107 = axis;+ local_4 = _e107;}- let _e110 = local_6;- toFrag = _e110;- let _e112 = (*sp)[3u];- let _e114 = (*sp)[2u];- let _e115 = axis;- let _e116 = toFrag;- return smoothstep(_e112, _e114, dot(_e115, _e116));+ let _e108 = local_4;+ toFrag = _e108;+ let _e110 = (*sp)[3u];+ let _e112 = (*sp)[2u];+ let _e113 = axis;+ let _e114 = toFrag;+ return smoothstep(_e110, _e112, dot(_e113, _e114));}fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_7: vec3<f32>;+ var local_5: vec3<f32>;- let _e86 = (*toLight_1);- let _e87 = (*toLight_1);- if (dot(_e86, _e87) > 0.00000001f) {- let _e90 = (*toLight_1);- local_7 = normalize(_e90);+ let _e84 = (*toLight_1);+ let _e85 = (*toLight_1);+ if (dot(_e84, _e85) > 0.00000001f) {+ let _e88 = (*toLight_1);+ local_5 = normalize(_e88);} else {- let _e92 = (*N_1);- local_7 = _e92;+ let _e90 = (*N_1);+ local_5 = _e90;}- let _e93 = local_7;- return _e93;+ let _e91 = local_5;+ return _e91;}fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {- let _e84 = (*toLight_2);- return length(_e84.xy);+ let _e82 = (*toLight_2);+ return length(_e82.xy);}fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {- let _e86 = (*pd);- let _e88 = (*worldPos_2);- let _e90 = (_e86.xy - _e88.xy);- let _e92 = (*pd)[3u];- return vec3<f32>(_e90.x, _e90.y, max(_e92, 1f));+ let _e84 = (*pd);+ let _e86 = (*worldPos_2);+ let _e88 = (_e84.xy - _e86.xy);+ let _e90 = (*pd)[3u];+ return vec3<f32>(_e88.x, _e88.y, max(_e90, 1f));}-fn envDirection_u0028_vf3_u003b(d_2: ptr<function, vec3<f32>>) -> vec3<f32> {- var a_4: f32;- var s_1: f32;+fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {+ var a_3: f32;+ var s: f32;var c: f32;- let _e89 = unnamed_1.u_envTint[3u];- a_4 = -(_e89);- let _e91 = a_4;- s_1 = sin(_e91);- let _e93 = a_4;- c = cos(_e93);- let _e95 = c;- let _e97 = (*d_2)[0u];- let _e99 = s_1;- let _e101 = (*d_2)[2u];- let _e105 = (*d_2)[1u];- let _e106 = s_1;- let _e109 = (*d_2)[0u];- let _e111 = c;- let _e113 = (*d_2)[2u];- return vec3<f32>(((_e95 * _e97) + (_e99 * _e101)), _e105, ((-(_e106) * _e109) + (_e111 * _e113)));+ let _e87 = unnamed_1.u_envTint[3u];+ a_3 = -(_e87);+ let _e89 = a_3;+ s = sin(_e89);+ let _e91 = a_3;+ c = cos(_e91);+ let _e93 = c;+ let _e95 = (*d_1)[0u];+ let _e97 = s;+ let _e99 = (*d_1)[2u];+ let _e103 = (*d_1)[1u];+ let _e104 = s;+ let _e107 = (*d_1)[0u];+ let _e109 = c;+ let _e111 = (*d_1)[2u];+ return vec3<f32>(((_e93 * _e95) + (_e97 * _e99)), _e103, ((-(_e104) * _e107) + (_e109 * _e111)));}fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {var N_2: vec3<f32>;- var param_10: vec3<f32>;+ var param_4: vec3<f32>;var sh_2: vec3<f32>;- let _e87 = (*Nw);- param_10 = _e87;- let _e88 = envDirection_u0028_vf3_u003b((¶m_10));- N_2 = _e88;- let _e91 = unnamed_1.u_envIrradiance[0i];- let _e96 = unnamed_1.u_envIrradiance[1i];- let _e99 = N_2[1u];- let _e105 = unnamed_1.u_envIrradiance[2i];- let _e108 = N_2[2u];- let _e114 = unnamed_1.u_envIrradiance[3i];- let _e117 = N_2[0u];- let _e123 = unnamed_1.u_envIrradiance[4i];- let _e126 = N_2[0u];- let _e129 = N_2[1u];- let _e135 = unnamed_1.u_envIrradiance[5i];- let _e138 = N_2[1u];- let _e141 = N_2[2u];- let _e147 = unnamed_1.u_envIrradiance[6i];- let _e150 = N_2[2u];- let _e153 = N_2[2u];- let _e161 = unnamed_1.u_envIrradiance[7i];- let _e164 = N_2[0u];- let _e167 = N_2[2u];- let _e173 = unnamed_1.u_envIrradiance[8i];+ let _e85 = (*Nw);+ param_4 = _e85;+ let _e86 = envDirection_u0028_vf3_u003b((¶m_4));+ N_2 = _e86;+ let _e89 = unnamed_1.u_envIrradiance[0i];+ let _e94 = unnamed_1.u_envIrradiance[1i];+ let _e97 = N_2[1u];+ let _e103 = unnamed_1.u_envIrradiance[2i];+ let _e106 = N_2[2u];+ let _e112 = unnamed_1.u_envIrradiance[3i];+ let _e115 = N_2[0u];+ let _e121 = unnamed_1.u_envIrradiance[4i];+ let _e124 = N_2[0u];+ let _e127 = N_2[1u];+ let _e133 = unnamed_1.u_envIrradiance[5i];+ let _e136 = N_2[1u];+ let _e139 = N_2[2u];+ let _e145 = unnamed_1.u_envIrradiance[6i];+ let _e148 = N_2[2u];+ let _e151 = N_2[2u];+ let _e159 = unnamed_1.u_envIrradiance[7i];+ let _e162 = N_2[0u];+ let _e165 = N_2[2u];+ let _e171 = unnamed_1.u_envIrradiance[8i];+ let _e174 = N_2[0u];let _e176 = N_2[0u];- let _e178 = N_2[0u];+ let _e179 = N_2[1u];let _e181 = N_2[1u];- let _e183 = N_2[1u];- sh_2 = (((((((((_e91.xyz * 0.282095f) + (_e96.xyz * (0.488603f * _e99))) + (_e105.xyz * (0.488603f * _e108))) + (_e114.xyz * (0.488603f * _e117))) + (_e123.xyz * ((1.092548f * _e126) * _e129))) + (_e135.xyz * ((1.092548f * _e138) * _e141))) + (_e147.xyz * (0.315392f * (((3f * _e150) * _e153) - 1f)))) + (_e161.xyz * ((1.092548f * _e164) * _e167))) + (_e173.xyz * (0.546274f * ((_e176 * _e178) - (_e181 * _e183)))));- let _e190 = unnamed_1.u_ambient;- let _e192 = sh_2;- let _e195 = unnamed_1.u_envTint;- return (_e190.xyz + (max(_e192, vec3<f32>(0f, 0f, 0f)) * _e195.xyz));+ sh_2 = (((((((((_e89.xyz * 0.282095f) + (_e94.xyz * (0.488603f * _e97))) + (_e103.xyz * (0.488603f * _e106))) + (_e112.xyz * (0.488603f * _e115))) + (_e121.xyz * ((1.092548f * _e124) * _e127))) + (_e133.xyz * ((1.092548f * _e136) * _e139))) + (_e145.xyz * (0.315392f * (((3f * _e148) * _e151) - 1f)))) + (_e159.xyz * ((1.092548f * _e162) * _e165))) + (_e171.xyz * (0.546274f * ((_e174 * _e176) - (_e179 * _e181)))));+ let _e188 = unnamed_1.u_ambient;+ let _e190 = sh_2;+ let _e193 = unnamed_1.u_envTint;+ return (_e188.xyz + (max(_e190, vec3<f32>(0f, 0f, 0f)) * _e193.xyz));}fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {var F0_1: vec3<f32>;- var a_5: f32;+ var a_4: f32;var NdotV_2: f32;var lit: vec3<f32>;- var param_11: vec3<f32>;+ var param_5: vec3<f32>;var gloss: vec3<f32>;- var i_2: i32;+ var i: i32;var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;- var target_1: vec2<f32>;+ var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;- var param_12: vec4<f32>;- var param_13: vec4<f32>;- var param_14: vec3<f32>;+ var param_6: vec4<f32>;+ var param_7: vec4<f32>;+ var param_8: vec3<f32>;var dist_1: f32;- var param_15: vec3<f32>;+ var param_9: vec3<f32>;var atten: f32;var L_1: vec3<f32>;- var param_16: vec3<f32>;- var param_17: vec3<f32>;+ var param_10: vec3<f32>;+ var param_11: vec3<f32>;var toLight_3: vec2<f32>;- var local_8: vec2<f32>;+ var local_6: vec2<f32>;var sp_1: vec4<f32>;var toL_1: vec3<f32>;+ var param_12: vec4<f32>;+ var param_13: vec4<f32>;+ var param_14: vec3<f32>;+ var dist_2: f32;+ var param_15: vec3<f32>;+ var param_16: vec3<f32>;+ var param_17: vec3<f32>;var param_18: vec4<f32>;var param_19: vec4<f32>;var param_20: vec3<f32>;- var dist_2: f32;- var param_21: vec3<f32>;- var param_22: vec3<f32>;- var param_23: vec3<f32>;- var param_24: vec4<f32>;- var param_25: vec4<f32>;- var param_26: vec3<f32>;- var param_27: f32;- var param_28: vec2<f32>;- var param_29: vec2<f32>;- var param_30: f32;+ var param_21: f32;+ var param_22: f32;+ var param_23: vec2<f32>;var sm: vec4<f32>;- var param_31: vec3<f32>;- var param_32: vec3<f32>;- var param_33: vec3<f32>;- var param_34: vec2<f32>;- var param_35: i32;- var param_36: i32;+ var param_24: vec3<f32>;+ var param_25: vec3<f32>;+ var param_26: vec3<f32>;+ var param_27: vec2<f32>;+ var param_28: i32;+ var param_29: i32;var ndotl: f32;var radiance: vec3<f32>;var H: vec3<f32>;var brdf: f32;+ var param_30: f32;+ var param_31: f32;+ var param_32: f32;+ var param_33: f32;+ var param_34: f32;+ var param_35: f32;+ var param_36: vec3<f32>;+ var ab: vec2<f32>;var param_37: f32;var param_38: f32;- var param_39: f32;+ var param_39: vec3<f32>;var param_40: f32;- var param_41: f32;- var param_42: f32;- var param_43: vec3<f32>;- var ab: vec2<f32>;- var param_44: f32;- var param_45: f32;- var param_46: vec3<f32>;- var param_47: f32;- var phi_956_: bool;- var phi_1010_: bool;-- let _e154 = (*albedo);- let _e155 = (*metallic);- F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e154, vec3(_e155));- let _e158 = (*roughness_3);- let _e159 = (*roughness_3);- a_5 = max((_e158 * _e159), 0.001f);- let _e162 = (*N_3);- let _e163 = (*V);- NdotV_2 = max(dot(_e162, _e163), 0.0001f);- let _e166 = (*N_3);- param_11 = _e166;- let _e167 = envIrradiance_u0028_vf3_u003b((¶m_11));- let _e168 = (*ao);- lit = (_e167 * _e168);+ var phi_768_: bool;+ var phi_822_: bool;++ let _e151 = (*albedo);+ let _e152 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e151, vec3(_e152));+ let _e155 = (*roughness_3);+ let _e156 = (*roughness_3);+ a_4 = max((_e155 * _e156), 0.001f);+ let _e159 = (*N_3);+ let _e160 = (*V);+ NdotV_2 = max(dot(_e159, _e160), 0.0001f);+ let _e163 = (*N_3);+ param_5 = _e163;+ let _e164 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e165 = (*ao);+ lit = (_e164 * _e165);gloss = vec3<f32>(0f, 0f, 0f);- i_2 = 0i;+ i = 0i;loop {- let _e170 = i_2;- if (_e170 < 16i) {- let _e172 = i_2;- let _e176 = unnamed_1.u_lights[_e172].posDir;- pd_1 = _e176;- let _e177 = i_2;- let _e181 = unnamed_1.u_lights[_e177].color;- col = _e181;- let _e182 = i_2;- let _e186 = unnamed_1.u_lights[_e182].shadow;- sh_3 = _e186;- let _e187 = pd_1;- target_1 = _e187.xy;+ let _e167 = i;+ if (_e167 < 16i) {+ let _e169 = i;+ let _e173 = unnamed_1.u_lights[_e169].posDir;+ pd_1 = _e173;+ let _e174 = i;+ let _e178 = unnamed_1.u_lights[_e174].color;+ col = _e178;+ let _e179 = i;+ let _e183 = unnamed_1.u_lights[_e179].shadow;+ sh_3 = _e183;+ let _e184 = pd_1;+ target_ = _e184.xy;castShadow = true;- let _e190 = pd_1[2u];- if (_e190 < 0.5f) {- let _e192 = pd_1;- param_12 = _e192;- let _e193 = sh_3;- param_13 = _e193;- let _e194 = (*worldPos_3);- param_14 = _e194;- let _e195 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));- toL = _e195;- let _e196 = toL;- param_15 = _e196;- let _e197 = lightDistance_u0028_vf3_u003b((¶m_15));- dist_1 = _e197;- let _e198 = dist_1;- let _e200 = pd_1[3u];- atten = max(0f, (1f - (_e198 / max(_e200, 0.0001f))));- let _e205 = toL;- param_16 = _e205;- let _e206 = (*N_3);- param_17 = _e206;- let _e207 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));- L_1 = _e207;+ let _e187 = pd_1[2u];+ if (_e187 < 0.5f) {+ let _e189 = pd_1;+ param_6 = _e189;+ let _e190 = sh_3;+ param_7 = _e190;+ let _e191 = (*worldPos_3);+ param_8 = _e191;+ let _e192 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e192;+ let _e193 = toL;+ param_9 = _e193;+ let _e194 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_1 = _e194;+ let _e195 = dist_1;+ let _e197 = pd_1[3u];+ atten = max(0f, (1f - (_e195 / max(_e197, 0.0001f))));+ let _e202 = toL;+ param_10 = _e202;+ let _e203 = (*N_3);+ param_11 = _e203;+ let _e204 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_10), (¶m_11));+ L_1 = _e204;} else {- let _e209 = pd_1[2u];- if (_e209 < 1.5f) {+ let _e206 = pd_1[2u];+ if (_e206 < 1.5f) {atten = 1f;- let _e211 = pd_1;- let _e212 = _e211.xy;- let _e214 = pd_1[3u];- L_1 = normalize(-(vec3<f32>(_e212.x, _e212.y, _e214)));- let _e220 = pd_1;- let _e222 = pd_1;- if (dot(_e220.xy, _e222.xy) > 0.00000001f) {- let _e226 = pd_1;- local_8 = normalize(-(_e226.xy));+ let _e208 = pd_1;+ let _e209 = _e208.xy;+ let _e211 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e209.x, _e209.y, _e211)));+ let _e217 = pd_1;+ let _e219 = pd_1;+ if (dot(_e217.xy, _e219.xy) > 0.00000001f) {+ let _e223 = pd_1;+ local_6 = normalize(-(_e223.xy));} else {- local_8 = vec2<f32>(0f, 0f);+ local_6 = vec2<f32>(0f, 0f);}- let _e230 = local_8;- toLight_3 = _e230;- let _e232 = sh_3[1u];- let _e233 = (_e232 > 0f);- phi_956_ = _e233;- if _e233 {- let _e234 = toLight_3;- let _e235 = toLight_3;- phi_956_ = (dot(_e234, _e235) > 0.5f);+ let _e227 = local_6;+ toLight_3 = _e227;+ let _e229 = sh_3[1u];+ let _e230 = (_e229 > 0f);+ phi_768_ = _e230;+ if _e230 {+ let _e231 = toLight_3;+ let _e232 = toLight_3;+ phi_768_ = (dot(_e231, _e232) > 0.5f);}- let _e239 = phi_956_;- castShadow = _e239;- let _e240 = (*worldPos_3);- let _e242 = toLight_3;- let _e244 = sh_3[1u];- target_1 = (_e240.xy + (_e242 * _e244));+ let _e236 = phi_768_;+ castShadow = _e236;+ let _e237 = (*worldPos_3);+ let _e239 = toLight_3;+ let _e241 = sh_3[1u];+ target_ = (_e237.xy + (_e239 * _e241));} else {- let _e247 = i_2;- let _e251 = unnamed_1.u_lights[_e247].spot;- sp_1 = _e251;- let _e252 = pd_1;- param_18 = _e252;- let _e253 = sh_3;- param_19 = _e253;- let _e254 = (*worldPos_3);- param_20 = _e254;- let _e255 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_18), (¶m_19), (¶m_20));- toL_1 = _e255;- let _e256 = toL_1;- param_21 = _e256;- let _e257 = lightDistance_u0028_vf3_u003b((¶m_21));- dist_2 = _e257;- let _e258 = dist_2;- let _e260 = pd_1[3u];- atten = max(0f, (1f - (_e258 / max(_e260, 0.0001f))));- let _e265 = toL_1;- param_22 = _e265;- let _e266 = (*N_3);- param_23 = _e266;- let _e267 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));- L_1 = _e267;- let _e268 = sp_1;- param_24 = _e268;- let _e269 = sh_3;- param_25 = _e269;- let _e270 = toL_1;- param_26 = _e270;- let _e271 = dist_2;- param_27 = _e271;- let _e272 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));- let _e273 = atten;- atten = (_e273 * _e272);+ let _e244 = i;+ let _e248 = unnamed_1.u_lights[_e244].spot;+ sp_1 = _e248;+ let _e249 = pd_1;+ param_12 = _e249;+ let _e250 = sh_3;+ param_13 = _e250;+ let _e251 = (*worldPos_3);+ param_14 = _e251;+ let _e252 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_12), (¶m_13), (¶m_14));+ toL_1 = _e252;+ let _e253 = toL_1;+ param_15 = _e253;+ let _e254 = lightDistance_u0028_vf3_u003b((¶m_15));+ dist_2 = _e254;+ let _e255 = dist_2;+ let _e257 = pd_1[3u];+ atten = max(0f, (1f - (_e255 / max(_e257, 0.0001f))));+ let _e262 = toL_1;+ param_16 = _e262;+ let _e263 = (*N_3);+ param_17 = _e263;+ let _e264 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_16), (¶m_17));+ L_1 = _e264;+ let _e265 = sp_1;+ param_18 = _e265;+ let _e266 = sh_3;+ param_19 = _e266;+ let _e267 = toL_1;+ param_20 = _e267;+ let _e268 = dist_2;+ param_21 = _e268;+ let _e269 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_18), (¶m_19), (¶m_20), (¶m_21));+ let _e270 = atten;+ atten = (_e270 * _e269);}}- let _e275 = castShadow;- phi_1010_ = _e275;- if _e275 {- let _e277 = col[3u];- phi_1010_ = (_e277 > 0f);+ let _e272 = castShadow;+ phi_822_ = _e272;+ if _e272 {+ let _e274 = col[3u];+ phi_822_ = (_e274 > 0f);}- let _e280 = phi_1010_;- let _e281 = atten;- if (_e280 && (_e281 > 0f)) {- let _e284 = (*worldPos_3);- param_28 = _e284.xy;- let _e286 = target_1;- param_29 = _e286;- let _e288 = sh_3[0u];- param_30 = _e288;- let _e289 = shadowFactor2D_u0028_vf2_u003b_vf2_u003b_f1_u003b((¶m_28), (¶m_29), (¶m_30));+ let _e277 = phi_822_;+ let _e278 = atten;+ if (_e277 && (_e278 > 0f)) {+ let _e281 = i;+ let _e286 = unnamed_1.u_lights[_e281].shadowMap[3u];+ param_22 = _e286;+ let _e287 = (*worldPos_3);+ param_23 = _e287.xy;+ let _e289 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_22), (¶m_23));let _e290 = atten;atten = (_e290 * _e289);}- let _e292 = i_2;+ let _e292 = i;let _e296 = unnamed_1.u_lights[_e292].shadowMap;sm = _e296;let _e298 = sm[1u];@@ -920,15 +720,15 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0let _e309 = sm[0u];let _e312 = sm[1u];let _e314 = (*worldPos_3);- param_31 = _e314;+ param_24 = _e314;let _e315 = (*N_3);- param_32 = _e315;+ param_25 = _e315;let _e316 = L_1;- param_33 = _e316;- param_34 = vec2<f32>(_e304, _e306);- param_35 = i32(_e309);- param_36 = i32(_e312);- let _e317 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35), (¶m_36));+ param_26 = _e316;+ param_27 = vec2<f32>(_e304, _e306);+ param_28 = i32(_e309);+ param_29 = i32(_e312);+ let _e317 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27), (¶m_28), (¶m_29));let _e318 = atten;atten = (_e318 * _e317);}@@ -950,27 +750,27 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0H = normalize((_e338 + _e339));let _e342 = (*N_3);let _e343 = H;- param_37 = max(dot(_e342, _e343), 0f);- let _e346 = a_5;- param_38 = _e346;- let _e347 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));+ param_30 = max(dot(_e342, _e343), 0f);+ let _e346 = a_4;+ param_31 = _e346;+ let _e347 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_30), (¶m_31));let _e348 = NdotV_2;- param_39 = _e348;+ param_32 = _e348;let _e349 = ndotl;- param_40 = _e349;+ param_33 = _e349;let _e350 = (*roughness_3);- param_41 = _e350;- let _e351 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_39), (¶m_40), (¶m_41));+ param_34 = _e350;+ let _e351 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_32), (¶m_33), (¶m_34));let _e353 = NdotV_2;let _e355 = ndotl;brdf = ((_e347 * _e351) / max(((4f * _e353) * _e355), 0.0001f));let _e359 = radiance;let _e360 = (*V);let _e361 = H;- param_42 = max(dot(_e360, _e361), 0f);+ param_35 = max(dot(_e360, _e361), 0f);let _e364 = F0_1;- param_43 = _e364;- let _e365 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_42), (¶m_43));+ param_36 = _e364;+ let _e365 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_35), (¶m_36));let _e367 = brdf;let _e369 = (*specular);let _e372 = gloss;@@ -981,22 +781,22 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0break;}continuing {- let _e374 = i_2;- i_2 = (_e374 + 1i);+ let _e374 = i;+ i = (_e374 + 1i);}}let _e376 = NdotV_2;- param_44 = _e376;+ param_37 = _e376;let _e377 = (*roughness_3);- param_45 = _e377;- let _e378 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_44), (¶m_45));+ param_38 = _e377;+ let _e378 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_37), (¶m_38));ab = _e378;let _e379 = (*V);let _e381 = (*N_3);- param_46 = reflect(-(_e379), _e381);+ param_39 = reflect(-(_e379), _e381);let _e383 = (*roughness_3);- param_47 = _e383;- let _e384 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_46), (¶m_47));+ param_40 = _e383;+ let _e384 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_39), (¶m_40));let _e385 = (*ao);let _e386 = (*specular);let _e389 = F0_1;@@ -1012,95 +812,95 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {- var local_9: vec3<f32>;+ var local_7: vec3<f32>;- let _e87 = unnamed.u_camera[3u];- if (_e87 > 0.5f) {- let _e90 = unnamed.u_camera;- let _e92 = (*worldPos_4);- local_9 = normalize((_e90.xyz - _e92));+ let _e85 = unnamed.u_camera[3u];+ if (_e85 > 0.5f) {+ let _e88 = unnamed.u_camera;+ let _e90 = (*worldPos_4);+ local_7 = normalize((_e88.xyz - _e90));} else {- let _e96 = unnamed.u_camera;- local_9 = _e96.xyz;+ let _e94 = unnamed.u_camera;+ local_7 = _e94.xyz;}- let _e98 = local_9;- return _e98;+ let _e96 = local_7;+ return _e96;}fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {var P: vec3<f32>;- var param_48: vec3<f32>;- var param_49: vec3<f32>;- var param_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec3<f32>;- var param_53: f32;- var param_54: f32;- var param_55: f32;- var param_56: f32;-- let _e97 = (*worldPos_5);- P = vec3<f32>(_e97.x, _e97.y, 0f);- let _e101 = P;- param_48 = _e101;- let _e102 = viewDirection_u0028_vf3_u003b((¶m_48));- let _e103 = (*albedo_1);- param_49 = _e103;- let _e104 = (*N_4);- param_50 = _e104;- let _e105 = P;- param_51 = _e105;- param_52 = _e102;- param_53 = 0f;- param_54 = 1f;- param_55 = 0f;- let _e106 = (*ao_1);- param_56 = _e106;- let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55), (¶m_56));- return _e107;+ var param_41: vec3<f32>;+ var param_42: vec3<f32>;+ var param_43: vec3<f32>;+ var param_44: vec3<f32>;+ var param_45: vec3<f32>;+ var param_46: f32;+ var param_47: f32;+ var param_48: f32;+ var param_49: f32;++ let _e95 = (*worldPos_5);+ P = vec3<f32>(_e95.x, _e95.y, 0f);+ let _e99 = P;+ param_41 = _e99;+ let _e100 = viewDirection_u0028_vf3_u003b((¶m_41));+ let _e101 = (*albedo_1);+ param_42 = _e101;+ let _e102 = (*N_4);+ param_43 = _e102;+ let _e103 = P;+ param_44 = _e103;+ param_45 = _e100;+ param_46 = 0f;+ param_47 = 1f;+ param_48 = 0f;+ let _e104 = (*ao_1);+ param_49 = _e104;+ let _e105 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_42), (¶m_43), (¶m_44), (¶m_45), (¶m_46), (¶m_47), (¶m_48), (¶m_49));+ return _e105;}fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_6: ptr<function, vec2<f32>>) -> vec3<f32> {- var param_57: vec3<f32>;- var param_58: vec3<f32>;- var param_59: vec2<f32>;- var param_60: f32;+ var param_50: vec3<f32>;+ var param_51: vec3<f32>;+ var param_52: vec2<f32>;+ var param_53: f32;- let _e90 = (*albedo_2);- param_57 = _e90;- let _e91 = (*N_5);- param_58 = _e91;- let _e92 = (*worldPos_6);- param_59 = _e92;- param_60 = 1f;- let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_57), (¶m_58), (¶m_59), (¶m_60));- return _e93;+ let _e88 = (*albedo_2);+ param_50 = _e88;+ let _e89 = (*N_5);+ param_51 = _e89;+ let _e90 = (*worldPos_6);+ param_52 = _e90;+ param_53 = 1f;+ let _e91 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_50), (¶m_51), (¶m_52), (¶m_53));+ return _e91;}fn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;var lit_1: vec3<f32>;- var param_61: vec3<f32>;- var param_62: vec3<f32>;- var param_63: vec2<f32>;-- let _e89 = v_texCoord_1;- let _e90 = textureSample(es_bt0_est, es_bt0_ess, _e89);- let _e91 = v_color_1;- base = (_e90 * _e91);+ var param_54: vec3<f32>;+ var param_55: vec3<f32>;+ var param_56: vec2<f32>;++ let _e87 = v_texCoord_1;+ let _e88 = textureSample(es_bt0_est, es_bt0_ess, _e87);+ let _e89 = v_color_1;+ base = (_e88 * _e89);N_6 = vec3<f32>(0f, 0f, 1f);- let _e93 = base;- param_61 = _e93.xyz;- let _e95 = N_6;- param_62 = _e95;- let _e96 = v_worldPos_1;- param_63 = _e96;- let _e97 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_61), (¶m_62), (¶m_63));- lit_1 = _e97;- let _e98 = lit_1;- let _e100 = base[3u];- fragColor = vec4<f32>(_e98.x, _e98.y, _e98.z, _e100);+ let _e91 = base;+ param_54 = _e91.xyz;+ let _e93 = N_6;+ param_55 = _e93;+ let _e94 = v_worldPos_1;+ param_56 = _e94;+ let _e95 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_54), (¶m_55), (¶m_56));+ lit_1 = _e95;+ let _e96 = lit_1;+ let _e98 = base[3u];+ fragColor = vec4<f32>(_e96.x, _e96.y, _e96.z, _e98);return;}diff --git a/src/esengine/data/shaders/mesh.esshader b/src/esengine/data/shaders/mesh.esshaderindex a89bf1ea0..00912955e 100644--- a/src/esengine/data/shaders/mesh.esshader+++ b/src/esengine/data/shaders/mesh.esshader@@ -276,6 +276,10 @@ struct VSOut {@group(1) @binding(3) var t3 : texture_2d<f32>;@group(1) @binding(11) var s3 : sampler;#endif+// The 2D shadow mask, on the top slot. Unconditional, because the injected+// lighting reads it for every Lit shader rather than behind a feature.+@group(1) @binding(7) var t7 : texture_2d<f32>;+@group(1) @binding(15) var s7 : sampler;struct VSOut {@builtin(position) pos : vec4f,diff --git a/src/esengine/data/shaders/shadow2d.esshader b/src/esengine/data/shaders/shadow2d.esshadernew file mode 100644index 000000000..ae46956a4--- /dev/null+++ b/src/esengine/data/shaders/shadow2d.esshader@@ -0,0 +1,72 @@+#pragma shader "Shadow2D"+#pragma version 300 es++// The 2D shadow mask: one channel per light that casts, drawn as the region each+// occluder's silhouette hides from it. The pass ADDS, which is what makes a+// source with width soft: its silhouette is drawn once per sample across the+// source, and a fragment collects a share for every sample hidden from it.+//+// `a_shadow` is the share this piece of geometry hides. `a_channel` is the+// light's own channel as a one-hot vector, which lets every light ride in one+// draw: the channels a vertex does not name receive zero.++#pragma vertex+layout(location = 0) in vec2 a_position;+layout(location = 1) in float a_shadow;+layout(location = 2) in vec4 a_channel;++out float v_shadow;+out vec4 v_channel;++void main() {+ gl_Position = u_projection * vec4(a_position, 0.0, 1.0);+ v_shadow = a_shadow;+ v_channel = a_channel;+}+#pragma end++#pragma fragment+precision highp float;++in float v_shadow;+in vec4 v_channel;++out vec4 fragColor;++void main() {+ fragColor = v_channel * v_shadow;+}+#pragma end++#pragma vertex wgsl+struct VSIn {+ @location(0) a_position : vec2f,+ @location(1) a_shadow : f32,+ @location(2) a_channel : vec4f,+};+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_shadow : f32,+ @location(1) v_channel : vec4f,+};++@vertex fn vs_main(v : VSIn) -> VSOut {+ var out : VSOut;+ out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);+ out.v_shadow = v.a_shadow;+ out.v_channel = v.a_channel;+ return out;+}+#pragma end++#pragma fragment wgsl+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_shadow : f32,+ @location(1) v_channel : vec4f,+};++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ return v.v_channel * v.v_shadow;+}+#pragma enddiff --git a/src/esengine/data/shaders/sky.esshader b/src/esengine/data/shaders/sky.esshaderindex 118de7463..d5412aca0 100644--- a/src/esengine/data/shaders/sky.esshader+++ b/src/esengine/data/shaders/sky.esshader@@ -60,6 +60,9 @@ struct VSOut {@group(1) @binding(8) var s0 : sampler;@group(1) @binding(3) var t3 : texture_2d<f32>;@group(1) @binding(11) var s3 : sampler;+// The 2D shadow mask, which the injected lighting reads for every Lit shader.+@group(1) @binding(7) var t7 : texture_2d<f32>;+@group(1) @binding(15) var s7 : sampler;// Declared again: each WGSL block is compiled on its own, so a struct defined in// the vertex one is an undeclared name here — and that reaches anyone as andiff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hppindex 057499333..28c694161 100644--- a/src/esengine/ecs/components/Light.hpp+++ b/src/esengine/ecs/components/Light.hpp@@ -81,8 +81,9 @@ struct Light {/** @brief Shadow penumbra softness = the light source's half-extent in world units; 0 is a* hard edge (default). It widens a penumbra the way a bigger source does, and the edge- * sharpens as a caster nears what it falls on. Read by the 2D occluder boxes of every- * type, and by a mesh shadow map only where the light HAS a position (Point/Spot). */+ * sharpens as a caster nears what it falls on. Read by the 2D shadow pass, which+ * draws the shadow once per sample across a source that has width, and by a mesh+ * shadow map only where the light HAS a position (Point/Spot). */ES_PROPERTY(animatable, min=0, shown_when=type:Point|Directional|Spot,tooltip="Shadow softness (light-source size); 0 = hard edge.")f32 shadowSoftness{0.0f};@@ -95,20 +96,17 @@ struct Light {tooltip="Angular size of a Directional light's source; 0 = hard edge (sun ~0.53).")f32 sourceAngle{0.0f};- /** @brief Directional-light shadow reach in world units: how far back toward the light a- * fragment searches for an occluder. 0 = a Directional light casts no shadow (default).- * Ignored by Point/Spot, which shadow along the segment to the light position. */+ /** @brief Directional-light shadow reach in world units: how far its shadows are carried+ * from whatever cast them. 0 = a Directional light casts no 2D shadow (default).+ * Ignored by Point/Spot, whose shadows reach as far as their own radius. */ES_PROPERTY(animatable, min=0, advanced, shown_when=type:Directional,tooltip="Directional shadow distance; 0 = no directional shadow.")f32 shadowDistance{0.0f};- /** @brief Casts a shadow map over 3D meshes. Every type but Ambient can: a- * Directional light's map is a set of cascades over the view, a Spot's is its- * cone, and a Point's is the six faces of a cube around it. Separate from- * @ref shadowDistance, which shadows 2D ShadowCaster2D boxes in the XY plane:- * one light can do both, and a 2.5D scene often wants exactly that. Lights- * that stand somewhere claim their tiles first and one sun takes what is left,- * so a crowded frame costs the sun its farthest cascade rather than a map. */+ /** @brief Casts a shadow map over 3D meshes. Every type but Ambient can: a sun's map+ * is cascades over the view, a Spot's its cone, a Point's a cube. Separate from+ * @ref shadowDistance, which shadows ShadowCaster2D edges in the plane — one+ * light can do both. Lights that stand somewhere claim tiles first. */ES_PROPERTY(shown_when=type:Point|Directional|Spot,tooltip="Cast a shadow map over 3D meshes (Directional, Spot, Point).")bool meshShadows{false};diff --git a/src/esengine/ecs/components/ShadowCaster2D.hpp b/src/esengine/ecs/components/ShadowCaster2D.hppindex fa859486d..81fef1619 100644--- a/src/esengine/ecs/components/ShadowCaster2D.hpp+++ b/src/esengine/ecs/components/ShadowCaster2D.hpp@@ -3,10 +3,11 @@/*** @file ShadowCaster2D.hpp* @brief Marks an entity as a 2D shadow occluder for the Lit lighting path.- * @details The render collect path turns each enabled caster into a world-space AABB (centered- * on the entity's Transform, `size` wide/tall) and feeds it to LightStore as an occluder.- * A point/spot light is then blocked at any fragment whose segment to the light crosses- * the box (see ShaderParser's injected shadowFactor2D). Carries no geometry of its own.+ * @details The render collect path turns each enabled caster into the four world-space edges+ * of a box centred on its Transform, and the 2D shadow pass DRAWS what those edges+ * hide from each casting light into a screen-space mask. A Lit fragment then reads+ * its light's channel of that mask. Drawn rather than solved per pixel, which is what+ * lets a scene hold as many occluders as it has walls.** @copyright Copyright (c) 2026 ESEngine Team* Licensed under the Apache License, Version 2.0.diff --git a/src/esengine/renderer/draw/DrawCommand.hpp b/src/esengine/renderer/draw/DrawCommand.hppindex 20170d5d9..eb1dfe80d 100644--- a/src/esengine/renderer/draw/DrawCommand.hpp+++ b/src/esengine/renderer/draw/DrawCommand.hpp@@ -280,12 +280,15 @@ struct DrawCommand {}/** @brief Finds @p texId in this command's texture set, adds it (returns its slot), or- * -1 if the set is full. Used by the merge to assign per-vertex sampler slots. */- i32 addTextureSlot(u32 texId) {+ * -1 if the set is full. Used by the merge to assign per-vertex sampler slots.+ * @p limit is how many slots the merge may spend: a frame with a 2D shadow+ * mask keeps the top one for it, and a merge that took it would bind a+ * sprite where every Lit fragment reads its shadow. */+ i32 addTextureSlot(u32 texId, u8 limit = MAX_CMD_TEXTURE_SLOTS) {for (u8 i = 0; i < texture_count; ++i) {if (texture_ids[i] == texId) return static_cast<i32>(i);}- if (texture_count >= MAX_CMD_TEXTURE_SLOTS) return -1;+ if (texture_count >= limit) return -1;texture_ids[texture_count] = texId;return static_cast<i32>(texture_count++);}diff --git a/src/esengine/renderer/draw/DrawList.cpp b/src/esengine/renderer/draw/DrawList.cppindex f271ae476..e536d7d5d 100644--- a/src/esengine/renderer/draw/DrawList.cpp+++ b/src/esengine/renderer/draw/DrawList.cpp@@ -123,7 +123,9 @@ void DrawList::finalize(TransientBufferPool& pool) {if (head.layout_id == LayoutId::Batch && commands_[i].texture_count >= 1) {// Multi-texture: give this command's texture a slot in the head's set// (or bail to a new draw if all 8 slots are taken), then stamp its verts.- i32 slot = head.addTextureSlot(commands_[i].texture_ids[0]);+ const u8 slotBudget = static_cast<u8>(+ shadow_2d_reserved_ ? MAX_CMD_TEXTURE_SLOTS - 1 : MAX_CMD_TEXTURE_SLOTS);+ i32 slot = head.addTextureSlot(commands_[i].texture_ids[0], slotBudget);if (slot >= 0) {// Staging verts default to texIndex 0, so only a non-zero slot// needs the per-vertex rewrite; a same-texture merge reuses@@ -237,7 +239,12 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,// any pass. The fill is a STABLE white, so unused units cost no rebind.if (cmd.texture_count > 0) {for (u8 slot = 0; slot < MAX_CMD_TEXTURE_SLOTS; ++slot) {- u32 tex = (slot < cmd.texture_count) ? cmd.texture_ids[slot] : white_texture_id;+ // The top unit is the frame's 2D shadow mask wherever one exists — the+ // merge was kept off it, so what a draw holds there is the fill.+ const bool masked = shadow_2d_reserved_ && slot == MAX_CMD_TEXTURE_SLOTS - 1;+ u32 tex = masked ? (shadow_2d_texture_ != 0 ? shadow_2d_texture_ : white_texture_id)+ : ((slot < cmd.texture_count) ? cmd.texture_ids[slot]+ : white_texture_id);device.bindTexture(slot, TextureHandle{tex});}}diff --git a/src/esengine/renderer/draw/DrawList.hpp b/src/esengine/renderer/draw/DrawList.hppindex 3335f6262..8f5ceb9a2 100644--- a/src/esengine/renderer/draw/DrawList.hpp+++ b/src/esengine/renderer/draw/DrawList.hpp@@ -26,6 +26,15 @@ public:// (hence the pool, whose staging it rewrites; call before upload()).void finalize(TransientBufferPool& pool);+ /// Whether the frame keeps its top texture unit for a 2D shadow mask. Set BEFORE+ /// finalize: the merge spends slots there, and the mask's own texture does not+ /// exist until the pass that draws it has run.+ void reserveShadow2DSlot(bool reserved) { shadow_2d_reserved_ = reserved; }++ /// The mask itself, which every draw then binds on that unit. Zero leaves the unit+ /// filled with white, which reads as "nothing shadows anything".+ void setShadow2DTexture(u32 textureId) { shadow_2d_texture_ = textureId; }+// Each merged command resolves to an immutable pipeline (program + layout + blend +// depth + stencil + cull) bound via GfxDevice::setPipeline; per-draw dynamic state// (scissor, stencil ref, textures) is applied directly. Per-frame constants come from@@ -166,6 +175,10 @@ private:std::vector<SortEntry> sort_entries_;std::vector<DrawCommand> sorted_scratch_; // reused across frames to avoid a// per-frame heap alloc in finalize()+ /// @see setShadow2DTexture+ u32 shadow_2d_texture_ = 0;+ /// @see reserveShadow2DSlot+ bool shadow_2d_reserved_ = false;u32 merged_draw_calls_ = 0;/// Members of a SortingGroup, by entity id — empty in the common frame.std::unordered_map<u32, GroupIdentity> group_identities_;diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex a5d3933c0..ccfee0f02 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -186,6 +186,7 @@ void RenderFrame::shutdown() {pool_.shutdown();shadow_pool_.shutdown();releaseShadowFrameUbos();+ releaseShadow2DResources();releaseFrameTargets();target_pool_.clear();@@ -206,6 +207,14 @@ void RenderFrame::recreateGpuResources() {// as it needs. Kept here rather than recreated eagerly: how many is a property// of the frame that has not been collected yet.releaseShadowFrameUbos();+ // The mask's buffer and layout died with the device too, and its shader has to be+ // compiled again against the new one. Forgotten rather than deleted: the handles+ // name nothing now, and the next frame that needs a mask makes its own.+ shadow_2d_vbo_ = BufferHandle::Invalid;+ shadow_2d_vbo_bytes_ = 0;+ shadow_2d_layout_ = VertexLayoutHandle::Invalid;+ shadow_2d_shader_ = {};+ shadow_2d_shader_tried_ = false;target_manager_.recreateGpuResources();// The framebuffers the pool is holding died with the device: the loans go// back and the memory behind them goes with it, or the next frame would draw@@ -251,6 +260,21 @@ void RenderFrame::resize(u32 width, u32 height) {// viewport; this is the draw and the constants it needs current.void RenderFrame::drawScene() {context_.updateCameraConstants(view_projection_);+ // Where THIS camera's pixels sit inside the 2D shadow mask. Per camera because the+ // mask is screen space: two cameras drew into two parts of one target, and a+ // fragment has to read the part its own camera filled.+ if (shadow2DActive() && width_ > 0 && height_ > 0) {+ const f32 w = static_cast<f32>(width_);+ const f32 h = static_cast<f32>(height_);+ context_.lights().setShadow2DRect(glm::vec4(+ static_cast<f32>(std::max(scene_viewport_.x, 0)) / w,+ static_cast<f32>(std::max(scene_viewport_.y, 0)) / h,+ static_cast<f32>(scene_viewport_.w) / w,+ static_cast<f32>(scene_viewport_.h) / h));+ } else {+ context_.lights().setShadow2DRect(glm::vec4(0.0f));+ }+ draw_list_.setShadow2DTexture(shadow_2d_texture_id_);// Here and not in flush(): the shadow pass runs before this one and decides// which atlas tile each light reads, so the block has to go up after it.context_.lights().uploadAndBind();@@ -480,6 +504,9 @@ void RenderFrame::flush() {// upload afterwards is its own clock and cannot be read off this one.{ES_PROFILE_SCOPE("render.finalize.drawList");+ // Before the merge, which spends texture slots: the mask needs the top one+ // and does not exist yet — its own pass has not run.+ draw_list_.reserveShadow2DSlot(shadow_2d_resource_ != rg::kNoResource);draw_list_.finalize(pool_);}{@@ -554,6 +581,11 @@ void RenderFrame::end() {if (shadow_resource_ != rg::kNoResource) {scene.dependencies.push_back(shadow_resource_);}+ // The same terms for the 2D mask: every Lit draw samples it through a pinned+ // unit, so the graph owes the scene its ordering and its lifetime, not a bind.+ if (shadow_2d_resource_ != rg::kNoResource) {+ scene.dependencies.push_back(shadow_2d_resource_);+ }scene.execute = [this](const rg::PassContext&) {drawScene();if (presented_overlay_draw_) presented_overlay_draw_->flushDeferred();@@ -1192,20 +1224,9 @@ void RenderFrame::collectLights(ecs::Registry& registry) {lights.addLight(collected[slot].gpu);}- // Shadow occluders: each enabled ShadowCaster2D becomes a world-space AABB (centered on its- // Transform, `size` wide/tall). The injected shadowFactor2D blocks point/spot light at any- // fragment whose segment to the light crosses a box. Past the cap are silently dropped.- auto occluders = registry.view<ecs::Transform, ecs::ShadowCaster2D>();- for (auto entity : occluders) {- const auto& caster = occluders.get<ecs::ShadowCaster2D>(entity);- if (!caster.enabled) continue;- auto& transform = occluders.get<ecs::Transform>(entity);- transform.ensureDecomposed();- const glm::vec3 p = transform.worldPosition;- const f32 hx = caster.size.x * 0.5f;- const f32 hy = caster.size.y * 0.5f;- lights.addOccluder(glm::vec4(p.x - hx, p.y - hy, p.x + hx, p.y + hy));- }+ // Last, because which lights the mask can carry is a question about the array the+ // loop above just filled.+ collectShadow2D(registry);}bool RenderFrame::collectEnvironment(const ecs::Light& light, const glm::vec3& scale) {@@ -1776,6 +1797,7 @@ void RenderFrame::collectAll(ecs::Registry& registry) {// between them, and a pass opened here would swallow them.{ ES_PROFILE_SCOPE("render.collect.shadowPlan"); buildShadowPlan(registry); }{ ES_PROFILE_SCOPE("render.collect.shadowDeclare"); declareShadowPass(registry); }+ { ES_PROFILE_SCOPE("render.collect.shadow2dDeclare"); declareShadow2DPass(); }auto ctx = makeContext();diff --git a/src/esengine/renderer/frame/RenderFrame.hpp b/src/esengine/renderer/frame/RenderFrame.hppindex c80e5131b..6618ba965 100644--- a/src/esengine/renderer/frame/RenderFrame.hpp+++ b/src/esengine/renderer/frame/RenderFrame.hpp@@ -610,6 +610,36 @@ private:/// see and draw them. The graph has bound and cleared the atlas.void executeShadowPass(ecs::Registry& registry);+ /**+ * @brief Gathers the frame's 2D occluders and hands the casting lights a mask channel.+ *+ * @details Runs inside collectLights, where nothing may touch the GPU: it turns each+ * enabled ShadowCaster2D into world-space edges and picks which lights the+ * mask can carry. A light past the cap keeps lighting the scene and stops+ * shadowing — said out loud in the plan rather than silently.+ */+ void collectShadow2D(ecs::Registry& registry);++ /// Declares the pass that draws the mask, ahead of the scene that samples it.+ void declareShadow2DPass();++ /// The mask pass's body: the shadow each edge casts from each light, drawn with MIN+ /// blending so a fragment keeps the darkest claim on it. The graph cleared the target.+ void executeShadow2DPass();++ /// Fills @ref shadow_2d_vertices_ with the geometry the mask pass draws.+ void buildShadow2DGeometry();++ /// Frees the mask's own GPU objects. Called while the device is still valid.+ void releaseShadow2DResources();++ /// Compiles the mask shader on first use, and says whether it is usable.+ bool ensureShadow2DShader();++ /// Whether this frame drew a mask — what the batch's slot budget and the sampler+ /// binding both key off.+ bool shadow2DActive() const { return shadow_2d_texture_id_ != 0; }+/// Grows the per-view frame-constant buffers to @p count and no further.void ensureShadowFrameUbos(u32 count);@@ -684,6 +714,51 @@ private:FramebufferHandle scene_fbo_ = FramebufferHandle::Default;/// The camera's rect within its target; the scene pass carries it.GfxDevice::Viewport scene_viewport_{};+ /**+ * @brief One occluder's outline in @ref shadow_points_2d_ — what a shadow is cast from.+ *+ * @details A ring rather than loose edges: a shadow is thrown by the SILHOUETTE —+ * the two points of the outline a light sees the edges of — and what lies+ * behind it is one shadow. Per edge, the shadows of one box overlap, and+ * the overlap is a question a ring never raises.+ */+ struct ShadowRing2D {+ u32 first = 0;+ u32 count = 0;+ };++ /** @brief A light whose 2D shadows the frame draws, and the mask channel it owns. */+ struct Shadow2DLight {+ /// Where it stands. A directional light has no position and uses @ref dir.+ glm::vec2 pos{0.0f};+ /// The way a directional light's rays travel; zero for the others.+ glm::vec2 dir{0.0f};+ /// How far its shadows reach: a point/spot light's radius, a directional+ /// light's march distance. Past it the light contributes nothing to shadow.+ f32 reach = 0.0f;+ /// Half-extent of the source, in world units — what widens the penumbra.+ f32 softness = 0.0f;+ /// Its slot in the light array, which is what the channel is recorded against.+ u32 slot = 0;+ bool directional = false;+ };++ std::vector<glm::vec2> shadow_points_2d_;+ std::vector<ShadowRing2D> shadow_rings_2d_;+ std::vector<Shadow2DLight> shadow_2d_lights_;+ /// The mask as a graph resource: the 2D shadow pass writes it, the scene reads it+ /// through a pinned sampler unit rather than a graph-bound one.+ rg::ResourceId shadow_2d_resource_ = rg::kNoResource;+ u32 shadow_2d_texture_id_ = 0;+ /// Interleaved (x, y, shadow, channel.rgba) — built on the CPU each frame, because+ /// the geometry is a function of where every light stands.+ std::vector<f32> shadow_2d_vertices_;+ BufferHandle shadow_2d_vbo_ = BufferHandle::Invalid;+ u32 shadow_2d_vbo_bytes_ = 0;+ VertexLayoutHandle shadow_2d_layout_ = VertexLayoutHandle::Invalid;+ resource::ShaderHandle shadow_2d_shader_{};+ bool shadow_2d_shader_tried_ = false;+/// The atlas as a graph resource: the shadow pass writes it and the scene names/// it, which is what orders the two. Borrowed from the pool every other target/// comes from. kNoResource = no map this frame.diff --git a/src/esengine/renderer/frame/RenderFrameShadow2D.cpp b/src/esengine/renderer/frame/RenderFrameShadow2D.cppnew file mode 100644index 000000000..b5c3ec6a8--- /dev/null+++ b/src/esengine/renderer/frame/RenderFrameShadow2D.cpp@@ -0,0 +1,321 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The 2D shadow mask: what each occluder edge hides from each light.+ *+ * The shadow is drawn rather than solved per pixel: one screen-sized+ * mask, a channel per casting light, and the geometry each edge hides+ * rasterised into it. So the occluder count is a vertex count rather than+ * a shader constant, and a Lit fragment pays one read whatever it is.+ */+#include "./RenderFrame.hpp"+#include "../../core/Log.hpp"+#include "../../ecs/components/Transform.hpp"+#include "../../ecs/components/ShadowCaster2D.hpp"+#include "../../resource/ShaderParser.hpp"+#include "../rhi/ShaderEmbeds.generated.hpp"++#include <algorithm>+#include <cmath>++namespace esengine {++namespace {++/// Floats one mask vertex carries: position, how much light survives, and the+/// one-hot channel of the light it was cast from.+constexpr u32 kShadow2DFloats = 7;++/// Samples across a source that has width. A penumbra made of samples IS banded,+/// and sixteen is where the bands stop reading as rays from the corner that threw+/// them — one silhouette each, over a scene with tens of occluders.+constexpr u32 kSoftSamples = 16;++/// How far past a light's own reach a shadow is extruded. A shadow that stopped+/// exactly at the reach would end in a visible edge where the light already+/// contributes nothing, so it is carried past the point of being looked at.+constexpr f32 kShadow2DOvershoot = 1.25f;++} // namespace++void RenderFrame::collectShadow2D(ecs::Registry& registry) {+ shadow_points_2d_.clear();+ shadow_rings_2d_.clear();+ shadow_2d_lights_.clear();+ shadow_2d_resource_ = rg::kNoResource;+ shadow_2d_texture_id_ = 0;+ context_.lights().setShadow2DRect(glm::vec4(0.0f));++ auto casters = registry.view<ecs::Transform, ecs::ShadowCaster2D>();+ for (auto entity : casters) {+ const auto& caster = casters.get<ecs::ShadowCaster2D>(entity);+ if (!caster.enabled) continue;+ auto& transform = casters.get<ecs::Transform>(entity);+ transform.ensureDecomposed();+ const glm::vec3 p = transform.worldPosition;+ const f32 hx = caster.size.x * 0.5f;+ const f32 hy = caster.size.y * 0.5f;+ if (hx <= 0.0f || hy <= 0.0f) continue;+ const glm::vec2 lo(p.x - hx, p.y - hy);+ const glm::vec2 hi(p.x + hx, p.y + hy);+ shadow_rings_2d_.push_back({static_cast<u32>(shadow_points_2d_.size()), 4});+ shadow_points_2d_.push_back({lo.x, lo.y});+ shadow_points_2d_.push_back({hi.x, lo.y});+ shadow_points_2d_.push_back({hi.x, hi.y});+ shadow_points_2d_.push_back({lo.x, hi.y});+ }+ if (shadow_rings_2d_.empty()) return;++ // Which lights the mask can carry. The collect already ordered the light array by+ // what the cap sorted on, so taking them in slot order takes the brightest first.+ const LightConstants& lights = context_.lights().data();+ for (u32 slot = 0; slot < context_.lights().count(); ++slot) {+ if (shadow_2d_lights_.size() >= MAX_SHADOW_2D_LIGHTS) break;+ const GpuLight& light = lights.lights[slot];+ if (light.color.a <= 0.0f) continue;+ const f32 type = light.posDir.z;+ Shadow2DLight entry;+ entry.slot = slot;+ entry.softness = light.shadow.x;+ if (type < 0.5f || type > 1.5f) {+ entry.pos = glm::vec2(light.posDir.x, light.posDir.y);+ entry.reach = light.posDir.w;+ } else {+ // A sun: its rays are parallel, so what a shadow needs is the direction they+ // travel and how far the author let one march. Zero distance is a sun that+ // casts none, which is the default.+ const glm::vec2 aim(light.posDir.x, light.posDir.y);+ if (light.shadow.y <= 0.0f || glm::dot(aim, aim) < 1e-8f) continue;+ entry.directional = true;+ entry.dir = glm::normalize(aim);+ entry.reach = light.shadow.y;+ }+ if (entry.reach <= 0.0f) continue;+ shadow_2d_lights_.push_back(entry);+ }+ if (shadow_2d_lights_.empty()) {+ shadow_rings_2d_.clear();+ shadow_points_2d_.clear();+ return;+ }++ for (u32 i = 0; i < shadow_2d_lights_.size(); ++i) {+ context_.lights().setLightShadow2DChannel(shadow_2d_lights_[i].slot, i);+ }++ rg::TargetDesc desc;+ desc.scale = 1.0f;+ desc.format = GfxPixelFormat::RGBA8;+ // Nearest: a fragment reads the texel it was drawn into, and a filtered read would+ // blend in the neighbouring light's shadow at a silhouette.+ desc.linearFilter = false;+ shadow_2d_resource_ = graph_.createTarget(desc);+}++void RenderFrame::releaseShadow2DResources() {+ if (shadow_2d_vbo_ != BufferHandle::Invalid) device_.deleteBuffer(shadow_2d_vbo_);+ if (shadow_2d_layout_ != VertexLayoutHandle::Invalid) device_.deleteVertexLayout(shadow_2d_layout_);+ shadow_2d_vbo_ = BufferHandle::Invalid;+ shadow_2d_vbo_bytes_ = 0;+ shadow_2d_layout_ = VertexLayoutHandle::Invalid;+}++bool RenderFrame::ensureShadow2DShader() {+ if (shadow_2d_shader_.isValid()) return true;+ if (shadow_2d_shader_tried_) return false;+ shadow_2d_shader_tried_ = true;++ auto& resources = resource_manager_;+ const auto target = resources.preferredShaderTarget();+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::SHADOW2D);+ shadow_2d_shader_ = resources.createShader(+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex, "", {}, target),+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment, "", {}, target),+ /*rewriteLoose=*/false, resources.preferredShaderLanguage());+ if (!shadow_2d_shader_.isValid()) {+ ES_LOG_ERROR("RenderFrame: no 2D shadow shader; 2D shadows are off this run");+ return false;+ }++ VertexLayoutDesc layout;+ layout.attributeCount = 3;+ layout.strides[0] = kShadow2DFloats * sizeof(f32);+ layout.attributes[0] = {0, 2, GfxDataType::Float, false, 0, 0};+ layout.attributes[1] = {1, 1, GfxDataType::Float, false, 2 * sizeof(f32), 0};+ layout.attributes[2] = {2, 4, GfxDataType::Float, false, 3 * sizeof(f32), 0};+ shadow_2d_layout_ = device_.createVertexLayout(layout);+ return shadow_2d_layout_ != VertexLayoutHandle::Invalid;+}++namespace {++/// The z of the cross product of two plane vectors — which side one turns to.+inline f32 cross2(const glm::vec2& a, const glm::vec2& b) {+ return a.x * b.y - a.y * b.x;+}++/// A unit vector at right angles to @p v; (1,0) where there is no direction to turn.+inline glm::vec2 perpendicularTo(const glm::vec2& v) {+ const f32 len = std::sqrt(v.x * v.x + v.y * v.y);+ if (len < 1e-6f) return {1.0f, 0.0f};+ return {-v.y / len, v.x / len};+}++/// Where a point lands once it is pushed away from @p from as far as @p reach.+inline glm::vec2 extrude(const glm::vec2& p, const glm::vec2& from, f32 reach) {+ const glm::vec2 d = p - from;+ const f32 len = std::sqrt(d.x * d.x + d.y * d.y);+ if (len < 1e-6f) return p;+ return p + d * (reach * kShadow2DOvershoot / len);+}++} // namespace++void RenderFrame::buildShadow2DGeometry() {+ shadow_2d_vertices_.clear();++ auto vertex = [this](const glm::vec2& p, f32 shadow, u32 channel) {+ shadow_2d_vertices_.push_back(p.x);+ shadow_2d_vertices_.push_back(p.y);+ shadow_2d_vertices_.push_back(shadow);+ for (u32 c = 0; c < 4; ++c) {+ shadow_2d_vertices_.push_back(c == channel ? 1.0f : 0.0f);+ }+ };+ auto triangle = [&vertex](const glm::vec2& a, f32 sa, const glm::vec2& b, f32 sb,+ const glm::vec2& c, f32 sc, u32 channel) {+ vertex(a, sa, channel);+ vertex(b, sb, channel);+ vertex(c, sc, channel);+ };++ for (u32 channel = 0; channel < shadow_2d_lights_.size(); ++channel) {+ const Shadow2DLight& light = shadow_2d_lights_[channel];+ // A source with width is sampled across, each sample throwing the silhouette+ // it sees at its own share. The shares add, which is the soft edge: hidden from+ // every sample collects all of them, from half collects half.+ const u32 samples = light.softness > 1e-4f ? kSoftSamples : 1u;+ const f32 share = 1.0f / static_cast<f32>(samples);+ // How far a sample sits from the middle of the source, in -1..1.+ const auto offsetOf = [samples](u32 s) {+ if (samples <= 1) return 0.0f;+ return (static_cast<f32>(s) + 0.5f) / static_cast<f32>(samples) * 2.0f - 1.0f;+ };++ for (const ShadowRing2D& ring : shadow_rings_2d_) {+ const glm::vec2* pts = shadow_points_2d_.data() + ring.first;+ glm::vec2 centre{0.0f};+ for (u32 i = 0; i < ring.count; ++i) centre += pts[i];+ centre /= static_cast<f32>(ring.count);++ for (u32 s = 0; s < samples; ++s) {+ const f32 t = offsetOf(s);+ if (light.directional) {+ // Parallel rays, so a source with width is an ANGLE rather than a+ // place: the softness is how wide it is where its shadows end, and+ // what a sample changes is the direction they all travel.+ const f32 spread = (light.reach > 1e-6f) ? light.softness / light.reach : 0.0f;+ const f32 angle = t * spread;+ const glm::vec2 dir{+ light.dir.x * std::cos(angle) - light.dir.y * std::sin(angle),+ light.dir.x * std::sin(angle) + light.dir.y * std::cos(angle),+ };+ // The silhouette of parallel rays: the two points furthest apart+ // across the way they travel.+ const glm::vec2 across = perpendicularTo(dir);+ u32 lo = 0;+ u32 hi = 0;+ for (u32 i = 1; i < ring.count; ++i) {+ if (glm::dot(pts[i] - pts[lo], across) < 0.0f) lo = i;+ if (glm::dot(pts[i] - pts[hi], across) > 0.0f) hi = i;+ }+ const glm::vec2 reach = dir * (light.reach * kShadow2DOvershoot);+ triangle(pts[lo], share, pts[hi], share, pts[hi] + reach, share, channel);+ triangle(pts[lo], share, pts[hi] + reach, share, pts[lo] + reach, share, channel);+ continue;+ }++ // The source is a disc, so it is sampled across the diameter square to+ // what it is lighting — the direction its width actually widens.+ const glm::vec2 from =+ light.pos + perpendicularTo(centre - light.pos) * (t * light.softness);+ // The silhouette from where this sample stands: the two points every+ // other point of the ring sits between, seen from here. A sample inside+ // the ring finds none and throws no shadow from it.+ u32 lo = 0;+ u32 hi = 0;+ for (u32 i = 1; i < ring.count; ++i) {+ if (cross2(pts[lo] - from, pts[i] - from) < 0.0f) lo = i;+ if (cross2(pts[hi] - from, pts[i] - from) > 0.0f) hi = i;+ }+ if (lo == hi) continue;+ const glm::vec2 farLo = extrude(pts[lo], from, light.reach);+ const glm::vec2 farHi = extrude(pts[hi], from, light.reach);+ triangle(pts[lo], share, pts[hi], share, farHi, share, channel);+ triangle(pts[lo], share, farHi, share, farLo, share, channel);+ }+ }+ }+}++void RenderFrame::declareShadow2DPass() {+ if (shadow_2d_resource_ == rg::kNoResource) return;++ rg::PassDesc mask;+ mask.name = "shadow-2d";+ mask.write = shadow_2d_resource_;+ mask.clear = true;+ // Zero is "nothing hides this light here" in all four channels, which is what a+ // frame whose geometry comes back empty has to read as.+ mask.clearColor[0] = mask.clearColor[1] = mask.clearColor[2] = 0.0f;+ mask.clearColor[3] = 0.0f;+ mask.execute = [this](const rg::PassContext&) { executeShadow2DPass(); };+ graph_.addPass(std::move(mask));+}++void RenderFrame::executeShadow2DPass() {+ if (shadow_2d_resource_ == rg::kNoResource) return;+ if (!ensureShadow2DShader()) return;++ buildShadow2DGeometry();+ if (shadow_2d_vertices_.empty()) return;++ const u32 bytes = static_cast<u32>(shadow_2d_vertices_.size() * sizeof(f32));+ if (shadow_2d_vbo_ == BufferHandle::Invalid || bytes > shadow_2d_vbo_bytes_) {+ if (shadow_2d_vbo_ != BufferHandle::Invalid) device_.deleteBuffer(shadow_2d_vbo_);+ // Grown in steps rather than to the exact size: the geometry follows how many+ // lights are moving, and a re-create every frame is a re-create every frame.+ shadow_2d_vbo_bytes_ = std::max(bytes * 2u, 4096u);+ shadow_2d_vbo_ = device_.createBuffer(+ {GfxBufferUsage::Vertex, shadow_2d_vbo_bytes_, /*dynamic=*/true}, nullptr);+ if (shadow_2d_vbo_ == BufferHandle::Invalid) return;+ }+ device_.updateBuffer(shadow_2d_vbo_, 0, shadow_2d_vertices_.data(), bytes);++ Shader* shader = resource_manager_.getShader(shadow_2d_shader_);+ if (!shader) return;++ PipelineDesc desc{};+ desc.program = shader->handle();+ desc.vertexLayout = shadow_2d_layout_;+ // Adding: one silhouette per sample across the source, each carrying its share, so+ // what a fragment collects is how much of the source is hidden from it. Two walls+ // over one pixel add past a whole shadow, and the read clamps.+ desc.blend = BlendMode::PmaAdditive;+ desc.blendEnabled = true;+ desc.depthTest = false;+ desc.depthWrite = false;+ device_.setPipeline(device_.createPipeline(desc));+ // The camera's own rect, as the scene pass will use it: the mask and the frame it+ // shadows have to land on the same pixels, and opening a pass resets the viewport.+ device_.setViewport(std::max(scene_viewport_.x, 0), std::max(scene_viewport_.y, 0),+ static_cast<i32>(scene_viewport_.w), static_cast<i32>(scene_viewport_.h));+ context_.updateCameraConstants(view_projection_);+ device_.setVertexBuffer(0, shadow_2d_vbo_, 0);+ device_.setIndexBuffer(BufferHandle::Invalid);+ device_.drawArrays(0, static_cast<u32>(shadow_2d_vertices_.size() / kShadow2DFloats));++ shadow_2d_texture_id_ = static_cast<u32>(graph_.textureOf(shadow_2d_resource_));+}++} // namespace esenginediff --git a/src/esengine/renderer/rhi/Shader.cpp b/src/esengine/renderer/rhi/Shader.cppindex 962f2db4c..59c59b5ea 100644--- a/src/esengine/renderer/rhi/Shader.cpp+++ b/src/esengine/renderer/rhi/Shader.cpp@@ -262,7 +262,8 @@ bool Shader::compile(const std::string& vertexSrc, const std::string& fragmentSr// Engine-injected samplers sit on fixed units, pinned here for the same reason the// blocks above are: the header reaches every Lit shader, so a compile site that// forgot the unit would sample slot 0 silently. GLSL ES 300 has no layout(binding).- if (hasUniform(SHADOW_MAP_SAMPLER) || hasUniform(ENV_MAP_SAMPLER)) {+ if (hasUniform(SHADOW_MAP_SAMPLER) || hasUniform(ENV_MAP_SAMPLER)+ || hasUniform(SHADOW_2D_SAMPLER)) {bind();if (hasUniform(SHADOW_MAP_SAMPLER)) {setUniform(SHADOW_MAP_SAMPLER, static_cast<i32>(SHADOW_MAP_TEXTURE_UNIT));@@ -270,6 +271,9 @@ bool Shader::compile(const std::string& vertexSrc, const std::string& fragmentSrif (hasUniform(ENV_MAP_SAMPLER)) {setUniform(ENV_MAP_SAMPLER, static_cast<i32>(ENV_MAP_TEXTURE_UNIT));}+ if (hasUniform(SHADOW_2D_SAMPLER)) {+ setUniform(SHADOW_2D_SAMPLER, static_cast<i32>(SHADOW_2D_TEXTURE_UNIT));+ }unbind();}diff --git a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hppindex 3bbe94a74..6c96a8f4e 100644--- a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp+++ b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp@@ -551,6 +551,10 @@ struct VSOut {@group(1) @binding(3) var t3 : texture_2d<f32>;@group(1) @binding(11) var s3 : sampler;#endif+// The 2D shadow mask, on the top slot. Unconditional, because the injected+// lighting reads it for every Lit shader rather than behind a feature.+@group(1) @binding(7) var t7 : texture_2d<f32>;+@group(1) @binding(15) var s7 : sampler;struct VSOut {@builtin(position) pos : vec4f,@@ -626,6 +630,80 @@ void main() {#pragma end)esshader";+inline constexpr const char* SHADOW2D = R"esshader(#pragma shader "Shadow2D"+#pragma version 300 es++// The 2D shadow mask: one channel per light that casts, drawn as the region each+// occluder's silhouette hides from it. The pass ADDS, which is what makes a+// source with width soft: its silhouette is drawn once per sample across the+// source, and a fragment collects a share for every sample hidden from it.+//+// `a_shadow` is the share this piece of geometry hides. `a_channel` is the+// light's own channel as a one-hot vector, which lets every light ride in one+// draw: the channels a vertex does not name receive zero.++#pragma vertex+layout(location = 0) in vec2 a_position;+layout(location = 1) in float a_shadow;+layout(location = 2) in vec4 a_channel;++out float v_shadow;+out vec4 v_channel;++void main() {+ gl_Position = u_projection * vec4(a_position, 0.0, 1.0);+ v_shadow = a_shadow;+ v_channel = a_channel;+}+#pragma end++#pragma fragment+precision highp float;++in float v_shadow;+in vec4 v_channel;++out vec4 fragColor;++void main() {+ fragColor = v_channel * v_shadow;+}+#pragma end++#pragma vertex wgsl+struct VSIn {+ @location(0) a_position : vec2f,+ @location(1) a_shadow : f32,+ @location(2) a_channel : vec4f,+};+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_shadow : f32,+ @location(1) v_channel : vec4f,+};++@vertex fn vs_main(v : VSIn) -> VSOut {+ var out : VSOut;+ out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);+ out.v_shadow = v.a_shadow;+ out.v_channel = v.a_channel;+ return out;+}+#pragma end++#pragma fragment wgsl+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_shadow : f32,+ @location(1) v_channel : vec4f,+};++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ return v.v_channel * v.v_shadow;+}+#pragma end+)esshader";+inline constexpr const char* SHAPE = R"esshader(#pragma shader "Shape"#pragma version 300 es@@ -808,6 +886,9 @@ struct VSOut {@group(1) @binding(8) var s0 : sampler;@group(1) @binding(3) var t3 : texture_2d<f32>;@group(1) @binding(11) var s3 : sampler;+// The 2D shadow mask, which the injected lighting reads for every Lit shader.+@group(1) @binding(7) var t7 : texture_2d<f32>;+@group(1) @binding(15) var s7 : sampler;// Declared again: each WGSL block is compiled on its own, so a struct defined in// the vertex one is an undeclared name here — and that reaches anyone as andiff --git a/src/esengine/renderer/store/LightConstants.hpp b/src/esengine/renderer/store/LightConstants.hppindex d0dfe569f..0f2ac827e 100644--- a/src/esengine/renderer/store/LightConstants.hpp+++ b/src/esengine/renderer/store/LightConstants.hpp@@ -45,12 +45,23 @@ inline constexpr u32 ENV_MAP_TEXTURE_UNIT = 3;inline constexpr u32 MAX_LIGHTS = 16;/**- * @brief Max 2D shadow occluders packed into the UBO (axis-aligned boxes in world space).- * The injected applyLighting2D loops up to the active count; 0 occluders = no- * shadowing (identity), so the feature is inert until the render path feeds boxes.- * Must match the `u_occluders[..]` array size in ShaderParser's injected GLSL.+ * @brief The 2D shadow mask, and the texture unit every Lit shader samples it from.+ * @details One screen-sized RGBA8 target, a channel per casting light: the shadow pass+ * draws what each occluder hides and a Lit fragment reads its own channel at+ * its own pixel. Unit 7 is the top of the batch stream's eight, taken from it+ * only while a mask exists — so a scene with no 2D shadows pays no merge slot.*/-inline constexpr u32 MAX_OCCLUDERS_2D = 8;+inline constexpr const char* SHADOW_2D_SAMPLER = "u_shadow2D";+inline constexpr u32 SHADOW_2D_TEXTURE_UNIT = 7;++/**+ * @brief Lights whose 2D shadows one frame can carry — the mask's four channels.+ * @details A cap on CASTERS, not on lights: past it a light still lights the scene and+ * stops shadowing, which is the failure a 2D scene can look at and understand.+ * Four because an RGBA8 target has four channels and a fifth would be a second+ * target, a second bind and a second sample for a case 2D art rarely reaches.+ */+inline constexpr u32 MAX_SHADOW_2D_LIGHTS = 4;/*** @brief Slices one directional shadow map is split into, each covering a stretch@@ -98,12 +109,10 @@ struct GpuLight {glm::vec4 color{0.0f};glm::vec4 spot{0.0f};glm::vec4 shadow{0.0f};- /// x = this light's first tile in the shadow atlas, y = how many it owns; w unused.- /// y = 0 is a light with no map, which is every light that did not ask for one.- /// z = how wide its source is where its own map cannot measure a distance to divide- /// by: the tangent of the angle it subtends, which is what a directional light has- /// instead of a half-extent. Zero for a light that stands somewhere.- glm::vec4 shadowMap{0.0f};+ /// x = first atlas tile, y = how many it owns (0 = no map); z = the tangent of the+ /// angle its source subtends, where the map has no distance to divide by (0 for a+ /// light that stands somewhere); w = its 2D mask channel, -1 for one casting none.+ glm::vec4 shadowMap{0.0f, 0.0f, 0.0f, -1.0f};};/**@@ -115,13 +124,10 @@ struct GpuLight {struct LightConstants {glm::vec4 ambient{0.0f};GpuLight lights[MAX_LIGHTS];- /// x = active occluder count; yzw unused. Appended after `lights` so existing std140- /// offsets (ambient, lights) are unchanged — old Lit shaders keep reading the same bytes.- glm::vec4 occluderCount{0.0f};- /// World-space AABBs: (minX, minY, maxX, maxY). A light is shadowed at a fragment when the- /// fragment→light segment (or, for directional, the fragment→far-along-light-dir segment)- /// crosses any box.- glm::vec4 occluders[MAX_OCCLUDERS_2D];+ /// Where the CAMERA NOW DRAWING lands in the 2D shadow mask: xy = its low corner,+ /// zw = its size, as fractions of the mask; zero width = no mask this frame. Per+ /// camera, because the mask is screen space and two cameras own two parts of it.+ glm::vec4 shadow2DRect{0.0f};/// World -> tile i's clip space. Identity where a tile is unclaimed; which tiles/// a light may read are the ones its own `shadowMap` names.glm::mat4 shadowMatrix[MAX_SHADOW_TILES];@@ -147,7 +153,7 @@ struct LightConstants {};static_assert(sizeof(GpuLight) == 80, "GpuLight must be std140-tight (five vec4s)");-static_assert(sizeof(LightConstants) == 16 + 80 * MAX_LIGHTS + 16 + 16 * MAX_OCCLUDERS_2D+static_assert(sizeof(LightConstants) == 16 + 80 * MAX_LIGHTS + 16+ 64 * MAX_SHADOW_TILES + 16 * MAX_SHADOW_TILES+ 16 + 16 * 9 + 16 + 16,"LightConstants must match the std140 GLSL block layout");diff --git a/src/esengine/renderer/store/LightStore.hpp b/src/esengine/renderer/store/LightStore.hppindex 95b6f3f97..17d5043a2 100644--- a/src/esengine/renderer/store/LightStore.hpp+++ b/src/esengine/renderer/store/LightStore.hpp@@ -111,13 +111,20 @@ public:bool hasEnvironment() const { return hasEnvironment_; }- /// Appends a world-space AABB occluder (minX, minY, maxX, maxY). Silently drops past- /// MAX_OCCLUDERS_2D. With no occluders added, the injected shader shadow test is a no-op.- void addOccluder(const glm::vec4& box) {- const u32 n = static_cast<u32>(data_.occluderCount.x);- if (n >= MAX_OCCLUDERS_2D) return;- data_.occluders[n] = box;- data_.occluderCount.x = static_cast<f32>(n + 1);+ /// Gives light @p slot a channel of the frame's 2D shadow mask, and says the mask+ /// exists. A slot nobody names keeps the -1 it was collected with, which is a light+ /// that lights without shadowing.+ void setLightShadow2DChannel(u32 slot, u32 channel) {+ if (slot >= count_ || channel >= MAX_SHADOW_2D_LIGHTS) return;+ data_.lights[slot].shadowMap.w = static_cast<f32>(channel);+ dirty_ = true;+ }++ /// Where the camera about to draw sits inside the mask (xy = low corner, zw = size,+ /// as fractions of it). A zero size says the frame has no mask; set per camera,+ /// because two cameras read two different parts of one screen-space target.+ void setShadow2DRect(const glm::vec4& rect) {+ data_.shadow2DRect = rect;dirty_ = true;}diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 2406d28a3..42f544146 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -832,8 +832,7 @@ const char* kLitHeaderWGSL = R"(struct Light { posDir : vec4f, color : vec4f, spstruct LightConstants {u_ambient : vec4f,u_lights : array<Light, 16>,- u_occluderCount : vec4f,- u_occluders : array<vec4f, 8>,+ u_shadow2DRect : vec4f,u_shadowMatrix : array<mat4x4f, 16>,u_shadowTile : array<vec4f, 16>,u_shadowParams : vec4f,@@ -1005,52 +1004,25 @@ fn perturbNormal(N : vec3f, worldPos : vec3f, uv : vec2f, tangentNormal : vec3f)let invmax = inverseSqrt(m);return normalize(mat3x3f(T * invmax, B * invmax, N) * tangentNormal);}-fn segHitsBox(p0 : vec2f, p1 : vec2f, box : vec4f) -> f32 {- if (p0.x >= box.x && p0.y >= box.y && p0.x <= box.z && p0.y <= box.w) { return 0.0; }- let d = p1 - p0;- var tmin = 0.0;- var tmax = 1.0;- for (var a = 0; a < 2; a++) {- let da = select(d.y, d.x, a == 0);- let p0a = select(p0.y, p0.x, a == 0);- let lo = select(box.y, box.x, a == 0) - p0a;- let hi = select(box.w, box.z, a == 0) - p0a;- if (abs(da) < 1e-5) {- if (lo > 0.0 || hi < 0.0) { return 0.0; }- } else {- let t1 = lo / da;- let t2 = hi / da;- tmin = max(tmin, min(t1, t2));- tmax = min(tmax, max(t1, t2));- if (tmin > tmax) { return 0.0; }- }- }- return 1.0;-}-fn shadowFactor2D(worldPos : vec2f, aim : vec2f, softness : f32) -> f32 {- let n = i32(lc.u_occluderCount.x);- if (n <= 0) { return 1.0; }- if (softness < 1e-4) {- for (var i = 0; i < 8; i++) {- if (i >= n) { break; }- if (segHitsBox(worldPos, aim, lc.u_occluders[i]) > 0.5) { return 0.0; }- }- return 1.0;- }- let dir = aim - worldPos;- let dl = length(dir);- var perp = vec2f(1.0, 0.0);- if (dl > 1e-4) { perp = vec2f(-dir.y, dir.x) / dl; }- var blocked = 0.0;- for (var s = 0; s < 5; s++) {- let t = f32(s) / 4.0 * 2.0 - 1.0;- let tp = aim + perp * (t * softness);- for (var i = 0; i < 8; i++) {- if (i >= n) { break; }- if (segHitsBox(worldPos, tp, lc.u_occluders[i]) > 0.5) { blocked += 1.0; break; }- }- }- return 1.0 - blocked / 5.0;+// What the frame's 2D shadow mask says about this fragment, for the light holding+// `channel` (negative = a light that casts none). Where a world point lands in the+// mask is where this same camera puts it, measured on the plane the occluders are in.+fn shadowFactor2D(channel : f32, worldPos : vec2f) -> f32 {+ if (channel < 0.0 || lc.u_shadow2DRect.z <= 0.0) { return 1.0; }+ let clip = frame.projection * vec4f(worldPos, 0.0, 1.0);+ if (clip.w <= 0.0) { return 1.0; }+ // The ONE place the twins must not agree: v = 0 samples the bottom of a texture in+ // GL and the top here, and the rect arrives in GL's terms — so the camera's corner+ // and the point inside it are both turned over.+ let ndc = clip.xy / clip.w * 0.5 + 0.5;+ let base = vec2f(lc.u_shadow2DRect.x, 1.0 - lc.u_shadow2DRect.y - lc.u_shadow2DRect.w);+ let uv = base + vec2f(ndc.x, 1.0 - ndc.y) * lc.u_shadow2DRect.zw;+ let m = textureSampleLevel(t7, s7, uv, 0.0);+ var hidden = m.a;+ if (channel < 0.5) { hidden = m.r; }+ else if (channel < 1.5) { hidden = m.g; }+ else if (channel < 2.5) { hidden = m.b; }+ return 1.0 - min(hidden, 1.0);})"// Split, not restructured: MSVC caps ONE string literal at 16380 bytes@@ -1197,7 +1169,7 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, metaatten *= spotCone(sp, sh, toL, dist);}if (castShadow && col.a > 0.0 && atten > 0.0) {- atten *= shadowFactor2D(worldPos.xy, aim, sh.x);+ atten *= shadowFactor2D(lc.u_lights[i].shadowMap.w, worldPos.xy);}let sm = lc.u_lights[i].shadowMap;if (sm.y > 0.0 && atten > 0.0) {@@ -1534,8 +1506,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p"layout(std140) uniform LightConstants {\n"" highp vec4 u_ambient;\n"" Light u_lights[16];\n"- " highp vec4 u_occluderCount;\n" // x = active occluder count- " highp vec4 u_occluders[8];\n" // world AABBs (minX,minY,maxX,maxY)+ " highp vec4 u_shadow2DRect;\n" // xy = this camera's corner of the mask, zw its size" highp mat4 u_shadowMatrix[16];\n" // world -> each atlas tile's clip" highp vec4 u_shadowTile[16];\n" // xy = origin, z = side, w = bias" highp vec4 u_shadowParams;\n" // x = has map, y = one atlas texel@@ -1552,6 +1523,10 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p"#ifdef ES_ENV_MAP\n""uniform highp sampler2D u_envMap;\n""#endif\n"+ // The 2D shadow mask, on the top slot of the batch stream's eight. Declared+ // for every Lit shader: a sprite receives 2D shadows, and a mesh standing in+ // the same scene receives the same ones.+ "uniform highp sampler2D u_shadow2D;\n"// 24 bits of depth across RGB — an 8-bit target is what both backends have// in common, and a metre of world depth does not survive 8 of them. The// pair lives together: two files would be two chances to disagree.@@ -1724,65 +1699,27 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp float invmax = inversesqrt(m);\n"" return normalize(mat3(T * invmax, B * invmax, N) * tangentNormal);\n""}\n"- // 2D hard shadows: a slab test of the fragment->light segment against a world AABB.- // Returns 1.0 when the segment crosses the box's interior, else 0.0. The [0,1] param- // clamp means boxes behind the fragment or beyond the light don't occlude. A box- // occludes the world OUTSIDE it, never a fragment inside itself — so a lit sprite- // that is also a ShadowCaster2D casts shadows without blacking out its own pixels- // (and geometry overlapping an occluder isn't spuriously darkened by it).- "highp float segHitsBox(in highp vec2 p0, in highp vec2 p1, in highp vec4 box) {\n"- " if (p0.x >= box.x && p0.y >= box.y && p0.x <= box.z && p0.y <= box.w) return 0.0;\n"- " highp vec2 d = p1 - p0;\n"- " highp float tmin = 0.0;\n"- " highp float tmax = 1.0;\n"- " for (int a = 0; a < 2; ++a) {\n"- " highp float da = (a == 0) ? d.x : d.y;\n"- " highp float p0a = (a == 0) ? p0.x : p0.y;\n"- " highp float lo = ((a == 0) ? box.x : box.y) - p0a;\n"- " highp float hi = ((a == 0) ? box.z : box.w) - p0a;\n"- " if (abs(da) < 1e-5) {\n"- " if (lo > 0.0 || hi < 0.0) return 0.0;\n"- " } else {\n"- " highp float t1 = lo / da;\n"- " highp float t2 = hi / da;\n"- " tmin = max(tmin, min(t1, t2));\n"- " tmax = min(tmax, max(t1, t2));\n"- " if (tmin > tmax) return 0.0;\n"- " }\n"- " }\n"- " return 1.0;\n"- "}\n"- // Soft 2D shadows: averages occlusion of K rays cast from the fragment toward points- // spread across the light's apparent size (softness = source half-extent, world units).- // softness 0 collapses to the single hard-edged centre ray — bit-identical to the prior- // behaviour; larger softness widens the penumbra the way an area light's shadow does.- // `target` is the point the rays aim at — the light position for point/spot, or a far- // point along the light direction for directional — so one primitive shadows every type.- // No occluders (count 0) -> always 1.0, inert until the render path feeds boxes.- "highp float shadowFactor2D(in highp vec2 worldPos, in highp vec2 target, in highp float softness) {\n"- " int n = int(u_occluderCount.x);\n"- " if (n <= 0) return 1.0;\n"- " if (softness < 1e-4) {\n"- " for (int i = 0; i < 8; ++i) {\n"- " if (i >= n) break;\n"- " if (segHitsBox(worldPos, target, u_occluders[i]) > 0.5) return 0.0;\n"- " }\n"- " return 1.0;\n"- " }\n"- " highp vec2 dir = target - worldPos;\n"- " highp float dl = length(dir);\n"- " highp vec2 perp = (dl > 1e-4) ? vec2(-dir.y, dir.x) / dl : vec2(1.0, 0.0);\n"- " const int K = 5;\n"- " highp float blocked = 0.0;\n"- " for (int s = 0; s < K; ++s) {\n"- " highp float t = float(s) / float(K - 1) * 2.0 - 1.0;\n"- " highp vec2 tp = target + perp * (t * softness);\n"- " for (int i = 0; i < 8; ++i) {\n"- " if (i >= n) break;\n"- " if (segHitsBox(worldPos, tp, u_occluders[i]) > 0.5) { blocked += 1.0; break; }\n"- " }\n"- " }\n"- " return 1.0 - blocked / float(K);\n"+ // What the frame's 2D shadow mask says about this fragment, for the light+ // holding `channel` (negative = a light that casts none). The rect is this+ // camera's own part of the mask, which is what serves a second camera.+ "highp float shadowFactor2D(in highp float channel, in highp vec2 worldPos) {\n"+ " if (channel < 0.0 || u_shadow2DRect.z <= 0.0) return 1.0;\n"+ // Measured on the Z = 0 plane, which is the plane a 2D occluder hides+ // things in — and drawn through this same camera, so the landing agrees.+ " highp vec4 clip = u_projection * vec4(worldPos, 0.0, 1.0);\n"+ " if (clip.w <= 0.0) return 1.0;\n"+ " highp vec2 uv = u_shadow2DRect.xy\n"+ " + (clip.xy / clip.w * 0.5 + 0.5) * u_shadow2DRect.zw;\n"+ // An explicit level, not an implicit one: this is read inside the light loop,+ // where a twin's WGSL forbids a sampled derivative — and the mask has no+ // mip chain for one to choose from anyway.+ " highp vec4 m = textureLod(u_shadow2D, uv, 0.0);\n"+ // The mask holds how much of this light is hidden, summed over the samples+ // that make a source soft — clamped, because two walls over one pixel add+ // past one and a light cannot be hidden more than entirely.+ " highp float hidden = (channel < 0.5) ? m.r\n"+ " : (channel < 1.5) ? m.g : (channel < 2.5) ? m.b : m.a;\n"+ " return 1.0 - min(hidden, 1.0);\n""}\n"// The microfacet terms: GGX distribution, Smith geometry (the direct-light k,// off perceptual roughness), Schlick fresnel. Guarded denominators, because a@@ -1956,10 +1893,10 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" L = towardLight(toL, N);\n"" atten *= spotCone(sp, sh, toL, dist);\n"" }\n"- // Only pay for the shadow test when the light actually reaches this fragment (skips the- // zeroed/inactive slots and unlit fragments — cheaper than the old unconditional call).+ // Only pay for the mask read when the light actually reaches this fragment (skips+ // the zeroed/inactive slots and unlit fragments)." if (castShadow && col.a > 0.0 && atten > 0.0) {\n"- " atten *= shadowFactor2D(worldPos.xy, target, sh.x);\n"+ " atten *= shadowFactor2D(u_lights[i].shadowMap.w, worldPos.xy);\n"" }\n"// The tiles this light rendered into, which are its own: a fragment// tested against every map in the atlas would be darkened by geometrydiff --git a/tests/renderer/test_shader_device.cpp b/tests/renderer/test_shader_device.cppindex af0dcec80..415db602b 100644--- a/tests/renderer/test_shader_device.cpp+++ b/tests/renderer/test_shader_device.cpp@@ -32,14 +32,14 @@ int main() {// compile() pins the engine-injected samplers to their units, so the counts// the rest of this block asserts start from what that seeding left behind.- // Two of them: the shadow map and the environment's reflection.- CHECK(d.setUniform1iCalls == 2- && d.lastUniform1iVal == static_cast<i32>(ENV_MAP_TEXTURE_UNIT),+ // Three of them: the shadow map, the environment's reflection, the 2D mask.+ CHECK(d.setUniform1iCalls == 3+ && d.lastUniform1iVal == static_cast<i32>(SHADOW_2D_TEXTURE_UNIT),"compile pins the injected samplers to their texture units");CHECK(d.useProgramCalls == 2, "seeding them binds and unbinds the program once");shader->setUniform("u_tex", 3);- CHECK(d.setUniform1iCalls == 3, "setUniform(name,int) routes through device.setUniform1i");+ CHECK(d.setUniform1iCalls == 4, "setUniform(name,int) routes through device.setUniform1i");CHECK(d.lastUniform1iVal == 3, "uniform value forwarded");shader->setUniform("u_color", glm::vec4(1, 0, 0, 1));diff --git a/tools/check-wgsl-twin.mjs b/tools/check-wgsl-twin.mjsindex 305958939..5b475b638 100644--- a/tools/check-wgsl-twin.mjs+++ b/tools/check-wgsl-twin.mjs@@ -63,6 +63,27 @@ function helperBindings(source) {const HELPERS = helperBindings(injected);+/**+ * The bindings a Lit twin must declare whether or not anything in it reads them: a+ * stage is one WGSL module, so a name any injected helper mentions has to resolve even+ * where nothing calls it. What sits behind an `#ifdef` is the exception — only a stage+ * asking for the feature has that text, or binds it.+ */+function unconditionalBindings(source) {+ const out = new Set();+ let depth = 0;+ for (const line of source.split('\n')) {+ if (/^\s*#\s*if/.test(line)) { depth++; continue; }+ if (/^\s*#\s*endif/.test(line)) { depth = Math.max(0, depth - 1); continue; }+ if (/^\s*#\s*(else|elif)/.test(line)) continue;+ if (depth > 0) continue;+ for (const m of line.matchAll(/\b([ts]\d+)\b/g)) out.add(m[1]);+ }+ return out;+}++const ALWAYS_INJECTED = unconditionalBindings(injected);+/** Everything calling `name` can end up sampling, following calls transitively. */function bindingsReachedBy(name, seen = new Set()) {if (seen.has(name)) return new Set();@@ -133,11 +154,16 @@ for (const { label: file, text } of sources) {+ ' — its own vertex stage means nothing injects one');}- // Textures it samples itself, plus the ones the injected helpers it calls do.+ // Textures it samples itself, the ones the injected helpers it calls do, and the+ // ones every injected helper mentions unconditionally — those are in the module+ // whether or not this stage ever calls them.const needed = new Set([...frag.matchAll(/\b([ts]\d+)\b/g)].map((m) => m[1]));for (const [, call] of frag.matchAll(/\b(\w+)\s*\(/g)) {for (const n of bindingsReachedBy(call)) needed.add(n);}+ if (/#pragma\s+domain\s+Lit\b/.test(text)) {+ for (const n of ALWAYS_INJECTED) needed.add(n);+ }for (const name of [...needed].sort()) {if (declaredBindings.has(name)) continue;problems.push(`${file}: the fragment twin reaches \`${name}\` and does not declare it`diff --git a/tools/gen-shader-twins.mjs b/tools/gen-shader-twins.mjsindex 3a4a8fd6d..49a5b89c5 100644--- a/tools/gen-shader-twins.mjs+++ b/tools/gen-shader-twins.mjs@@ -58,11 +58,13 @@ const BLOCK_BINDINGS = {TimeConstants: 3,};-// The samplers the Lit-2D header declares, on the units it pins them to — the-// same two mesh.esshader's hand-written twin names.+// The samplers the Lit-2D header declares, on the units it pins them to. Mirrors+// LightConstants.hpp, which is where a unit is decided: a twin generated against a+// stale copy binds the wrong texture and says nothing.const ENGINE_SAMPLERS = [{ name: 'u_shadowMap', unit: 2 },{ name: 'u_envMap', unit: 3 },+ { name: 'u_shadow2D', unit: 7 },];// Group-1 unit map — mirrors WebGPUMappings textureBindingForUnit/samplerBindingForUnit.diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex fdd0efd3c..f29be3d57 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -386,11 +386,16 @@ export const SCENES = [// light reaches, dark where the box is in the way.{ id: "shadow2d-point", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },{ id: "shadow2d-hard", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-hard.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-hard.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },- { id: "shadow2d-soft", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-soft.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-soft.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },- // This scene names its light's aim as `direction`, so the criterion covers the- // light-aim migration in a real frame too. Lit at 180, not 255: a directional- // light carries its Lambert term.+ // Two probes inside the penumbra, where a hard shadow reads 0 and an unshadowed+ // surface reads 166: a soft edge is the only thing that lands between them.+ { id: "shadow2d-soft", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-soft.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-soft.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40},{\"x\":0.75,\"y\":0.30,\"rgb\":[0,44,0],\"tol\":22},{\"x\":0.75,\"y\":0.70,\"rgb\":[0,52,0],\"tol\":22}]" } },+ // The sun is aimed by its Transform, a quarter turn short of face-on: its forward+ // has a component in the plane to cast along and one out of it to light with. Lit+ // at 180 rather than 255 because a directional light carries its Lambert term.{ id: "shadow2d-directional", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-dir.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-dir.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,180,0],\"tol\":40},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },+ // Twelve occluders, the twelfth being the one the probes are about — a cap on how+ // many a frame carries drops whichever it collected last.+ { id: "shadow2d-many-occluders", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-many.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-many.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },// The same red-over-blue image as a PNG and as a KTX2, side by side: a// transcode that arrives upside down swaps the KTX2 pair and nothing else,// which a criterion probing only one half — or only the colours — cannot see.@@ -555,6 +560,9 @@ export const SCENES = [// material sampler — so a recovered material sampling every texture from unit// 0 looked exactly like one with no normal map, and nothing could tell.{ id: "device-loss-material", tier: "pr", env: { ESTELLA_VERIFY_DEVICE_LOSS: "1", ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-normal.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-normal.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.333,\"y\":0.5,\"rgb\":[0,252,0],\"tol\":45},{\"x\":0.667,\"y\":0.5,\"rgb\":[0,36,0],\"tol\":50}]" } },+ // The mask again after the device it was drawn on went away: the pass owns a+ // buffer, a layout and a shader, and one kept across a loss names nothing.+ { id: "device-loss-shadow2d", tier: "pr", env: { ESTELLA_VERIFY_DEVICE_LOSS: "1", ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-many.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-many.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":40}]" } },{ id: "device-loss", tier: "pr", env: { ESTELLA_VERIFY_DEVICE_LOSS: "1", ESTELLA_VERIFY_SCENE: "/scenes/tilemap-flip.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/tilemap-flip.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.40,\"y\":0.36,\"rgb\":[255,0,0]},{\"x\":0.60,\"y\":0.36,\"rgb\":[0,255,0]},{\"x\":0.40,\"y\":0.58,\"rgb\":[0,0,255]},{\"x\":0.60,\"y\":0.58,\"rgb\":[255,255,0]}]" } },// The textures above prove content comes back; a mesh proves IDENTITY does —// the handles the world points at are the ones re-realized, not new ones the