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 light can be shaped, and its shadow can be partial
esengineb0d1e432657c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e14e88551..70930ceeb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,19 @@ published separately; it ships inside the editor.## [Unreleased]+### Added++- **A 2D light can be shaped, and its shadows can be less than total.** A Point or Spot+ light faded from its own centre to nothing at `radius`, in a straight line, and there+ was no other line available. `innerRadius` holds it at full strength out to a radius of+ its own and fades over the band that is left; `falloff` is the power that ramp is+ raised to — above 1 the light pools near its source, below it the light reaches further+ and then ends. `shadowStrength` says how much of the light a shadow takes away, because+ real shade is lit by everything that bounced and 1 is the only value that cannot be.++ All three default to what the engine already did, so every scene renders as it did;+ the criterion that says so runs beside the three that change one field each.+### Fixed- **A 2D shadow caster can carry its own outline.** Every occluder was a box, so adiff --git a/docs/astro/src/content/docs/graphics/lighting.mdx b/docs/astro/src/content/docs/graphics/lighting.mdxindex 9090938bf..aeca7a0c8 100644--- a/docs/astro/src/content/docs/graphics/lighting.mdx+++ b/docs/astro/src/content/docs/graphics/lighting.mdx@@ -46,6 +46,9 @@ const addSun = defineSystem([Commands()], (cmds) => {| `color` | `{1,1,1,1}` | Light color, RGBA 0..1. || `intensity` | `1` | Brightness multiplier. || `radius` | `200` | Falloff reach in world units (Point / Spot). |+| `innerRadius` | `0` | Radius held at full strength before the falloff starts (Point / Spot). |+| `falloff` | `1` | Falloff shape: `1` is linear, higher pools near the light, lower reaches further. |+| `shadowStrength` | `1` | How much of this light its shadows remove; `0.6` leaves a shadow that is dark rather than black. || `innerAngle` | `30` | Spot cone inner angle, degrees (full brightness inside). || `outerAngle` | `45` | Spot cone outer angle, degrees (falls to zero by here). || `shadowSoftness` | `0` | Shadow edge softness (light-source size); `0` = hard edge. |@@ -75,6 +78,29 @@ const addSun = defineSystem([Commands()], (cmds) => {.insert(Light, { type: LightType.Ambient, intensity: 0.25 });```+## Shaping the falloff++A Point or Spot light fades from its own centre to nothing at `radius`, in a straight+line. Two fields bend that line, and neither moves where the light ends:++- **`innerRadius`** holds the light at full strength out to a radius of its own, and the+ fade happens in the band that is left. A lamp with a bright core is `innerRadius` most+ of the way to `radius`; a light with none is the straight line it always was.+- **`falloff`** is the power the remaining ramp is raised to. `1` is linear. Above it the+ light pools near its source and the outer reach dims quickly — closer to how light+ actually behaves. Below it the light stays bright most of the way out and then ends,+ which is the look a stylised 2D scene often wants.++```ts+// A lantern: a bright core, then a quick fade.+entity.insert(Light, {+ type: LightType.Point, radius: 400, innerRadius: 120, falloff: 2.5, intensity: 1.4,+});+```++Both default to the straight line, so a scene written before them renders exactly as it+did.+## Making a renderer receive lightBy default a `Sprite` draws with an **unlit** material and ignores every light. The@@ -273,6 +299,9 @@ Shadow **quality** is controlled on the light, not the caster:give a soft penumbra (a bigger, closer light casts softer shadows).- **`shadowDistance`** — for a **Directional** light, how far its shadows extend; `0`leaves a directional light shadow-free.+- **`shadowStrength`** — how much of the light a shadow takes away, `0..1`. A 2D scene+ usually wants less than all of it: real shade is lit by everything that bounced, and+ `1` is the only value that cannot be.### How many, and what it costsdiff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.jsonindex e83f0df40..0013e162f 100644--- a/docs/astro/src/data/components.generated.json+++ b/docs/astro/src/data/components.generated.json@@ -1934,6 +1934,27 @@"doc": "Falloff reach in world units (Point / Spot).","range": "≥ 0"},+ {+ "key": "innerRadius",+ "type": "number",+ "default": "0",+ "doc": "Radius held at full strength before the falloff starts.",+ "range": "≥ 0"+ },+ {+ "key": "falloff",+ "type": "number",+ "default": "1",+ "doc": "Falloff shape: 1 = linear, higher pools near the light, lower reaches further.",+ "range": "0–8"+ },+ {+ "key": "shadowStrength",+ "type": "number",+ "default": "1",+ "doc": "How much of this light its shadows remove (1 = all of it).",+ "range": "0–1"+ },{"key": "innerAngle","type": "number",@@ -2016,6 +2037,9 @@"color.a","intensity","radius",+ "innerRadius",+ "falloff",+ "shadowStrength","innerAngle","outerAngle","shadowSoftness",diff --git a/fixtures/scenes/light-falloff.esscene b/fixtures/scenes/light-falloff.esscenenew file mode 100644index 000000000..3bc6b0804--- /dev/null+++ b/fixtures/scenes/light-falloff.esscene@@ -0,0 +1,57 @@+{+ "version": 4,+ "name": "Main",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "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 } }+ ],+ "visible": true+ },+ {+ "id": 1,+ "name": "Lit",+ "parent": null,+ "children": [],+ "components": [+ { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },+ {+ "type": "Sprite",+ "data": {+ "size": { "x": 500, "y": 500 },+ "color": { "r": 1, "g": 1, "b": 1, "a": 1 },+ "material": "/scenes/mat-lit/lit.esmaterial"+ }+ }+ ],+ "visible": true+ },+ {+ "id": 2,+ "name": "GreenPointLight",+ "parent": null,+ "children": [],+ "components": [+ { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },+ {+ "type": "Light",+ "data": {+ "type": 0,+ "color": { "r": 0, "g": 1, "b": 0, "a": 1 },+ "intensity": 1,+ "radius": 200,+ "innerRadius": 0,+ "falloff": 1,+ "shadowSoftness": 0+ }+ }+ ],+ "visible": true+ }+ ]+}diff --git a/fixtures/scenes/light-falloff.textures.json b/fixtures/scenes/light-falloff.textures.jsonnew file mode 100644index 000000000..0967ef424--- /dev/null+++ b/fixtures/scenes/light-falloff.textures.json@@ -0,0 +1 @@+{}diff --git a/fixtures/scenes/mat-builtin-lit/lit.esshader b/fixtures/scenes/mat-builtin-lit/lit.esshaderindex 333eb529e..18222740c 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: cb37ad9d1a961ffb+// assembled-hash: 76a4f0aa490853a2struct 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: cb37ad9d1a961ffb+// assembled-hash: 76a4f0aa490853a2struct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -121,6 +121,7 @@ struct Light {spot: vec4<f32>,shadow: vec4<f32>,shadowMap: vec4<f32>,+ falloff: vec4<f32>,}struct LightConstants {@@ -316,16 +317,16 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPosvar local_1: f32;var local_2: f32;var local_3: f32;- var phi_194_: bool;+ var phi_200_: bool;let _e96 = (*channel);let _e97 = (_e96 < 0f);- phi_194_ = _e97;+ phi_200_ = _e97;if !(_e97) {let _e101 = unnamed_1.u_shadow2DRect[2u];- phi_194_ = (_e101 <= 0f);+ phi_200_ = (_e101 <= 0f);}- let _e104 = phi_194_;+ let _e104 = phi_200_;if _e104 {return 1f;}@@ -438,6 +439,19 @@ fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_return _e94;}+fn distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b(dist_1: ptr<function, f32>, reach: ptr<function, f32>, fo: ptr<function, vec4<f32>>) -> f32 {+ var ramp: f32;++ let _e88 = (*reach);+ let _e89 = (*dist_1);+ let _e91 = (*reach);+ let _e93 = (*fo)[0u];+ ramp = clamp(((_e88 - _e89) / max((_e91 - _e93), 0.0001f)), 0f, 1f);+ let _e98 = ramp;+ let _e100 = (*fo)[1u];+ return pow(_e98, max(_e100, 0.001f));+}+fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {let _e85 = (*toLight_2);return length(_e85.xy);@@ -525,303 +539,325 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;+ var fo_1: vec4<f32>;var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;var param_6: vec4<f32>;var param_7: vec4<f32>;var param_8: vec3<f32>;- var dist_1: f32;+ var dist_2: f32;var param_9: vec3<f32>;var atten: f32;+ var param_10: f32;+ var param_11: f32;+ var param_12: vec4<f32>;var L_1: vec3<f32>;- var param_10: vec3<f32>;- var param_11: vec3<f32>;+ var param_13: vec3<f32>;+ var param_14: vec3<f32>;var toLight_3: vec2<f32>;var local_7: 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_15: vec4<f32>;+ var param_16: vec4<f32>;var param_17: vec3<f32>;- var param_18: vec4<f32>;- var param_19: vec4<f32>;- var param_20: vec3<f32>;- var param_21: f32;- var param_22: f32;- var param_23: vec2<f32>;- var sm: vec4<f32>;- var param_24: vec3<f32>;- var param_25: vec3<f32>;+ var dist_3: f32;+ var param_18: vec3<f32>;+ var param_19: f32;+ var param_20: f32;+ var param_21: vec4<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: vec2<f32>;- var param_28: i32;- var param_29: i32;+ var param_27: f32;+ var param_28: f32;+ var param_29: vec2<f32>;+ var sm: vec4<f32>;+ var param_30: vec3<f32>;+ var param_31: vec3<f32>;+ var param_32: vec3<f32>;+ var param_33: vec2<f32>;+ var param_34: i32;+ var param_35: 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_36: f32;var param_37: f32;var param_38: f32;- var param_39: vec3<f32>;+ var param_39: f32;var param_40: f32;- var phi_809_: bool;- var phi_863_: 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);+ var param_41: f32;+ var param_42: vec3<f32>;+ var ab: vec2<f32>;+ var param_43: f32;+ var param_44: f32;+ var param_45: vec3<f32>;+ var param_46: f32;+ var phi_839_: bool;+ var phi_895_: bool;++ let _e161 = (*albedo);+ let _e162 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e161, vec3(_e162));+ let _e165 = (*roughness_3);+ let _e166 = (*roughness_3);+ a_4 = max((_e165 * _e166), 0.001f);+ let _e169 = (*N_3);+ let _e170 = (*V);+ NdotV_2 = max(dot(_e169, _e170), 0.0001f);+ let _e173 = (*N_3);+ param_5 = _e173;+ let _e174 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e175 = (*ao);+ lit = (_e174 * _e175);gloss = vec3<f32>(0f, 0f, 0f);i = 0i;loop {- 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;+ let _e177 = i;+ if (_e177 < 16i) {+ let _e179 = i;+ let _e183 = unnamed_1.u_lights[_e179].posDir;+ pd_1 = _e183;+ let _e184 = i;+ let _e188 = unnamed_1.u_lights[_e184].color;+ col = _e188;+ let _e189 = i;+ let _e193 = unnamed_1.u_lights[_e189].shadow;+ sh_3 = _e193;+ let _e194 = i;+ let _e198 = unnamed_1.u_lights[_e194].falloff;+ fo_1 = _e198;+ let _e199 = pd_1;+ target_ = _e199.xy;castShadow = true;- 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;+ let _e202 = pd_1[2u];+ if (_e202 < 0.5f) {+ let _e204 = pd_1;+ param_6 = _e204;+ let _e205 = sh_3;+ param_7 = _e205;+ let _e206 = (*worldPos_3);+ param_8 = _e206;+ let _e207 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e207;+ let _e208 = toL;+ param_9 = _e208;+ let _e209 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_2 = _e209;+ let _e211 = pd_1[3u];+ let _e213 = dist_2;+ param_10 = _e213;+ param_11 = max(_e211, 0.0001f);+ let _e214 = fo_1;+ param_12 = _e214;+ let _e215 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_10), (¶m_11), (¶m_12));+ atten = _e215;+ let _e216 = toL;+ param_13 = _e216;+ let _e217 = (*N_3);+ param_14 = _e217;+ let _e218 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_13), (¶m_14));+ L_1 = _e218;} else {- let _e209 = pd_1[2u];- if (_e209 < 1.5f) {+ let _e220 = pd_1[2u];+ if (_e220 < 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_7 = normalize(-(_e226.xy));+ let _e223 = _e222.xy;+ let _e225 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e223.x, _e223.y, _e225)));+ let _e231 = pd_1;+ let _e233 = pd_1;+ if (dot(_e231.xy, _e233.xy) > 0.00000001f) {+ let _e237 = pd_1;+ local_7 = normalize(-(_e237.xy));} else {local_7 = vec2<f32>(0f, 0f);}- let _e230 = local_7;- toLight_3 = _e230;- let _e232 = sh_3[1u];- let _e233 = (_e232 > 0f);- phi_809_ = _e233;- if _e233 {- let _e234 = toLight_3;- let _e235 = toLight_3;- phi_809_ = (dot(_e234, _e235) > 0.5f);+ let _e241 = local_7;+ toLight_3 = _e241;+ let _e243 = sh_3[1u];+ let _e244 = (_e243 > 0f);+ phi_839_ = _e244;+ if _e244 {+ let _e245 = toLight_3;+ let _e246 = toLight_3;+ phi_839_ = (dot(_e245, _e246) > 0.5f);}- let _e239 = phi_809_;- castShadow = _e239;- let _e240 = (*worldPos_3);- let _e242 = toLight_3;- let _e244 = sh_3[1u];- target_ = (_e240.xy + (_e242 * _e244));+ let _e250 = phi_839_;+ castShadow = _e250;+ let _e251 = (*worldPos_3);+ let _e253 = toLight_3;+ let _e255 = sh_3[1u];+ target_ = (_e251.xy + (_e253 * _e255));} else {- 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 _e258 = i;+ let _e262 = unnamed_1.u_lights[_e258].spot;+ sp_1 = _e262;+ let _e263 = pd_1;+ param_15 = _e263;+ let _e264 = sh_3;+ param_16 = _e264;+ let _e265 = (*worldPos_3);+ param_17 = _e265;+ let _e266 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_15), (¶m_16), (¶m_17));+ toL_1 = _e266;+ let _e267 = toL_1;+ param_18 = _e267;+ let _e268 = lightDistance_u0028_vf3_u003b((¶m_18));+ dist_3 = _e268;+ let _e270 = pd_1[3u];+ let _e272 = dist_3;+ param_19 = _e272;+ param_20 = max(_e270, 0.0001f);+ let _e273 = fo_1;+ param_21 = _e273;+ let _e274 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_19), (¶m_20), (¶m_21));+ atten = _e274;+ let _e275 = toL_1;+ param_22 = _e275;+ let _e276 = (*N_3);+ param_23 = _e276;+ let _e277 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));+ L_1 = _e277;+ let _e278 = sp_1;+ param_24 = _e278;+ let _e279 = sh_3;+ param_25 = _e279;+ let _e280 = toL_1;+ param_26 = _e280;+ let _e281 = dist_3;+ param_27 = _e281;+ let _e282 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));+ let _e283 = atten;+ atten = (_e283 * _e282);}}- let _e275 = castShadow;- phi_863_ = _e275;- if _e275 {- let _e277 = col[3u];- phi_863_ = (_e277 > 0f);+ let _e285 = castShadow;+ phi_895_ = _e285;+ if _e285 {+ let _e287 = col[3u];+ phi_895_ = (_e287 > 0f);}- let _e280 = phi_863_;- 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 _e290 = phi_895_;+ let _e291 = atten;+ if (_e290 && (_e291 > 0f)) {+ let _e294 = i;+ let _e299 = unnamed_1.u_lights[_e294].shadowMap[3u];+ param_28 = _e299;+ let _e300 = (*worldPos_3);+ param_29 = _e300.xy;+ let _e302 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_28), (¶m_29));+ let _e304 = fo_1[2u];+ let _e306 = atten;+ atten = (_e306 * mix(1f, _e302, _e304));}- 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 _e308 = i;+ let _e312 = unnamed_1.u_lights[_e308].shadowMap;+ sm = _e312;+ let _e314 = sm[1u];+ let _e316 = atten;+ if ((_e314 > 0f) && (_e316 > 0f)) {+ let _e320 = sh_3[0u];+ let _e322 = sm[2u];+ let _e325 = sm[0u];+ let _e328 = sm[1u];+ let _e330 = (*worldPos_3);+ param_30 = _e330;+ let _e331 = (*N_3);+ param_31 = _e331;+ let _e332 = L_1;+ param_32 = _e332;+ param_33 = vec2<f32>(_e320, _e322);+ param_34 = i32(_e325);+ param_35 = i32(_e328);+ let _e333 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_30), (¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35));+ let _e335 = fo_1[2u];+ let _e337 = atten;+ atten = (_e337 * mix(1f, _e333, _e335));}- 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)));+ let _e339 = (*N_3);+ let _e340 = L_1;+ ndotl = max(dot(_e339, _e340), 0f);+ let _e343 = col;+ let _e346 = col[3u];+ let _e347 = ndotl;+ let _e349 = atten;+ radiance = (_e343.xyz * ((_e346 * _e347) * _e349));+ let _e352 = radiance;+ let _e353 = lit;+ lit = (_e353 + _e352);+ let _e355 = (*specular);+ if (_e355 > 0f) {+ let _e357 = L_1;+ let _e358 = (*V);+ H = normalize((_e357 + _e358));+ let _e361 = (*N_3);+ let _e362 = H;+ param_36 = max(dot(_e361, _e362), 0f);+ let _e365 = a_4;+ param_37 = _e365;+ let _e366 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_36), (¶m_37));+ let _e367 = NdotV_2;+ param_38 = _e367;+ let _e368 = ndotl;+ param_39 = _e368;+ let _e369 = (*roughness_3);+ param_40 = _e369;+ let _e370 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_38), (¶m_39), (¶m_40));+ let _e372 = NdotV_2;+ let _e374 = ndotl;+ brdf = ((_e366 * _e370) / max(((4f * _e372) * _e374), 0.0001f));+ let _e378 = radiance;+ let _e379 = (*V);+ let _e380 = H;+ param_41 = max(dot(_e379, _e380), 0f);+ let _e383 = F0_1;+ param_42 = _e383;+ let _e384 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_41), (¶m_42));+ let _e386 = brdf;+ let _e388 = (*specular);+ let _e391 = gloss;+ gloss = (_e391 + ((_e378 * _e384) * ((_e386 * 3.1415927f) * _e388)));}continue;} else {break;}continuing {- let _e377 = i;- i = (_e377 + 1i);+ let _e393 = i;+ i = (_e393 + 1i);}}- 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);+ let _e395 = NdotV_2;+ param_43 = _e395;+ let _e396 = (*roughness_3);+ param_44 = _e396;+ let _e397 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_43), (¶m_44));+ ab = _e397;+ let _e398 = (*V);+ let _e400 = (*N_3);+ param_45 = reflect(-(_e398), _e400);+ let _e402 = (*roughness_3);+ param_46 = _e402;+ let _e403 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_45), (¶m_46));+ let _e404 = (*ao);+ let _e405 = (*specular);+ let _e408 = F0_1;+ let _e410 = ab[0u];+ let _e413 = ab[1u];+ let _e417 = gloss;+ gloss = (_e417 + ((_e403 * (_e404 * _e405)) * ((_e408 * _e410) + vec3(_e413))));+ let _e419 = (*albedo);+ let _e420 = (*metallic);+ let _e423 = lit;+ let _e425 = gloss;+ return (((_e419 * (1f - _e420)) * _e423) + _e425);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {@@ -842,51 +878,51 @@ fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<ffn 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_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;+ var param_47: 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: f32;+ var param_53: f32;+ var param_54: f32;+ var param_55: 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));+ param_47 = _e102;+ let _e103 = viewDirection_u0028_vf3_u003b((¶m_47));let _e104 = (*albedo_1);- param_42 = _e104;+ param_48 = _e104;let _e105 = (*N_4);- param_43 = _e105;+ param_49 = _e105;let _e106 = P;- param_44 = _e106;- param_45 = _e103;- param_46 = 0f;- param_47 = 1f;- param_48 = 0f;+ param_50 = _e106;+ param_51 = _e103;+ param_52 = 0f;+ param_53 = 1f;+ param_54 = 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));+ param_55 = _e107;+ let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_48), (¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55));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_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec2<f32>;- var param_53: f32;+ var param_56: vec3<f32>;+ var param_57: vec3<f32>;+ var param_58: vec2<f32>;+ var param_59: f32;let _e91 = (*albedo_2);- param_50 = _e91;+ param_56 = _e91;let _e92 = (*N_5);- param_51 = _e92;+ param_57 = _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));+ param_58 = _e93;+ param_59 = 1f;+ let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_56), (¶m_57), (¶m_58), (¶m_59));return _e94;}@@ -899,10 +935,10 @@ fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, mapfn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_54: vec2<f32>;- var param_55: vec3<f32>;- var param_56: vec3<f32>;- var param_57: vec2<f32>;+ var param_60: vec2<f32>;+ var param_61: vec3<f32>;+ var param_62: vec3<f32>;+ var param_63: vec2<f32>;let _e90 = v_texCoord_1;let _e91 = textureSample(es_bt0_est, es_bt0_ess, _e90);@@ -910,16 +946,16 @@ fn main_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));+ param_60 = _e97;+ let _e98 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (¶m_60));N_6 = _e98;let _e99 = base;- param_55 = _e99.xyz;+ param_61 = _e99.xyz;let _e101 = N_6;- param_56 = _e101;+ param_62 = _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));+ param_63 = _e102;+ let _e103 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_61), (¶m_62), (¶m_63));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 351316e28..22da7f44d 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: ee5bb8b28abd70da+// assembled-hash: 5b9e7d2e0ace2c2estruct 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: ee5bb8b28abd70da+// assembled-hash: 5b9e7d2e0ace2c2estruct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -133,6 +133,7 @@ struct Light {spot: vec4<f32>,shadow: vec4<f32>,shadowMap: vec4<f32>,+ falloff: vec4<f32>,}struct LightConstants {@@ -322,16 +323,16 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPosvar local_1: f32;var local_2: f32;var local_3: f32;- var phi_194_: bool;+ var phi_200_: bool;let _e95 = (*channel);let _e96 = (_e95 < 0f);- phi_194_ = _e96;+ phi_200_ = _e96;if !(_e96) {let _e100 = unnamed_1.u_shadow2DRect[2u];- phi_194_ = (_e100 <= 0f);+ phi_200_ = (_e100 <= 0f);}- let _e103 = phi_194_;+ let _e103 = phi_200_;if _e103 {return 1f;}@@ -444,6 +445,19 @@ fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_return _e93;}+fn distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b(dist_1: ptr<function, f32>, reach: ptr<function, f32>, fo: ptr<function, vec4<f32>>) -> f32 {+ var ramp: f32;++ let _e87 = (*reach);+ let _e88 = (*dist_1);+ let _e90 = (*reach);+ let _e92 = (*fo)[0u];+ ramp = clamp(((_e87 - _e88) / max((_e90 - _e92), 0.0001f)), 0f, 1f);+ let _e97 = ramp;+ let _e99 = (*fo)[1u];+ return pow(_e97, max(_e99, 0.001f));+}+fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {let _e84 = (*toLight_2);return length(_e84.xy);@@ -531,303 +545,325 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;+ var fo_1: vec4<f32>;var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;var param_6: vec4<f32>;var param_7: vec4<f32>;var param_8: vec3<f32>;- var dist_1: f32;+ var dist_2: f32;var param_9: vec3<f32>;var atten: f32;+ var param_10: f32;+ var param_11: f32;+ var param_12: vec4<f32>;var L_1: vec3<f32>;- var param_10: vec3<f32>;- var param_11: vec3<f32>;+ var param_13: vec3<f32>;+ var param_14: vec3<f32>;var toLight_3: vec2<f32>;var local_7: 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_15: vec4<f32>;+ var param_16: vec4<f32>;var param_17: vec3<f32>;- var param_18: vec4<f32>;- var param_19: vec4<f32>;- var param_20: vec3<f32>;- var param_21: f32;- var param_22: f32;- var param_23: vec2<f32>;- var sm: vec4<f32>;- var param_24: vec3<f32>;- var param_25: vec3<f32>;+ var dist_3: f32;+ var param_18: vec3<f32>;+ var param_19: f32;+ var param_20: f32;+ var param_21: vec4<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: vec2<f32>;- var param_28: i32;- var param_29: i32;+ var param_27: f32;+ var param_28: f32;+ var param_29: vec2<f32>;+ var sm: vec4<f32>;+ var param_30: vec3<f32>;+ var param_31: vec3<f32>;+ var param_32: vec3<f32>;+ var param_33: vec2<f32>;+ var param_34: i32;+ var param_35: 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_36: f32;var param_37: f32;var param_38: f32;- var param_39: vec3<f32>;+ var param_39: f32;var param_40: f32;- var phi_809_: bool;- var phi_863_: 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);+ var param_41: f32;+ var param_42: vec3<f32>;+ var ab: vec2<f32>;+ var param_43: f32;+ var param_44: f32;+ var param_45: vec3<f32>;+ var param_46: f32;+ var phi_839_: bool;+ var phi_895_: bool;++ let _e160 = (*albedo);+ let _e161 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e160, vec3(_e161));+ let _e164 = (*roughness_3);+ let _e165 = (*roughness_3);+ a_4 = max((_e164 * _e165), 0.001f);+ let _e168 = (*N_3);+ let _e169 = (*V);+ NdotV_2 = max(dot(_e168, _e169), 0.0001f);+ let _e172 = (*N_3);+ param_5 = _e172;+ let _e173 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e174 = (*ao);+ lit = (_e173 * _e174);gloss = vec3<f32>(0f, 0f, 0f);i = 0i;loop {- 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;+ let _e176 = i;+ if (_e176 < 16i) {+ let _e178 = i;+ let _e182 = unnamed_1.u_lights[_e178].posDir;+ pd_1 = _e182;+ let _e183 = i;+ let _e187 = unnamed_1.u_lights[_e183].color;+ col = _e187;+ let _e188 = i;+ let _e192 = unnamed_1.u_lights[_e188].shadow;+ sh_3 = _e192;+ let _e193 = i;+ let _e197 = unnamed_1.u_lights[_e193].falloff;+ fo_1 = _e197;+ let _e198 = pd_1;+ target_ = _e198.xy;castShadow = true;- 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;+ let _e201 = pd_1[2u];+ if (_e201 < 0.5f) {+ let _e203 = pd_1;+ param_6 = _e203;+ let _e204 = sh_3;+ param_7 = _e204;+ let _e205 = (*worldPos_3);+ param_8 = _e205;+ let _e206 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e206;+ let _e207 = toL;+ param_9 = _e207;+ let _e208 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_2 = _e208;+ let _e210 = pd_1[3u];+ let _e212 = dist_2;+ param_10 = _e212;+ param_11 = max(_e210, 0.0001f);+ let _e213 = fo_1;+ param_12 = _e213;+ let _e214 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_10), (¶m_11), (¶m_12));+ atten = _e214;+ let _e215 = toL;+ param_13 = _e215;+ let _e216 = (*N_3);+ param_14 = _e216;+ let _e217 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_13), (¶m_14));+ L_1 = _e217;} else {- let _e208 = pd_1[2u];- if (_e208 < 1.5f) {+ let _e219 = pd_1[2u];+ if (_e219 < 1.5f) {atten = 1f;- 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;- if (dot(_e219.xy, _e221.xy) > 0.00000001f) {- let _e225 = pd_1;- local_7 = normalize(-(_e225.xy));+ let _e222 = _e221.xy;+ let _e224 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e222.x, _e222.y, _e224)));+ let _e230 = pd_1;+ let _e232 = pd_1;+ if (dot(_e230.xy, _e232.xy) > 0.00000001f) {+ let _e236 = pd_1;+ local_7 = normalize(-(_e236.xy));} else {local_7 = vec2<f32>(0f, 0f);}- let _e229 = local_7;- toLight_3 = _e229;- let _e231 = sh_3[1u];- let _e232 = (_e231 > 0f);- phi_809_ = _e232;- if _e232 {- let _e233 = toLight_3;- let _e234 = toLight_3;- phi_809_ = (dot(_e233, _e234) > 0.5f);+ let _e240 = local_7;+ toLight_3 = _e240;+ let _e242 = sh_3[1u];+ let _e243 = (_e242 > 0f);+ phi_839_ = _e243;+ if _e243 {+ let _e244 = toLight_3;+ let _e245 = toLight_3;+ phi_839_ = (dot(_e244, _e245) > 0.5f);}- let _e238 = phi_809_;- castShadow = _e238;- let _e239 = (*worldPos_3);- let _e241 = toLight_3;- let _e243 = sh_3[1u];- target_ = (_e239.xy + (_e241 * _e243));+ let _e249 = phi_839_;+ castShadow = _e249;+ let _e250 = (*worldPos_3);+ let _e252 = toLight_3;+ let _e254 = sh_3[1u];+ target_ = (_e250.xy + (_e252 * _e254));} else {- 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 _e257 = i;+ let _e261 = unnamed_1.u_lights[_e257].spot;+ sp_1 = _e261;+ let _e262 = pd_1;+ param_15 = _e262;+ let _e263 = sh_3;+ param_16 = _e263;+ let _e264 = (*worldPos_3);+ param_17 = _e264;+ let _e265 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_15), (¶m_16), (¶m_17));+ toL_1 = _e265;+ let _e266 = toL_1;+ param_18 = _e266;+ let _e267 = lightDistance_u0028_vf3_u003b((¶m_18));+ dist_3 = _e267;+ let _e269 = pd_1[3u];+ let _e271 = dist_3;+ param_19 = _e271;+ param_20 = max(_e269, 0.0001f);+ let _e272 = fo_1;+ param_21 = _e272;+ let _e273 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_19), (¶m_20), (¶m_21));+ atten = _e273;+ let _e274 = toL_1;+ param_22 = _e274;+ let _e275 = (*N_3);+ param_23 = _e275;+ let _e276 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));+ L_1 = _e276;+ let _e277 = sp_1;+ param_24 = _e277;+ let _e278 = sh_3;+ param_25 = _e278;+ let _e279 = toL_1;+ param_26 = _e279;+ let _e280 = dist_3;+ param_27 = _e280;+ let _e281 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));+ let _e282 = atten;+ atten = (_e282 * _e281);}}- let _e274 = castShadow;- phi_863_ = _e274;- if _e274 {- let _e276 = col[3u];- phi_863_ = (_e276 > 0f);+ let _e284 = castShadow;+ phi_895_ = _e284;+ if _e284 {+ let _e286 = col[3u];+ phi_895_ = (_e286 > 0f);}- let _e279 = phi_863_;- 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 _e289 = phi_895_;+ let _e290 = atten;+ if (_e289 && (_e290 > 0f)) {+ let _e293 = i;+ let _e298 = unnamed_1.u_lights[_e293].shadowMap[3u];+ param_28 = _e298;+ let _e299 = (*worldPos_3);+ param_29 = _e299.xy;+ let _e301 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_28), (¶m_29));+ let _e303 = fo_1[2u];+ let _e305 = atten;+ atten = (_e305 * mix(1f, _e301, _e303));}- 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 _e307 = i;+ let _e311 = unnamed_1.u_lights[_e307].shadowMap;+ sm = _e311;+ let _e313 = sm[1u];+ let _e315 = atten;+ if ((_e313 > 0f) && (_e315 > 0f)) {+ let _e319 = sh_3[0u];+ let _e321 = sm[2u];+ let _e324 = sm[0u];+ let _e327 = sm[1u];+ let _e329 = (*worldPos_3);+ param_30 = _e329;+ let _e330 = (*N_3);+ param_31 = _e330;+ let _e331 = L_1;+ param_32 = _e331;+ param_33 = vec2<f32>(_e319, _e321);+ param_34 = i32(_e324);+ param_35 = i32(_e327);+ let _e332 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_30), (¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35));+ let _e334 = fo_1[2u];+ let _e336 = atten;+ atten = (_e336 * mix(1f, _e332, _e334));}- 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)));+ let _e338 = (*N_3);+ let _e339 = L_1;+ ndotl = max(dot(_e338, _e339), 0f);+ let _e342 = col;+ let _e345 = col[3u];+ let _e346 = ndotl;+ let _e348 = atten;+ radiance = (_e342.xyz * ((_e345 * _e346) * _e348));+ let _e351 = radiance;+ let _e352 = lit;+ lit = (_e352 + _e351);+ let _e354 = (*specular);+ if (_e354 > 0f) {+ let _e356 = L_1;+ let _e357 = (*V);+ H = normalize((_e356 + _e357));+ let _e360 = (*N_3);+ let _e361 = H;+ param_36 = max(dot(_e360, _e361), 0f);+ let _e364 = a_4;+ param_37 = _e364;+ let _e365 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_36), (¶m_37));+ let _e366 = NdotV_2;+ param_38 = _e366;+ let _e367 = ndotl;+ param_39 = _e367;+ let _e368 = (*roughness_3);+ param_40 = _e368;+ let _e369 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_38), (¶m_39), (¶m_40));+ let _e371 = NdotV_2;+ let _e373 = ndotl;+ brdf = ((_e365 * _e369) / max(((4f * _e371) * _e373), 0.0001f));+ let _e377 = radiance;+ let _e378 = (*V);+ let _e379 = H;+ param_41 = max(dot(_e378, _e379), 0f);+ let _e382 = F0_1;+ param_42 = _e382;+ let _e383 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_41), (¶m_42));+ let _e385 = brdf;+ let _e387 = (*specular);+ let _e390 = gloss;+ gloss = (_e390 + ((_e377 * _e383) * ((_e385 * 3.1415927f) * _e387)));}continue;} else {break;}continuing {- let _e376 = i;- i = (_e376 + 1i);+ let _e392 = i;+ i = (_e392 + 1i);}}- 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);+ let _e394 = NdotV_2;+ param_43 = _e394;+ let _e395 = (*roughness_3);+ param_44 = _e395;+ let _e396 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_43), (¶m_44));+ ab = _e396;+ let _e397 = (*V);+ let _e399 = (*N_3);+ param_45 = reflect(-(_e397), _e399);+ let _e401 = (*roughness_3);+ param_46 = _e401;+ let _e402 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_45), (¶m_46));+ let _e403 = (*ao);+ let _e404 = (*specular);+ let _e407 = F0_1;+ let _e409 = ab[0u];+ let _e412 = ab[1u];+ let _e416 = gloss;+ gloss = (_e416 + ((_e402 * (_e403 * _e404)) * ((_e407 * _e409) + vec3(_e412))));+ let _e418 = (*albedo);+ let _e419 = (*metallic);+ let _e422 = lit;+ let _e424 = gloss;+ return (((_e418 * (1f - _e419)) * _e422) + _e424);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {@@ -848,51 +884,51 @@ fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<ffn 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_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;+ var param_47: 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: f32;+ var param_53: f32;+ var param_54: f32;+ var param_55: 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));+ param_47 = _e101;+ let _e102 = viewDirection_u0028_vf3_u003b((¶m_47));let _e103 = (*albedo_1);- param_42 = _e103;+ param_48 = _e103;let _e104 = (*N_4);- param_43 = _e104;+ param_49 = _e104;let _e105 = P;- param_44 = _e105;- param_45 = _e102;- param_46 = 0f;- param_47 = 1f;- param_48 = 0f;+ param_50 = _e105;+ param_51 = _e102;+ param_52 = 0f;+ param_53 = 1f;+ param_54 = 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));+ param_55 = _e106;+ let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_48), (¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55));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_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec2<f32>;- var param_53: f32;+ var param_56: vec3<f32>;+ var param_57: vec3<f32>;+ var param_58: vec2<f32>;+ var param_59: f32;let _e90 = (*albedo_2);- param_50 = _e90;+ param_56 = _e90;let _e91 = (*N_5);- param_51 = _e91;+ param_57 = _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));+ param_58 = _e92;+ param_59 = 1f;+ let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_56), (¶m_57), (¶m_58), (¶m_59));return _e93;}@@ -905,27 +941,27 @@ fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, mapfn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_54: vec2<f32>;+ var param_60: vec2<f32>;var lit_1: vec3<f32>;- var param_55: vec3<f32>;- var param_56: vec3<f32>;- var param_57: vec2<f32>;+ var param_61: vec3<f32>;+ var param_62: vec3<f32>;+ var param_63: 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));+ param_60 = _e94;+ let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_60));N_6 = _e95;let _e96 = base;- param_55 = _e96.xyz;+ param_61 = _e96.xyz;let _e98 = N_6;- param_56 = _e98;+ param_62 = _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));+ param_63 = _e99;+ let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_61), (¶m_62), (¶m_63));lit_1 = _e100;let _e101 = lit_1;let _e103 = base[3u];diff --git a/fixtures/scenes/mat-lit-normal/lit-normal.esshader b/fixtures/scenes/mat-lit-normal/lit-normal.esshaderindex 3db252db8..7d59dd92f 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: 69321241a50459db+// assembled-hash: 65f09903605b6341struct 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: 69321241a50459db+// assembled-hash: 65f09903605b6341struct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -133,6 +133,7 @@ struct Light {spot: vec4<f32>,shadow: vec4<f32>,shadowMap: vec4<f32>,+ falloff: vec4<f32>,}struct LightConstants {@@ -322,16 +323,16 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPosvar local_1: f32;var local_2: f32;var local_3: f32;- var phi_194_: bool;+ var phi_200_: bool;let _e95 = (*channel);let _e96 = (_e95 < 0f);- phi_194_ = _e96;+ phi_200_ = _e96;if !(_e96) {let _e100 = unnamed_1.u_shadow2DRect[2u];- phi_194_ = (_e100 <= 0f);+ phi_200_ = (_e100 <= 0f);}- let _e103 = phi_194_;+ let _e103 = phi_200_;if _e103 {return 1f;}@@ -444,6 +445,19 @@ fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_return _e93;}+fn distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b(dist_1: ptr<function, f32>, reach: ptr<function, f32>, fo: ptr<function, vec4<f32>>) -> f32 {+ var ramp: f32;++ let _e87 = (*reach);+ let _e88 = (*dist_1);+ let _e90 = (*reach);+ let _e92 = (*fo)[0u];+ ramp = clamp(((_e87 - _e88) / max((_e90 - _e92), 0.0001f)), 0f, 1f);+ let _e97 = ramp;+ let _e99 = (*fo)[1u];+ return pow(_e97, max(_e99, 0.001f));+}+fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {let _e84 = (*toLight_2);return length(_e84.xy);@@ -531,303 +545,325 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;+ var fo_1: vec4<f32>;var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;var param_6: vec4<f32>;var param_7: vec4<f32>;var param_8: vec3<f32>;- var dist_1: f32;+ var dist_2: f32;var param_9: vec3<f32>;var atten: f32;+ var param_10: f32;+ var param_11: f32;+ var param_12: vec4<f32>;var L_1: vec3<f32>;- var param_10: vec3<f32>;- var param_11: vec3<f32>;+ var param_13: vec3<f32>;+ var param_14: vec3<f32>;var toLight_3: vec2<f32>;var local_7: 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_15: vec4<f32>;+ var param_16: vec4<f32>;var param_17: vec3<f32>;- var param_18: vec4<f32>;- var param_19: vec4<f32>;- var param_20: vec3<f32>;- var param_21: f32;- var param_22: f32;- var param_23: vec2<f32>;- var sm: vec4<f32>;- var param_24: vec3<f32>;- var param_25: vec3<f32>;+ var dist_3: f32;+ var param_18: vec3<f32>;+ var param_19: f32;+ var param_20: f32;+ var param_21: vec4<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: vec2<f32>;- var param_28: i32;- var param_29: i32;+ var param_27: f32;+ var param_28: f32;+ var param_29: vec2<f32>;+ var sm: vec4<f32>;+ var param_30: vec3<f32>;+ var param_31: vec3<f32>;+ var param_32: vec3<f32>;+ var param_33: vec2<f32>;+ var param_34: i32;+ var param_35: 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_36: f32;var param_37: f32;var param_38: f32;- var param_39: vec3<f32>;+ var param_39: f32;var param_40: f32;- var phi_809_: bool;- var phi_863_: 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);+ var param_41: f32;+ var param_42: vec3<f32>;+ var ab: vec2<f32>;+ var param_43: f32;+ var param_44: f32;+ var param_45: vec3<f32>;+ var param_46: f32;+ var phi_839_: bool;+ var phi_895_: bool;++ let _e160 = (*albedo);+ let _e161 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e160, vec3(_e161));+ let _e164 = (*roughness_3);+ let _e165 = (*roughness_3);+ a_4 = max((_e164 * _e165), 0.001f);+ let _e168 = (*N_3);+ let _e169 = (*V);+ NdotV_2 = max(dot(_e168, _e169), 0.0001f);+ let _e172 = (*N_3);+ param_5 = _e172;+ let _e173 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e174 = (*ao);+ lit = (_e173 * _e174);gloss = vec3<f32>(0f, 0f, 0f);i = 0i;loop {- 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;+ let _e176 = i;+ if (_e176 < 16i) {+ let _e178 = i;+ let _e182 = unnamed_1.u_lights[_e178].posDir;+ pd_1 = _e182;+ let _e183 = i;+ let _e187 = unnamed_1.u_lights[_e183].color;+ col = _e187;+ let _e188 = i;+ let _e192 = unnamed_1.u_lights[_e188].shadow;+ sh_3 = _e192;+ let _e193 = i;+ let _e197 = unnamed_1.u_lights[_e193].falloff;+ fo_1 = _e197;+ let _e198 = pd_1;+ target_ = _e198.xy;castShadow = true;- 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;+ let _e201 = pd_1[2u];+ if (_e201 < 0.5f) {+ let _e203 = pd_1;+ param_6 = _e203;+ let _e204 = sh_3;+ param_7 = _e204;+ let _e205 = (*worldPos_3);+ param_8 = _e205;+ let _e206 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e206;+ let _e207 = toL;+ param_9 = _e207;+ let _e208 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_2 = _e208;+ let _e210 = pd_1[3u];+ let _e212 = dist_2;+ param_10 = _e212;+ param_11 = max(_e210, 0.0001f);+ let _e213 = fo_1;+ param_12 = _e213;+ let _e214 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_10), (¶m_11), (¶m_12));+ atten = _e214;+ let _e215 = toL;+ param_13 = _e215;+ let _e216 = (*N_3);+ param_14 = _e216;+ let _e217 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_13), (¶m_14));+ L_1 = _e217;} else {- let _e208 = pd_1[2u];- if (_e208 < 1.5f) {+ let _e219 = pd_1[2u];+ if (_e219 < 1.5f) {atten = 1f;- 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;- if (dot(_e219.xy, _e221.xy) > 0.00000001f) {- let _e225 = pd_1;- local_7 = normalize(-(_e225.xy));+ let _e222 = _e221.xy;+ let _e224 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e222.x, _e222.y, _e224)));+ let _e230 = pd_1;+ let _e232 = pd_1;+ if (dot(_e230.xy, _e232.xy) > 0.00000001f) {+ let _e236 = pd_1;+ local_7 = normalize(-(_e236.xy));} else {local_7 = vec2<f32>(0f, 0f);}- let _e229 = local_7;- toLight_3 = _e229;- let _e231 = sh_3[1u];- let _e232 = (_e231 > 0f);- phi_809_ = _e232;- if _e232 {- let _e233 = toLight_3;- let _e234 = toLight_3;- phi_809_ = (dot(_e233, _e234) > 0.5f);+ let _e240 = local_7;+ toLight_3 = _e240;+ let _e242 = sh_3[1u];+ let _e243 = (_e242 > 0f);+ phi_839_ = _e243;+ if _e243 {+ let _e244 = toLight_3;+ let _e245 = toLight_3;+ phi_839_ = (dot(_e244, _e245) > 0.5f);}- let _e238 = phi_809_;- castShadow = _e238;- let _e239 = (*worldPos_3);- let _e241 = toLight_3;- let _e243 = sh_3[1u];- target_ = (_e239.xy + (_e241 * _e243));+ let _e249 = phi_839_;+ castShadow = _e249;+ let _e250 = (*worldPos_3);+ let _e252 = toLight_3;+ let _e254 = sh_3[1u];+ target_ = (_e250.xy + (_e252 * _e254));} else {- 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 _e257 = i;+ let _e261 = unnamed_1.u_lights[_e257].spot;+ sp_1 = _e261;+ let _e262 = pd_1;+ param_15 = _e262;+ let _e263 = sh_3;+ param_16 = _e263;+ let _e264 = (*worldPos_3);+ param_17 = _e264;+ let _e265 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_15), (¶m_16), (¶m_17));+ toL_1 = _e265;+ let _e266 = toL_1;+ param_18 = _e266;+ let _e267 = lightDistance_u0028_vf3_u003b((¶m_18));+ dist_3 = _e267;+ let _e269 = pd_1[3u];+ let _e271 = dist_3;+ param_19 = _e271;+ param_20 = max(_e269, 0.0001f);+ let _e272 = fo_1;+ param_21 = _e272;+ let _e273 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_19), (¶m_20), (¶m_21));+ atten = _e273;+ let _e274 = toL_1;+ param_22 = _e274;+ let _e275 = (*N_3);+ param_23 = _e275;+ let _e276 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));+ L_1 = _e276;+ let _e277 = sp_1;+ param_24 = _e277;+ let _e278 = sh_3;+ param_25 = _e278;+ let _e279 = toL_1;+ param_26 = _e279;+ let _e280 = dist_3;+ param_27 = _e280;+ let _e281 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));+ let _e282 = atten;+ atten = (_e282 * _e281);}}- let _e274 = castShadow;- phi_863_ = _e274;- if _e274 {- let _e276 = col[3u];- phi_863_ = (_e276 > 0f);+ let _e284 = castShadow;+ phi_895_ = _e284;+ if _e284 {+ let _e286 = col[3u];+ phi_895_ = (_e286 > 0f);}- let _e279 = phi_863_;- 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 _e289 = phi_895_;+ let _e290 = atten;+ if (_e289 && (_e290 > 0f)) {+ let _e293 = i;+ let _e298 = unnamed_1.u_lights[_e293].shadowMap[3u];+ param_28 = _e298;+ let _e299 = (*worldPos_3);+ param_29 = _e299.xy;+ let _e301 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_28), (¶m_29));+ let _e303 = fo_1[2u];+ let _e305 = atten;+ atten = (_e305 * mix(1f, _e301, _e303));}- 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 _e307 = i;+ let _e311 = unnamed_1.u_lights[_e307].shadowMap;+ sm = _e311;+ let _e313 = sm[1u];+ let _e315 = atten;+ if ((_e313 > 0f) && (_e315 > 0f)) {+ let _e319 = sh_3[0u];+ let _e321 = sm[2u];+ let _e324 = sm[0u];+ let _e327 = sm[1u];+ let _e329 = (*worldPos_3);+ param_30 = _e329;+ let _e330 = (*N_3);+ param_31 = _e330;+ let _e331 = L_1;+ param_32 = _e331;+ param_33 = vec2<f32>(_e319, _e321);+ param_34 = i32(_e324);+ param_35 = i32(_e327);+ let _e332 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_30), (¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35));+ let _e334 = fo_1[2u];+ let _e336 = atten;+ atten = (_e336 * mix(1f, _e332, _e334));}- 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)));+ let _e338 = (*N_3);+ let _e339 = L_1;+ ndotl = max(dot(_e338, _e339), 0f);+ let _e342 = col;+ let _e345 = col[3u];+ let _e346 = ndotl;+ let _e348 = atten;+ radiance = (_e342.xyz * ((_e345 * _e346) * _e348));+ let _e351 = radiance;+ let _e352 = lit;+ lit = (_e352 + _e351);+ let _e354 = (*specular);+ if (_e354 > 0f) {+ let _e356 = L_1;+ let _e357 = (*V);+ H = normalize((_e356 + _e357));+ let _e360 = (*N_3);+ let _e361 = H;+ param_36 = max(dot(_e360, _e361), 0f);+ let _e364 = a_4;+ param_37 = _e364;+ let _e365 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_36), (¶m_37));+ let _e366 = NdotV_2;+ param_38 = _e366;+ let _e367 = ndotl;+ param_39 = _e367;+ let _e368 = (*roughness_3);+ param_40 = _e368;+ let _e369 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_38), (¶m_39), (¶m_40));+ let _e371 = NdotV_2;+ let _e373 = ndotl;+ brdf = ((_e365 * _e369) / max(((4f * _e371) * _e373), 0.0001f));+ let _e377 = radiance;+ let _e378 = (*V);+ let _e379 = H;+ param_41 = max(dot(_e378, _e379), 0f);+ let _e382 = F0_1;+ param_42 = _e382;+ let _e383 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_41), (¶m_42));+ let _e385 = brdf;+ let _e387 = (*specular);+ let _e390 = gloss;+ gloss = (_e390 + ((_e377 * _e383) * ((_e385 * 3.1415927f) * _e387)));}continue;} else {break;}continuing {- let _e376 = i;- i = (_e376 + 1i);+ let _e392 = i;+ i = (_e392 + 1i);}}- 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);+ let _e394 = NdotV_2;+ param_43 = _e394;+ let _e395 = (*roughness_3);+ param_44 = _e395;+ let _e396 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_43), (¶m_44));+ ab = _e396;+ let _e397 = (*V);+ let _e399 = (*N_3);+ param_45 = reflect(-(_e397), _e399);+ let _e401 = (*roughness_3);+ param_46 = _e401;+ let _e402 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_45), (¶m_46));+ let _e403 = (*ao);+ let _e404 = (*specular);+ let _e407 = F0_1;+ let _e409 = ab[0u];+ let _e412 = ab[1u];+ let _e416 = gloss;+ gloss = (_e416 + ((_e402 * (_e403 * _e404)) * ((_e407 * _e409) + vec3(_e412))));+ let _e418 = (*albedo);+ let _e419 = (*metallic);+ let _e422 = lit;+ let _e424 = gloss;+ return (((_e418 * (1f - _e419)) * _e422) + _e424);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {@@ -848,51 +884,51 @@ fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<ffn 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_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;+ var param_47: 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: f32;+ var param_53: f32;+ var param_54: f32;+ var param_55: 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));+ param_47 = _e101;+ let _e102 = viewDirection_u0028_vf3_u003b((¶m_47));let _e103 = (*albedo_1);- param_42 = _e103;+ param_48 = _e103;let _e104 = (*N_4);- param_43 = _e104;+ param_49 = _e104;let _e105 = P;- param_44 = _e105;- param_45 = _e102;- param_46 = 0f;- param_47 = 1f;- param_48 = 0f;+ param_50 = _e105;+ param_51 = _e102;+ param_52 = 0f;+ param_53 = 1f;+ param_54 = 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));+ param_55 = _e106;+ let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_48), (¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55));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_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec2<f32>;- var param_53: f32;+ var param_56: vec3<f32>;+ var param_57: vec3<f32>;+ var param_58: vec2<f32>;+ var param_59: f32;let _e90 = (*albedo_2);- param_50 = _e90;+ param_56 = _e90;let _e91 = (*N_5);- param_51 = _e91;+ param_57 = _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));+ param_58 = _e92;+ param_59 = 1f;+ let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_56), (¶m_57), (¶m_58), (¶m_59));return _e93;}@@ -905,27 +941,27 @@ fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, mapfn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;- var param_54: vec2<f32>;+ var param_60: vec2<f32>;var lit_1: vec3<f32>;- var param_55: vec3<f32>;- var param_56: vec3<f32>;- var param_57: vec2<f32>;+ var param_61: vec3<f32>;+ var param_62: vec3<f32>;+ var param_63: 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));+ param_60 = _e94;+ let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (¶m_60));N_6 = _e95;let _e96 = base;- param_55 = _e96.xyz;+ param_61 = _e96.xyz;let _e98 = N_6;- param_56 = _e98;+ param_62 = _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));+ param_63 = _e99;+ let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_61), (¶m_62), (¶m_63));lit_1 = _e100;let _e101 = lit_1;let _e103 = base[3u];diff --git a/fixtures/scenes/mat-lit/lit.esshader b/fixtures/scenes/mat-lit/lit.esshaderindex 02cd613c3..1d7633508 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: 76e79c2465ad522f+// assembled-hash: 935c6a785109fe67struct 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: 76e79c2465ad522f+// assembled-hash: 935c6a785109fe67struct FrameConstants {u_projection: mat4x4<f32>,u_camera: vec4<f32>,@@ -135,6 +135,7 @@ struct Light {spot: vec4<f32>,shadow: vec4<f32>,shadowMap: vec4<f32>,+ falloff: vec4<f32>,}struct LightConstants {@@ -320,16 +321,16 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPosvar local_1: f32;var local_2: f32;var local_3: f32;- var phi_170_: bool;+ var phi_176_: bool;let _e93 = (*channel);let _e94 = (_e93 < 0f);- phi_170_ = _e94;+ phi_176_ = _e94;if !(_e94) {let _e98 = unnamed_1.u_shadow2DRect[2u];- phi_170_ = (_e98 <= 0f);+ phi_176_ = (_e98 <= 0f);}- let _e101 = phi_170_;+ let _e101 = phi_176_;if _e101 {return 1f;}@@ -442,6 +443,19 @@ fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_return _e91;}+fn distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b(dist_1: ptr<function, f32>, reach: ptr<function, f32>, fo: ptr<function, vec4<f32>>) -> f32 {+ var ramp: f32;++ let _e85 = (*reach);+ let _e86 = (*dist_1);+ let _e88 = (*reach);+ let _e90 = (*fo)[0u];+ ramp = clamp(((_e85 - _e86) / max((_e88 - _e90), 0.0001f)), 0f, 1f);+ let _e95 = ramp;+ let _e97 = (*fo)[1u];+ return pow(_e95, max(_e97, 0.001f));+}+fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {let _e82 = (*toLight_2);return length(_e82.xy);@@ -529,303 +543,325 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0var pd_1: vec4<f32>;var col: vec4<f32>;var sh_3: vec4<f32>;+ var fo_1: vec4<f32>;var target_: vec2<f32>;var castShadow: bool;var toL: vec3<f32>;var param_6: vec4<f32>;var param_7: vec4<f32>;var param_8: vec3<f32>;- var dist_1: f32;+ var dist_2: f32;var param_9: vec3<f32>;var atten: f32;+ var param_10: f32;+ var param_11: f32;+ var param_12: vec4<f32>;var L_1: vec3<f32>;- var param_10: vec3<f32>;- var param_11: vec3<f32>;+ var param_13: vec3<f32>;+ var param_14: vec3<f32>;var toLight_3: vec2<f32>;var local_7: 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_15: vec4<f32>;+ var param_16: vec4<f32>;var param_17: vec3<f32>;- var param_18: vec4<f32>;- var param_19: vec4<f32>;- var param_20: vec3<f32>;- var param_21: f32;- var param_22: f32;- var param_23: vec2<f32>;- var sm: vec4<f32>;- var param_24: vec3<f32>;- var param_25: vec3<f32>;+ var dist_3: f32;+ var param_18: vec3<f32>;+ var param_19: f32;+ var param_20: f32;+ var param_21: vec4<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: vec2<f32>;- var param_28: i32;- var param_29: i32;+ var param_27: f32;+ var param_28: f32;+ var param_29: vec2<f32>;+ var sm: vec4<f32>;+ var param_30: vec3<f32>;+ var param_31: vec3<f32>;+ var param_32: vec3<f32>;+ var param_33: vec2<f32>;+ var param_34: i32;+ var param_35: 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_36: f32;var param_37: f32;var param_38: f32;- var param_39: vec3<f32>;+ var param_39: f32;var param_40: f32;- var phi_790_: bool;- var phi_844_: 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);+ var param_41: f32;+ var param_42: vec3<f32>;+ var ab: vec2<f32>;+ var param_43: f32;+ var param_44: f32;+ var param_45: vec3<f32>;+ var param_46: f32;+ var phi_820_: bool;+ var phi_876_: bool;++ let _e158 = (*albedo);+ let _e159 = (*metallic);+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e158, vec3(_e159));+ let _e162 = (*roughness_3);+ let _e163 = (*roughness_3);+ a_4 = max((_e162 * _e163), 0.001f);+ let _e166 = (*N_3);+ let _e167 = (*V);+ NdotV_2 = max(dot(_e166, _e167), 0.0001f);+ let _e170 = (*N_3);+ param_5 = _e170;+ let _e171 = envIrradiance_u0028_vf3_u003b((¶m_5));+ let _e172 = (*ao);+ lit = (_e171 * _e172);gloss = vec3<f32>(0f, 0f, 0f);i = 0i;loop {- 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;+ let _e174 = i;+ if (_e174 < 16i) {+ let _e176 = i;+ let _e180 = unnamed_1.u_lights[_e176].posDir;+ pd_1 = _e180;+ let _e181 = i;+ let _e185 = unnamed_1.u_lights[_e181].color;+ col = _e185;+ let _e186 = i;+ let _e190 = unnamed_1.u_lights[_e186].shadow;+ sh_3 = _e190;+ let _e191 = i;+ let _e195 = unnamed_1.u_lights[_e191].falloff;+ fo_1 = _e195;+ let _e196 = pd_1;+ target_ = _e196.xy;castShadow = true;- 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;+ let _e199 = pd_1[2u];+ if (_e199 < 0.5f) {+ let _e201 = pd_1;+ param_6 = _e201;+ let _e202 = sh_3;+ param_7 = _e202;+ let _e203 = (*worldPos_3);+ param_8 = _e203;+ let _e204 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_6), (¶m_7), (¶m_8));+ toL = _e204;+ let _e205 = toL;+ param_9 = _e205;+ let _e206 = lightDistance_u0028_vf3_u003b((¶m_9));+ dist_2 = _e206;+ let _e208 = pd_1[3u];+ let _e210 = dist_2;+ param_10 = _e210;+ param_11 = max(_e208, 0.0001f);+ let _e211 = fo_1;+ param_12 = _e211;+ let _e212 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_10), (¶m_11), (¶m_12));+ atten = _e212;+ let _e213 = toL;+ param_13 = _e213;+ let _e214 = (*N_3);+ param_14 = _e214;+ let _e215 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_13), (¶m_14));+ L_1 = _e215;} else {- let _e206 = pd_1[2u];- if (_e206 < 1.5f) {+ let _e217 = pd_1[2u];+ if (_e217 < 1.5f) {atten = 1f;- 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_7 = normalize(-(_e223.xy));+ let _e220 = _e219.xy;+ let _e222 = pd_1[3u];+ L_1 = normalize(-(vec3<f32>(_e220.x, _e220.y, _e222)));+ let _e228 = pd_1;+ let _e230 = pd_1;+ if (dot(_e228.xy, _e230.xy) > 0.00000001f) {+ let _e234 = pd_1;+ local_7 = normalize(-(_e234.xy));} else {local_7 = vec2<f32>(0f, 0f);}- let _e227 = local_7;- toLight_3 = _e227;- let _e229 = sh_3[1u];- let _e230 = (_e229 > 0f);- phi_790_ = _e230;- if _e230 {- let _e231 = toLight_3;- let _e232 = toLight_3;- phi_790_ = (dot(_e231, _e232) > 0.5f);+ let _e238 = local_7;+ toLight_3 = _e238;+ let _e240 = sh_3[1u];+ let _e241 = (_e240 > 0f);+ phi_820_ = _e241;+ if _e241 {+ let _e242 = toLight_3;+ let _e243 = toLight_3;+ phi_820_ = (dot(_e242, _e243) > 0.5f);}- let _e236 = phi_790_;- castShadow = _e236;- let _e237 = (*worldPos_3);- let _e239 = toLight_3;- let _e241 = sh_3[1u];- target_ = (_e237.xy + (_e239 * _e241));+ let _e247 = phi_820_;+ castShadow = _e247;+ let _e248 = (*worldPos_3);+ let _e250 = toLight_3;+ let _e252 = sh_3[1u];+ target_ = (_e248.xy + (_e250 * _e252));} else {- 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 _e255 = i;+ let _e259 = unnamed_1.u_lights[_e255].spot;+ sp_1 = _e259;+ let _e260 = pd_1;+ param_15 = _e260;+ let _e261 = sh_3;+ param_16 = _e261;+ let _e262 = (*worldPos_3);+ param_17 = _e262;+ let _e263 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((¶m_15), (¶m_16), (¶m_17));+ toL_1 = _e263;+ let _e264 = toL_1;+ param_18 = _e264;+ let _e265 = lightDistance_u0028_vf3_u003b((¶m_18));+ dist_3 = _e265;+ let _e267 = pd_1[3u];+ let _e269 = dist_3;+ param_19 = _e269;+ param_20 = max(_e267, 0.0001f);+ let _e270 = fo_1;+ param_21 = _e270;+ let _e271 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((¶m_19), (¶m_20), (¶m_21));+ atten = _e271;+ let _e272 = toL_1;+ param_22 = _e272;+ let _e273 = (*N_3);+ param_23 = _e273;+ let _e274 = towardLight_u0028_vf3_u003b_vf3_u003b((¶m_22), (¶m_23));+ L_1 = _e274;+ let _e275 = sp_1;+ param_24 = _e275;+ let _e276 = sh_3;+ param_25 = _e276;+ let _e277 = toL_1;+ param_26 = _e277;+ let _e278 = dist_3;+ param_27 = _e278;+ let _e279 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((¶m_24), (¶m_25), (¶m_26), (¶m_27));+ let _e280 = atten;+ atten = (_e280 * _e279);}}- let _e272 = castShadow;- phi_844_ = _e272;- if _e272 {- let _e274 = col[3u];- phi_844_ = (_e274 > 0f);+ let _e282 = castShadow;+ phi_876_ = _e282;+ if _e282 {+ let _e284 = col[3u];+ phi_876_ = (_e284 > 0f);}- let _e277 = phi_844_;- 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 _e287 = phi_876_;+ let _e288 = atten;+ if (_e287 && (_e288 > 0f)) {+ let _e291 = i;+ let _e296 = unnamed_1.u_lights[_e291].shadowMap[3u];+ param_28 = _e296;+ let _e297 = (*worldPos_3);+ param_29 = _e297.xy;+ let _e299 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((¶m_28), (¶m_29));+ let _e301 = fo_1[2u];+ let _e303 = atten;+ atten = (_e303 * mix(1f, _e299, _e301));}- let _e292 = i;- let _e296 = unnamed_1.u_lights[_e292].shadowMap;- sm = _e296;- let _e298 = sm[1u];- let _e300 = atten;- if ((_e298 > 0f) && (_e300 > 0f)) {- let _e304 = sh_3[0u];- let _e306 = sm[2u];- let _e309 = sm[0u];- let _e312 = sm[1u];- let _e314 = (*worldPos_3);- param_24 = _e314;- let _e315 = (*N_3);- param_25 = _e315;- let _e316 = L_1;- 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);+ let _e305 = i;+ let _e309 = unnamed_1.u_lights[_e305].shadowMap;+ sm = _e309;+ let _e311 = sm[1u];+ let _e313 = atten;+ if ((_e311 > 0f) && (_e313 > 0f)) {+ let _e317 = sh_3[0u];+ let _e319 = sm[2u];+ let _e322 = sm[0u];+ let _e325 = sm[1u];+ let _e327 = (*worldPos_3);+ param_30 = _e327;+ let _e328 = (*N_3);+ param_31 = _e328;+ let _e329 = L_1;+ param_32 = _e329;+ param_33 = vec2<f32>(_e317, _e319);+ param_34 = i32(_e322);+ param_35 = i32(_e325);+ let _e330 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((¶m_30), (¶m_31), (¶m_32), (¶m_33), (¶m_34), (¶m_35));+ let _e332 = fo_1[2u];+ let _e334 = atten;+ atten = (_e334 * mix(1f, _e330, _e332));}- let _e320 = (*N_3);- let _e321 = L_1;- ndotl = max(dot(_e320, _e321), 0f);- let _e324 = col;- let _e327 = col[3u];- let _e328 = ndotl;- let _e330 = atten;- radiance = (_e324.xyz * ((_e327 * _e328) * _e330));- let _e333 = radiance;- let _e334 = lit;- lit = (_e334 + _e333);- let _e336 = (*specular);- if (_e336 > 0f) {- let _e338 = L_1;- let _e339 = (*V);- H = normalize((_e338 + _e339));- let _e342 = (*N_3);- let _e343 = H;- 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_32 = _e348;- let _e349 = ndotl;- param_33 = _e349;- let _e350 = (*roughness_3);- 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_35 = max(dot(_e360, _e361), 0f);- let _e364 = F0_1;- param_36 = _e364;- let _e365 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_35), (¶m_36));- let _e367 = brdf;- let _e369 = (*specular);- let _e372 = gloss;- gloss = (_e372 + ((_e359 * _e365) * ((_e367 * 3.1415927f) * _e369)));+ let _e336 = (*N_3);+ let _e337 = L_1;+ ndotl = max(dot(_e336, _e337), 0f);+ let _e340 = col;+ let _e343 = col[3u];+ let _e344 = ndotl;+ let _e346 = atten;+ radiance = (_e340.xyz * ((_e343 * _e344) * _e346));+ let _e349 = radiance;+ let _e350 = lit;+ lit = (_e350 + _e349);+ let _e352 = (*specular);+ if (_e352 > 0f) {+ let _e354 = L_1;+ let _e355 = (*V);+ H = normalize((_e354 + _e355));+ let _e358 = (*N_3);+ let _e359 = H;+ param_36 = max(dot(_e358, _e359), 0f);+ let _e362 = a_4;+ param_37 = _e362;+ let _e363 = distributionGGX_u0028_f1_u003b_f1_u003b((¶m_36), (¶m_37));+ let _e364 = NdotV_2;+ param_38 = _e364;+ let _e365 = ndotl;+ param_39 = _e365;+ let _e366 = (*roughness_3);+ param_40 = _e366;+ let _e367 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((¶m_38), (¶m_39), (¶m_40));+ let _e369 = NdotV_2;+ let _e371 = ndotl;+ brdf = ((_e363 * _e367) / max(((4f * _e369) * _e371), 0.0001f));+ let _e375 = radiance;+ let _e376 = (*V);+ let _e377 = H;+ param_41 = max(dot(_e376, _e377), 0f);+ let _e380 = F0_1;+ param_42 = _e380;+ let _e381 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((¶m_41), (¶m_42));+ let _e383 = brdf;+ let _e385 = (*specular);+ let _e388 = gloss;+ gloss = (_e388 + ((_e375 * _e381) * ((_e383 * 3.1415927f) * _e385)));}continue;} else {break;}continuing {- let _e374 = i;- i = (_e374 + 1i);+ let _e390 = i;+ i = (_e390 + 1i);}}- let _e376 = NdotV_2;- param_37 = _e376;- let _e377 = (*roughness_3);- 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_39 = reflect(-(_e379), _e381);- let _e383 = (*roughness_3);- 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;- let _e391 = ab[0u];- let _e394 = ab[1u];- let _e398 = gloss;- gloss = (_e398 + ((_e384 * (_e385 * _e386)) * ((_e389 * _e391) + vec3(_e394))));- let _e400 = (*albedo);- let _e401 = (*metallic);- let _e404 = lit;- let _e406 = gloss;- return (((_e400 * (1f - _e401)) * _e404) + _e406);+ let _e392 = NdotV_2;+ param_43 = _e392;+ let _e393 = (*roughness_3);+ param_44 = _e393;+ let _e394 = envBRDFApprox_u0028_f1_u003b_f1_u003b((¶m_43), (¶m_44));+ ab = _e394;+ let _e395 = (*V);+ let _e397 = (*N_3);+ param_45 = reflect(-(_e395), _e397);+ let _e399 = (*roughness_3);+ param_46 = _e399;+ let _e400 = envRadiance_u0028_vf3_u003b_f1_u003b((¶m_45), (¶m_46));+ let _e401 = (*ao);+ let _e402 = (*specular);+ let _e405 = F0_1;+ let _e407 = ab[0u];+ let _e410 = ab[1u];+ let _e414 = gloss;+ gloss = (_e414 + ((_e400 * (_e401 * _e402)) * ((_e405 * _e407) + vec3(_e410))));+ let _e416 = (*albedo);+ let _e417 = (*metallic);+ let _e420 = lit;+ let _e422 = gloss;+ return (((_e416 * (1f - _e417)) * _e420) + _e422);}fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {@@ -846,51 +882,51 @@ fn viewDirection_u0028_vf3_u003b(worldPos_4: ptr<function, vec3<f32>>) -> vec3<ffn 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_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;+ var param_47: 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: f32;+ var param_53: f32;+ var param_54: f32;+ var param_55: 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));+ param_47 = _e99;+ let _e100 = viewDirection_u0028_vf3_u003b((¶m_47));let _e101 = (*albedo_1);- param_42 = _e101;+ param_48 = _e101;let _e102 = (*N_4);- param_43 = _e102;+ param_49 = _e102;let _e103 = P;- param_44 = _e103;- param_45 = _e100;- param_46 = 0f;- param_47 = 1f;- param_48 = 0f;+ param_50 = _e103;+ param_51 = _e100;+ param_52 = 0f;+ param_53 = 1f;+ param_54 = 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));+ param_55 = _e104;+ let _e105 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((¶m_48), (¶m_49), (¶m_50), (¶m_51), (¶m_52), (¶m_53), (¶m_54), (¶m_55));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_50: vec3<f32>;- var param_51: vec3<f32>;- var param_52: vec2<f32>;- var param_53: f32;+ var param_56: vec3<f32>;+ var param_57: vec3<f32>;+ var param_58: vec2<f32>;+ var param_59: f32;let _e88 = (*albedo_2);- param_50 = _e88;+ param_56 = _e88;let _e89 = (*N_5);- param_51 = _e89;+ param_57 = _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));+ param_58 = _e90;+ param_59 = 1f;+ let _e91 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((¶m_56), (¶m_57), (¶m_58), (¶m_59));return _e91;}@@ -898,9 +934,9 @@ fn main_1() {var base: vec4<f32>;var N_6: vec3<f32>;var lit_1: vec3<f32>;- var param_54: vec3<f32>;- var param_55: vec3<f32>;- var param_56: vec2<f32>;+ var param_60: vec3<f32>;+ var param_61: vec3<f32>;+ var param_62: vec2<f32>;let _e87 = v_texCoord_1;let _e88 = textureSample(es_bt0_est, es_bt0_ess, _e87);@@ -908,12 +944,12 @@ fn main_1() {base = (_e88 * _e89);N_6 = vec3<f32>(0f, 0f, 1f);let _e91 = base;- param_54 = _e91.xyz;+ param_60 = _e91.xyz;let _e93 = N_6;- param_55 = _e93;+ param_61 = _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));+ param_62 = _e94;+ let _e95 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((¶m_60), (¶m_61), (¶m_62));lit_1 = _e95;let _e96 = lit_1;let _e98 = base[3u];diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 0b0ce9231..26ea6f358 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 114 public · 94 beta · 1681 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"f8b3b5501ea0afe4"+"e2362078463a35b5"```## ANCHOR_AXES — const @experimental@@ -4456,7 +4456,9 @@ drawEnvironment: booleanenabled: booleanenvironment: numberenvironmentRotation: number+falloff: numberinnerAngle: number+innerRadius: numberintensity: numbermeshShadows: booleanouterAngle: number@@ -4464,6 +4466,7 @@ radius: numbershadowDistance: numbershadowExtent: numbershadowSoftness: number+shadowStrength: numbersourceAngle: numbertype: LightType```diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex d78faf557..a5e518c0d 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 114 public · 99 beta · 1700 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"f8b3b5501ea0afe4"+"e2362078463a35b5"```## ANCHOR_AXES — const @experimental@@ -4464,7 +4464,9 @@ drawEnvironment: booleanenabled: booleanenvironment: numberenvironmentRotation: number+falloff: numberinnerAngle: number+innerRadius: numberintensity: numbermeshShadows: booleanouterAngle: number@@ -4472,6 +4474,7 @@ radius: numbershadowDistance: numbershadowExtent: numbershadowSoftness: number+shadowStrength: numbersourceAngle: numbertype: LightType```diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 139bf3663..bf9baa75d 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -4451,7 +4451,9 @@ drawEnvironment: booleanenabled: booleanenvironment: numberenvironmentRotation: number+falloff: numberinnerAngle: number+innerRadius: numberintensity: numbermeshShadows: booleanouterAngle: number@@ -4459,6 +4461,7 @@ radius: numbershadowDistance: numbershadowExtent: numbershadowSoftness: number+shadowStrength: numbersourceAngle: numbertype: LightType```diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex db9b2a077..cd1be6f8d 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -4451,7 +4451,9 @@ drawEnvironment: booleanenabled: booleanenvironment: numberenvironmentRotation: number+falloff: numberinnerAngle: number+innerRadius: numberintensity: numbermeshShadows: booleanouterAngle: number@@ -4459,6 +4461,7 @@ radius: numbershadowDistance: numbershadowExtent: numbershadowSoftness: number+shadowStrength: numbersourceAngle: numbertype: LightType```diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 3f1c98bb0..be6acfcfc 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -4458,7 +4458,9 @@ drawEnvironment: booleanenabled: booleanenvironment: numberenvironmentRotation: number+falloff: numberinnerAngle: number+innerRadius: numberintensity: numbermeshShadows: booleanouterAngle: number@@ -4466,6 +4468,7 @@ radius: numbershadowDistance: numbershadowExtent: numbershadowSoftness: number+shadowStrength: numbersourceAngle: numbertype: LightType```diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex 67a73bc51..c5b24e56b 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -802,6 +802,9 @@ export interface LightPtrData {color: Color;intensity: number;radius: number;+ innerRadius: number;+ falloff: number;+ shadowStrength: number;innerAngle: number;outerAngle: number;shadowSoftness: number;@@ -823,17 +826,20 @@ export function fillLight(const color_ = out.color; color_.r = f32[(ptr + 4) >> 2]; color_.g = f32[((ptr + 4) >> 2) + 1]; color_.b = f32[((ptr + 4) >> 2) + 2]; color_.a = f32[((ptr + 4) >> 2) + 3];out.intensity = f32[(ptr + 20) >> 2];out.radius = f32[(ptr + 24) >> 2];- out.innerAngle = f32[(ptr + 28) >> 2];- out.outerAngle = f32[(ptr + 32) >> 2];- out.shadowSoftness = f32[(ptr + 36) >> 2];- out.sourceAngle = f32[(ptr + 40) >> 2];- out.shadowDistance = f32[(ptr + 44) >> 2];- out.meshShadows = u8[ptr + 48] !== 0;- out.shadowExtent = f32[(ptr + 52) >> 2];- out.environment = u32[(ptr + 56) >> 2];- out.environmentRotation = f32[(ptr + 60) >> 2];- out.drawEnvironment = u8[ptr + 64] !== 0;- out.enabled = u8[ptr + 65] !== 0;+ out.innerRadius = f32[(ptr + 28) >> 2];+ out.falloff = f32[(ptr + 32) >> 2];+ out.shadowStrength = f32[(ptr + 36) >> 2];+ out.innerAngle = f32[(ptr + 40) >> 2];+ out.outerAngle = f32[(ptr + 44) >> 2];+ out.shadowSoftness = f32[(ptr + 48) >> 2];+ out.sourceAngle = f32[(ptr + 52) >> 2];+ out.shadowDistance = f32[(ptr + 56) >> 2];+ out.meshShadows = u8[ptr + 60] !== 0;+ out.shadowExtent = f32[(ptr + 64) >> 2];+ out.environment = u32[(ptr + 68) >> 2];+ out.environmentRotation = f32[(ptr + 72) >> 2];+ out.drawEnvironment = u8[ptr + 76] !== 0;+ out.enabled = u8[ptr + 77] !== 0;}export function writeLight(@@ -844,17 +850,20 @@ export function writeLight(f32[(ptr + 4) >> 2] = data.color.r; f32[((ptr + 4) >> 2) + 1] = data.color.g; f32[((ptr + 4) >> 2) + 2] = data.color.b; f32[((ptr + 4) >> 2) + 3] = data.color.a;f32[(ptr + 20) >> 2] = data.intensity;f32[(ptr + 24) >> 2] = data.radius;- f32[(ptr + 28) >> 2] = data.innerAngle;- f32[(ptr + 32) >> 2] = data.outerAngle;- f32[(ptr + 36) >> 2] = data.shadowSoftness;- f32[(ptr + 40) >> 2] = data.sourceAngle;- f32[(ptr + 44) >> 2] = data.shadowDistance;- u8[ptr + 48] = data.meshShadows ? 1 : 0;- f32[(ptr + 52) >> 2] = data.shadowExtent;- u32[(ptr + 56) >> 2] = data.environment;- f32[(ptr + 60) >> 2] = data.environmentRotation;- u8[ptr + 64] = data.drawEnvironment ? 1 : 0;- u8[ptr + 65] = data.enabled ? 1 : 0;+ f32[(ptr + 28) >> 2] = data.innerRadius;+ f32[(ptr + 32) >> 2] = data.falloff;+ f32[(ptr + 36) >> 2] = data.shadowStrength;+ f32[(ptr + 40) >> 2] = data.innerAngle;+ f32[(ptr + 44) >> 2] = data.outerAngle;+ f32[(ptr + 48) >> 2] = data.shadowSoftness;+ f32[(ptr + 52) >> 2] = data.sourceAngle;+ f32[(ptr + 56) >> 2] = data.shadowDistance;+ u8[ptr + 60] = data.meshShadows ? 1 : 0;+ f32[(ptr + 64) >> 2] = data.shadowExtent;+ u32[(ptr + 68) >> 2] = data.environment;+ f32[(ptr + 72) >> 2] = data.environmentRotation;+ u8[ptr + 76] = data.drawEnvironment ? 1 : 0;+ u8[ptr + 77] = data.enabled ? 1 : 0;}export function createLightData(): LightPtrData {@@ -863,6 +872,9 @@ export function createLightData(): LightPtrData {color: { r: 0, g: 0, b: 0, a: 0 },intensity: 0,radius: 0,+ innerRadius: 0,+ falloff: 0,+ shadowStrength: 0,innerAngle: 0,outerAngle: 0,shadowSoftness: 0,diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex 0e9042051..8144f9165 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, Cl* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = 'f8b3b5501ea0afe4';+export const ABI_LAYOUT_HASH = 'e2362078463a35b5';/*** One asset-valued field of a component: which field, and what kind of@@ -456,6 +456,9 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {color: { r: 1, g: 1, b: 1, a: 1 },intensity: 1,radius: 200,+ innerRadius: 0,+ falloff: 1,+ shadowStrength: 1,innerAngle: 30,outerAngle: 45,shadowSoftness: 0,@@ -472,11 +475,14 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {assetFields: [{ field: 'environment', type: 'environment' as AssetFieldType }],entityFields: [],colorFields: ['color'],- animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerAngle', 'outerAngle', 'shadowSoftness', 'sourceAngle', 'shadowDistance'],+ animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerRadius', 'falloff', 'shadowStrength', 'innerAngle', 'outerAngle', 'shadowSoftness', 'sourceAngle', 'shadowDistance'],fields: {type: { enum: [{ label: 'Point', value: 0 }, { label: 'Directional', value: 1 }, { label: 'Ambient', value: 2 }, { label: 'Spot', value: 3 }], tooltip: "Point, Directional, Ambient, or Spot." },intensity: { min: 0, tooltip: "Brightness multiplier of the light." },radius: { min: 0, tooltip: "Falloff reach in world units (Point / Spot).", shownWhen: { field: "type", values: [0, 3] } },+ innerRadius: { min: 0, tooltip: "Radius held at full strength before the falloff starts.", shownWhen: { field: "type", values: [0, 3] } },+ falloff: { min: 0, max: 8, tooltip: "Falloff shape: 1 = linear, higher pools near the light, lower reaches further.", shownWhen: { field: "type", values: [0, 3] } },+ shadowStrength: { min: 0, max: 1, slider: true, tooltip: "How much of this light its shadows remove (1 = all of it).", shownWhen: { field: "type", values: [0, 1, 3] } },innerAngle: { min: 0, max: 180, unit: "°", advanced: true, shownWhen: { field: "type", values: [3] } },outerAngle: { min: 0, max: 180, unit: "°", advanced: true, shownWhen: { field: "type", values: [3] } },shadowSoftness: { min: 0, tooltip: "Shadow softness (light-source size); 0 = hard edge.", shownWhen: { field: "type", values: [0, 1, 3] } },@@ -1341,6 +1347,9 @@ export interface LightData {color: Color;intensity: number;radius: number;+ innerRadius: number;+ falloff: number;+ shadowStrength: number;innerAngle: number;outerAngle: number;shadowSoftness: number;diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex cde271df0..32948c9c5 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -231,17 +231,20 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'color', type: 'color', offset: 4 },{ name: 'intensity', type: 'f32', offset: 20 },{ name: 'radius', type: 'f32', offset: 24 },- { name: 'innerAngle', type: 'f32', offset: 28 },- { name: 'outerAngle', type: 'f32', offset: 32 },- { name: 'shadowSoftness', type: 'f32', offset: 36 },- { name: 'sourceAngle', type: 'f32', offset: 40 },- { name: 'shadowDistance', type: 'f32', offset: 44 },- { name: 'meshShadows', type: 'bool', offset: 48 },- { name: 'shadowExtent', type: 'f32', offset: 52 },- { name: 'environment', type: 'u32', offset: 56 },- { name: 'environmentRotation', type: 'f32', offset: 60 },- { name: 'drawEnvironment', type: 'bool', offset: 64 },- { name: 'enabled', type: 'bool', offset: 65 },+ { name: 'innerRadius', type: 'f32', offset: 28 },+ { name: 'falloff', type: 'f32', offset: 32 },+ { name: 'shadowStrength', type: 'f32', offset: 36 },+ { name: 'innerAngle', type: 'f32', offset: 40 },+ { name: 'outerAngle', type: 'f32', offset: 44 },+ { name: 'shadowSoftness', type: 'f32', offset: 48 },+ { name: 'sourceAngle', type: 'f32', offset: 52 },+ { name: 'shadowDistance', type: 'f32', offset: 56 },+ { name: 'meshShadows', type: 'bool', offset: 60 },+ { name: 'shadowExtent', type: 'f32', offset: 64 },+ { name: 'environment', type: 'u32', offset: 68 },+ { name: 'environmentRotation', type: 'f32', offset: 72 },+ { name: 'drawEnvironment', type: 'bool', offset: 76 },+ { name: 'enabled', type: 'bool', offset: 77 },],},MeshCollider3D: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex 7a4296d4f..4bec9add1 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -545,6 +545,9 @@ export interface Light {color: Vec4;intensity: number;radius: number;+ innerRadius: number;+ falloff: number;+ shadowStrength: number;innerAngle: number;outerAngle: number;shadowSoftness: number;diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snapindex 14701cfd4..9d7982f90 100644--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap@@ -245,6 +245,18 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho"tooltip": "Turn the environment about the up axis, in degrees.","unit": "deg",},+ "falloff": {+ "max": 8,+ "min": 0,+ "shownWhen": {+ "field": "type",+ "values": [+ 0,+ 3,+ ],+ },+ "tooltip": "Falloff shape: 1 = linear, higher pools near the light, lower reaches further.",+ },"innerAngle": {"advanced": true,"max": 180,@@ -257,6 +269,17 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho},"unit": "°",},+ "innerRadius": {+ "min": 0,+ "shownWhen": {+ "field": "type",+ "values": [+ 0,+ 3,+ ],+ },+ "tooltip": "Radius held at full strength before the falloff starts.",+ },"intensity": {"min": 0,"tooltip": "Brightness multiplier of the light.",@@ -329,6 +352,20 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho},"tooltip": "Shadow softness (light-source size); 0 = hard edge.",},+ "shadowStrength": {+ "max": 1,+ "min": 0,+ "shownWhen": {+ "field": "type",+ "values": [+ 0,+ 1,+ 3,+ ],+ },+ "slider": true,+ "tooltip": "How much of this light its shadows remove (1 = all of it).",+ },"sourceAngle": {"advanced": true,"max": 90,diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex 7f3d6be9d..93db1d7e9 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -2,10 +2,10 @@* @file EditorAPI.generated.cpp* @brief Auto-generated editor API with string-dispatched component access* @details Generated by EHT - DO NOT EDIT- * @schema_hash 62b2c5d11cb4451c+ * @schema_hash cb3769144284aede*/-#define ES_EDITOR_API_SCHEMA_HASH "62b2c5d11cb4451c"+#define ES_EDITOR_API_SCHEMA_HASH "cb3769144284aede"#include <emscripten/bind.h>#include <string>@@ -329,6 +329,9 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"color.a","type":"color","group":"Light"},{"key":"intensity","type":"float","group":"Light"},{"key":"radius","type":"float","group":"Light"},+ {"key":"innerRadius","type":"float","group":"Light"},+ {"key":"falloff","type":"float","group":"Light"},+ {"key":"shadowStrength","type":"float","group":"Light"},{"key":"innerAngle","type":"float","group":"Light"},{"key":"outerAngle","type":"float","group":"Light"},{"key":"shadowSoftness","type":"float","group":"Light"},@@ -1246,6 +1249,9 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::selse if (field == "color.a") { c.color.a = value; }else if (field == "intensity") { c.intensity = value; }else if (field == "radius") { c.radius = value; }+ else if (field == "innerRadius") { c.innerRadius = value; }+ else if (field == "falloff") { c.falloff = value; }+ else if (field == "shadowStrength") { c.shadowStrength = value; }else if (field == "innerAngle") { c.innerAngle = value; }else if (field == "outerAngle") { c.outerAngle = value; }else if (field == "shadowSoftness") { c.shadowSoftness = value; }@@ -1727,6 +1733,9 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "color.a") { return c.color.a; }else if (field == "intensity") { return c.intensity; }else if (field == "radius") { return c.radius; }+ else if (field == "innerRadius") { return c.innerRadius; }+ else if (field == "falloff") { return c.falloff; }+ else if (field == "shadowStrength") { return c.shadowStrength; }else if (field == "innerAngle") { return c.innerAngle; }else if (field == "outerAngle") { return c.outerAngle; }else if (field == "shadowSoftness") { return c.shadowSoftness; }diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex cb66b040c..9e56bd413 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -580,6 +580,9 @@ struct LightJS {glm::vec4 color;f32 intensity;f32 radius;+ f32 innerRadius;+ f32 falloff;+ f32 shadowStrength;f32 innerAngle;f32 outerAngle;f32 shadowSoftness;@@ -598,6 +601,9 @@ void lightApplyJS(esengine::ecs::Light& c, const LightJS& js) {c.color = js.color;c.intensity = js.intensity;c.radius = js.radius;+ c.innerRadius = js.innerRadius;+ c.falloff = js.falloff;+ c.shadowStrength = js.shadowStrength;c.innerAngle = js.innerAngle;c.outerAngle = js.outerAngle;c.shadowSoftness = js.shadowSoftness;@@ -623,6 +629,9 @@ LightJS lightToJS(const esengine::ecs::Light& c) {js.color = c.color;js.intensity = c.intensity;js.radius = c.radius;+ js.innerRadius = c.innerRadius;+ js.falloff = c.falloff;+ js.shadowStrength = c.shadowStrength;js.innerAngle = c.innerAngle;js.outerAngle = c.outerAngle;js.shadowSoftness = c.shadowSoftness;@@ -1601,6 +1610,9 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("color", &LightJS::color).field("intensity", &LightJS::intensity).field("radius", &LightJS::radius)+ .field("innerRadius", &LightJS::innerRadius)+ .field("falloff", &LightJS::falloff)+ .field("shadowStrength", &LightJS::shadowStrength).field("innerAngle", &LightJS::innerAngle).field("outerAngle", &LightJS::outerAngle).field("shadowSoftness", &LightJS::shadowSoftness)@@ -3074,17 +3086,20 @@ static_assert(offsetof(esengine::ecs::Light, type) == 0, "ABI offset drift: esenstatic_assert(offsetof(esengine::ecs::Light, color) == 4, "ABI offset drift: esengine::ecs::Light.color (EHT expected 4)");static_assert(offsetof(esengine::ecs::Light, intensity) == 20, "ABI offset drift: esengine::ecs::Light.intensity (EHT expected 20)");static_assert(offsetof(esengine::ecs::Light, radius) == 24, "ABI offset drift: esengine::ecs::Light.radius (EHT expected 24)");-static_assert(offsetof(esengine::ecs::Light, innerAngle) == 28, "ABI offset drift: esengine::ecs::Light.innerAngle (EHT expected 28)");-static_assert(offsetof(esengine::ecs::Light, outerAngle) == 32, "ABI offset drift: esengine::ecs::Light.outerAngle (EHT expected 32)");-static_assert(offsetof(esengine::ecs::Light, shadowSoftness) == 36, "ABI offset drift: esengine::ecs::Light.shadowSoftness (EHT expected 36)");-static_assert(offsetof(esengine::ecs::Light, sourceAngle) == 40, "ABI offset drift: esengine::ecs::Light.sourceAngle (EHT expected 40)");-static_assert(offsetof(esengine::ecs::Light, shadowDistance) == 44, "ABI offset drift: esengine::ecs::Light.shadowDistance (EHT expected 44)");-static_assert(offsetof(esengine::ecs::Light, meshShadows) == 48, "ABI offset drift: esengine::ecs::Light.meshShadows (EHT expected 48)");-static_assert(offsetof(esengine::ecs::Light, shadowExtent) == 52, "ABI offset drift: esengine::ecs::Light.shadowExtent (EHT expected 52)");-static_assert(offsetof(esengine::ecs::Light, environment) == 56, "ABI offset drift: esengine::ecs::Light.environment (EHT expected 56)");-static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 60, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 60)");-static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 64, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 64)");-static_assert(offsetof(esengine::ecs::Light, enabled) == 65, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 65)");+static_assert(offsetof(esengine::ecs::Light, innerRadius) == 28, "ABI offset drift: esengine::ecs::Light.innerRadius (EHT expected 28)");+static_assert(offsetof(esengine::ecs::Light, falloff) == 32, "ABI offset drift: esengine::ecs::Light.falloff (EHT expected 32)");+static_assert(offsetof(esengine::ecs::Light, shadowStrength) == 36, "ABI offset drift: esengine::ecs::Light.shadowStrength (EHT expected 36)");+static_assert(offsetof(esengine::ecs::Light, innerAngle) == 40, "ABI offset drift: esengine::ecs::Light.innerAngle (EHT expected 40)");+static_assert(offsetof(esengine::ecs::Light, outerAngle) == 44, "ABI offset drift: esengine::ecs::Light.outerAngle (EHT expected 44)");+static_assert(offsetof(esengine::ecs::Light, shadowSoftness) == 48, "ABI offset drift: esengine::ecs::Light.shadowSoftness (EHT expected 48)");+static_assert(offsetof(esengine::ecs::Light, sourceAngle) == 52, "ABI offset drift: esengine::ecs::Light.sourceAngle (EHT expected 52)");+static_assert(offsetof(esengine::ecs::Light, shadowDistance) == 56, "ABI offset drift: esengine::ecs::Light.shadowDistance (EHT expected 56)");+static_assert(offsetof(esengine::ecs::Light, meshShadows) == 60, "ABI offset drift: esengine::ecs::Light.meshShadows (EHT expected 60)");+static_assert(offsetof(esengine::ecs::Light, shadowExtent) == 64, "ABI offset drift: esengine::ecs::Light.shadowExtent (EHT expected 64)");+static_assert(offsetof(esengine::ecs::Light, environment) == 68, "ABI offset drift: esengine::ecs::Light.environment (EHT expected 68)");+static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 72, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 72)");+static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 76, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 76)");+static_assert(offsetof(esengine::ecs::Light, enabled) == 77, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 77)");static_assert(offsetof(esengine::ecs::MeshCollider3D, mesh) == 0, "ABI offset drift: esengine::ecs::MeshCollider3D.mesh (EHT expected 0)");static_assert(offsetof(esengine::ecs::MeshCollider3D, friction) == 4, "ABI offset drift: esengine::ecs::MeshCollider3D.friction (EHT expected 4)");static_assert(offsetof(esengine::ecs::MeshCollider3D, restitution) == 8, "ABI offset drift: esengine::ecs::MeshCollider3D.restitution (EHT expected 8)");@@ -3327,7 +3342,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "f8b3b5501ea0afe4";+static const char* kEsAbiLayoutHash = "e2362078463a35b5";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hppindex 28c694161..5a85fe65f 100644--- a/src/esengine/ecs/components/Light.hpp+++ b/src/esengine/ecs/components/Light.hpp@@ -71,6 +71,31 @@ struct Light {tooltip="Falloff reach in world units (Point / Spot).")f32 radius{200.0f};+ /** @brief How far the light stays at full strength before it starts falling off,+ * in world units. 0 (the default) falls off from the light itself; a+ * value at or past @ref radius is a hard-edged disc. Ignored by+ * Directional/Ambient, which have no distance to fall off over. */+ ES_PROPERTY(animatable, min=0, shown_when=type:Point|Spot,+ tooltip="Radius held at full strength before the falloff starts.")+ f32 innerRadius{0.0f};++ /** @brief The shape of the falloff between @ref innerRadius and @ref radius, as the+ * power the linear ramp is raised to. 1 (the default) IS linear; above it+ * the light pools near its centre, below it it reaches further and ends+ * abruptly. Ignored by Directional/Ambient. */+ ES_PROPERTY(animatable, min=0, max=8, shown_when=type:Point|Spot,+ tooltip="Falloff shape: 1 = linear, higher pools near the light, lower reaches further.")+ f32 falloff{1.0f};++ /** @brief How much of this light a shadow takes away, 0..1. 1 (the default) is the+ * whole of it; 0.7 leaves a shadow that is dark rather than black, which is+ * what a 2D scene with bounce light in it looks like. Applies to both kinds+ * of shadow this light casts. */+ ES_PROPERTY(animatable, min=0, max=1, slider,+ shown_when=type:Point|Directional|Spot,+ tooltip="How much of this light its shadows remove (1 = all of it).")+ f32 shadowStrength{1.0f};+/** @brief Spot inner cone angle in degrees (full angle; fully lit inside). */ES_PROPERTY(animatable, min=0, max=180, unit="°", advanced, shown_when=type:Spot)f32 innerAngle{30.0f};diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex d9aed2b10..b8f767c01 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -1138,6 +1138,12 @@ void RenderFrame::collectLights(ecs::Registry& registry) {// directional branch of shadowFactor2D reads it; 0 keeps directional shadows off).gpu.shadow = glm::vec4(std::max(light.shadowSoftness, 0.0f),std::max(light.shadowDistance, 0.0f), 0.0f, 0.0f);+ // Clamped where it is PACKED: a shader given a negative exponent lights the far+ // side of the radius, and a fragment cannot say who authored it. The shader+ // floors the exponent too — pow(0, 0) is 1, which lights the whole screen.+ gpu.falloff = glm::vec4(std::max(light.innerRadius, 0.0f),+ std::max(light.falloff, 0.0f),+ std::clamp(light.shadowStrength, 0.0f, 1.0f), 0.0f);if (type == ecs::LightType::Directional) {// z=1 flags directional (no attenuation) in the shader; w carries the aim's third// component, which only a directional light has a use for — point and spot spenddiff --git a/src/esengine/renderer/store/LightConstants.hpp b/src/esengine/renderer/store/LightConstants.hppindex 0f2ac827e..e13749c5e 100644--- a/src/esengine/renderer/store/LightConstants.hpp+++ b/src/esengine/renderer/store/LightConstants.hpp@@ -88,38 +88,39 @@ inline constexpr u32 SHADOW_CUBE_FACES = 6;inline constexpr u32 MAX_SHADOW_TILES = 16;/**- * @brief One 2D light, std140-packed (five vec4s, 80 bytes, 16-aligned).- * @details posDir: xy = world position (point/spot) or aim direction (directional); z = type- * (0 = point, 1 = directional, 2 = spot); w = falloff radius in world units for- * point/spot, and the aim's third component for directional — the two never share- * a use for it, which is what lets a sun be aimed out of the plane.- * color: rgb = light color, a = intensity.- * spot: xy = normalized cone axis, z = cos(innerHalfAngle), w = cos(outerHalfAngle)- * (spot only; zero for other types). Ambient lights are folded into- * LightConstants::ambient instead of occupying a slot.- * shadowMap: x = first atlas tile, y = tile count (0 = casts no map).- * shadow: x = penumbra softness (light-source half-extent in world units; 0 = hard,- * backward-compatible); y = directional shadow march distance (world units; 0 = a- * directional light casts no shadow); z = a point/spot light's world height, which- * only a surface with real geometry measures against (MESH_NORMALS); w = a spot's- * cone-axis third component. Read by shadowFactor2D and lightVector/spotCone.+ * @brief One 2D light, std140-packed (six vec4s, 96 bytes, 16-aligned).+ * @details Every lane is spoken for; each field says which. An Ambient light occupies no+ * slot at all — it folds into LightConstants::ambient.*/struct GpuLight {+ /// xy = world position (point/spot) or aim direction (directional); z = the type+ /// (0 point, 1 directional, 2 spot); w = the falloff radius, or a directional aim's+ /// third component — never both, which is what lets a sun aim out of the plane.glm::vec4 posDir{0.0f};+ /// rgb = colour, a = intensity.glm::vec4 color{0.0f};+ /// Spot only, zero otherwise: xy = the cone axis in the plane, z = cos(inner half+ /// angle), w = cos(outer half angle).glm::vec4 spot{0.0f};+ /// x = penumbra softness (the source's half-extent in world units; 0 = hard); y = a+ /// directional light's shadow march distance (0 = it casts none); z = a positional+ /// light's world height, measured against only by real geometry; w = a spot axis' z.glm::vec4 shadow{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.+ /// angle its source subtends, for the map with no distance to divide by (0 for a+ /// light that stands somewhere); w = its 2D mask channel, -1 for none.glm::vec4 shadowMap{0.0f, 0.0f, 0.0f, -1.0f};+ /// How the light ENDS, as opposed to where: x = the radius it holds full strength+ /// out to, y = the power its ramp is raised to (1 = linear), z = how much of it a+ /// shadow removes (1 = all). The defaults ARE the old linear ramp. w unused.+ glm::vec4 falloff{0.0f, 1.0f, 1.0f, 0.0f};};/*** @brief CPU mirror of the GLSL LightConstants block (std140).* @details ambient: rgb = summed ambient color, a = active light count (informational).- * std140 array-of-struct stride is 80 (each GpuLight is five 16-aligned vec4s), so- * lights start at offset 16 and the lights array spans 80*MAX_LIGHTS bytes.+ * std140 array-of-struct stride is 96 (each GpuLight is six 16-aligned vec4s), so+ * lights start at offset 16 and the lights array spans 96*MAX_LIGHTS bytes.*/struct LightConstants {glm::vec4 ambient{0.0f};@@ -152,8 +153,8 @@ struct LightConstants {glm::vec4 envTint{0.0f};};-static_assert(sizeof(GpuLight) == 80, "GpuLight must be std140-tight (five vec4s)");-static_assert(sizeof(LightConstants) == 16 + 80 * MAX_LIGHTS + 16+static_assert(sizeof(GpuLight) == 96, "GpuLight must be std140-tight (six vec4s)");+static_assert(sizeof(LightConstants) == 16 + 96 * 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/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 56ccf34b2..3d0f61ebc 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -828,7 +828,7 @@ fn acesFilmic(x : vec3f) -> vec3f {})";-const char* kLitHeaderWGSL = R"(struct Light { posDir : vec4f, color : vec4f, spot : vec4f, shadow : vec4f, shadowMap : vec4f };+const char* kLitHeaderWGSL = R"(struct Light { posDir : vec4f, color : vec4f, spot : vec4f, shadow : vec4f, shadowMap : vec4f, falloff : vec4f };struct LightConstants {u_ambient : vec4f,u_lights : array<Light, 16>,@@ -1132,6 +1132,13 @@ fn towardLight(toLight : vec3f, N : vec3f) -> vec3f {if (dot(toLight, toLight) > 1e-8) { return normalize(toLight); }return N;}+// The ramp from a light's reach down to nothing. fo.x holds it at full out to its own+// radius; fo.y shapes what is left. The exponent is floored because pow(0, 0) is 1 —+// a light that reaches nowhere would light everything.+fn distanceFalloff(dist : f32, reach : f32, fo : vec4f) -> f32 {+ let ramp = clamp((reach - dist) / max(reach - fo.x, 1e-4), 0.0, 1.0);+ return pow(ramp, max(fo.y, 1e-3));+}fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, metallic : f32,roughness : f32, specular : f32, ao : f32) -> vec3f {let F0 = mix(vec3f(0.04), albedo, vec3f(metallic));@@ -1143,6 +1150,7 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, metalet pd = lc.u_lights[i].posDir;let col = lc.u_lights[i].color;let sh = lc.u_lights[i].shadow;+ let fo = lc.u_lights[i].falloff;var L : vec3f;var atten : f32;var aim = pd.xy;@@ -1150,7 +1158,7 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, metaif (pd.z < 0.5) {let toL = lightVector(pd, sh, worldPos);let dist = lightDistance(toL);- atten = max(0.0, 1.0 - dist / max(pd.w, 0.0001));+ atten = distanceFalloff(dist, max(pd.w, 0.0001), fo);L = towardLight(toL, N);} else if (pd.z < 1.5) {atten = 1.0;@@ -1163,16 +1171,18 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, metalet sp = lc.u_lights[i].spot;let toL = lightVector(pd, sh, worldPos);let dist = lightDistance(toL);- atten = max(0.0, 1.0 - dist / max(pd.w, 0.0001));+ atten = distanceFalloff(dist, max(pd.w, 0.0001), fo);L = towardLight(toL, N);atten *= spotCone(sp, sh, toL, dist);}if (castShadow && col.a > 0.0 && atten > 0.0) {- atten *= shadowFactor2D(lc.u_lights[i].shadowMap.w, worldPos.xy);+ atten *= mix(1.0, shadowFactor2D(lc.u_lights[i].shadowMap.w, worldPos.xy), fo.z);}let sm = lc.u_lights[i].shadowMap;if (sm.y > 0.0 && atten > 0.0) {- atten *= shadowFactor3D(worldPos, N, L, vec2f(sh.x, sm.z), i32(sm.x), i32(sm.y));+ atten *= mix(1.0,+ shadowFactor3D(worldPos, N, L, vec2f(sh.x, sm.z), i32(sm.x), i32(sm.y)),+ fo.z);}let ndotl = max(dot(N, L), 0.0);let radiance = col.rgb * (col.a * ndotl * atten);@@ -1501,7 +1511,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& pif (stage == ShaderStage::Fragment && parsed.domain == "Lit") {static const char* kLitHeader ="struct Light { highp vec4 posDir; highp vec4 color; highp vec4 spot; highp vec4 shadow;"- " highp vec4 shadowMap; };\n"+ " highp vec4 shadowMap; highp vec4 falloff; };\n""layout(std140) uniform LightConstants {\n"" highp vec4 u_ambient;\n"" Light u_lights[16];\n"@@ -1847,6 +1857,14 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p"highp vec3 towardLight(in highp vec3 toLight, in highp vec3 N) {\n"" return dot(toLight, toLight) > 1e-8 ? normalize(toLight) : N;\n""}\n"+ // The ramp from a light's reach down to nothing: fo.x holds it at full out to+ // its own radius, fo.y shapes what is left. The exponent is floored because+ // pow(0, 0) is 1 — a light that reaches nowhere would light everything.+ "highp float distanceFalloff(in highp float dist, in highp float reach,\n"+ " in highp vec4 fo) {\n"+ " highp float ramp = clamp((reach - dist) / max(reach - fo.x, 1e-4), 0.0, 1.0);\n"+ " return pow(ramp, max(fo.y, 1e-3));\n"+ "}\n"// The lighting model in its general form; a lit 2D surface is its zero// (metallic 0, roughness 1, specular 0 leaves albedo * NdotL, pixel for pixel// what this engine has always drawn), so there is one model and not two.@@ -1869,6 +1887,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp vec4 pd = u_lights[i].posDir;\n"" highp vec4 col = u_lights[i].color;\n"" highp vec4 sh = u_lights[i].shadow;\n" // x = penumbra softness, y = directional distance+ " highp vec4 fo = u_lights[i].falloff;\n" // x = inner radius, y = exponent, z = shadow strength" highp vec3 L;\n"" highp float atten;\n"" highp vec2 target = pd.xy;\n" // shadow-ray aim point (light position by default)@@ -1876,7 +1895,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" if (pd.z < 0.5) {\n"" highp vec3 toL = lightVector(pd, sh, worldPos);\n"" highp float dist = lightDistance(toL);\n"- " atten = max(0.0, 1.0 - dist / max(pd.w, 0.0001));\n"+ " atten = distanceFalloff(dist, max(pd.w, 0.0001), fo);\n"" L = towardLight(toL, N);\n"" } else if (pd.z < 1.5) {\n"" atten = 1.0;\n"@@ -1891,22 +1910,22 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp vec4 sp = u_lights[i].spot;\n"" highp vec3 toL = lightVector(pd, sh, worldPos);\n"" highp float dist = lightDistance(toL);\n"- " atten = max(0.0, 1.0 - dist / max(pd.w, 0.0001));\n"+ " atten = distanceFalloff(dist, max(pd.w, 0.0001), fo);\n"" L = towardLight(toL, N);\n"" atten *= spotCone(sp, sh, toL, dist);\n"" }\n"// 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(u_lights[i].shadowMap.w, worldPos.xy);\n"+ " atten *= mix(1.0, shadowFactor2D(u_lights[i].shadowMap.w, worldPos.xy), fo.z);\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 geometry// seen from somewhere no light reaching it is standing." highp vec4 sm = u_lights[i].shadowMap;\n"" if (sm.y > 0.0 && atten > 0.0) {\n"- " atten *= shadowFactor3D(worldPos, N, L, vec2(sh.x, sm.z),\n"- " int(sm.x), int(sm.y));\n"+ " atten *= mix(1.0, shadowFactor3D(worldPos, N, L, vec2(sh.x, sm.z),\n"+ " int(sm.x), int(sm.y)), fo.z);\n"" }\n"" highp float ndotl = max(dot(N, L), 0.0);\n"" highp vec3 radiance = col.rgb * (col.a * ndotl * atten);\n"diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.hindex 695172dde..c76158ad5 100644--- a/tests/aot/generated/conformance/handshake.h+++ b/tests/aot/generated/conformance/handshake.h@@ -1,5 +1,5 @@/* GENERATED by sdk/tests/aot-conformance.test.ts — do not edit. *//* The contract half of the handshake. The width half is the harness. */-#define ES_CONF_EXPECTED_CONTRACT_HASH 0x2d9ebb9002fcf15aULL+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x552e2aec43cbd107ULL/* And which BUILD the artifact beside this one is. */#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULLdiff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.cindex 20c96d870..38bcdb0aa 100644--- a/tests/aot/generated/conformance/systems_decl.c+++ b/tests/aot/generated/conformance/systems_decl.c@@ -10,7 +10,7 @@answer, it is a read of a different field. The address width belongsto the MACHINE, so it mixes in here rather than in the compiler and a32-bit artifact cannot load into a 64-bit host. */-#define ES_ABI_ENGINE_DIGEST 0x2d9ebb9002fcf15aULL+#define ES_ABI_ENGINE_DIGEST 0x552e2aec43cbd107ULLES_EXPORT const uint64_t es_abi_hash =ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex c6baf5571..3bbab00c8 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -392,6 +392,18 @@ export const SCENES = [{ id: "material-instance", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-instance.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-instance.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40}]" } },{ id: "material-texture", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-tex.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-tex.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":50}]" } },{ id: "material-switch", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-sw.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-sw.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":50},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":50}]" } },+ // What a light's reach LOOKS like on the way out. One fixture, one light, three+ // probes along its radius; each gate changes exactly the field it is named for,+ // and the first changes nothing — the linear ramp every scene was written against.+ { id: "light-falloff-linear", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/light-falloff.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/light-falloff.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5833,\"y\":0.5,\"rgb\":[0,186,0],\"tol\":20},{\"x\":0.6667,\"y\":0.5,\"rgb\":[0,114,0],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,51,0],\"tol\":20}]" } },+ // A core held at full strength: the ramp starts AT the inner radius, so the first+ // two probes are only the surface's own angle to the light and the third, half+ // way out the band, keeps half where the linear ramp had it at a quarter.+ { id: "light-falloff-inner", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/light-falloff.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/light-falloff.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":2,\"component\":\"Light\",\"key\":\"innerRadius\",\"value\":100}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5833,\"y\":0.5,\"rgb\":[0,247,0],\"tol\":20},{\"x\":0.6667,\"y\":0.5,\"rgb\":[0,228,0],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,102,0],\"tol\":20}]" } },+ // The same reach, pooled: squaring the ramp darkens every point on it and moves+ // none of them, so a gate that only read the edge could not tell the two apart.+ { id: "light-falloff-curve", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/light-falloff.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/light-falloff.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":2,\"component\":\"Light\",\"key\":\"falloff\",\"value\":2}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5833,\"y\":0.5,\"rgb\":[0,139,0],\"tol\":20},{\"x\":0.6667,\"y\":0.5,\"rgb\":[0,57,0],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,13,0],\"tol\":15}]" } },+// 2D shadows: a ShadowCaster2D box between a light and a lit surface. The// probes sit either side of the wall on the light's axis — lit where the// light reaches, dark where the box is in the way.@@ -401,6 +413,10 @@ export const SCENES = [// light's line is inside an UNTURNED box's shadow and outside this one's,// and a turn the other way would put it back in.{ id: "shadow2d-turned", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-lit-shadow-turned.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-lit-shadow-turned.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.7332,\"rgb\":[0,149,0],\"tol\":60}]" } },+ // A shadow that takes only half the light. The same scene as shadow2d-hard, whose+ // shadowed probe is black — half of it is the whole point, and 0 there would mean+ // the strength never reached the light.+ { id: "shadow2d-strength", 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: "3", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":2,\"component\":\"Light\",\"key\":\"shadowStrength\",\"value\":0.5}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":60},{\"x\":0.75,\"y\":0.5,\"rgb\":[0,75,0],\"tol\":25}]" } },// An occluder with an OUTLINE of its own: a triangle whose shadow reaches where// the box beside it (20 units, and still authored) never could. The lower probe// is the discriminating one — lit the moment the outline stops being read.