Skip to content

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.

feat(render): a 2D light can take the shape of a texture

esengine611654c93aad
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70930ceeb..054f3c8d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,18 @@ published separately; it ships inside the editor.
### Added
+- **A 2D light can take the shape of a texture.** Every light was a circle or a cone,
+ and a lantern's ragged glow or a window's shaft was not expressible at all. `Light.cookie`
+ is a texture whose ALPHA is the shape: drawn where the light is, turned by its entity,
+ sized by `cookieSize` or by the light's own reach, and multiplied into the falloff
+ rather than replacing it — so a shaped light still fades out at `radius`.
+
+ It is drawn into a screen-space mask, a channel per shaped light, which is the machine
+ the 2D shadows already are: one quad per light instead of a texture slot per light, and
+ any number of distinct cookies without an atlas to pack them into. Four shaped lights
+ fit a frame; past that a light lights without a shape, the way a fifth caster keeps
+ lighting without casting.
+
- **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
diff --git a/desktop b/desktop
index f7be32701..e07acb39e 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit f7be32701a9e470a4c81c5528a8ff425f9d101fc
+Subproject commit e07acb39ebd1494504bf1ea7b1095e35d93cd5ad
diff --git a/docs/astro/src/content/docs/graphics/lighting.mdx b/docs/astro/src/content/docs/graphics/lighting.mdx
index aeca7a0c8..a57a236a0 100644
--- a/docs/astro/src/content/docs/graphics/lighting.mdx
+++ b/docs/astro/src/content/docs/graphics/lighting.mdx
@@ -49,6 +49,8 @@ const addSun = defineSystem([Commands()], (cmds) => {
| `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. |
+| `cookie` | — | A texture whose **alpha** is this light's shape (Point / Spot). |
+| `cookieSize` | `{0,0}` | How big the cookie is drawn, in world units; `0` covers the light's own reach. |
| `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. |
@@ -101,6 +103,32 @@ entity.insert(Light, {
Both default to the straight line, so a scene written before them renders exactly as it
did.
+## Giving a light a shape
+
+A light is a circle, or a cone. Real ones are neither: a lantern throws a ragged glow, a
+window throws a shaft, a torch flickers in a shape a falloff curve cannot describe. Hand
+a light a **`cookie`** — a texture whose alpha is the shape — and that is what it lights.
+
+```ts
+entity.insert(Light, {
+ type: LightType.Point, radius: 300, intensity: 1.6,
+ cookie: 'assets/textures/lantern-glow.png',
+});
+```
+
+- **The alpha is the shape.** The cookie's colour is not read: a light's colour is the
+ light's, and two places to set it is one too many.
+- **It is drawn where the light is**, turned by the entity's rotation and sized by
+ `cookieSize` — or, when that is zero, covering the light's own reach.
+- It **multiplies** the falloff rather than replacing it, so a shaped light still fades
+ out at `radius` and still respects `innerRadius` and `falloff`.
+- **Four shaped lights fit a frame.** Past that a light lights the scene without a shape,
+ the same way a fifth shadow-caster keeps lighting without casting.
+
+The shape is drawn into a screen-space mask, one channel per shaped light — the same
+machine the 2D shadows use, which is why a cookie costs one quad rather than a texture
+slot per light.
+
## Making a renderer receive light
By default a `Sprite` draws with an **unlit** material and ignores every light. The
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index 0013e162f..c2848e076 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -1955,6 +1955,19 @@
"doc": "How much of this light its shadows remove (1 = all of it).",
"range": "0–1"
},
+ {
+ "key": "cookie",
+ "type": "Asset<texture>",
+ "default": "none",
+ "doc": "A texture whose alpha shapes this light (a cookie)."
+ },
+ {
+ "key": "cookieSize",
+ "type": "Vec2",
+ "default": "(0, 0)",
+ "doc": "Cookie size in world units; 0 = the light's own reach.",
+ "range": "≥ 0"
+ },
{
"key": "innerAngle",
"type": "number",
@@ -2040,6 +2053,8 @@
"innerRadius",
"falloff",
"shadowStrength",
+ "cookieSize.x",
+ "cookieSize.y",
"innerAngle",
"outerAngle",
"shadowSoftness",
diff --git a/fixtures/scenes/light-cookie.esscene b/fixtures/scenes/light-cookie.esscene
new file mode 100644
index 000000000..b3e1a55e0
--- /dev/null
+++ b/fixtures/scenes/light-cookie.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": "ShapedLight",
+ "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": 400,
+ "cookie": "/scenes/light-cookie/cookie.png",
+ "cookieSize": { "x": 400, "y": 400 },
+ "shadowSoftness": 0
+ }
+ }
+ ],
+ "visible": true
+ }
+ ]
+}
diff --git a/fixtures/scenes/light-cookie.textures.json b/fixtures/scenes/light-cookie.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/fixtures/scenes/light-cookie.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/fixtures/scenes/light-cookie/cookie.png b/fixtures/scenes/light-cookie/cookie.png
new file mode 100644
index 000000000..eab6fe0c3
Binary files /dev/null and b/fixtures/scenes/light-cookie/cookie.png differ
diff --git a/fixtures/scenes/mat-builtin-lit/lit.esshader b/fixtures/scenes/mat-builtin-lit/lit.esshader
index 18222740c..8f31d60f9 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: 76a4f0aa490853a2
+// assembled-hash: a3fdbc8ad17bed89
struct 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: 76a4f0aa490853a2
+// assembled-hash: a3fdbc8ad17bed89
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -127,7 +127,7 @@ struct Light {
struct LightConstants {
u_ambient: vec4<f32>,
u_lights: array<Light, 16>,
- u_shadow2DRect: vec4<f32>,
+ u_mask2DRect: vec4<f32>,
u_shadowMatrix: array<mat4x4<f32>, 16>,
u_shadowTile: array<vec4<f32>, 16>,
u_shadowParams: vec4<f32>,
@@ -153,6 +153,10 @@ var<uniform> unnamed_1: LightConstants;
var u_shadow2D_est: texture_2d<f32>;
@group(1) @binding(15)
var u_shadow2D_ess: sampler;
+@group(1) @binding(6)
+var u_lightShape2D_est: texture_2d<f32>;
+@group(1) @binding(14)
+var u_lightShape2D_ess: sampler;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -212,181 +216,238 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e96 = unnamed_1.u_envParams[0u];
- if (_e96 < 0.5f) {
- let _e99 = unnamed_1.u_ambient;
- return _e99.xyz;
+ let _e99 = unnamed_1.u_envParams[0u];
+ if (_e99 < 0.5f) {
+ let _e102 = unnamed_1.u_ambient;
+ return _e102.xyz;
}
- let _e101 = (*roughness);
- let _e105 = unnamed_1.u_envParams[2u];
- lod = (clamp(_e101, 0f, 1f) * _e105);
- let _e107 = lod;
- lo = floor(_e107);
- let _e109 = (*R_1);
- param = _e109;
- let _e110 = lo;
- param_1 = _e110;
- let _e111 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
- a = _e111;
- let _e112 = lo;
- let _e116 = unnamed_1.u_envParams[2u];
- let _e118 = (*R_1);
- param_2 = _e118;
- param_3 = min((_e112 + 1f), _e116);
- let _e119 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
- b = _e119;
- let _e121 = unnamed_1.u_ambient;
- let _e123 = a;
- let _e124 = b;
- let _e125 = lod;
- let _e126 = lo;
- let _e131 = unnamed_1.u_envTint;
- return (_e121.xyz + (mix(_e123, _e124, vec3((_e125 - _e126))) * _e131.xyz));
+ let _e104 = (*roughness);
+ let _e108 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e104, 0f, 1f) * _e108);
+ let _e110 = lod;
+ lo = floor(_e110);
+ let _e112 = (*R_1);
+ param = _e112;
+ let _e113 = lo;
+ param_1 = _e113;
+ let _e114 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e114;
+ let _e115 = lo;
+ let _e119 = unnamed_1.u_envParams[2u];
+ let _e121 = (*R_1);
+ param_2 = _e121;
+ param_3 = min((_e115 + 1f), _e119);
+ let _e122 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e122;
+ let _e124 = unnamed_1.u_ambient;
+ let _e126 = a;
+ let _e127 = b;
+ let _e128 = lod;
+ let _e129 = lo;
+ let _e134 = unnamed_1.u_envTint;
+ return (_e124.xyz + (mix(_e126, _e127, vec3((_e128 - _e129))) * _e134.xyz));
}
fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {
var r: vec4<f32>;
var a_1: f32;
- let _e88 = (*roughness_1);
- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e88) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
- let _e92 = r[0u];
- let _e94 = r[0u];
- let _e96 = (*NdotV);
- let _e101 = r[0u];
- let _e104 = r[1u];
- a_1 = ((min((_e92 * _e94), exp2((-9.28f * _e96))) * _e101) + _e104);
- let _e106 = a_1;
- let _e108 = r;
- return ((vec2<f32>(-1.04f, 1.04f) * _e106) + _e108.zw);
+ let _e91 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e91) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e95 = r[0u];
+ let _e97 = r[0u];
+ let _e99 = (*NdotV);
+ let _e104 = r[0u];
+ let _e107 = r[1u];
+ a_1 = ((min((_e95 * _e97), exp2((-9.28f * _e99))) * _e104) + _e107);
+ let _e109 = a_1;
+ let _e111 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e109) + _e111.zw);
}
fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e86 = (*F0_);
- let _e87 = (*F0_);
- let _e89 = (*VdotH);
- return (_e86 + ((vec3<f32>(1f, 1f, 1f) - _e87) * pow((1f - _e89), 5f)));
+ let _e89 = (*F0_);
+ let _e90 = (*F0_);
+ let _e92 = (*VdotH);
+ return (_e89 + ((vec3<f32>(1f, 1f, 1f) - _e90) * pow((1f - _e92), 5f)));
}
fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {
var k: f32;
- let _e88 = (*roughness_2);
- let _e90 = (*roughness_2);
- k = (((_e88 + 1f) * (_e90 + 1f)) * 0.125f);
- let _e94 = (*NdotV_1);
- let _e95 = (*NdotV_1);
- let _e96 = k;
+ let _e91 = (*roughness_2);
+ let _e93 = (*roughness_2);
+ k = (((_e91 + 1f) * (_e93 + 1f)) * 0.125f);
+ let _e97 = (*NdotV_1);
+ let _e98 = (*NdotV_1);
let _e99 = k;
- let _e102 = (*NdotL);
- let _e103 = (*NdotL);
- let _e104 = k;
+ let _e102 = k;
+ let _e105 = (*NdotL);
+ let _e106 = (*NdotL);
let _e107 = k;
- return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));
+ let _e110 = k;
+ return ((_e97 / ((_e98 * (1f - _e99)) + _e102)) * (_e105 / ((_e106 * (1f - _e107)) + _e110)));
}
fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {
var a2_: f32;
var d: f32;
- let _e88 = (*a_2);
- let _e89 = (*a_2);
- a2_ = (_e88 * _e89);
- let _e91 = (*NdotH);
- let _e92 = (*NdotH);
- let _e94 = a2_;
- d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);
- let _e98 = a2_;
- let _e99 = d;
- let _e101 = d;
- return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));
+ let _e91 = (*a_2);
+ let _e92 = (*a_2);
+ a2_ = (_e91 * _e92);
+ let _e94 = (*NdotH);
+ let _e95 = (*NdotH);
+ let _e97 = a2_;
+ d = (((_e94 * _e95) * (_e97 - 1f)) + 1f);
+ let _e101 = a2_;
+ let _e102 = d;
+ let _e104 = d;
+ return (_e101 / max(((3.1415927f * _e102) * _e104), 0.0000001f));
}
fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {
return 1f;
}
-fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {
+fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel: ptr<function, f32>) -> f32 {
+ var local: f32;
+ var local_1: f32;
+ var local_2: f32;
+
+ let _e92 = (*channel);
+ if (_e92 < 0.5f) {
+ let _e95 = (*m)[0u];
+ local = _e95;
+ } else {
+ let _e96 = (*channel);
+ if (_e96 < 1.5f) {
+ let _e99 = (*m)[1u];
+ local_1 = _e99;
+ } else {
+ let _e100 = (*channel);
+ if (_e100 < 2.5f) {
+ let _e103 = (*m)[2u];
+ local_2 = _e103;
+ } else {
+ let _e105 = (*m)[3u];
+ local_2 = _e105;
+ }
+ let _e106 = local_2;
+ local_1 = _e106;
+ }
+ let _e107 = local_1;
+ local = _e107;
+ }
+ let _e108 = local;
+ return _e108;
+}
+
+fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var clip: vec4<f32>;
var ndc: vec2<f32>;
var v: f32;
- var local: f32;
+ var local_3: f32;
+
+ let _e93 = unnamed.u_projection;
+ let _e94 = (*worldPos_1);
+ clip = (_e93 * vec4<f32>(_e94.x, _e94.y, 0f, 1f));
+ let _e100 = clip[3u];
+ if (_e100 <= 0f) {
+ return vec2<f32>(-1f, -1f);
+ }
+ let _e102 = clip;
+ let _e105 = clip[3u];
+ ndc = (((_e102.xy / vec2(_e105)) * 0.5f) + vec2(0.5f));
+ let _e113 = unnamed_1.u_mask2DRect[3u];
+ if (_e113 < 0f) {
+ let _e116 = ndc[1u];
+ local_3 = (1f - _e116);
+ } else {
+ let _e119 = ndc[1u];
+ local_3 = _e119;
+ }
+ let _e120 = local_3;
+ v = _e120;
+ let _e122 = unnamed_1.u_mask2DRect;
+ let _e125 = ndc[0u];
+ let _e128 = unnamed_1.u_mask2DRect[2u];
+ let _e130 = v;
+ let _e133 = unnamed_1.u_mask2DRect[3u];
+ return (_e122.xy + vec2<f32>((_e125 * _e128), (_e130 * abs(_e133))));
+}
+
+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
var uv: vec2<f32>;
- var m: vec4<f32>;
+ var param_4: vec2<f32>;
var hidden: f32;
- var local_1: f32;
- var local_2: f32;
- var local_3: f32;
- var phi_200_: bool;
-
- let _e96 = (*channel);
- let _e97 = (_e96 < 0f);
- phi_200_ = _e97;
- if !(_e97) {
- let _e101 = unnamed_1.u_shadow2DRect[2u];
- phi_200_ = (_e101 <= 0f);
+ var param_5: vec4<f32>;
+ var param_6: f32;
+ var phi_307_: bool;
+
+ let _e94 = (*channel_1);
+ let _e95 = (_e94 < 0f);
+ phi_307_ = _e95;
+ if !(_e95) {
+ let _e99 = unnamed_1.u_mask2DRect[2u];
+ phi_307_ = (_e99 <= 0f);
}
- let _e104 = phi_200_;
- if _e104 {
+ let _e102 = phi_307_;
+ if _e102 {
return 1f;
}
- let _e106 = unnamed.u_projection;
- let _e107 = (*worldPos_1);
- clip = (_e106 * vec4<f32>(_e107.x, _e107.y, 0f, 1f));
- let _e113 = clip[3u];
- if (_e113 <= 0f) {
+ let _e103 = (*worldPos_2);
+ param_4 = _e103;
+ let _e104 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e104;
+ let _e106 = uv[0u];
+ if (_e106 < 0f) {
return 1f;
}
- let _e115 = clip;
- let _e118 = clip[3u];
- ndc = (((_e115.xy / vec2(_e118)) * 0.5f) + vec2(0.5f));
- let _e126 = unnamed_1.u_shadow2DRect[3u];
- if (_e126 < 0f) {
- let _e129 = ndc[1u];
- local = (1f - _e129);
- } else {
- let _e132 = ndc[1u];
- local = _e132;
+ let _e108 = uv;
+ let _e109 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e108, 0f);
+ param_5 = _e109;
+ let _e110 = (*channel_1);
+ param_6 = _e110;
+ let _e111 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e111;
+ let _e112 = hidden;
+ return (1f - min(_e112, 1f));
+}
+
+fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
+ var uv_1: vec2<f32>;
+ var param_7: vec2<f32>;
+ var param_8: vec4<f32>;
+ var param_9: f32;
+ var phi_346_: bool;
+
+ let _e93 = (*channel_2);
+ let _e94 = (_e93 < 0f);
+ phi_346_ = _e94;
+ if !(_e94) {
+ let _e98 = unnamed_1.u_mask2DRect[2u];
+ phi_346_ = (_e98 <= 0f);
}
- let _e133 = local;
- v = _e133;
- let _e135 = unnamed_1.u_shadow2DRect;
- let _e138 = ndc[0u];
- let _e141 = unnamed_1.u_shadow2DRect[2u];
- let _e143 = v;
- let _e146 = unnamed_1.u_shadow2DRect[3u];
- uv = (_e135.xy + vec2<f32>((_e138 * _e141), (_e143 * abs(_e146))));
- let _e151 = uv;
- let _e152 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e151, 0f);
- m = _e152;
- let _e153 = (*channel);
- if (_e153 < 0.5f) {
- let _e156 = m[0u];
- local_1 = _e156;
- } else {
- let _e157 = (*channel);
- if (_e157 < 1.5f) {
- let _e160 = m[1u];
- local_2 = _e160;
- } else {
- let _e161 = (*channel);
- if (_e161 < 2.5f) {
- let _e164 = m[2u];
- local_3 = _e164;
- } else {
- let _e166 = m[3u];
- local_3 = _e166;
- }
- let _e167 = local_3;
- local_2 = _e167;
- }
- let _e168 = local_2;
- local_1 = _e168;
+ let _e101 = phi_346_;
+ if _e101 {
+ return 1f;
}
- let _e169 = local_1;
- hidden = _e169;
- let _e170 = hidden;
- return (1f - min(_e170, 1f));
+ let _e102 = (*worldPos_3);
+ param_7 = _e102;
+ let _e103 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e103;
+ let _e105 = uv_1[0u];
+ if (_e105 < 0f) {
+ return 1f;
+ }
+ let _e107 = uv_1;
+ let _e108 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e107, 0f);
+ param_8 = _e108;
+ let _e109 = (*channel_2);
+ param_9 = _e109;
+ let _e110 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e110, 1f);
}
fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {
@@ -395,74 +456,74 @@ fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<
var toFrag: vec2<f32>;
var local_5: vec2<f32>;
- let _e92 = (*sp);
- let _e94 = (*sp);
- if (dot(_e92.xy, _e94.xy) > 0.00000001f) {
- let _e98 = (*sp);
- local_4 = normalize(_e98.xy);
+ let _e95 = (*sp);
+ let _e97 = (*sp);
+ if (dot(_e95.xy, _e97.xy) > 0.00000001f) {
+ let _e101 = (*sp);
+ local_4 = normalize(_e101.xy);
} else {
local_4 = vec2<f32>(0f, -1f);
}
- let _e101 = local_4;
- axis = _e101;
- let _e102 = (*dist);
- if (_e102 > 0.0001f) {
- let _e104 = (*toLight);
- let _e107 = (*dist);
- local_5 = (-(_e104.xy) / vec2(_e107));
+ let _e104 = local_4;
+ axis = _e104;
+ let _e105 = (*dist);
+ if (_e105 > 0.0001f) {
+ let _e107 = (*toLight);
+ let _e110 = (*dist);
+ local_5 = (-(_e107.xy) / vec2(_e110));
} else {
- let _e110 = axis;
- local_5 = _e110;
+ let _e113 = axis;
+ local_5 = _e113;
}
- let _e111 = local_5;
- toFrag = _e111;
- let _e113 = (*sp)[3u];
- let _e115 = (*sp)[2u];
- let _e116 = axis;
- let _e117 = toFrag;
- return smoothstep(_e113, _e115, dot(_e116, _e117));
+ let _e114 = local_5;
+ toFrag = _e114;
+ let _e116 = (*sp)[3u];
+ let _e118 = (*sp)[2u];
+ let _e119 = axis;
+ let _e120 = toFrag;
+ return smoothstep(_e116, _e118, dot(_e119, _e120));
}
fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_6: vec3<f32>;
- let _e87 = (*toLight_1);
- let _e88 = (*toLight_1);
- if (dot(_e87, _e88) > 0.00000001f) {
- let _e91 = (*toLight_1);
- local_6 = normalize(_e91);
+ let _e90 = (*toLight_1);
+ let _e91 = (*toLight_1);
+ if (dot(_e90, _e91) > 0.00000001f) {
+ let _e94 = (*toLight_1);
+ local_6 = normalize(_e94);
} else {
- let _e93 = (*N_1);
- local_6 = _e93;
+ let _e96 = (*N_1);
+ local_6 = _e96;
}
- let _e94 = local_6;
- return _e94;
+ let _e97 = local_6;
+ return _e97;
}
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));
+ let _e92 = (*dist_1);
+ let _e94 = (*reach);
+ let _e96 = (*fo)[0u];
+ ramp = clamp(((_e91 - _e92) / max((_e94 - _e96), 0.0001f)), 0f, 1f);
+ let _e101 = ramp;
+ let _e103 = (*fo)[1u];
+ return pow(_e101, max(_e103, 0.001f));
}
fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {
- let _e85 = (*toLight_2);
- return length(_e85.xy);
+ let _e88 = (*toLight_2);
+ return length(_e88.xy);
}
-fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e87 = (*pd);
- let _e89 = (*worldPos_2);
- let _e91 = (_e87.xy - _e89.xy);
- let _e93 = (*pd)[3u];
- return vec3<f32>(_e91.x, _e91.y, max(_e93, 1f));
+fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e90 = (*pd);
+ let _e92 = (*worldPos_4);
+ let _e94 = (_e90.xy - _e92.xy);
+ let _e96 = (*pd)[3u];
+ return vec3<f32>(_e94.x, _e94.y, max(_e96, 1f));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -470,70 +531,70 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- let _e90 = unnamed_1.u_envTint[3u];
- a_3 = -(_e90);
- let _e92 = a_3;
- s = sin(_e92);
- let _e94 = a_3;
- c = cos(_e94);
- let _e96 = c;
- let _e98 = (*d_1)[0u];
- let _e100 = s;
- let _e102 = (*d_1)[2u];
- let _e106 = (*d_1)[1u];
- let _e107 = s;
- let _e110 = (*d_1)[0u];
- let _e112 = c;
- let _e114 = (*d_1)[2u];
- return vec3<f32>(((_e96 * _e98) + (_e100 * _e102)), _e106, ((-(_e107) * _e110) + (_e112 * _e114)));
+ let _e93 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e93);
+ let _e95 = a_3;
+ s = sin(_e95);
+ let _e97 = a_3;
+ c = cos(_e97);
+ let _e99 = c;
+ let _e101 = (*d_1)[0u];
+ let _e103 = s;
+ let _e105 = (*d_1)[2u];
+ let _e109 = (*d_1)[1u];
+ let _e110 = s;
+ let _e113 = (*d_1)[0u];
+ let _e115 = c;
+ let _e117 = (*d_1)[2u];
+ return vec3<f32>(((_e99 * _e101) + (_e103 * _e105)), _e109, ((-(_e110) * _e113) + (_e115 * _e117)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
var N_2: vec3<f32>;
- var param_4: vec3<f32>;
+ var param_10: vec3<f32>;
var sh_2: vec3<f32>;
- let _e88 = (*Nw);
- param_4 = _e88;
- let _e89 = envDirection_u0028_vf3_u003b((&param_4));
- N_2 = _e89;
- let _e92 = unnamed_1.u_envIrradiance[0i];
- let _e97 = unnamed_1.u_envIrradiance[1i];
- let _e100 = N_2[1u];
- let _e106 = unnamed_1.u_envIrradiance[2i];
- let _e109 = N_2[2u];
- let _e115 = unnamed_1.u_envIrradiance[3i];
- let _e118 = N_2[0u];
- let _e124 = unnamed_1.u_envIrradiance[4i];
- let _e127 = N_2[0u];
- let _e130 = N_2[1u];
- let _e136 = unnamed_1.u_envIrradiance[5i];
- let _e139 = N_2[1u];
- let _e142 = N_2[2u];
- let _e148 = unnamed_1.u_envIrradiance[6i];
- let _e151 = N_2[2u];
+ let _e91 = (*Nw);
+ param_10 = _e91;
+ let _e92 = envDirection_u0028_vf3_u003b((&param_10));
+ N_2 = _e92;
+ let _e95 = unnamed_1.u_envIrradiance[0i];
+ let _e100 = unnamed_1.u_envIrradiance[1i];
+ let _e103 = N_2[1u];
+ let _e109 = unnamed_1.u_envIrradiance[2i];
+ let _e112 = N_2[2u];
+ let _e118 = unnamed_1.u_envIrradiance[3i];
+ let _e121 = N_2[0u];
+ let _e127 = unnamed_1.u_envIrradiance[4i];
+ let _e130 = N_2[0u];
+ let _e133 = N_2[1u];
+ let _e139 = unnamed_1.u_envIrradiance[5i];
+ let _e142 = N_2[1u];
+ let _e145 = N_2[2u];
+ let _e151 = unnamed_1.u_envIrradiance[6i];
let _e154 = N_2[2u];
- let _e162 = unnamed_1.u_envIrradiance[7i];
- let _e165 = N_2[0u];
- let _e168 = N_2[2u];
- let _e174 = unnamed_1.u_envIrradiance[8i];
- let _e177 = N_2[0u];
- let _e179 = N_2[0u];
- let _e182 = N_2[1u];
- let _e184 = N_2[1u];
- sh_2 = (((((((((_e92.xyz * 0.282095f) + (_e97.xyz * (0.488603f * _e100))) + (_e106.xyz * (0.488603f * _e109))) + (_e115.xyz * (0.488603f * _e118))) + (_e124.xyz * ((1.092548f * _e127) * _e130))) + (_e136.xyz * ((1.092548f * _e139) * _e142))) + (_e148.xyz * (0.315392f * (((3f * _e151) * _e154) - 1f)))) + (_e162.xyz * ((1.092548f * _e165) * _e168))) + (_e174.xyz * (0.546274f * ((_e177 * _e179) - (_e182 * _e184)))));
- let _e191 = unnamed_1.u_ambient;
- let _e193 = sh_2;
- let _e196 = unnamed_1.u_envTint;
- return (_e191.xyz + (max(_e193, vec3<f32>(0f, 0f, 0f)) * _e196.xyz));
-}
-
-fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
+ let _e157 = N_2[2u];
+ let _e165 = unnamed_1.u_envIrradiance[7i];
+ let _e168 = N_2[0u];
+ let _e171 = N_2[2u];
+ let _e177 = unnamed_1.u_envIrradiance[8i];
+ let _e180 = N_2[0u];
+ let _e182 = N_2[0u];
+ let _e185 = N_2[1u];
+ let _e187 = N_2[1u];
+ sh_2 = (((((((((_e95.xyz * 0.282095f) + (_e100.xyz * (0.488603f * _e103))) + (_e109.xyz * (0.488603f * _e112))) + (_e118.xyz * (0.488603f * _e121))) + (_e127.xyz * ((1.092548f * _e130) * _e133))) + (_e139.xyz * ((1.092548f * _e142) * _e145))) + (_e151.xyz * (0.315392f * (((3f * _e154) * _e157) - 1f)))) + (_e165.xyz * ((1.092548f * _e168) * _e171))) + (_e177.xyz * (0.546274f * ((_e180 * _e182) - (_e185 * _e187)))));
+ let _e194 = unnamed_1.u_ambient;
+ let _e196 = sh_2;
+ let _e199 = unnamed_1.u_envTint;
+ return (_e194.xyz + (max(_e196, vec3<f32>(0f, 0f, 0f)) * _e199.xyz));
+}
+
+fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
var F0_1: vec3<f32>;
var a_4: f32;
var NdotV_2: f32;
var lit: vec3<f32>;
- var param_5: vec3<f32>;
+ var param_11: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
@@ -543,421 +604,434 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0
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 param_12: vec4<f32>;
+ var param_13: vec4<f32>;
+ var param_14: vec3<f32>;
var dist_2: f32;
- var param_9: vec3<f32>;
+ var param_15: vec3<f32>;
var atten: f32;
- var param_10: f32;
- var param_11: f32;
- var param_12: vec4<f32>;
+ var param_16: f32;
+ var param_17: f32;
+ var param_18: vec4<f32>;
var L_1: vec3<f32>;
- var param_13: vec3<f32>;
- var param_14: vec3<f32>;
+ var param_19: vec3<f32>;
+ var param_20: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_15: vec4<f32>;
- var param_16: vec4<f32>;
- var param_17: 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_22: vec4<f32>;
var param_23: vec3<f32>;
- var param_24: vec4<f32>;
- var param_25: vec4<f32>;
- var param_26: vec3<f32>;
- var param_27: f32;
- var param_28: f32;
- var param_29: vec2<f32>;
- var sm: vec4<f32>;
- var param_30: vec3<f32>;
- var param_31: vec3<f32>;
+ var dist_3: f32;
+ var param_24: vec3<f32>;
+ var param_25: f32;
+ var param_26: f32;
+ var param_27: vec4<f32>;
+ var param_28: vec3<f32>;
+ var param_29: vec3<f32>;
+ var param_30: vec4<f32>;
+ var param_31: vec4<f32>;
var param_32: vec3<f32>;
- var param_33: vec2<f32>;
- var param_34: i32;
- var param_35: i32;
+ var param_33: f32;
+ var param_34: f32;
+ var param_35: vec2<f32>;
+ var param_36: f32;
+ var param_37: vec2<f32>;
+ var sm: vec4<f32>;
+ var param_38: vec3<f32>;
+ var param_39: vec3<f32>;
+ var param_40: vec3<f32>;
+ var param_41: vec2<f32>;
+ var param_42: i32;
+ var param_43: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_36: f32;
- var param_37: f32;
- var param_38: f32;
- var param_39: f32;
- var param_40: f32;
- 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_45: 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((&param_5));
- let _e175 = (*ao);
- lit = (_e174 * _e175);
+ var param_47: f32;
+ var param_48: f32;
+ var param_49: f32;
+ var param_50: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_51: f32;
+ var param_52: f32;
+ var param_53: vec3<f32>;
+ var param_54: f32;
+ var phi_905_: bool;
+ var phi_978_: bool;
+
+ let _e166 = (*albedo);
+ let _e167 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e166, vec3(_e167));
+ let _e170 = (*roughness_3);
+ let _e171 = (*roughness_3);
+ a_4 = max((_e170 * _e171), 0.001f);
+ let _e174 = (*N_3);
+ let _e175 = (*V);
+ NdotV_2 = max(dot(_e174, _e175), 0.0001f);
+ let _e178 = (*N_3);
+ param_11 = _e178;
+ let _e179 = envIrradiance_u0028_vf3_u003b((&param_11));
+ let _e180 = (*ao);
+ lit = (_e179 * _e180);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e177 = i;
- if (_e177 < 16i) {
- let _e179 = i;
- let _e183 = unnamed_1.u_lights[_e179].posDir;
- pd_1 = _e183;
+ let _e182 = i;
+ if (_e182 < 16i) {
let _e184 = i;
- let _e188 = unnamed_1.u_lights[_e184].color;
- col = _e188;
+ let _e188 = unnamed_1.u_lights[_e184].posDir;
+ pd_1 = _e188;
let _e189 = i;
- let _e193 = unnamed_1.u_lights[_e189].shadow;
- sh_3 = _e193;
+ let _e193 = unnamed_1.u_lights[_e189].color;
+ col = _e193;
let _e194 = i;
- let _e198 = unnamed_1.u_lights[_e194].falloff;
- fo_1 = _e198;
- let _e199 = pd_1;
- target_ = _e199.xy;
+ let _e198 = unnamed_1.u_lights[_e194].shadow;
+ sh_3 = _e198;
+ let _e199 = i;
+ let _e203 = unnamed_1.u_lights[_e199].falloff;
+ fo_1 = _e203;
+ let _e204 = pd_1;
+ target_ = _e204.xy;
castShadow = true;
- 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((&param_6), (&param_7), (&param_8));
- toL = _e207;
- let _e208 = toL;
- param_9 = _e208;
- let _e209 = lightDistance_u0028_vf3_u003b((&param_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((&param_10), (&param_11), (&param_12));
- atten = _e215;
- let _e216 = toL;
- param_13 = _e216;
- let _e217 = (*N_3);
- param_14 = _e217;
- let _e218 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_13), (&param_14));
- L_1 = _e218;
+ let _e207 = pd_1[2u];
+ if (_e207 < 0.5f) {
+ let _e209 = pd_1;
+ param_12 = _e209;
+ let _e210 = sh_3;
+ param_13 = _e210;
+ let _e211 = (*worldPos_5);
+ param_14 = _e211;
+ let _e212 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_12), (&param_13), (&param_14));
+ toL = _e212;
+ let _e213 = toL;
+ param_15 = _e213;
+ let _e214 = lightDistance_u0028_vf3_u003b((&param_15));
+ dist_2 = _e214;
+ let _e216 = pd_1[3u];
+ let _e218 = dist_2;
+ param_16 = _e218;
+ param_17 = max(_e216, 0.0001f);
+ let _e219 = fo_1;
+ param_18 = _e219;
+ let _e220 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_16), (&param_17), (&param_18));
+ atten = _e220;
+ let _e221 = toL;
+ param_19 = _e221;
+ let _e222 = (*N_3);
+ param_20 = _e222;
+ let _e223 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_19), (&param_20));
+ L_1 = _e223;
} else {
- let _e220 = pd_1[2u];
- if (_e220 < 1.5f) {
+ let _e225 = pd_1[2u];
+ if (_e225 < 1.5f) {
atten = 1f;
- let _e222 = pd_1;
- 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));
+ let _e227 = pd_1;
+ let _e228 = _e227.xy;
+ let _e230 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e228.x, _e228.y, _e230)));
+ let _e236 = pd_1;
+ let _e238 = pd_1;
+ if (dot(_e236.xy, _e238.xy) > 0.00000001f) {
+ let _e242 = pd_1;
+ local_7 = normalize(-(_e242.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e246 = local_7;
+ toLight_3 = _e246;
+ let _e248 = sh_3[1u];
+ let _e249 = (_e248 > 0f);
+ phi_905_ = _e249;
+ if _e249 {
+ let _e250 = toLight_3;
+ let _e251 = toLight_3;
+ phi_905_ = (dot(_e250, _e251) > 0.5f);
}
- let _e250 = phi_839_;
- castShadow = _e250;
- let _e251 = (*worldPos_3);
- let _e253 = toLight_3;
- let _e255 = sh_3[1u];
- target_ = (_e251.xy + (_e253 * _e255));
+ let _e255 = phi_905_;
+ castShadow = _e255;
+ let _e256 = (*worldPos_5);
+ let _e258 = toLight_3;
+ let _e260 = sh_3[1u];
+ target_ = (_e256.xy + (_e258 * _e260));
} else {
- 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((&param_15), (&param_16), (&param_17));
- toL_1 = _e266;
- let _e267 = toL_1;
- param_18 = _e267;
- let _e268 = lightDistance_u0028_vf3_u003b((&param_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((&param_19), (&param_20), (&param_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((&param_22), (&param_23));
- L_1 = _e277;
- let _e278 = sp_1;
- param_24 = _e278;
- let _e279 = sh_3;
- param_25 = _e279;
+ let _e263 = i;
+ let _e267 = unnamed_1.u_lights[_e263].spot;
+ sp_1 = _e267;
+ let _e268 = pd_1;
+ param_21 = _e268;
+ let _e269 = sh_3;
+ param_22 = _e269;
+ let _e270 = (*worldPos_5);
+ param_23 = _e270;
+ let _e271 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_21), (&param_22), (&param_23));
+ toL_1 = _e271;
+ let _e272 = toL_1;
+ param_24 = _e272;
+ let _e273 = lightDistance_u0028_vf3_u003b((&param_24));
+ dist_3 = _e273;
+ let _e275 = pd_1[3u];
+ let _e277 = dist_3;
+ param_25 = _e277;
+ param_26 = max(_e275, 0.0001f);
+ let _e278 = fo_1;
+ param_27 = _e278;
+ let _e279 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_25), (&param_26), (&param_27));
+ atten = _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((&param_24), (&param_25), (&param_26), (&param_27));
- let _e283 = atten;
- atten = (_e283 * _e282);
+ param_28 = _e280;
+ let _e281 = (*N_3);
+ param_29 = _e281;
+ let _e282 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_28), (&param_29));
+ L_1 = _e282;
+ let _e283 = sp_1;
+ param_30 = _e283;
+ let _e284 = sh_3;
+ param_31 = _e284;
+ let _e285 = toL_1;
+ param_32 = _e285;
+ let _e286 = dist_3;
+ param_33 = _e286;
+ let _e287 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_30), (&param_31), (&param_32), (&param_33));
+ let _e288 = atten;
+ atten = (_e288 * _e287);
}
}
- let _e285 = castShadow;
- phi_895_ = _e285;
- if _e285 {
- let _e287 = col[3u];
- phi_895_ = (_e287 > 0f);
+ let _e291 = col[3u];
+ let _e293 = atten;
+ if ((_e291 > 0f) && (_e293 > 0f)) {
+ let _e297 = fo_1[3u];
+ param_34 = _e297;
+ let _e298 = (*worldPos_5);
+ param_35 = _e298.xy;
+ let _e300 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_34), (&param_35));
+ let _e301 = atten;
+ atten = (_e301 * _e300);
+ }
+ let _e303 = castShadow;
+ phi_978_ = _e303;
+ if _e303 {
+ let _e305 = col[3u];
+ phi_978_ = (_e305 > 0f);
}
- 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((&param_28), (&param_29));
- let _e304 = fo_1[2u];
- let _e306 = atten;
- atten = (_e306 * mix(1f, _e302, _e304));
+ let _e308 = phi_978_;
+ let _e309 = atten;
+ if (_e308 && (_e309 > 0f)) {
+ let _e312 = i;
+ let _e317 = unnamed_1.u_lights[_e312].shadowMap[3u];
+ param_36 = _e317;
+ let _e318 = (*worldPos_5);
+ param_37 = _e318.xy;
+ let _e320 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_36), (&param_37));
+ let _e322 = fo_1[2u];
+ let _e324 = atten;
+ atten = (_e324 * mix(1f, _e320, _e322));
}
- 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((&param_30), (&param_31), (&param_32), (&param_33), (&param_34), (&param_35));
- let _e335 = fo_1[2u];
- let _e337 = atten;
- atten = (_e337 * mix(1f, _e333, _e335));
+ let _e326 = i;
+ let _e330 = unnamed_1.u_lights[_e326].shadowMap;
+ sm = _e330;
+ let _e332 = sm[1u];
+ let _e334 = atten;
+ if ((_e332 > 0f) && (_e334 > 0f)) {
+ let _e338 = sh_3[0u];
+ let _e340 = sm[2u];
+ let _e343 = sm[0u];
+ let _e346 = sm[1u];
+ let _e348 = (*worldPos_5);
+ param_38 = _e348;
+ let _e349 = (*N_3);
+ param_39 = _e349;
+ let _e350 = L_1;
+ param_40 = _e350;
+ param_41 = vec2<f32>(_e338, _e340);
+ param_42 = i32(_e343);
+ param_43 = i32(_e346);
+ let _e351 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_38), (&param_39), (&param_40), (&param_41), (&param_42), (&param_43));
+ let _e353 = fo_1[2u];
+ let _e355 = atten;
+ atten = (_e355 * mix(1f, _e351, _e353));
}
- 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((&param_36), (&param_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((&param_38), (&param_39), (&param_40));
- let _e372 = NdotV_2;
- let _e374 = ndotl;
- brdf = ((_e366 * _e370) / max(((4f * _e372) * _e374), 0.0001f));
- let _e378 = radiance;
- let _e379 = (*V);
+ let _e357 = (*N_3);
+ let _e358 = L_1;
+ ndotl = max(dot(_e357, _e358), 0f);
+ let _e361 = col;
+ let _e364 = col[3u];
+ let _e365 = ndotl;
+ let _e367 = atten;
+ radiance = (_e361.xyz * ((_e364 * _e365) * _e367));
+ let _e370 = radiance;
+ let _e371 = lit;
+ lit = (_e371 + _e370);
+ let _e373 = (*specular);
+ if (_e373 > 0f) {
+ let _e375 = L_1;
+ let _e376 = (*V);
+ H = normalize((_e375 + _e376));
+ let _e379 = (*N_3);
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((&param_41), (&param_42));
- let _e386 = brdf;
- let _e388 = (*specular);
- let _e391 = gloss;
- gloss = (_e391 + ((_e378 * _e384) * ((_e386 * 3.1415927f) * _e388)));
+ param_44 = max(dot(_e379, _e380), 0f);
+ let _e383 = a_4;
+ param_45 = _e383;
+ let _e384 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_44), (&param_45));
+ let _e385 = NdotV_2;
+ param_46 = _e385;
+ let _e386 = ndotl;
+ param_47 = _e386;
+ let _e387 = (*roughness_3);
+ param_48 = _e387;
+ let _e388 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_46), (&param_47), (&param_48));
+ let _e390 = NdotV_2;
+ let _e392 = ndotl;
+ brdf = ((_e384 * _e388) / max(((4f * _e390) * _e392), 0.0001f));
+ let _e396 = radiance;
+ let _e397 = (*V);
+ let _e398 = H;
+ param_49 = max(dot(_e397, _e398), 0f);
+ let _e401 = F0_1;
+ param_50 = _e401;
+ let _e402 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_49), (&param_50));
+ let _e404 = brdf;
+ let _e406 = (*specular);
+ let _e409 = gloss;
+ gloss = (_e409 + ((_e396 * _e402) * ((_e404 * 3.1415927f) * _e406)));
}
continue;
} else {
break;
}
continuing {
- let _e393 = i;
- i = (_e393 + 1i);
+ let _e411 = i;
+ i = (_e411 + 1i);
}
}
- let _e395 = NdotV_2;
- param_43 = _e395;
- let _e396 = (*roughness_3);
- param_44 = _e396;
- let _e397 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_43), (&param_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((&param_45), (&param_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> {
+ let _e413 = NdotV_2;
+ param_51 = _e413;
+ let _e414 = (*roughness_3);
+ param_52 = _e414;
+ let _e415 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_51), (&param_52));
+ ab = _e415;
+ let _e416 = (*V);
+ let _e418 = (*N_3);
+ param_53 = reflect(-(_e416), _e418);
+ let _e420 = (*roughness_3);
+ param_54 = _e420;
+ let _e421 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_53), (&param_54));
+ let _e422 = (*ao);
+ let _e423 = (*specular);
+ let _e426 = F0_1;
+ let _e428 = ab[0u];
+ let _e431 = ab[1u];
+ let _e435 = gloss;
+ gloss = (_e435 + ((_e421 * (_e422 * _e423)) * ((_e426 * _e428) + vec3(_e431))));
+ let _e437 = (*albedo);
+ let _e438 = (*metallic);
+ let _e441 = lit;
+ let _e443 = gloss;
+ return (((_e437 * (1f - _e438)) * _e441) + _e443);
+}
+
+fn viewDirection_u0028_vf3_u003b(worldPos_6: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_8: vec3<f32>;
- let _e88 = unnamed.u_camera[3u];
- if (_e88 > 0.5f) {
- let _e91 = unnamed.u_camera;
- let _e93 = (*worldPos_4);
- local_8 = normalize((_e91.xyz - _e93));
+ let _e91 = unnamed.u_camera[3u];
+ if (_e91 > 0.5f) {
+ let _e94 = unnamed.u_camera;
+ let _e96 = (*worldPos_6);
+ local_8 = normalize((_e94.xyz - _e96));
} else {
- let _e97 = unnamed.u_camera;
- local_8 = _e97.xyz;
+ let _e100 = unnamed.u_camera;
+ local_8 = _e100.xyz;
}
- let _e99 = local_8;
- return _e99;
+ let _e102 = local_8;
+ return _e102;
}
-fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<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_47 = _e102;
- let _e103 = viewDirection_u0028_vf3_u003b((&param_47));
- let _e104 = (*albedo_1);
- param_48 = _e104;
- let _e105 = (*N_4);
- param_49 = _e105;
- let _e106 = P;
- param_50 = _e106;
- param_51 = _e103;
- param_52 = 0f;
- param_53 = 1f;
- param_54 = 0f;
- let _e107 = (*ao_1);
- param_55 = _e107;
- let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_48), (&param_49), (&param_50), (&param_51), (&param_52), (&param_53), (&param_54), (&param_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_55: vec3<f32>;
var param_56: vec3<f32>;
var param_57: vec3<f32>;
- var param_58: vec2<f32>;
- var param_59: f32;
+ var param_58: vec3<f32>;
+ var param_59: vec3<f32>;
+ var param_60: f32;
+ var param_61: f32;
+ var param_62: f32;
+ var param_63: f32;
- let _e91 = (*albedo_2);
- param_56 = _e91;
- let _e92 = (*N_5);
- param_57 = _e92;
- let _e93 = (*worldPos_6);
- param_58 = _e93;
- param_59 = 1f;
- let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59));
- return _e94;
+ let _e101 = (*worldPos_7);
+ P = vec3<f32>(_e101.x, _e101.y, 0f);
+ let _e105 = P;
+ param_55 = _e105;
+ let _e106 = viewDirection_u0028_vf3_u003b((&param_55));
+ let _e107 = (*albedo_1);
+ param_56 = _e107;
+ let _e108 = (*N_4);
+ param_57 = _e108;
+ let _e109 = P;
+ param_58 = _e109;
+ param_59 = _e106;
+ param_60 = 0f;
+ param_61 = 1f;
+ param_62 = 0f;
+ let _e110 = (*ao_1);
+ param_63 = _e110;
+ let _e111 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59), (&param_60), (&param_61), (&param_62), (&param_63));
+ return _e111;
}
-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {
- let _e87 = (*uv_1);
- let _e88 = textureSample(map_est, map_ess, _e87);
- return normalize(((_e88.xyz * 2f) - vec3(1f)));
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_64: vec3<f32>;
+ var param_65: vec3<f32>;
+ var param_66: vec2<f32>;
+ var param_67: f32;
+
+ let _e94 = (*albedo_2);
+ param_64 = _e94;
+ let _e95 = (*N_5);
+ param_65 = _e95;
+ let _e96 = (*worldPos_8);
+ param_66 = _e96;
+ param_67 = 1f;
+ let _e97 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_64), (&param_65), (&param_66), (&param_67));
+ return _e97;
+}
+
+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_2: ptr<function, vec2<f32>>) -> vec3<f32> {
+ let _e90 = (*uv_2);
+ let _e91 = textureSample(map_est, map_ess, _e90);
+ return normalize(((_e91.xyz * 2f) - vec3(1f)));
}
fn main_1() {
var base: vec4<f32>;
var N_6: vec3<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);
- let _e92 = v_color_1;
- let _e95 = unnamed_2.u_tint;
- base = ((_e91 * _e92) * _e95);
- let _e97 = v_texCoord_1;
- param_60 = _e97;
- let _e98 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (&param_60));
- N_6 = _e98;
- let _e99 = base;
- param_61 = _e99.xyz;
- let _e101 = N_6;
- param_62 = _e101;
- let _e102 = v_worldPos_1;
- param_63 = _e102;
- let _e103 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_61), (&param_62), (&param_63));
- let _e105 = base[3u];
- fragColor = vec4<f32>(_e103.x, _e103.y, _e103.z, _e105);
+ var param_68: vec2<f32>;
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+
+ let _e93 = v_texCoord_1;
+ let _e94 = textureSample(es_bt0_est, es_bt0_ess, _e93);
+ let _e95 = v_color_1;
+ let _e98 = unnamed_2.u_tint;
+ base = ((_e94 * _e95) * _e98);
+ let _e100 = v_texCoord_1;
+ param_68 = _e100;
+ let _e101 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (&param_68));
+ N_6 = _e101;
+ let _e102 = base;
+ param_69 = _e102.xyz;
+ let _e104 = N_6;
+ param_70 = _e104;
+ let _e105 = v_worldPos_1;
+ param_71 = _e105;
+ let _e106 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_69), (&param_70), (&param_71));
+ let _e108 = base[3u];
+ fragColor = vec4<f32>(_e106.x, _e106.y, _e106.z, _e108);
return;
}
diff --git a/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader b/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader
index 22da7f44d..59012c9e4 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: 5b9e7d2e0ace2c2e
+// assembled-hash: 0be517726802c71e
struct 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: 5b9e7d2e0ace2c2e
+// assembled-hash: 0be517726802c71e
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -139,7 +139,7 @@ struct Light {
struct LightConstants {
u_ambient: vec4<f32>,
u_lights: array<Light, 16>,
- u_shadow2DRect: vec4<f32>,
+ u_mask2DRect: vec4<f32>,
u_shadowMatrix: array<mat4x4<f32>, 16>,
u_shadowTile: array<vec4<f32>, 16>,
u_shadowParams: vec4<f32>,
@@ -161,6 +161,10 @@ var<uniform> unnamed_1: LightConstants;
var u_shadow2D_est: texture_2d<f32>;
@group(1) @binding(15)
var u_shadow2D_ess: sampler;
+@group(1) @binding(6)
+var u_lightShape2D_est: texture_2d<f32>;
+@group(1) @binding(14)
+var u_lightShape2D_ess: sampler;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -218,181 +222,238 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e95 = unnamed_1.u_envParams[0u];
- if (_e95 < 0.5f) {
- let _e98 = unnamed_1.u_ambient;
- return _e98.xyz;
+ let _e98 = unnamed_1.u_envParams[0u];
+ if (_e98 < 0.5f) {
+ let _e101 = unnamed_1.u_ambient;
+ return _e101.xyz;
}
- let _e100 = (*roughness);
- let _e104 = unnamed_1.u_envParams[2u];
- lod = (clamp(_e100, 0f, 1f) * _e104);
- let _e106 = lod;
- lo = floor(_e106);
- let _e108 = (*R_1);
- param = _e108;
- let _e109 = lo;
- param_1 = _e109;
- let _e110 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
- a = _e110;
- let _e111 = lo;
- let _e115 = unnamed_1.u_envParams[2u];
- let _e117 = (*R_1);
- param_2 = _e117;
- param_3 = min((_e111 + 1f), _e115);
- let _e118 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
- b = _e118;
- let _e120 = unnamed_1.u_ambient;
- let _e122 = a;
- let _e123 = b;
- let _e124 = lod;
- let _e125 = lo;
- let _e130 = unnamed_1.u_envTint;
- return (_e120.xyz + (mix(_e122, _e123, vec3((_e124 - _e125))) * _e130.xyz));
+ let _e103 = (*roughness);
+ let _e107 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e103, 0f, 1f) * _e107);
+ let _e109 = lod;
+ lo = floor(_e109);
+ let _e111 = (*R_1);
+ param = _e111;
+ let _e112 = lo;
+ param_1 = _e112;
+ let _e113 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e113;
+ let _e114 = lo;
+ let _e118 = unnamed_1.u_envParams[2u];
+ let _e120 = (*R_1);
+ param_2 = _e120;
+ param_3 = min((_e114 + 1f), _e118);
+ let _e121 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e121;
+ let _e123 = unnamed_1.u_ambient;
+ let _e125 = a;
+ let _e126 = b;
+ let _e127 = lod;
+ let _e128 = lo;
+ let _e133 = unnamed_1.u_envTint;
+ return (_e123.xyz + (mix(_e125, _e126, vec3((_e127 - _e128))) * _e133.xyz));
}
fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {
var r: vec4<f32>;
var a_1: f32;
- let _e87 = (*roughness_1);
- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e87) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
- let _e91 = r[0u];
- let _e93 = r[0u];
- let _e95 = (*NdotV);
- let _e100 = r[0u];
- let _e103 = r[1u];
- a_1 = ((min((_e91 * _e93), exp2((-9.28f * _e95))) * _e100) + _e103);
- let _e105 = a_1;
- let _e107 = r;
- return ((vec2<f32>(-1.04f, 1.04f) * _e105) + _e107.zw);
+ let _e90 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e90) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e94 = r[0u];
+ let _e96 = r[0u];
+ let _e98 = (*NdotV);
+ let _e103 = r[0u];
+ let _e106 = r[1u];
+ a_1 = ((min((_e94 * _e96), exp2((-9.28f * _e98))) * _e103) + _e106);
+ let _e108 = a_1;
+ let _e110 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e108) + _e110.zw);
}
fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e85 = (*F0_);
- let _e86 = (*F0_);
- let _e88 = (*VdotH);
- return (_e85 + ((vec3<f32>(1f, 1f, 1f) - _e86) * pow((1f - _e88), 5f)));
+ let _e88 = (*F0_);
+ let _e89 = (*F0_);
+ let _e91 = (*VdotH);
+ return (_e88 + ((vec3<f32>(1f, 1f, 1f) - _e89) * pow((1f - _e91), 5f)));
}
fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {
var k: f32;
- let _e87 = (*roughness_2);
- let _e89 = (*roughness_2);
- k = (((_e87 + 1f) * (_e89 + 1f)) * 0.125f);
- let _e93 = (*NdotV_1);
- let _e94 = (*NdotV_1);
- let _e95 = k;
+ let _e90 = (*roughness_2);
+ let _e92 = (*roughness_2);
+ k = (((_e90 + 1f) * (_e92 + 1f)) * 0.125f);
+ let _e96 = (*NdotV_1);
+ let _e97 = (*NdotV_1);
let _e98 = k;
- let _e101 = (*NdotL);
- let _e102 = (*NdotL);
- let _e103 = k;
+ let _e101 = k;
+ let _e104 = (*NdotL);
+ let _e105 = (*NdotL);
let _e106 = k;
- return ((_e93 / ((_e94 * (1f - _e95)) + _e98)) * (_e101 / ((_e102 * (1f - _e103)) + _e106)));
+ let _e109 = k;
+ return ((_e96 / ((_e97 * (1f - _e98)) + _e101)) * (_e104 / ((_e105 * (1f - _e106)) + _e109)));
}
fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {
var a2_: f32;
var d: f32;
- let _e87 = (*a_2);
- let _e88 = (*a_2);
- a2_ = (_e87 * _e88);
- let _e90 = (*NdotH);
- let _e91 = (*NdotH);
- let _e93 = a2_;
- d = (((_e90 * _e91) * (_e93 - 1f)) + 1f);
- let _e97 = a2_;
- let _e98 = d;
- let _e100 = d;
- return (_e97 / max(((3.1415927f * _e98) * _e100), 0.0000001f));
+ let _e90 = (*a_2);
+ let _e91 = (*a_2);
+ a2_ = (_e90 * _e91);
+ let _e93 = (*NdotH);
+ let _e94 = (*NdotH);
+ let _e96 = a2_;
+ d = (((_e93 * _e94) * (_e96 - 1f)) + 1f);
+ let _e100 = a2_;
+ let _e101 = d;
+ let _e103 = d;
+ return (_e100 / max(((3.1415927f * _e101) * _e103), 0.0000001f));
}
fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {
return 1f;
}
-fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {
+fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel: ptr<function, f32>) -> f32 {
+ var local: f32;
+ var local_1: f32;
+ var local_2: f32;
+
+ let _e91 = (*channel);
+ if (_e91 < 0.5f) {
+ let _e94 = (*m)[0u];
+ local = _e94;
+ } else {
+ let _e95 = (*channel);
+ if (_e95 < 1.5f) {
+ let _e98 = (*m)[1u];
+ local_1 = _e98;
+ } else {
+ let _e99 = (*channel);
+ if (_e99 < 2.5f) {
+ let _e102 = (*m)[2u];
+ local_2 = _e102;
+ } else {
+ let _e104 = (*m)[3u];
+ local_2 = _e104;
+ }
+ let _e105 = local_2;
+ local_1 = _e105;
+ }
+ let _e106 = local_1;
+ local = _e106;
+ }
+ let _e107 = local;
+ return _e107;
+}
+
+fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var clip: vec4<f32>;
var ndc: vec2<f32>;
var v: f32;
- var local: f32;
+ var local_3: f32;
+
+ let _e92 = unnamed.u_projection;
+ let _e93 = (*worldPos_1);
+ clip = (_e92 * vec4<f32>(_e93.x, _e93.y, 0f, 1f));
+ let _e99 = clip[3u];
+ if (_e99 <= 0f) {
+ return vec2<f32>(-1f, -1f);
+ }
+ let _e101 = clip;
+ let _e104 = clip[3u];
+ ndc = (((_e101.xy / vec2(_e104)) * 0.5f) + vec2(0.5f));
+ let _e112 = unnamed_1.u_mask2DRect[3u];
+ if (_e112 < 0f) {
+ let _e115 = ndc[1u];
+ local_3 = (1f - _e115);
+ } else {
+ let _e118 = ndc[1u];
+ local_3 = _e118;
+ }
+ let _e119 = local_3;
+ v = _e119;
+ let _e121 = unnamed_1.u_mask2DRect;
+ let _e124 = ndc[0u];
+ let _e127 = unnamed_1.u_mask2DRect[2u];
+ let _e129 = v;
+ let _e132 = unnamed_1.u_mask2DRect[3u];
+ return (_e121.xy + vec2<f32>((_e124 * _e127), (_e129 * abs(_e132))));
+}
+
+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
var uv: vec2<f32>;
- var m: vec4<f32>;
+ var param_4: vec2<f32>;
var hidden: f32;
- var local_1: f32;
- var local_2: f32;
- var local_3: f32;
- var phi_200_: bool;
-
- let _e95 = (*channel);
- let _e96 = (_e95 < 0f);
- phi_200_ = _e96;
- if !(_e96) {
- let _e100 = unnamed_1.u_shadow2DRect[2u];
- phi_200_ = (_e100 <= 0f);
+ var param_5: vec4<f32>;
+ var param_6: f32;
+ var phi_307_: bool;
+
+ let _e93 = (*channel_1);
+ let _e94 = (_e93 < 0f);
+ phi_307_ = _e94;
+ if !(_e94) {
+ let _e98 = unnamed_1.u_mask2DRect[2u];
+ phi_307_ = (_e98 <= 0f);
}
- let _e103 = phi_200_;
- if _e103 {
+ let _e101 = phi_307_;
+ if _e101 {
return 1f;
}
- let _e105 = unnamed.u_projection;
- let _e106 = (*worldPos_1);
- clip = (_e105 * vec4<f32>(_e106.x, _e106.y, 0f, 1f));
- let _e112 = clip[3u];
- if (_e112 <= 0f) {
+ let _e102 = (*worldPos_2);
+ param_4 = _e102;
+ let _e103 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e103;
+ let _e105 = uv[0u];
+ if (_e105 < 0f) {
return 1f;
}
- let _e114 = clip;
- let _e117 = clip[3u];
- ndc = (((_e114.xy / vec2(_e117)) * 0.5f) + vec2(0.5f));
- let _e125 = unnamed_1.u_shadow2DRect[3u];
- if (_e125 < 0f) {
- let _e128 = ndc[1u];
- local = (1f - _e128);
- } else {
- let _e131 = ndc[1u];
- local = _e131;
+ let _e107 = uv;
+ let _e108 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e107, 0f);
+ param_5 = _e108;
+ let _e109 = (*channel_1);
+ param_6 = _e109;
+ let _e110 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e110;
+ let _e111 = hidden;
+ return (1f - min(_e111, 1f));
+}
+
+fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
+ var uv_1: vec2<f32>;
+ var param_7: vec2<f32>;
+ var param_8: vec4<f32>;
+ var param_9: f32;
+ var phi_346_: bool;
+
+ let _e92 = (*channel_2);
+ let _e93 = (_e92 < 0f);
+ phi_346_ = _e93;
+ if !(_e93) {
+ let _e97 = unnamed_1.u_mask2DRect[2u];
+ phi_346_ = (_e97 <= 0f);
}
- let _e132 = local;
- v = _e132;
- let _e134 = unnamed_1.u_shadow2DRect;
- let _e137 = ndc[0u];
- let _e140 = unnamed_1.u_shadow2DRect[2u];
- let _e142 = v;
- let _e145 = unnamed_1.u_shadow2DRect[3u];
- uv = (_e134.xy + vec2<f32>((_e137 * _e140), (_e142 * abs(_e145))));
- let _e150 = uv;
- let _e151 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e150, 0f);
- m = _e151;
- let _e152 = (*channel);
- if (_e152 < 0.5f) {
- let _e155 = m[0u];
- local_1 = _e155;
- } else {
- let _e156 = (*channel);
- if (_e156 < 1.5f) {
- let _e159 = m[1u];
- local_2 = _e159;
- } else {
- let _e160 = (*channel);
- if (_e160 < 2.5f) {
- let _e163 = m[2u];
- local_3 = _e163;
- } else {
- let _e165 = m[3u];
- local_3 = _e165;
- }
- let _e166 = local_3;
- local_2 = _e166;
- }
- let _e167 = local_2;
- local_1 = _e167;
+ let _e100 = phi_346_;
+ if _e100 {
+ return 1f;
}
- let _e168 = local_1;
- hidden = _e168;
- let _e169 = hidden;
- return (1f - min(_e169, 1f));
+ let _e101 = (*worldPos_3);
+ param_7 = _e101;
+ let _e102 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e102;
+ let _e104 = uv_1[0u];
+ if (_e104 < 0f) {
+ return 1f;
+ }
+ let _e106 = uv_1;
+ let _e107 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e106, 0f);
+ param_8 = _e107;
+ let _e108 = (*channel_2);
+ param_9 = _e108;
+ let _e109 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e109, 1f);
}
fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {
@@ -401,74 +462,74 @@ fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<
var toFrag: vec2<f32>;
var local_5: vec2<f32>;
- let _e91 = (*sp);
- let _e93 = (*sp);
- if (dot(_e91.xy, _e93.xy) > 0.00000001f) {
- let _e97 = (*sp);
- local_4 = normalize(_e97.xy);
+ let _e94 = (*sp);
+ let _e96 = (*sp);
+ if (dot(_e94.xy, _e96.xy) > 0.00000001f) {
+ let _e100 = (*sp);
+ local_4 = normalize(_e100.xy);
} else {
local_4 = vec2<f32>(0f, -1f);
}
- let _e100 = local_4;
- axis = _e100;
- let _e101 = (*dist);
- if (_e101 > 0.0001f) {
- let _e103 = (*toLight);
- let _e106 = (*dist);
- local_5 = (-(_e103.xy) / vec2(_e106));
+ let _e103 = local_4;
+ axis = _e103;
+ let _e104 = (*dist);
+ if (_e104 > 0.0001f) {
+ let _e106 = (*toLight);
+ let _e109 = (*dist);
+ local_5 = (-(_e106.xy) / vec2(_e109));
} else {
- let _e109 = axis;
- local_5 = _e109;
+ let _e112 = axis;
+ local_5 = _e112;
}
- let _e110 = local_5;
- toFrag = _e110;
- let _e112 = (*sp)[3u];
- let _e114 = (*sp)[2u];
- let _e115 = axis;
- let _e116 = toFrag;
- return smoothstep(_e112, _e114, dot(_e115, _e116));
+ let _e113 = local_5;
+ toFrag = _e113;
+ let _e115 = (*sp)[3u];
+ let _e117 = (*sp)[2u];
+ let _e118 = axis;
+ let _e119 = toFrag;
+ return smoothstep(_e115, _e117, dot(_e118, _e119));
}
fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_6: vec3<f32>;
- let _e86 = (*toLight_1);
- let _e87 = (*toLight_1);
- if (dot(_e86, _e87) > 0.00000001f) {
- let _e90 = (*toLight_1);
- local_6 = normalize(_e90);
+ let _e89 = (*toLight_1);
+ let _e90 = (*toLight_1);
+ if (dot(_e89, _e90) > 0.00000001f) {
+ let _e93 = (*toLight_1);
+ local_6 = normalize(_e93);
} else {
- let _e92 = (*N_1);
- local_6 = _e92;
+ let _e95 = (*N_1);
+ local_6 = _e95;
}
- let _e93 = local_6;
- return _e93;
+ let _e96 = local_6;
+ return _e96;
}
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));
+ let _e91 = (*dist_1);
+ let _e93 = (*reach);
+ let _e95 = (*fo)[0u];
+ ramp = clamp(((_e90 - _e91) / max((_e93 - _e95), 0.0001f)), 0f, 1f);
+ let _e100 = ramp;
+ let _e102 = (*fo)[1u];
+ return pow(_e100, max(_e102, 0.001f));
}
fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {
- let _e84 = (*toLight_2);
- return length(_e84.xy);
+ let _e87 = (*toLight_2);
+ return length(_e87.xy);
}
-fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e86 = (*pd);
- let _e88 = (*worldPos_2);
- let _e90 = (_e86.xy - _e88.xy);
- let _e92 = (*pd)[3u];
- return vec3<f32>(_e90.x, _e90.y, max(_e92, 1f));
+fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e89 = (*pd);
+ let _e91 = (*worldPos_4);
+ let _e93 = (_e89.xy - _e91.xy);
+ let _e95 = (*pd)[3u];
+ return vec3<f32>(_e93.x, _e93.y, max(_e95, 1f));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -476,70 +537,70 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- let _e89 = unnamed_1.u_envTint[3u];
- a_3 = -(_e89);
- let _e91 = a_3;
- s = sin(_e91);
- let _e93 = a_3;
- c = cos(_e93);
- let _e95 = c;
- let _e97 = (*d_1)[0u];
- let _e99 = s;
- let _e101 = (*d_1)[2u];
- let _e105 = (*d_1)[1u];
- let _e106 = s;
- let _e109 = (*d_1)[0u];
- let _e111 = c;
- let _e113 = (*d_1)[2u];
- return vec3<f32>(((_e95 * _e97) + (_e99 * _e101)), _e105, ((-(_e106) * _e109) + (_e111 * _e113)));
+ let _e92 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e92);
+ let _e94 = a_3;
+ s = sin(_e94);
+ let _e96 = a_3;
+ c = cos(_e96);
+ let _e98 = c;
+ let _e100 = (*d_1)[0u];
+ let _e102 = s;
+ let _e104 = (*d_1)[2u];
+ let _e108 = (*d_1)[1u];
+ let _e109 = s;
+ let _e112 = (*d_1)[0u];
+ let _e114 = c;
+ let _e116 = (*d_1)[2u];
+ return vec3<f32>(((_e98 * _e100) + (_e102 * _e104)), _e108, ((-(_e109) * _e112) + (_e114 * _e116)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
var N_2: vec3<f32>;
- var param_4: vec3<f32>;
+ var param_10: vec3<f32>;
var sh_2: vec3<f32>;
- let _e87 = (*Nw);
- param_4 = _e87;
- let _e88 = envDirection_u0028_vf3_u003b((&param_4));
- N_2 = _e88;
- let _e91 = unnamed_1.u_envIrradiance[0i];
- let _e96 = unnamed_1.u_envIrradiance[1i];
- let _e99 = N_2[1u];
- let _e105 = unnamed_1.u_envIrradiance[2i];
- let _e108 = N_2[2u];
- let _e114 = unnamed_1.u_envIrradiance[3i];
- let _e117 = N_2[0u];
- let _e123 = unnamed_1.u_envIrradiance[4i];
- let _e126 = N_2[0u];
- let _e129 = N_2[1u];
- let _e135 = unnamed_1.u_envIrradiance[5i];
- let _e138 = N_2[1u];
- let _e141 = N_2[2u];
- let _e147 = unnamed_1.u_envIrradiance[6i];
- let _e150 = N_2[2u];
+ let _e90 = (*Nw);
+ param_10 = _e90;
+ let _e91 = envDirection_u0028_vf3_u003b((&param_10));
+ N_2 = _e91;
+ let _e94 = unnamed_1.u_envIrradiance[0i];
+ let _e99 = unnamed_1.u_envIrradiance[1i];
+ let _e102 = N_2[1u];
+ let _e108 = unnamed_1.u_envIrradiance[2i];
+ let _e111 = N_2[2u];
+ let _e117 = unnamed_1.u_envIrradiance[3i];
+ let _e120 = N_2[0u];
+ let _e126 = unnamed_1.u_envIrradiance[4i];
+ let _e129 = N_2[0u];
+ let _e132 = N_2[1u];
+ let _e138 = unnamed_1.u_envIrradiance[5i];
+ let _e141 = N_2[1u];
+ let _e144 = N_2[2u];
+ let _e150 = unnamed_1.u_envIrradiance[6i];
let _e153 = N_2[2u];
- let _e161 = unnamed_1.u_envIrradiance[7i];
- let _e164 = N_2[0u];
- let _e167 = N_2[2u];
- let _e173 = unnamed_1.u_envIrradiance[8i];
- let _e176 = N_2[0u];
- let _e178 = N_2[0u];
- let _e181 = N_2[1u];
- let _e183 = N_2[1u];
- sh_2 = (((((((((_e91.xyz * 0.282095f) + (_e96.xyz * (0.488603f * _e99))) + (_e105.xyz * (0.488603f * _e108))) + (_e114.xyz * (0.488603f * _e117))) + (_e123.xyz * ((1.092548f * _e126) * _e129))) + (_e135.xyz * ((1.092548f * _e138) * _e141))) + (_e147.xyz * (0.315392f * (((3f * _e150) * _e153) - 1f)))) + (_e161.xyz * ((1.092548f * _e164) * _e167))) + (_e173.xyz * (0.546274f * ((_e176 * _e178) - (_e181 * _e183)))));
- let _e190 = unnamed_1.u_ambient;
- let _e192 = sh_2;
- let _e195 = unnamed_1.u_envTint;
- return (_e190.xyz + (max(_e192, vec3<f32>(0f, 0f, 0f)) * _e195.xyz));
-}
-
-fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
+ let _e156 = N_2[2u];
+ let _e164 = unnamed_1.u_envIrradiance[7i];
+ let _e167 = N_2[0u];
+ let _e170 = N_2[2u];
+ let _e176 = unnamed_1.u_envIrradiance[8i];
+ let _e179 = N_2[0u];
+ let _e181 = N_2[0u];
+ let _e184 = N_2[1u];
+ let _e186 = N_2[1u];
+ sh_2 = (((((((((_e94.xyz * 0.282095f) + (_e99.xyz * (0.488603f * _e102))) + (_e108.xyz * (0.488603f * _e111))) + (_e117.xyz * (0.488603f * _e120))) + (_e126.xyz * ((1.092548f * _e129) * _e132))) + (_e138.xyz * ((1.092548f * _e141) * _e144))) + (_e150.xyz * (0.315392f * (((3f * _e153) * _e156) - 1f)))) + (_e164.xyz * ((1.092548f * _e167) * _e170))) + (_e176.xyz * (0.546274f * ((_e179 * _e181) - (_e184 * _e186)))));
+ let _e193 = unnamed_1.u_ambient;
+ let _e195 = sh_2;
+ let _e198 = unnamed_1.u_envTint;
+ return (_e193.xyz + (max(_e195, vec3<f32>(0f, 0f, 0f)) * _e198.xyz));
+}
+
+fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
var F0_1: vec3<f32>;
var a_4: f32;
var NdotV_2: f32;
var lit: vec3<f32>;
- var param_5: vec3<f32>;
+ var param_11: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
@@ -549,423 +610,436 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0
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 param_12: vec4<f32>;
+ var param_13: vec4<f32>;
+ var param_14: vec3<f32>;
var dist_2: f32;
- var param_9: vec3<f32>;
+ var param_15: vec3<f32>;
var atten: f32;
- var param_10: f32;
- var param_11: f32;
- var param_12: vec4<f32>;
+ var param_16: f32;
+ var param_17: f32;
+ var param_18: vec4<f32>;
var L_1: vec3<f32>;
- var param_13: vec3<f32>;
- var param_14: vec3<f32>;
+ var param_19: vec3<f32>;
+ var param_20: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_15: vec4<f32>;
- var param_16: vec4<f32>;
- var param_17: 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_22: vec4<f32>;
var param_23: vec3<f32>;
- var param_24: vec4<f32>;
- var param_25: vec4<f32>;
- var param_26: vec3<f32>;
- var param_27: f32;
- var param_28: f32;
- var param_29: vec2<f32>;
- var sm: vec4<f32>;
- var param_30: vec3<f32>;
- var param_31: vec3<f32>;
+ var dist_3: f32;
+ var param_24: vec3<f32>;
+ var param_25: f32;
+ var param_26: f32;
+ var param_27: vec4<f32>;
+ var param_28: vec3<f32>;
+ var param_29: vec3<f32>;
+ var param_30: vec4<f32>;
+ var param_31: vec4<f32>;
var param_32: vec3<f32>;
- var param_33: vec2<f32>;
- var param_34: i32;
- var param_35: i32;
+ var param_33: f32;
+ var param_34: f32;
+ var param_35: vec2<f32>;
+ var param_36: f32;
+ var param_37: vec2<f32>;
+ var sm: vec4<f32>;
+ var param_38: vec3<f32>;
+ var param_39: vec3<f32>;
+ var param_40: vec3<f32>;
+ var param_41: vec2<f32>;
+ var param_42: i32;
+ var param_43: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_36: f32;
- var param_37: f32;
- var param_38: f32;
- var param_39: f32;
- var param_40: f32;
- 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_45: 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((&param_5));
- let _e174 = (*ao);
- lit = (_e173 * _e174);
+ var param_47: f32;
+ var param_48: f32;
+ var param_49: f32;
+ var param_50: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_51: f32;
+ var param_52: f32;
+ var param_53: vec3<f32>;
+ var param_54: f32;
+ var phi_905_: bool;
+ var phi_978_: bool;
+
+ let _e165 = (*albedo);
+ let _e166 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e165, vec3(_e166));
+ let _e169 = (*roughness_3);
+ let _e170 = (*roughness_3);
+ a_4 = max((_e169 * _e170), 0.001f);
+ let _e173 = (*N_3);
+ let _e174 = (*V);
+ NdotV_2 = max(dot(_e173, _e174), 0.0001f);
+ let _e177 = (*N_3);
+ param_11 = _e177;
+ let _e178 = envIrradiance_u0028_vf3_u003b((&param_11));
+ let _e179 = (*ao);
+ lit = (_e178 * _e179);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e176 = i;
- if (_e176 < 16i) {
- let _e178 = i;
- let _e182 = unnamed_1.u_lights[_e178].posDir;
- pd_1 = _e182;
+ let _e181 = i;
+ if (_e181 < 16i) {
let _e183 = i;
- let _e187 = unnamed_1.u_lights[_e183].color;
- col = _e187;
+ let _e187 = unnamed_1.u_lights[_e183].posDir;
+ pd_1 = _e187;
let _e188 = i;
- let _e192 = unnamed_1.u_lights[_e188].shadow;
- sh_3 = _e192;
+ let _e192 = unnamed_1.u_lights[_e188].color;
+ col = _e192;
let _e193 = i;
- let _e197 = unnamed_1.u_lights[_e193].falloff;
- fo_1 = _e197;
- let _e198 = pd_1;
- target_ = _e198.xy;
+ let _e197 = unnamed_1.u_lights[_e193].shadow;
+ sh_3 = _e197;
+ let _e198 = i;
+ let _e202 = unnamed_1.u_lights[_e198].falloff;
+ fo_1 = _e202;
+ let _e203 = pd_1;
+ target_ = _e203.xy;
castShadow = true;
- 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((&param_6), (&param_7), (&param_8));
- toL = _e206;
- let _e207 = toL;
- param_9 = _e207;
- let _e208 = lightDistance_u0028_vf3_u003b((&param_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((&param_10), (&param_11), (&param_12));
- atten = _e214;
- let _e215 = toL;
- param_13 = _e215;
- let _e216 = (*N_3);
- param_14 = _e216;
- let _e217 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_13), (&param_14));
- L_1 = _e217;
+ let _e206 = pd_1[2u];
+ if (_e206 < 0.5f) {
+ let _e208 = pd_1;
+ param_12 = _e208;
+ let _e209 = sh_3;
+ param_13 = _e209;
+ let _e210 = (*worldPos_5);
+ param_14 = _e210;
+ let _e211 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_12), (&param_13), (&param_14));
+ toL = _e211;
+ let _e212 = toL;
+ param_15 = _e212;
+ let _e213 = lightDistance_u0028_vf3_u003b((&param_15));
+ dist_2 = _e213;
+ let _e215 = pd_1[3u];
+ let _e217 = dist_2;
+ param_16 = _e217;
+ param_17 = max(_e215, 0.0001f);
+ let _e218 = fo_1;
+ param_18 = _e218;
+ let _e219 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_16), (&param_17), (&param_18));
+ atten = _e219;
+ let _e220 = toL;
+ param_19 = _e220;
+ let _e221 = (*N_3);
+ param_20 = _e221;
+ let _e222 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_19), (&param_20));
+ L_1 = _e222;
} else {
- let _e219 = pd_1[2u];
- if (_e219 < 1.5f) {
+ let _e224 = pd_1[2u];
+ if (_e224 < 1.5f) {
atten = 1f;
- let _e221 = pd_1;
- 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));
+ let _e226 = pd_1;
+ let _e227 = _e226.xy;
+ let _e229 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e227.x, _e227.y, _e229)));
+ let _e235 = pd_1;
+ let _e237 = pd_1;
+ if (dot(_e235.xy, _e237.xy) > 0.00000001f) {
+ let _e241 = pd_1;
+ local_7 = normalize(-(_e241.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e245 = local_7;
+ toLight_3 = _e245;
+ let _e247 = sh_3[1u];
+ let _e248 = (_e247 > 0f);
+ phi_905_ = _e248;
+ if _e248 {
+ let _e249 = toLight_3;
+ let _e250 = toLight_3;
+ phi_905_ = (dot(_e249, _e250) > 0.5f);
}
- let _e249 = phi_839_;
- castShadow = _e249;
- let _e250 = (*worldPos_3);
- let _e252 = toLight_3;
- let _e254 = sh_3[1u];
- target_ = (_e250.xy + (_e252 * _e254));
+ let _e254 = phi_905_;
+ castShadow = _e254;
+ let _e255 = (*worldPos_5);
+ let _e257 = toLight_3;
+ let _e259 = sh_3[1u];
+ target_ = (_e255.xy + (_e257 * _e259));
} else {
- 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((&param_15), (&param_16), (&param_17));
- toL_1 = _e265;
- let _e266 = toL_1;
- param_18 = _e266;
- let _e267 = lightDistance_u0028_vf3_u003b((&param_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((&param_19), (&param_20), (&param_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((&param_22), (&param_23));
- L_1 = _e276;
- let _e277 = sp_1;
- param_24 = _e277;
- let _e278 = sh_3;
- param_25 = _e278;
+ let _e262 = i;
+ let _e266 = unnamed_1.u_lights[_e262].spot;
+ sp_1 = _e266;
+ let _e267 = pd_1;
+ param_21 = _e267;
+ let _e268 = sh_3;
+ param_22 = _e268;
+ let _e269 = (*worldPos_5);
+ param_23 = _e269;
+ let _e270 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_21), (&param_22), (&param_23));
+ toL_1 = _e270;
+ let _e271 = toL_1;
+ param_24 = _e271;
+ let _e272 = lightDistance_u0028_vf3_u003b((&param_24));
+ dist_3 = _e272;
+ let _e274 = pd_1[3u];
+ let _e276 = dist_3;
+ param_25 = _e276;
+ param_26 = max(_e274, 0.0001f);
+ let _e277 = fo_1;
+ param_27 = _e277;
+ let _e278 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_25), (&param_26), (&param_27));
+ atten = _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((&param_24), (&param_25), (&param_26), (&param_27));
- let _e282 = atten;
- atten = (_e282 * _e281);
+ param_28 = _e279;
+ let _e280 = (*N_3);
+ param_29 = _e280;
+ let _e281 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_28), (&param_29));
+ L_1 = _e281;
+ let _e282 = sp_1;
+ param_30 = _e282;
+ let _e283 = sh_3;
+ param_31 = _e283;
+ let _e284 = toL_1;
+ param_32 = _e284;
+ let _e285 = dist_3;
+ param_33 = _e285;
+ let _e286 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_30), (&param_31), (&param_32), (&param_33));
+ let _e287 = atten;
+ atten = (_e287 * _e286);
}
}
- let _e284 = castShadow;
- phi_895_ = _e284;
- if _e284 {
- let _e286 = col[3u];
- phi_895_ = (_e286 > 0f);
+ let _e290 = col[3u];
+ let _e292 = atten;
+ if ((_e290 > 0f) && (_e292 > 0f)) {
+ let _e296 = fo_1[3u];
+ param_34 = _e296;
+ let _e297 = (*worldPos_5);
+ param_35 = _e297.xy;
+ let _e299 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_34), (&param_35));
+ let _e300 = atten;
+ atten = (_e300 * _e299);
+ }
+ let _e302 = castShadow;
+ phi_978_ = _e302;
+ if _e302 {
+ let _e304 = col[3u];
+ phi_978_ = (_e304 > 0f);
}
- 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((&param_28), (&param_29));
- let _e303 = fo_1[2u];
- let _e305 = atten;
- atten = (_e305 * mix(1f, _e301, _e303));
+ let _e307 = phi_978_;
+ let _e308 = atten;
+ if (_e307 && (_e308 > 0f)) {
+ let _e311 = i;
+ let _e316 = unnamed_1.u_lights[_e311].shadowMap[3u];
+ param_36 = _e316;
+ let _e317 = (*worldPos_5);
+ param_37 = _e317.xy;
+ let _e319 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_36), (&param_37));
+ let _e321 = fo_1[2u];
+ let _e323 = atten;
+ atten = (_e323 * mix(1f, _e319, _e321));
}
- 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((&param_30), (&param_31), (&param_32), (&param_33), (&param_34), (&param_35));
- let _e334 = fo_1[2u];
- let _e336 = atten;
- atten = (_e336 * mix(1f, _e332, _e334));
+ let _e325 = i;
+ let _e329 = unnamed_1.u_lights[_e325].shadowMap;
+ sm = _e329;
+ let _e331 = sm[1u];
+ let _e333 = atten;
+ if ((_e331 > 0f) && (_e333 > 0f)) {
+ let _e337 = sh_3[0u];
+ let _e339 = sm[2u];
+ let _e342 = sm[0u];
+ let _e345 = sm[1u];
+ let _e347 = (*worldPos_5);
+ param_38 = _e347;
+ let _e348 = (*N_3);
+ param_39 = _e348;
+ let _e349 = L_1;
+ param_40 = _e349;
+ param_41 = vec2<f32>(_e337, _e339);
+ param_42 = i32(_e342);
+ param_43 = i32(_e345);
+ let _e350 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_38), (&param_39), (&param_40), (&param_41), (&param_42), (&param_43));
+ let _e352 = fo_1[2u];
+ let _e354 = atten;
+ atten = (_e354 * mix(1f, _e350, _e352));
}
- 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((&param_36), (&param_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((&param_38), (&param_39), (&param_40));
- let _e371 = NdotV_2;
- let _e373 = ndotl;
- brdf = ((_e365 * _e369) / max(((4f * _e371) * _e373), 0.0001f));
- let _e377 = radiance;
- let _e378 = (*V);
+ let _e356 = (*N_3);
+ let _e357 = L_1;
+ ndotl = max(dot(_e356, _e357), 0f);
+ let _e360 = col;
+ let _e363 = col[3u];
+ let _e364 = ndotl;
+ let _e366 = atten;
+ radiance = (_e360.xyz * ((_e363 * _e364) * _e366));
+ let _e369 = radiance;
+ let _e370 = lit;
+ lit = (_e370 + _e369);
+ let _e372 = (*specular);
+ if (_e372 > 0f) {
+ let _e374 = L_1;
+ let _e375 = (*V);
+ H = normalize((_e374 + _e375));
+ let _e378 = (*N_3);
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((&param_41), (&param_42));
- let _e385 = brdf;
- let _e387 = (*specular);
- let _e390 = gloss;
- gloss = (_e390 + ((_e377 * _e383) * ((_e385 * 3.1415927f) * _e387)));
+ param_44 = max(dot(_e378, _e379), 0f);
+ let _e382 = a_4;
+ param_45 = _e382;
+ let _e383 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_44), (&param_45));
+ let _e384 = NdotV_2;
+ param_46 = _e384;
+ let _e385 = ndotl;
+ param_47 = _e385;
+ let _e386 = (*roughness_3);
+ param_48 = _e386;
+ let _e387 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_46), (&param_47), (&param_48));
+ let _e389 = NdotV_2;
+ let _e391 = ndotl;
+ brdf = ((_e383 * _e387) / max(((4f * _e389) * _e391), 0.0001f));
+ let _e395 = radiance;
+ let _e396 = (*V);
+ let _e397 = H;
+ param_49 = max(dot(_e396, _e397), 0f);
+ let _e400 = F0_1;
+ param_50 = _e400;
+ let _e401 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_49), (&param_50));
+ let _e403 = brdf;
+ let _e405 = (*specular);
+ let _e408 = gloss;
+ gloss = (_e408 + ((_e395 * _e401) * ((_e403 * 3.1415927f) * _e405)));
}
continue;
} else {
break;
}
continuing {
- let _e392 = i;
- i = (_e392 + 1i);
+ let _e410 = i;
+ i = (_e410 + 1i);
}
}
- let _e394 = NdotV_2;
- param_43 = _e394;
- let _e395 = (*roughness_3);
- param_44 = _e395;
- let _e396 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_43), (&param_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((&param_45), (&param_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> {
+ let _e412 = NdotV_2;
+ param_51 = _e412;
+ let _e413 = (*roughness_3);
+ param_52 = _e413;
+ let _e414 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_51), (&param_52));
+ ab = _e414;
+ let _e415 = (*V);
+ let _e417 = (*N_3);
+ param_53 = reflect(-(_e415), _e417);
+ let _e419 = (*roughness_3);
+ param_54 = _e419;
+ let _e420 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_53), (&param_54));
+ let _e421 = (*ao);
+ let _e422 = (*specular);
+ let _e425 = F0_1;
+ let _e427 = ab[0u];
+ let _e430 = ab[1u];
+ let _e434 = gloss;
+ gloss = (_e434 + ((_e420 * (_e421 * _e422)) * ((_e425 * _e427) + vec3(_e430))));
+ let _e436 = (*albedo);
+ let _e437 = (*metallic);
+ let _e440 = lit;
+ let _e442 = gloss;
+ return (((_e436 * (1f - _e437)) * _e440) + _e442);
+}
+
+fn viewDirection_u0028_vf3_u003b(worldPos_6: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_8: vec3<f32>;
- let _e87 = unnamed.u_camera[3u];
- if (_e87 > 0.5f) {
- let _e90 = unnamed.u_camera;
- let _e92 = (*worldPos_4);
- local_8 = normalize((_e90.xyz - _e92));
+ let _e90 = unnamed.u_camera[3u];
+ if (_e90 > 0.5f) {
+ let _e93 = unnamed.u_camera;
+ let _e95 = (*worldPos_6);
+ local_8 = normalize((_e93.xyz - _e95));
} else {
- let _e96 = unnamed.u_camera;
- local_8 = _e96.xyz;
+ let _e99 = unnamed.u_camera;
+ local_8 = _e99.xyz;
}
- let _e98 = local_8;
- return _e98;
+ let _e101 = local_8;
+ return _e101;
}
-fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<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_47 = _e101;
- let _e102 = viewDirection_u0028_vf3_u003b((&param_47));
- let _e103 = (*albedo_1);
- param_48 = _e103;
- let _e104 = (*N_4);
- param_49 = _e104;
- let _e105 = P;
- param_50 = _e105;
- param_51 = _e102;
- param_52 = 0f;
- param_53 = 1f;
- param_54 = 0f;
- let _e106 = (*ao_1);
- param_55 = _e106;
- let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_48), (&param_49), (&param_50), (&param_51), (&param_52), (&param_53), (&param_54), (&param_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_55: vec3<f32>;
var param_56: vec3<f32>;
var param_57: vec3<f32>;
- var param_58: vec2<f32>;
- var param_59: f32;
+ var param_58: vec3<f32>;
+ var param_59: vec3<f32>;
+ var param_60: f32;
+ var param_61: f32;
+ var param_62: f32;
+ var param_63: f32;
- let _e90 = (*albedo_2);
- param_56 = _e90;
- let _e91 = (*N_5);
- param_57 = _e91;
- let _e92 = (*worldPos_6);
- param_58 = _e92;
- param_59 = 1f;
- let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59));
- return _e93;
+ let _e100 = (*worldPos_7);
+ P = vec3<f32>(_e100.x, _e100.y, 0f);
+ let _e104 = P;
+ param_55 = _e104;
+ let _e105 = viewDirection_u0028_vf3_u003b((&param_55));
+ let _e106 = (*albedo_1);
+ param_56 = _e106;
+ let _e107 = (*N_4);
+ param_57 = _e107;
+ let _e108 = P;
+ param_58 = _e108;
+ param_59 = _e105;
+ param_60 = 0f;
+ param_61 = 1f;
+ param_62 = 0f;
+ let _e109 = (*ao_1);
+ param_63 = _e109;
+ let _e110 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59), (&param_60), (&param_61), (&param_62), (&param_63));
+ return _e110;
}
-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {
- let _e86 = (*uv_1);
- let _e87 = textureSample(map_est, map_ess, _e86);
- return normalize(((_e87.xyz * 2f) - vec3(1f)));
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_64: vec3<f32>;
+ var param_65: vec3<f32>;
+ var param_66: vec2<f32>;
+ var param_67: f32;
+
+ let _e93 = (*albedo_2);
+ param_64 = _e93;
+ let _e94 = (*N_5);
+ param_65 = _e94;
+ let _e95 = (*worldPos_8);
+ param_66 = _e95;
+ param_67 = 1f;
+ let _e96 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_64), (&param_65), (&param_66), (&param_67));
+ return _e96;
+}
+
+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_2: ptr<function, vec2<f32>>) -> vec3<f32> {
+ let _e89 = (*uv_2);
+ let _e90 = textureSample(map_est, map_ess, _e89);
+ return normalize(((_e90.xyz * 2f) - vec3(1f)));
}
fn main_1() {
var base: vec4<f32>;
var N_6: vec3<f32>;
- var param_60: vec2<f32>;
+ var param_68: vec2<f32>;
var lit_1: vec3<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_60 = _e94;
- let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_60));
- N_6 = _e95;
- let _e96 = base;
- param_61 = _e96.xyz;
- let _e98 = N_6;
- param_62 = _e98;
- let _e99 = v_worldPos_1;
- param_63 = _e99;
- let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_61), (&param_62), (&param_63));
- lit_1 = _e100;
- let _e101 = lit_1;
- let _e103 = base[3u];
- fragColor = vec4<f32>(_e101.x, _e101.y, _e101.z, _e103);
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+
+ let _e93 = v_texCoord_1;
+ let _e94 = textureSample(es_bt0_est, es_bt0_ess, _e93);
+ let _e95 = v_color_1;
+ base = (_e94 * _e95);
+ let _e97 = v_texCoord_1;
+ param_68 = _e97;
+ let _e98 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_68));
+ N_6 = _e98;
+ let _e99 = base;
+ param_69 = _e99.xyz;
+ let _e101 = N_6;
+ param_70 = _e101;
+ let _e102 = v_worldPos_1;
+ param_71 = _e102;
+ let _e103 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_69), (&param_70), (&param_71));
+ lit_1 = _e103;
+ let _e104 = lit_1;
+ let _e106 = base[3u];
+ fragColor = vec4<f32>(_e104.x, _e104.y, _e104.z, _e106);
return;
}
diff --git a/fixtures/scenes/mat-lit-normal/lit-normal.esshader b/fixtures/scenes/mat-lit-normal/lit-normal.esshader
index 7d59dd92f..e870166ef 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: 65f09903605b6341
+// assembled-hash: db03d794334dafe3
struct 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: 65f09903605b6341
+// assembled-hash: db03d794334dafe3
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -139,7 +139,7 @@ struct Light {
struct LightConstants {
u_ambient: vec4<f32>,
u_lights: array<Light, 16>,
- u_shadow2DRect: vec4<f32>,
+ u_mask2DRect: vec4<f32>,
u_shadowMatrix: array<mat4x4<f32>, 16>,
u_shadowTile: array<vec4<f32>, 16>,
u_shadowParams: vec4<f32>,
@@ -161,6 +161,10 @@ var<uniform> unnamed_1: LightConstants;
var u_shadow2D_est: texture_2d<f32>;
@group(1) @binding(15)
var u_shadow2D_ess: sampler;
+@group(1) @binding(6)
+var u_lightShape2D_est: texture_2d<f32>;
+@group(1) @binding(14)
+var u_lightShape2D_ess: sampler;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -218,181 +222,238 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e95 = unnamed_1.u_envParams[0u];
- if (_e95 < 0.5f) {
- let _e98 = unnamed_1.u_ambient;
- return _e98.xyz;
+ let _e98 = unnamed_1.u_envParams[0u];
+ if (_e98 < 0.5f) {
+ let _e101 = unnamed_1.u_ambient;
+ return _e101.xyz;
}
- let _e100 = (*roughness);
- let _e104 = unnamed_1.u_envParams[2u];
- lod = (clamp(_e100, 0f, 1f) * _e104);
- let _e106 = lod;
- lo = floor(_e106);
- let _e108 = (*R_1);
- param = _e108;
- let _e109 = lo;
- param_1 = _e109;
- let _e110 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
- a = _e110;
- let _e111 = lo;
- let _e115 = unnamed_1.u_envParams[2u];
- let _e117 = (*R_1);
- param_2 = _e117;
- param_3 = min((_e111 + 1f), _e115);
- let _e118 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
- b = _e118;
- let _e120 = unnamed_1.u_ambient;
- let _e122 = a;
- let _e123 = b;
- let _e124 = lod;
- let _e125 = lo;
- let _e130 = unnamed_1.u_envTint;
- return (_e120.xyz + (mix(_e122, _e123, vec3((_e124 - _e125))) * _e130.xyz));
+ let _e103 = (*roughness);
+ let _e107 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e103, 0f, 1f) * _e107);
+ let _e109 = lod;
+ lo = floor(_e109);
+ let _e111 = (*R_1);
+ param = _e111;
+ let _e112 = lo;
+ param_1 = _e112;
+ let _e113 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e113;
+ let _e114 = lo;
+ let _e118 = unnamed_1.u_envParams[2u];
+ let _e120 = (*R_1);
+ param_2 = _e120;
+ param_3 = min((_e114 + 1f), _e118);
+ let _e121 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e121;
+ let _e123 = unnamed_1.u_ambient;
+ let _e125 = a;
+ let _e126 = b;
+ let _e127 = lod;
+ let _e128 = lo;
+ let _e133 = unnamed_1.u_envTint;
+ return (_e123.xyz + (mix(_e125, _e126, vec3((_e127 - _e128))) * _e133.xyz));
}
fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {
var r: vec4<f32>;
var a_1: f32;
- let _e87 = (*roughness_1);
- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e87) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
- let _e91 = r[0u];
- let _e93 = r[0u];
- let _e95 = (*NdotV);
- let _e100 = r[0u];
- let _e103 = r[1u];
- a_1 = ((min((_e91 * _e93), exp2((-9.28f * _e95))) * _e100) + _e103);
- let _e105 = a_1;
- let _e107 = r;
- return ((vec2<f32>(-1.04f, 1.04f) * _e105) + _e107.zw);
+ let _e90 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e90) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e94 = r[0u];
+ let _e96 = r[0u];
+ let _e98 = (*NdotV);
+ let _e103 = r[0u];
+ let _e106 = r[1u];
+ a_1 = ((min((_e94 * _e96), exp2((-9.28f * _e98))) * _e103) + _e106);
+ let _e108 = a_1;
+ let _e110 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e108) + _e110.zw);
}
fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e85 = (*F0_);
- let _e86 = (*F0_);
- let _e88 = (*VdotH);
- return (_e85 + ((vec3<f32>(1f, 1f, 1f) - _e86) * pow((1f - _e88), 5f)));
+ let _e88 = (*F0_);
+ let _e89 = (*F0_);
+ let _e91 = (*VdotH);
+ return (_e88 + ((vec3<f32>(1f, 1f, 1f) - _e89) * pow((1f - _e91), 5f)));
}
fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {
var k: f32;
- let _e87 = (*roughness_2);
- let _e89 = (*roughness_2);
- k = (((_e87 + 1f) * (_e89 + 1f)) * 0.125f);
- let _e93 = (*NdotV_1);
- let _e94 = (*NdotV_1);
- let _e95 = k;
+ let _e90 = (*roughness_2);
+ let _e92 = (*roughness_2);
+ k = (((_e90 + 1f) * (_e92 + 1f)) * 0.125f);
+ let _e96 = (*NdotV_1);
+ let _e97 = (*NdotV_1);
let _e98 = k;
- let _e101 = (*NdotL);
- let _e102 = (*NdotL);
- let _e103 = k;
+ let _e101 = k;
+ let _e104 = (*NdotL);
+ let _e105 = (*NdotL);
let _e106 = k;
- return ((_e93 / ((_e94 * (1f - _e95)) + _e98)) * (_e101 / ((_e102 * (1f - _e103)) + _e106)));
+ let _e109 = k;
+ return ((_e96 / ((_e97 * (1f - _e98)) + _e101)) * (_e104 / ((_e105 * (1f - _e106)) + _e109)));
}
fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {
var a2_: f32;
var d: f32;
- let _e87 = (*a_2);
- let _e88 = (*a_2);
- a2_ = (_e87 * _e88);
- let _e90 = (*NdotH);
- let _e91 = (*NdotH);
- let _e93 = a2_;
- d = (((_e90 * _e91) * (_e93 - 1f)) + 1f);
- let _e97 = a2_;
- let _e98 = d;
- let _e100 = d;
- return (_e97 / max(((3.1415927f * _e98) * _e100), 0.0000001f));
+ let _e90 = (*a_2);
+ let _e91 = (*a_2);
+ a2_ = (_e90 * _e91);
+ let _e93 = (*NdotH);
+ let _e94 = (*NdotH);
+ let _e96 = a2_;
+ d = (((_e93 * _e94) * (_e96 - 1f)) + 1f);
+ let _e100 = a2_;
+ let _e101 = d;
+ let _e103 = d;
+ return (_e100 / max(((3.1415927f * _e101) * _e103), 0.0000001f));
}
fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {
return 1f;
}
-fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {
+fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel: ptr<function, f32>) -> f32 {
+ var local: f32;
+ var local_1: f32;
+ var local_2: f32;
+
+ let _e91 = (*channel);
+ if (_e91 < 0.5f) {
+ let _e94 = (*m)[0u];
+ local = _e94;
+ } else {
+ let _e95 = (*channel);
+ if (_e95 < 1.5f) {
+ let _e98 = (*m)[1u];
+ local_1 = _e98;
+ } else {
+ let _e99 = (*channel);
+ if (_e99 < 2.5f) {
+ let _e102 = (*m)[2u];
+ local_2 = _e102;
+ } else {
+ let _e104 = (*m)[3u];
+ local_2 = _e104;
+ }
+ let _e105 = local_2;
+ local_1 = _e105;
+ }
+ let _e106 = local_1;
+ local = _e106;
+ }
+ let _e107 = local;
+ return _e107;
+}
+
+fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var clip: vec4<f32>;
var ndc: vec2<f32>;
var v: f32;
- var local: f32;
+ var local_3: f32;
+
+ let _e92 = unnamed.u_projection;
+ let _e93 = (*worldPos_1);
+ clip = (_e92 * vec4<f32>(_e93.x, _e93.y, 0f, 1f));
+ let _e99 = clip[3u];
+ if (_e99 <= 0f) {
+ return vec2<f32>(-1f, -1f);
+ }
+ let _e101 = clip;
+ let _e104 = clip[3u];
+ ndc = (((_e101.xy / vec2(_e104)) * 0.5f) + vec2(0.5f));
+ let _e112 = unnamed_1.u_mask2DRect[3u];
+ if (_e112 < 0f) {
+ let _e115 = ndc[1u];
+ local_3 = (1f - _e115);
+ } else {
+ let _e118 = ndc[1u];
+ local_3 = _e118;
+ }
+ let _e119 = local_3;
+ v = _e119;
+ let _e121 = unnamed_1.u_mask2DRect;
+ let _e124 = ndc[0u];
+ let _e127 = unnamed_1.u_mask2DRect[2u];
+ let _e129 = v;
+ let _e132 = unnamed_1.u_mask2DRect[3u];
+ return (_e121.xy + vec2<f32>((_e124 * _e127), (_e129 * abs(_e132))));
+}
+
+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
var uv: vec2<f32>;
- var m: vec4<f32>;
+ var param_4: vec2<f32>;
var hidden: f32;
- var local_1: f32;
- var local_2: f32;
- var local_3: f32;
- var phi_200_: bool;
-
- let _e95 = (*channel);
- let _e96 = (_e95 < 0f);
- phi_200_ = _e96;
- if !(_e96) {
- let _e100 = unnamed_1.u_shadow2DRect[2u];
- phi_200_ = (_e100 <= 0f);
+ var param_5: vec4<f32>;
+ var param_6: f32;
+ var phi_307_: bool;
+
+ let _e93 = (*channel_1);
+ let _e94 = (_e93 < 0f);
+ phi_307_ = _e94;
+ if !(_e94) {
+ let _e98 = unnamed_1.u_mask2DRect[2u];
+ phi_307_ = (_e98 <= 0f);
}
- let _e103 = phi_200_;
- if _e103 {
+ let _e101 = phi_307_;
+ if _e101 {
return 1f;
}
- let _e105 = unnamed.u_projection;
- let _e106 = (*worldPos_1);
- clip = (_e105 * vec4<f32>(_e106.x, _e106.y, 0f, 1f));
- let _e112 = clip[3u];
- if (_e112 <= 0f) {
+ let _e102 = (*worldPos_2);
+ param_4 = _e102;
+ let _e103 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e103;
+ let _e105 = uv[0u];
+ if (_e105 < 0f) {
return 1f;
}
- let _e114 = clip;
- let _e117 = clip[3u];
- ndc = (((_e114.xy / vec2(_e117)) * 0.5f) + vec2(0.5f));
- let _e125 = unnamed_1.u_shadow2DRect[3u];
- if (_e125 < 0f) {
- let _e128 = ndc[1u];
- local = (1f - _e128);
- } else {
- let _e131 = ndc[1u];
- local = _e131;
+ let _e107 = uv;
+ let _e108 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e107, 0f);
+ param_5 = _e108;
+ let _e109 = (*channel_1);
+ param_6 = _e109;
+ let _e110 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e110;
+ let _e111 = hidden;
+ return (1f - min(_e111, 1f));
+}
+
+fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
+ var uv_1: vec2<f32>;
+ var param_7: vec2<f32>;
+ var param_8: vec4<f32>;
+ var param_9: f32;
+ var phi_346_: bool;
+
+ let _e92 = (*channel_2);
+ let _e93 = (_e92 < 0f);
+ phi_346_ = _e93;
+ if !(_e93) {
+ let _e97 = unnamed_1.u_mask2DRect[2u];
+ phi_346_ = (_e97 <= 0f);
}
- let _e132 = local;
- v = _e132;
- let _e134 = unnamed_1.u_shadow2DRect;
- let _e137 = ndc[0u];
- let _e140 = unnamed_1.u_shadow2DRect[2u];
- let _e142 = v;
- let _e145 = unnamed_1.u_shadow2DRect[3u];
- uv = (_e134.xy + vec2<f32>((_e137 * _e140), (_e142 * abs(_e145))));
- let _e150 = uv;
- let _e151 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e150, 0f);
- m = _e151;
- let _e152 = (*channel);
- if (_e152 < 0.5f) {
- let _e155 = m[0u];
- local_1 = _e155;
- } else {
- let _e156 = (*channel);
- if (_e156 < 1.5f) {
- let _e159 = m[1u];
- local_2 = _e159;
- } else {
- let _e160 = (*channel);
- if (_e160 < 2.5f) {
- let _e163 = m[2u];
- local_3 = _e163;
- } else {
- let _e165 = m[3u];
- local_3 = _e165;
- }
- let _e166 = local_3;
- local_2 = _e166;
- }
- let _e167 = local_2;
- local_1 = _e167;
+ let _e100 = phi_346_;
+ if _e100 {
+ return 1f;
}
- let _e168 = local_1;
- hidden = _e168;
- let _e169 = hidden;
- return (1f - min(_e169, 1f));
+ let _e101 = (*worldPos_3);
+ param_7 = _e101;
+ let _e102 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e102;
+ let _e104 = uv_1[0u];
+ if (_e104 < 0f) {
+ return 1f;
+ }
+ let _e106 = uv_1;
+ let _e107 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e106, 0f);
+ param_8 = _e107;
+ let _e108 = (*channel_2);
+ param_9 = _e108;
+ let _e109 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e109, 1f);
}
fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {
@@ -401,74 +462,74 @@ fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<
var toFrag: vec2<f32>;
var local_5: vec2<f32>;
- let _e91 = (*sp);
- let _e93 = (*sp);
- if (dot(_e91.xy, _e93.xy) > 0.00000001f) {
- let _e97 = (*sp);
- local_4 = normalize(_e97.xy);
+ let _e94 = (*sp);
+ let _e96 = (*sp);
+ if (dot(_e94.xy, _e96.xy) > 0.00000001f) {
+ let _e100 = (*sp);
+ local_4 = normalize(_e100.xy);
} else {
local_4 = vec2<f32>(0f, -1f);
}
- let _e100 = local_4;
- axis = _e100;
- let _e101 = (*dist);
- if (_e101 > 0.0001f) {
- let _e103 = (*toLight);
- let _e106 = (*dist);
- local_5 = (-(_e103.xy) / vec2(_e106));
+ let _e103 = local_4;
+ axis = _e103;
+ let _e104 = (*dist);
+ if (_e104 > 0.0001f) {
+ let _e106 = (*toLight);
+ let _e109 = (*dist);
+ local_5 = (-(_e106.xy) / vec2(_e109));
} else {
- let _e109 = axis;
- local_5 = _e109;
+ let _e112 = axis;
+ local_5 = _e112;
}
- let _e110 = local_5;
- toFrag = _e110;
- let _e112 = (*sp)[3u];
- let _e114 = (*sp)[2u];
- let _e115 = axis;
- let _e116 = toFrag;
- return smoothstep(_e112, _e114, dot(_e115, _e116));
+ let _e113 = local_5;
+ toFrag = _e113;
+ let _e115 = (*sp)[3u];
+ let _e117 = (*sp)[2u];
+ let _e118 = axis;
+ let _e119 = toFrag;
+ return smoothstep(_e115, _e117, dot(_e118, _e119));
}
fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_6: vec3<f32>;
- let _e86 = (*toLight_1);
- let _e87 = (*toLight_1);
- if (dot(_e86, _e87) > 0.00000001f) {
- let _e90 = (*toLight_1);
- local_6 = normalize(_e90);
+ let _e89 = (*toLight_1);
+ let _e90 = (*toLight_1);
+ if (dot(_e89, _e90) > 0.00000001f) {
+ let _e93 = (*toLight_1);
+ local_6 = normalize(_e93);
} else {
- let _e92 = (*N_1);
- local_6 = _e92;
+ let _e95 = (*N_1);
+ local_6 = _e95;
}
- let _e93 = local_6;
- return _e93;
+ let _e96 = local_6;
+ return _e96;
}
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));
+ let _e91 = (*dist_1);
+ let _e93 = (*reach);
+ let _e95 = (*fo)[0u];
+ ramp = clamp(((_e90 - _e91) / max((_e93 - _e95), 0.0001f)), 0f, 1f);
+ let _e100 = ramp;
+ let _e102 = (*fo)[1u];
+ return pow(_e100, max(_e102, 0.001f));
}
fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {
- let _e84 = (*toLight_2);
- return length(_e84.xy);
+ let _e87 = (*toLight_2);
+ return length(_e87.xy);
}
-fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e86 = (*pd);
- let _e88 = (*worldPos_2);
- let _e90 = (_e86.xy - _e88.xy);
- let _e92 = (*pd)[3u];
- return vec3<f32>(_e90.x, _e90.y, max(_e92, 1f));
+fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e89 = (*pd);
+ let _e91 = (*worldPos_4);
+ let _e93 = (_e89.xy - _e91.xy);
+ let _e95 = (*pd)[3u];
+ return vec3<f32>(_e93.x, _e93.y, max(_e95, 1f));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -476,70 +537,70 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- let _e89 = unnamed_1.u_envTint[3u];
- a_3 = -(_e89);
- let _e91 = a_3;
- s = sin(_e91);
- let _e93 = a_3;
- c = cos(_e93);
- let _e95 = c;
- let _e97 = (*d_1)[0u];
- let _e99 = s;
- let _e101 = (*d_1)[2u];
- let _e105 = (*d_1)[1u];
- let _e106 = s;
- let _e109 = (*d_1)[0u];
- let _e111 = c;
- let _e113 = (*d_1)[2u];
- return vec3<f32>(((_e95 * _e97) + (_e99 * _e101)), _e105, ((-(_e106) * _e109) + (_e111 * _e113)));
+ let _e92 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e92);
+ let _e94 = a_3;
+ s = sin(_e94);
+ let _e96 = a_3;
+ c = cos(_e96);
+ let _e98 = c;
+ let _e100 = (*d_1)[0u];
+ let _e102 = s;
+ let _e104 = (*d_1)[2u];
+ let _e108 = (*d_1)[1u];
+ let _e109 = s;
+ let _e112 = (*d_1)[0u];
+ let _e114 = c;
+ let _e116 = (*d_1)[2u];
+ return vec3<f32>(((_e98 * _e100) + (_e102 * _e104)), _e108, ((-(_e109) * _e112) + (_e114 * _e116)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
var N_2: vec3<f32>;
- var param_4: vec3<f32>;
+ var param_10: vec3<f32>;
var sh_2: vec3<f32>;
- let _e87 = (*Nw);
- param_4 = _e87;
- let _e88 = envDirection_u0028_vf3_u003b((&param_4));
- N_2 = _e88;
- let _e91 = unnamed_1.u_envIrradiance[0i];
- let _e96 = unnamed_1.u_envIrradiance[1i];
- let _e99 = N_2[1u];
- let _e105 = unnamed_1.u_envIrradiance[2i];
- let _e108 = N_2[2u];
- let _e114 = unnamed_1.u_envIrradiance[3i];
- let _e117 = N_2[0u];
- let _e123 = unnamed_1.u_envIrradiance[4i];
- let _e126 = N_2[0u];
- let _e129 = N_2[1u];
- let _e135 = unnamed_1.u_envIrradiance[5i];
- let _e138 = N_2[1u];
- let _e141 = N_2[2u];
- let _e147 = unnamed_1.u_envIrradiance[6i];
- let _e150 = N_2[2u];
+ let _e90 = (*Nw);
+ param_10 = _e90;
+ let _e91 = envDirection_u0028_vf3_u003b((&param_10));
+ N_2 = _e91;
+ let _e94 = unnamed_1.u_envIrradiance[0i];
+ let _e99 = unnamed_1.u_envIrradiance[1i];
+ let _e102 = N_2[1u];
+ let _e108 = unnamed_1.u_envIrradiance[2i];
+ let _e111 = N_2[2u];
+ let _e117 = unnamed_1.u_envIrradiance[3i];
+ let _e120 = N_2[0u];
+ let _e126 = unnamed_1.u_envIrradiance[4i];
+ let _e129 = N_2[0u];
+ let _e132 = N_2[1u];
+ let _e138 = unnamed_1.u_envIrradiance[5i];
+ let _e141 = N_2[1u];
+ let _e144 = N_2[2u];
+ let _e150 = unnamed_1.u_envIrradiance[6i];
let _e153 = N_2[2u];
- let _e161 = unnamed_1.u_envIrradiance[7i];
- let _e164 = N_2[0u];
- let _e167 = N_2[2u];
- let _e173 = unnamed_1.u_envIrradiance[8i];
- let _e176 = N_2[0u];
- let _e178 = N_2[0u];
- let _e181 = N_2[1u];
- let _e183 = N_2[1u];
- sh_2 = (((((((((_e91.xyz * 0.282095f) + (_e96.xyz * (0.488603f * _e99))) + (_e105.xyz * (0.488603f * _e108))) + (_e114.xyz * (0.488603f * _e117))) + (_e123.xyz * ((1.092548f * _e126) * _e129))) + (_e135.xyz * ((1.092548f * _e138) * _e141))) + (_e147.xyz * (0.315392f * (((3f * _e150) * _e153) - 1f)))) + (_e161.xyz * ((1.092548f * _e164) * _e167))) + (_e173.xyz * (0.546274f * ((_e176 * _e178) - (_e181 * _e183)))));
- let _e190 = unnamed_1.u_ambient;
- let _e192 = sh_2;
- let _e195 = unnamed_1.u_envTint;
- return (_e190.xyz + (max(_e192, vec3<f32>(0f, 0f, 0f)) * _e195.xyz));
-}
-
-fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
+ let _e156 = N_2[2u];
+ let _e164 = unnamed_1.u_envIrradiance[7i];
+ let _e167 = N_2[0u];
+ let _e170 = N_2[2u];
+ let _e176 = unnamed_1.u_envIrradiance[8i];
+ let _e179 = N_2[0u];
+ let _e181 = N_2[0u];
+ let _e184 = N_2[1u];
+ let _e186 = N_2[1u];
+ sh_2 = (((((((((_e94.xyz * 0.282095f) + (_e99.xyz * (0.488603f * _e102))) + (_e108.xyz * (0.488603f * _e111))) + (_e117.xyz * (0.488603f * _e120))) + (_e126.xyz * ((1.092548f * _e129) * _e132))) + (_e138.xyz * ((1.092548f * _e141) * _e144))) + (_e150.xyz * (0.315392f * (((3f * _e153) * _e156) - 1f)))) + (_e164.xyz * ((1.092548f * _e167) * _e170))) + (_e176.xyz * (0.546274f * ((_e179 * _e181) - (_e184 * _e186)))));
+ let _e193 = unnamed_1.u_ambient;
+ let _e195 = sh_2;
+ let _e198 = unnamed_1.u_envTint;
+ return (_e193.xyz + (max(_e195, vec3<f32>(0f, 0f, 0f)) * _e198.xyz));
+}
+
+fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
var F0_1: vec3<f32>;
var a_4: f32;
var NdotV_2: f32;
var lit: vec3<f32>;
- var param_5: vec3<f32>;
+ var param_11: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
@@ -549,423 +610,436 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0
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 param_12: vec4<f32>;
+ var param_13: vec4<f32>;
+ var param_14: vec3<f32>;
var dist_2: f32;
- var param_9: vec3<f32>;
+ var param_15: vec3<f32>;
var atten: f32;
- var param_10: f32;
- var param_11: f32;
- var param_12: vec4<f32>;
+ var param_16: f32;
+ var param_17: f32;
+ var param_18: vec4<f32>;
var L_1: vec3<f32>;
- var param_13: vec3<f32>;
- var param_14: vec3<f32>;
+ var param_19: vec3<f32>;
+ var param_20: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_15: vec4<f32>;
- var param_16: vec4<f32>;
- var param_17: 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_22: vec4<f32>;
var param_23: vec3<f32>;
- var param_24: vec4<f32>;
- var param_25: vec4<f32>;
- var param_26: vec3<f32>;
- var param_27: f32;
- var param_28: f32;
- var param_29: vec2<f32>;
- var sm: vec4<f32>;
- var param_30: vec3<f32>;
- var param_31: vec3<f32>;
+ var dist_3: f32;
+ var param_24: vec3<f32>;
+ var param_25: f32;
+ var param_26: f32;
+ var param_27: vec4<f32>;
+ var param_28: vec3<f32>;
+ var param_29: vec3<f32>;
+ var param_30: vec4<f32>;
+ var param_31: vec4<f32>;
var param_32: vec3<f32>;
- var param_33: vec2<f32>;
- var param_34: i32;
- var param_35: i32;
+ var param_33: f32;
+ var param_34: f32;
+ var param_35: vec2<f32>;
+ var param_36: f32;
+ var param_37: vec2<f32>;
+ var sm: vec4<f32>;
+ var param_38: vec3<f32>;
+ var param_39: vec3<f32>;
+ var param_40: vec3<f32>;
+ var param_41: vec2<f32>;
+ var param_42: i32;
+ var param_43: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_36: f32;
- var param_37: f32;
- var param_38: f32;
- var param_39: f32;
- var param_40: f32;
- 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_45: 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((&param_5));
- let _e174 = (*ao);
- lit = (_e173 * _e174);
+ var param_47: f32;
+ var param_48: f32;
+ var param_49: f32;
+ var param_50: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_51: f32;
+ var param_52: f32;
+ var param_53: vec3<f32>;
+ var param_54: f32;
+ var phi_905_: bool;
+ var phi_978_: bool;
+
+ let _e165 = (*albedo);
+ let _e166 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e165, vec3(_e166));
+ let _e169 = (*roughness_3);
+ let _e170 = (*roughness_3);
+ a_4 = max((_e169 * _e170), 0.001f);
+ let _e173 = (*N_3);
+ let _e174 = (*V);
+ NdotV_2 = max(dot(_e173, _e174), 0.0001f);
+ let _e177 = (*N_3);
+ param_11 = _e177;
+ let _e178 = envIrradiance_u0028_vf3_u003b((&param_11));
+ let _e179 = (*ao);
+ lit = (_e178 * _e179);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e176 = i;
- if (_e176 < 16i) {
- let _e178 = i;
- let _e182 = unnamed_1.u_lights[_e178].posDir;
- pd_1 = _e182;
+ let _e181 = i;
+ if (_e181 < 16i) {
let _e183 = i;
- let _e187 = unnamed_1.u_lights[_e183].color;
- col = _e187;
+ let _e187 = unnamed_1.u_lights[_e183].posDir;
+ pd_1 = _e187;
let _e188 = i;
- let _e192 = unnamed_1.u_lights[_e188].shadow;
- sh_3 = _e192;
+ let _e192 = unnamed_1.u_lights[_e188].color;
+ col = _e192;
let _e193 = i;
- let _e197 = unnamed_1.u_lights[_e193].falloff;
- fo_1 = _e197;
- let _e198 = pd_1;
- target_ = _e198.xy;
+ let _e197 = unnamed_1.u_lights[_e193].shadow;
+ sh_3 = _e197;
+ let _e198 = i;
+ let _e202 = unnamed_1.u_lights[_e198].falloff;
+ fo_1 = _e202;
+ let _e203 = pd_1;
+ target_ = _e203.xy;
castShadow = true;
- 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((&param_6), (&param_7), (&param_8));
- toL = _e206;
- let _e207 = toL;
- param_9 = _e207;
- let _e208 = lightDistance_u0028_vf3_u003b((&param_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((&param_10), (&param_11), (&param_12));
- atten = _e214;
- let _e215 = toL;
- param_13 = _e215;
- let _e216 = (*N_3);
- param_14 = _e216;
- let _e217 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_13), (&param_14));
- L_1 = _e217;
+ let _e206 = pd_1[2u];
+ if (_e206 < 0.5f) {
+ let _e208 = pd_1;
+ param_12 = _e208;
+ let _e209 = sh_3;
+ param_13 = _e209;
+ let _e210 = (*worldPos_5);
+ param_14 = _e210;
+ let _e211 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_12), (&param_13), (&param_14));
+ toL = _e211;
+ let _e212 = toL;
+ param_15 = _e212;
+ let _e213 = lightDistance_u0028_vf3_u003b((&param_15));
+ dist_2 = _e213;
+ let _e215 = pd_1[3u];
+ let _e217 = dist_2;
+ param_16 = _e217;
+ param_17 = max(_e215, 0.0001f);
+ let _e218 = fo_1;
+ param_18 = _e218;
+ let _e219 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_16), (&param_17), (&param_18));
+ atten = _e219;
+ let _e220 = toL;
+ param_19 = _e220;
+ let _e221 = (*N_3);
+ param_20 = _e221;
+ let _e222 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_19), (&param_20));
+ L_1 = _e222;
} else {
- let _e219 = pd_1[2u];
- if (_e219 < 1.5f) {
+ let _e224 = pd_1[2u];
+ if (_e224 < 1.5f) {
atten = 1f;
- let _e221 = pd_1;
- 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));
+ let _e226 = pd_1;
+ let _e227 = _e226.xy;
+ let _e229 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e227.x, _e227.y, _e229)));
+ let _e235 = pd_1;
+ let _e237 = pd_1;
+ if (dot(_e235.xy, _e237.xy) > 0.00000001f) {
+ let _e241 = pd_1;
+ local_7 = normalize(-(_e241.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e245 = local_7;
+ toLight_3 = _e245;
+ let _e247 = sh_3[1u];
+ let _e248 = (_e247 > 0f);
+ phi_905_ = _e248;
+ if _e248 {
+ let _e249 = toLight_3;
+ let _e250 = toLight_3;
+ phi_905_ = (dot(_e249, _e250) > 0.5f);
}
- let _e249 = phi_839_;
- castShadow = _e249;
- let _e250 = (*worldPos_3);
- let _e252 = toLight_3;
- let _e254 = sh_3[1u];
- target_ = (_e250.xy + (_e252 * _e254));
+ let _e254 = phi_905_;
+ castShadow = _e254;
+ let _e255 = (*worldPos_5);
+ let _e257 = toLight_3;
+ let _e259 = sh_3[1u];
+ target_ = (_e255.xy + (_e257 * _e259));
} else {
- 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((&param_15), (&param_16), (&param_17));
- toL_1 = _e265;
- let _e266 = toL_1;
- param_18 = _e266;
- let _e267 = lightDistance_u0028_vf3_u003b((&param_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((&param_19), (&param_20), (&param_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((&param_22), (&param_23));
- L_1 = _e276;
- let _e277 = sp_1;
- param_24 = _e277;
- let _e278 = sh_3;
- param_25 = _e278;
+ let _e262 = i;
+ let _e266 = unnamed_1.u_lights[_e262].spot;
+ sp_1 = _e266;
+ let _e267 = pd_1;
+ param_21 = _e267;
+ let _e268 = sh_3;
+ param_22 = _e268;
+ let _e269 = (*worldPos_5);
+ param_23 = _e269;
+ let _e270 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_21), (&param_22), (&param_23));
+ toL_1 = _e270;
+ let _e271 = toL_1;
+ param_24 = _e271;
+ let _e272 = lightDistance_u0028_vf3_u003b((&param_24));
+ dist_3 = _e272;
+ let _e274 = pd_1[3u];
+ let _e276 = dist_3;
+ param_25 = _e276;
+ param_26 = max(_e274, 0.0001f);
+ let _e277 = fo_1;
+ param_27 = _e277;
+ let _e278 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_25), (&param_26), (&param_27));
+ atten = _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((&param_24), (&param_25), (&param_26), (&param_27));
- let _e282 = atten;
- atten = (_e282 * _e281);
+ param_28 = _e279;
+ let _e280 = (*N_3);
+ param_29 = _e280;
+ let _e281 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_28), (&param_29));
+ L_1 = _e281;
+ let _e282 = sp_1;
+ param_30 = _e282;
+ let _e283 = sh_3;
+ param_31 = _e283;
+ let _e284 = toL_1;
+ param_32 = _e284;
+ let _e285 = dist_3;
+ param_33 = _e285;
+ let _e286 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_30), (&param_31), (&param_32), (&param_33));
+ let _e287 = atten;
+ atten = (_e287 * _e286);
}
}
- let _e284 = castShadow;
- phi_895_ = _e284;
- if _e284 {
- let _e286 = col[3u];
- phi_895_ = (_e286 > 0f);
+ let _e290 = col[3u];
+ let _e292 = atten;
+ if ((_e290 > 0f) && (_e292 > 0f)) {
+ let _e296 = fo_1[3u];
+ param_34 = _e296;
+ let _e297 = (*worldPos_5);
+ param_35 = _e297.xy;
+ let _e299 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_34), (&param_35));
+ let _e300 = atten;
+ atten = (_e300 * _e299);
+ }
+ let _e302 = castShadow;
+ phi_978_ = _e302;
+ if _e302 {
+ let _e304 = col[3u];
+ phi_978_ = (_e304 > 0f);
}
- 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((&param_28), (&param_29));
- let _e303 = fo_1[2u];
- let _e305 = atten;
- atten = (_e305 * mix(1f, _e301, _e303));
+ let _e307 = phi_978_;
+ let _e308 = atten;
+ if (_e307 && (_e308 > 0f)) {
+ let _e311 = i;
+ let _e316 = unnamed_1.u_lights[_e311].shadowMap[3u];
+ param_36 = _e316;
+ let _e317 = (*worldPos_5);
+ param_37 = _e317.xy;
+ let _e319 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_36), (&param_37));
+ let _e321 = fo_1[2u];
+ let _e323 = atten;
+ atten = (_e323 * mix(1f, _e319, _e321));
}
- 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((&param_30), (&param_31), (&param_32), (&param_33), (&param_34), (&param_35));
- let _e334 = fo_1[2u];
- let _e336 = atten;
- atten = (_e336 * mix(1f, _e332, _e334));
+ let _e325 = i;
+ let _e329 = unnamed_1.u_lights[_e325].shadowMap;
+ sm = _e329;
+ let _e331 = sm[1u];
+ let _e333 = atten;
+ if ((_e331 > 0f) && (_e333 > 0f)) {
+ let _e337 = sh_3[0u];
+ let _e339 = sm[2u];
+ let _e342 = sm[0u];
+ let _e345 = sm[1u];
+ let _e347 = (*worldPos_5);
+ param_38 = _e347;
+ let _e348 = (*N_3);
+ param_39 = _e348;
+ let _e349 = L_1;
+ param_40 = _e349;
+ param_41 = vec2<f32>(_e337, _e339);
+ param_42 = i32(_e342);
+ param_43 = i32(_e345);
+ let _e350 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_38), (&param_39), (&param_40), (&param_41), (&param_42), (&param_43));
+ let _e352 = fo_1[2u];
+ let _e354 = atten;
+ atten = (_e354 * mix(1f, _e350, _e352));
}
- 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((&param_36), (&param_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((&param_38), (&param_39), (&param_40));
- let _e371 = NdotV_2;
- let _e373 = ndotl;
- brdf = ((_e365 * _e369) / max(((4f * _e371) * _e373), 0.0001f));
- let _e377 = radiance;
- let _e378 = (*V);
+ let _e356 = (*N_3);
+ let _e357 = L_1;
+ ndotl = max(dot(_e356, _e357), 0f);
+ let _e360 = col;
+ let _e363 = col[3u];
+ let _e364 = ndotl;
+ let _e366 = atten;
+ radiance = (_e360.xyz * ((_e363 * _e364) * _e366));
+ let _e369 = radiance;
+ let _e370 = lit;
+ lit = (_e370 + _e369);
+ let _e372 = (*specular);
+ if (_e372 > 0f) {
+ let _e374 = L_1;
+ let _e375 = (*V);
+ H = normalize((_e374 + _e375));
+ let _e378 = (*N_3);
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((&param_41), (&param_42));
- let _e385 = brdf;
- let _e387 = (*specular);
- let _e390 = gloss;
- gloss = (_e390 + ((_e377 * _e383) * ((_e385 * 3.1415927f) * _e387)));
+ param_44 = max(dot(_e378, _e379), 0f);
+ let _e382 = a_4;
+ param_45 = _e382;
+ let _e383 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_44), (&param_45));
+ let _e384 = NdotV_2;
+ param_46 = _e384;
+ let _e385 = ndotl;
+ param_47 = _e385;
+ let _e386 = (*roughness_3);
+ param_48 = _e386;
+ let _e387 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_46), (&param_47), (&param_48));
+ let _e389 = NdotV_2;
+ let _e391 = ndotl;
+ brdf = ((_e383 * _e387) / max(((4f * _e389) * _e391), 0.0001f));
+ let _e395 = radiance;
+ let _e396 = (*V);
+ let _e397 = H;
+ param_49 = max(dot(_e396, _e397), 0f);
+ let _e400 = F0_1;
+ param_50 = _e400;
+ let _e401 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_49), (&param_50));
+ let _e403 = brdf;
+ let _e405 = (*specular);
+ let _e408 = gloss;
+ gloss = (_e408 + ((_e395 * _e401) * ((_e403 * 3.1415927f) * _e405)));
}
continue;
} else {
break;
}
continuing {
- let _e392 = i;
- i = (_e392 + 1i);
+ let _e410 = i;
+ i = (_e410 + 1i);
}
}
- let _e394 = NdotV_2;
- param_43 = _e394;
- let _e395 = (*roughness_3);
- param_44 = _e395;
- let _e396 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_43), (&param_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((&param_45), (&param_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> {
+ let _e412 = NdotV_2;
+ param_51 = _e412;
+ let _e413 = (*roughness_3);
+ param_52 = _e413;
+ let _e414 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_51), (&param_52));
+ ab = _e414;
+ let _e415 = (*V);
+ let _e417 = (*N_3);
+ param_53 = reflect(-(_e415), _e417);
+ let _e419 = (*roughness_3);
+ param_54 = _e419;
+ let _e420 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_53), (&param_54));
+ let _e421 = (*ao);
+ let _e422 = (*specular);
+ let _e425 = F0_1;
+ let _e427 = ab[0u];
+ let _e430 = ab[1u];
+ let _e434 = gloss;
+ gloss = (_e434 + ((_e420 * (_e421 * _e422)) * ((_e425 * _e427) + vec3(_e430))));
+ let _e436 = (*albedo);
+ let _e437 = (*metallic);
+ let _e440 = lit;
+ let _e442 = gloss;
+ return (((_e436 * (1f - _e437)) * _e440) + _e442);
+}
+
+fn viewDirection_u0028_vf3_u003b(worldPos_6: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_8: vec3<f32>;
- let _e87 = unnamed.u_camera[3u];
- if (_e87 > 0.5f) {
- let _e90 = unnamed.u_camera;
- let _e92 = (*worldPos_4);
- local_8 = normalize((_e90.xyz - _e92));
+ let _e90 = unnamed.u_camera[3u];
+ if (_e90 > 0.5f) {
+ let _e93 = unnamed.u_camera;
+ let _e95 = (*worldPos_6);
+ local_8 = normalize((_e93.xyz - _e95));
} else {
- let _e96 = unnamed.u_camera;
- local_8 = _e96.xyz;
+ let _e99 = unnamed.u_camera;
+ local_8 = _e99.xyz;
}
- let _e98 = local_8;
- return _e98;
+ let _e101 = local_8;
+ return _e101;
}
-fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<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_47 = _e101;
- let _e102 = viewDirection_u0028_vf3_u003b((&param_47));
- let _e103 = (*albedo_1);
- param_48 = _e103;
- let _e104 = (*N_4);
- param_49 = _e104;
- let _e105 = P;
- param_50 = _e105;
- param_51 = _e102;
- param_52 = 0f;
- param_53 = 1f;
- param_54 = 0f;
- let _e106 = (*ao_1);
- param_55 = _e106;
- let _e107 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_48), (&param_49), (&param_50), (&param_51), (&param_52), (&param_53), (&param_54), (&param_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_55: vec3<f32>;
var param_56: vec3<f32>;
var param_57: vec3<f32>;
- var param_58: vec2<f32>;
- var param_59: f32;
+ var param_58: vec3<f32>;
+ var param_59: vec3<f32>;
+ var param_60: f32;
+ var param_61: f32;
+ var param_62: f32;
+ var param_63: f32;
- let _e90 = (*albedo_2);
- param_56 = _e90;
- let _e91 = (*N_5);
- param_57 = _e91;
- let _e92 = (*worldPos_6);
- param_58 = _e92;
- param_59 = 1f;
- let _e93 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59));
- return _e93;
+ let _e100 = (*worldPos_7);
+ P = vec3<f32>(_e100.x, _e100.y, 0f);
+ let _e104 = P;
+ param_55 = _e104;
+ let _e105 = viewDirection_u0028_vf3_u003b((&param_55));
+ let _e106 = (*albedo_1);
+ param_56 = _e106;
+ let _e107 = (*N_4);
+ param_57 = _e107;
+ let _e108 = P;
+ param_58 = _e108;
+ param_59 = _e105;
+ param_60 = 0f;
+ param_61 = 1f;
+ param_62 = 0f;
+ let _e109 = (*ao_1);
+ param_63 = _e109;
+ let _e110 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59), (&param_60), (&param_61), (&param_62), (&param_63));
+ return _e110;
}
-fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_1: ptr<function, vec2<f32>>) -> vec3<f32> {
- let _e86 = (*uv_1);
- let _e87 = textureSample(map_est, map_ess, _e86);
- return normalize(((_e87.xyz * 2f) - vec3(1f)));
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_64: vec3<f32>;
+ var param_65: vec3<f32>;
+ var param_66: vec2<f32>;
+ var param_67: f32;
+
+ let _e93 = (*albedo_2);
+ param_64 = _e93;
+ let _e94 = (*N_5);
+ param_65 = _e94;
+ let _e95 = (*worldPos_8);
+ param_66 = _e95;
+ param_67 = 1f;
+ let _e96 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_64), (&param_65), (&param_66), (&param_67));
+ return _e96;
+}
+
+fn sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(map_est: texture_2d<f32>, map_ess: sampler, uv_2: ptr<function, vec2<f32>>) -> vec3<f32> {
+ let _e89 = (*uv_2);
+ let _e90 = textureSample(map_est, map_ess, _e89);
+ return normalize(((_e90.xyz * 2f) - vec3(1f)));
}
fn main_1() {
var base: vec4<f32>;
var N_6: vec3<f32>;
- var param_60: vec2<f32>;
+ var param_68: vec2<f32>;
var lit_1: vec3<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_60 = _e94;
- let _e95 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_60));
- N_6 = _e95;
- let _e96 = base;
- param_61 = _e96.xyz;
- let _e98 = N_6;
- param_62 = _e98;
- let _e99 = v_worldPos_1;
- param_63 = _e99;
- let _e100 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_61), (&param_62), (&param_63));
- lit_1 = _e100;
- let _e101 = lit_1;
- let _e103 = base[3u];
- fragColor = vec4<f32>(_e101.x, _e101.y, _e101.z, _e103);
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+
+ let _e93 = v_texCoord_1;
+ let _e94 = textureSample(es_bt0_est, es_bt0_ess, _e93);
+ let _e95 = v_color_1;
+ base = (_e94 * _e95);
+ let _e97 = v_texCoord_1;
+ param_68 = _e97;
+ let _e98 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_68));
+ N_6 = _e98;
+ let _e99 = base;
+ param_69 = _e99.xyz;
+ let _e101 = N_6;
+ param_70 = _e101;
+ let _e102 = v_worldPos_1;
+ param_71 = _e102;
+ let _e103 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_69), (&param_70), (&param_71));
+ lit_1 = _e103;
+ let _e104 = lit_1;
+ let _e106 = base[3u];
+ fragColor = vec4<f32>(_e104.x, _e104.y, _e104.z, _e106);
return;
}
diff --git a/fixtures/scenes/mat-lit/lit.esshader b/fixtures/scenes/mat-lit/lit.esshader
index 1d7633508..31414fd51 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: 935c6a785109fe67
+// assembled-hash: 87933b753dc5e053
struct 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: 935c6a785109fe67
+// assembled-hash: 87933b753dc5e053
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -141,7 +141,7 @@ struct Light {
struct LightConstants {
u_ambient: vec4<f32>,
u_lights: array<Light, 16>,
- u_shadow2DRect: vec4<f32>,
+ u_mask2DRect: vec4<f32>,
u_shadowMatrix: array<mat4x4<f32>, 16>,
u_shadowTile: array<vec4<f32>, 16>,
u_shadowParams: vec4<f32>,
@@ -163,6 +163,10 @@ var<uniform> unnamed_1: LightConstants;
var u_shadow2D_est: texture_2d<f32>;
@group(1) @binding(15)
var u_shadow2D_ess: sampler;
+@group(1) @binding(6)
+var u_lightShape2D_est: texture_2d<f32>;
+@group(1) @binding(14)
+var u_lightShape2D_ess: sampler;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -216,181 +220,238 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e93 = unnamed_1.u_envParams[0u];
- if (_e93 < 0.5f) {
- let _e96 = unnamed_1.u_ambient;
- return _e96.xyz;
+ let _e96 = unnamed_1.u_envParams[0u];
+ if (_e96 < 0.5f) {
+ let _e99 = unnamed_1.u_ambient;
+ return _e99.xyz;
}
- let _e98 = (*roughness);
- let _e102 = unnamed_1.u_envParams[2u];
- lod = (clamp(_e98, 0f, 1f) * _e102);
- let _e104 = lod;
- lo = floor(_e104);
- let _e106 = (*R_1);
- param = _e106;
- let _e107 = lo;
- param_1 = _e107;
- let _e108 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
- a = _e108;
- let _e109 = lo;
- let _e113 = unnamed_1.u_envParams[2u];
- let _e115 = (*R_1);
- param_2 = _e115;
- param_3 = min((_e109 + 1f), _e113);
- let _e116 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
- b = _e116;
- let _e118 = unnamed_1.u_ambient;
- let _e120 = a;
- let _e121 = b;
- let _e122 = lod;
- let _e123 = lo;
- let _e128 = unnamed_1.u_envTint;
- return (_e118.xyz + (mix(_e120, _e121, vec3((_e122 - _e123))) * _e128.xyz));
+ let _e101 = (*roughness);
+ let _e105 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e101, 0f, 1f) * _e105);
+ let _e107 = lod;
+ lo = floor(_e107);
+ let _e109 = (*R_1);
+ param = _e109;
+ let _e110 = lo;
+ param_1 = _e110;
+ let _e111 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e111;
+ let _e112 = lo;
+ let _e116 = unnamed_1.u_envParams[2u];
+ let _e118 = (*R_1);
+ param_2 = _e118;
+ param_3 = min((_e112 + 1f), _e116);
+ let _e119 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e119;
+ let _e121 = unnamed_1.u_ambient;
+ let _e123 = a;
+ let _e124 = b;
+ let _e125 = lod;
+ let _e126 = lo;
+ let _e131 = unnamed_1.u_envTint;
+ return (_e121.xyz + (mix(_e123, _e124, vec3((_e125 - _e126))) * _e131.xyz));
}
fn envBRDFApprox_u0028_f1_u003b_f1_u003b(NdotV: ptr<function, f32>, roughness_1: ptr<function, f32>) -> vec2<f32> {
var r: vec4<f32>;
var a_1: f32;
- let _e85 = (*roughness_1);
- r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e85) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
- let _e89 = r[0u];
- let _e91 = r[0u];
- let _e93 = (*NdotV);
- let _e98 = r[0u];
- let _e101 = r[1u];
- a_1 = ((min((_e89 * _e91), exp2((-9.28f * _e93))) * _e98) + _e101);
- let _e103 = a_1;
- let _e105 = r;
- return ((vec2<f32>(-1.04f, 1.04f) * _e103) + _e105.zw);
+ let _e88 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e88) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e92 = r[0u];
+ let _e94 = r[0u];
+ let _e96 = (*NdotV);
+ let _e101 = r[0u];
+ let _e104 = r[1u];
+ a_1 = ((min((_e92 * _e94), exp2((-9.28f * _e96))) * _e101) + _e104);
+ let _e106 = a_1;
+ let _e108 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e106) + _e108.zw);
}
fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e83 = (*F0_);
- let _e84 = (*F0_);
- let _e86 = (*VdotH);
- return (_e83 + ((vec3<f32>(1f, 1f, 1f) - _e84) * pow((1f - _e86), 5f)));
+ let _e86 = (*F0_);
+ let _e87 = (*F0_);
+ let _e89 = (*VdotH);
+ return (_e86 + ((vec3<f32>(1f, 1f, 1f) - _e87) * pow((1f - _e89), 5f)));
}
fn geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b(NdotV_1: ptr<function, f32>, NdotL: ptr<function, f32>, roughness_2: ptr<function, f32>) -> f32 {
var k: f32;
- let _e85 = (*roughness_2);
- let _e87 = (*roughness_2);
- k = (((_e85 + 1f) * (_e87 + 1f)) * 0.125f);
- let _e91 = (*NdotV_1);
- let _e92 = (*NdotV_1);
- let _e93 = k;
+ let _e88 = (*roughness_2);
+ let _e90 = (*roughness_2);
+ k = (((_e88 + 1f) * (_e90 + 1f)) * 0.125f);
+ let _e94 = (*NdotV_1);
+ let _e95 = (*NdotV_1);
let _e96 = k;
- let _e99 = (*NdotL);
- let _e100 = (*NdotL);
- let _e101 = k;
+ let _e99 = k;
+ let _e102 = (*NdotL);
+ let _e103 = (*NdotL);
let _e104 = k;
- return ((_e91 / ((_e92 * (1f - _e93)) + _e96)) * (_e99 / ((_e100 * (1f - _e101)) + _e104)));
+ let _e107 = k;
+ return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));
}
fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {
var a2_: f32;
var d: f32;
- let _e85 = (*a_2);
- let _e86 = (*a_2);
- a2_ = (_e85 * _e86);
- let _e88 = (*NdotH);
- let _e89 = (*NdotH);
- let _e91 = a2_;
- d = (((_e88 * _e89) * (_e91 - 1f)) + 1f);
- let _e95 = a2_;
- let _e96 = d;
- let _e98 = d;
- return (_e95 / max(((3.1415927f * _e96) * _e98), 0.0000001f));
+ let _e88 = (*a_2);
+ let _e89 = (*a_2);
+ a2_ = (_e88 * _e89);
+ let _e91 = (*NdotH);
+ let _e92 = (*NdotH);
+ let _e94 = a2_;
+ d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);
+ let _e98 = a2_;
+ let _e99 = d;
+ let _e101 = d;
+ return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));
}
fn shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b(worldPos: ptr<function, vec3<f32>>, N: ptr<function, vec3<f32>>, L: ptr<function, vec3<f32>>, source: ptr<function, vec2<f32>>, first: ptr<function, i32>, count: ptr<function, i32>) -> f32 {
return 1f;
}
-fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel: ptr<function, f32>, worldPos_1: ptr<function, vec2<f32>>) -> f32 {
+fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel: ptr<function, f32>) -> f32 {
+ var local: f32;
+ var local_1: f32;
+ var local_2: f32;
+
+ let _e89 = (*channel);
+ if (_e89 < 0.5f) {
+ let _e92 = (*m)[0u];
+ local = _e92;
+ } else {
+ let _e93 = (*channel);
+ if (_e93 < 1.5f) {
+ let _e96 = (*m)[1u];
+ local_1 = _e96;
+ } else {
+ let _e97 = (*channel);
+ if (_e97 < 2.5f) {
+ let _e100 = (*m)[2u];
+ local_2 = _e100;
+ } else {
+ let _e102 = (*m)[3u];
+ local_2 = _e102;
+ }
+ let _e103 = local_2;
+ local_1 = _e103;
+ }
+ let _e104 = local_1;
+ local = _e104;
+ }
+ let _e105 = local;
+ return _e105;
+}
+
+fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var clip: vec4<f32>;
var ndc: vec2<f32>;
var v: f32;
- var local: f32;
+ var local_3: f32;
+
+ let _e90 = unnamed.u_projection;
+ let _e91 = (*worldPos_1);
+ clip = (_e90 * vec4<f32>(_e91.x, _e91.y, 0f, 1f));
+ let _e97 = clip[3u];
+ if (_e97 <= 0f) {
+ return vec2<f32>(-1f, -1f);
+ }
+ let _e99 = clip;
+ let _e102 = clip[3u];
+ ndc = (((_e99.xy / vec2(_e102)) * 0.5f) + vec2(0.5f));
+ let _e110 = unnamed_1.u_mask2DRect[3u];
+ if (_e110 < 0f) {
+ let _e113 = ndc[1u];
+ local_3 = (1f - _e113);
+ } else {
+ let _e116 = ndc[1u];
+ local_3 = _e116;
+ }
+ let _e117 = local_3;
+ v = _e117;
+ let _e119 = unnamed_1.u_mask2DRect;
+ let _e122 = ndc[0u];
+ let _e125 = unnamed_1.u_mask2DRect[2u];
+ let _e127 = v;
+ let _e130 = unnamed_1.u_mask2DRect[3u];
+ return (_e119.xy + vec2<f32>((_e122 * _e125), (_e127 * abs(_e130))));
+}
+
+fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
var uv: vec2<f32>;
- var m: vec4<f32>;
+ var param_4: vec2<f32>;
var hidden: f32;
- var local_1: f32;
- var local_2: f32;
- var local_3: f32;
- var phi_176_: bool;
-
- let _e93 = (*channel);
- let _e94 = (_e93 < 0f);
- phi_176_ = _e94;
- if !(_e94) {
- let _e98 = unnamed_1.u_shadow2DRect[2u];
- phi_176_ = (_e98 <= 0f);
+ var param_5: vec4<f32>;
+ var param_6: f32;
+ var phi_283_: bool;
+
+ let _e91 = (*channel_1);
+ let _e92 = (_e91 < 0f);
+ phi_283_ = _e92;
+ if !(_e92) {
+ let _e96 = unnamed_1.u_mask2DRect[2u];
+ phi_283_ = (_e96 <= 0f);
}
- let _e101 = phi_176_;
- if _e101 {
+ let _e99 = phi_283_;
+ if _e99 {
return 1f;
}
- let _e103 = unnamed.u_projection;
- let _e104 = (*worldPos_1);
- clip = (_e103 * vec4<f32>(_e104.x, _e104.y, 0f, 1f));
- let _e110 = clip[3u];
- if (_e110 <= 0f) {
+ let _e100 = (*worldPos_2);
+ param_4 = _e100;
+ let _e101 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e101;
+ let _e103 = uv[0u];
+ if (_e103 < 0f) {
return 1f;
}
- let _e112 = clip;
- let _e115 = clip[3u];
- ndc = (((_e112.xy / vec2(_e115)) * 0.5f) + vec2(0.5f));
- let _e123 = unnamed_1.u_shadow2DRect[3u];
- if (_e123 < 0f) {
- let _e126 = ndc[1u];
- local = (1f - _e126);
- } else {
- let _e129 = ndc[1u];
- local = _e129;
+ let _e105 = uv;
+ let _e106 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e105, 0f);
+ param_5 = _e106;
+ let _e107 = (*channel_1);
+ param_6 = _e107;
+ let _e108 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e108;
+ let _e109 = hidden;
+ return (1f - min(_e109, 1f));
+}
+
+fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
+ var uv_1: vec2<f32>;
+ var param_7: vec2<f32>;
+ var param_8: vec4<f32>;
+ var param_9: f32;
+ var phi_327_: bool;
+
+ let _e90 = (*channel_2);
+ let _e91 = (_e90 < 0f);
+ phi_327_ = _e91;
+ if !(_e91) {
+ let _e95 = unnamed_1.u_mask2DRect[2u];
+ phi_327_ = (_e95 <= 0f);
}
- let _e130 = local;
- v = _e130;
- let _e132 = unnamed_1.u_shadow2DRect;
- let _e135 = ndc[0u];
- let _e138 = unnamed_1.u_shadow2DRect[2u];
- let _e140 = v;
- let _e143 = unnamed_1.u_shadow2DRect[3u];
- uv = (_e132.xy + vec2<f32>((_e135 * _e138), (_e140 * abs(_e143))));
- let _e148 = uv;
- let _e149 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e148, 0f);
- m = _e149;
- let _e150 = (*channel);
- if (_e150 < 0.5f) {
- let _e153 = m[0u];
- local_1 = _e153;
- } else {
- let _e154 = (*channel);
- if (_e154 < 1.5f) {
- let _e157 = m[1u];
- local_2 = _e157;
- } else {
- let _e158 = (*channel);
- if (_e158 < 2.5f) {
- let _e161 = m[2u];
- local_3 = _e161;
- } else {
- let _e163 = m[3u];
- local_3 = _e163;
- }
- let _e164 = local_3;
- local_2 = _e164;
- }
- let _e165 = local_2;
- local_1 = _e165;
+ let _e98 = phi_327_;
+ if _e98 {
+ return 1f;
}
- let _e166 = local_1;
- hidden = _e166;
- let _e167 = hidden;
- return (1f - min(_e167, 1f));
+ let _e99 = (*worldPos_3);
+ param_7 = _e99;
+ let _e100 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e100;
+ let _e102 = uv_1[0u];
+ if (_e102 < 0f) {
+ return 1f;
+ }
+ let _e104 = uv_1;
+ let _e105 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e104, 0f);
+ param_8 = _e105;
+ let _e106 = (*channel_2);
+ param_9 = _e106;
+ let _e107 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e107, 1f);
}
fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<f32>>, sh: ptr<function, vec4<f32>>, toLight: ptr<function, vec3<f32>>, dist: ptr<function, f32>) -> f32 {
@@ -399,74 +460,74 @@ fn spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b(sp: ptr<function, vec4<
var toFrag: vec2<f32>;
var local_5: vec2<f32>;
- let _e89 = (*sp);
- let _e91 = (*sp);
- if (dot(_e89.xy, _e91.xy) > 0.00000001f) {
- let _e95 = (*sp);
- local_4 = normalize(_e95.xy);
+ let _e92 = (*sp);
+ let _e94 = (*sp);
+ if (dot(_e92.xy, _e94.xy) > 0.00000001f) {
+ let _e98 = (*sp);
+ local_4 = normalize(_e98.xy);
} else {
local_4 = vec2<f32>(0f, -1f);
}
- let _e98 = local_4;
- axis = _e98;
- let _e99 = (*dist);
- if (_e99 > 0.0001f) {
- let _e101 = (*toLight);
- let _e104 = (*dist);
- local_5 = (-(_e101.xy) / vec2(_e104));
+ let _e101 = local_4;
+ axis = _e101;
+ let _e102 = (*dist);
+ if (_e102 > 0.0001f) {
+ let _e104 = (*toLight);
+ let _e107 = (*dist);
+ local_5 = (-(_e104.xy) / vec2(_e107));
} else {
- let _e107 = axis;
- local_5 = _e107;
+ let _e110 = axis;
+ local_5 = _e110;
}
- let _e108 = local_5;
- toFrag = _e108;
- let _e110 = (*sp)[3u];
- let _e112 = (*sp)[2u];
- let _e113 = axis;
- let _e114 = toFrag;
- return smoothstep(_e110, _e112, dot(_e113, _e114));
+ let _e111 = local_5;
+ toFrag = _e111;
+ let _e113 = (*sp)[3u];
+ let _e115 = (*sp)[2u];
+ let _e116 = axis;
+ let _e117 = toFrag;
+ return smoothstep(_e113, _e115, dot(_e116, _e117));
}
fn towardLight_u0028_vf3_u003b_vf3_u003b(toLight_1: ptr<function, vec3<f32>>, N_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_6: vec3<f32>;
- let _e84 = (*toLight_1);
- let _e85 = (*toLight_1);
- if (dot(_e84, _e85) > 0.00000001f) {
- let _e88 = (*toLight_1);
- local_6 = normalize(_e88);
+ let _e87 = (*toLight_1);
+ let _e88 = (*toLight_1);
+ if (dot(_e87, _e88) > 0.00000001f) {
+ let _e91 = (*toLight_1);
+ local_6 = normalize(_e91);
} else {
- let _e90 = (*N_1);
- local_6 = _e90;
+ let _e93 = (*N_1);
+ local_6 = _e93;
}
- let _e91 = local_6;
- return _e91;
+ let _e94 = local_6;
+ 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 _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));
+ 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 _e82 = (*toLight_2);
- return length(_e82.xy);
+ let _e85 = (*toLight_2);
+ return length(_e85.xy);
}
-fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_2: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e84 = (*pd);
- let _e86 = (*worldPos_2);
- let _e88 = (_e84.xy - _e86.xy);
- let _e90 = (*pd)[3u];
- return vec3<f32>(_e88.x, _e88.y, max(_e90, 1f));
+fn lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b(pd: ptr<function, vec4<f32>>, sh_1: ptr<function, vec4<f32>>, worldPos_4: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e87 = (*pd);
+ let _e89 = (*worldPos_4);
+ let _e91 = (_e87.xy - _e89.xy);
+ let _e93 = (*pd)[3u];
+ return vec3<f32>(_e91.x, _e91.y, max(_e93, 1f));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -474,70 +535,70 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- let _e87 = unnamed_1.u_envTint[3u];
- a_3 = -(_e87);
- let _e89 = a_3;
- s = sin(_e89);
- let _e91 = a_3;
- c = cos(_e91);
- let _e93 = c;
- let _e95 = (*d_1)[0u];
- let _e97 = s;
- let _e99 = (*d_1)[2u];
- let _e103 = (*d_1)[1u];
- let _e104 = s;
- let _e107 = (*d_1)[0u];
- let _e109 = c;
- let _e111 = (*d_1)[2u];
- return vec3<f32>(((_e93 * _e95) + (_e97 * _e99)), _e103, ((-(_e104) * _e107) + (_e109 * _e111)));
+ let _e90 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e90);
+ let _e92 = a_3;
+ s = sin(_e92);
+ let _e94 = a_3;
+ c = cos(_e94);
+ let _e96 = c;
+ let _e98 = (*d_1)[0u];
+ let _e100 = s;
+ let _e102 = (*d_1)[2u];
+ let _e106 = (*d_1)[1u];
+ let _e107 = s;
+ let _e110 = (*d_1)[0u];
+ let _e112 = c;
+ let _e114 = (*d_1)[2u];
+ return vec3<f32>(((_e96 * _e98) + (_e100 * _e102)), _e106, ((-(_e107) * _e110) + (_e112 * _e114)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
var N_2: vec3<f32>;
- var param_4: vec3<f32>;
+ var param_10: vec3<f32>;
var sh_2: vec3<f32>;
- let _e85 = (*Nw);
- param_4 = _e85;
- let _e86 = envDirection_u0028_vf3_u003b((&param_4));
- N_2 = _e86;
- let _e89 = unnamed_1.u_envIrradiance[0i];
- let _e94 = unnamed_1.u_envIrradiance[1i];
- let _e97 = N_2[1u];
- let _e103 = unnamed_1.u_envIrradiance[2i];
- let _e106 = N_2[2u];
- let _e112 = unnamed_1.u_envIrradiance[3i];
- let _e115 = N_2[0u];
- let _e121 = unnamed_1.u_envIrradiance[4i];
- let _e124 = N_2[0u];
- let _e127 = N_2[1u];
- let _e133 = unnamed_1.u_envIrradiance[5i];
- let _e136 = N_2[1u];
- let _e139 = N_2[2u];
- let _e145 = unnamed_1.u_envIrradiance[6i];
- let _e148 = N_2[2u];
+ let _e88 = (*Nw);
+ param_10 = _e88;
+ let _e89 = envDirection_u0028_vf3_u003b((&param_10));
+ N_2 = _e89;
+ let _e92 = unnamed_1.u_envIrradiance[0i];
+ let _e97 = unnamed_1.u_envIrradiance[1i];
+ let _e100 = N_2[1u];
+ let _e106 = unnamed_1.u_envIrradiance[2i];
+ let _e109 = N_2[2u];
+ let _e115 = unnamed_1.u_envIrradiance[3i];
+ let _e118 = N_2[0u];
+ let _e124 = unnamed_1.u_envIrradiance[4i];
+ let _e127 = N_2[0u];
+ let _e130 = N_2[1u];
+ let _e136 = unnamed_1.u_envIrradiance[5i];
+ let _e139 = N_2[1u];
+ let _e142 = N_2[2u];
+ let _e148 = unnamed_1.u_envIrradiance[6i];
let _e151 = N_2[2u];
- let _e159 = unnamed_1.u_envIrradiance[7i];
- let _e162 = N_2[0u];
- let _e165 = N_2[2u];
- let _e171 = unnamed_1.u_envIrradiance[8i];
- let _e174 = N_2[0u];
- let _e176 = N_2[0u];
- let _e179 = N_2[1u];
- let _e181 = N_2[1u];
- sh_2 = (((((((((_e89.xyz * 0.282095f) + (_e94.xyz * (0.488603f * _e97))) + (_e103.xyz * (0.488603f * _e106))) + (_e112.xyz * (0.488603f * _e115))) + (_e121.xyz * ((1.092548f * _e124) * _e127))) + (_e133.xyz * ((1.092548f * _e136) * _e139))) + (_e145.xyz * (0.315392f * (((3f * _e148) * _e151) - 1f)))) + (_e159.xyz * ((1.092548f * _e162) * _e165))) + (_e171.xyz * (0.546274f * ((_e174 * _e176) - (_e179 * _e181)))));
- let _e188 = unnamed_1.u_ambient;
- let _e190 = sh_2;
- let _e193 = unnamed_1.u_envTint;
- return (_e188.xyz + (max(_e190, vec3<f32>(0f, 0f, 0f)) * _e193.xyz));
-}
-
-fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_3: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
+ let _e154 = N_2[2u];
+ let _e162 = unnamed_1.u_envIrradiance[7i];
+ let _e165 = N_2[0u];
+ let _e168 = N_2[2u];
+ let _e174 = unnamed_1.u_envIrradiance[8i];
+ let _e177 = N_2[0u];
+ let _e179 = N_2[0u];
+ let _e182 = N_2[1u];
+ let _e184 = N_2[1u];
+ sh_2 = (((((((((_e92.xyz * 0.282095f) + (_e97.xyz * (0.488603f * _e100))) + (_e106.xyz * (0.488603f * _e109))) + (_e115.xyz * (0.488603f * _e118))) + (_e124.xyz * ((1.092548f * _e127) * _e130))) + (_e136.xyz * ((1.092548f * _e139) * _e142))) + (_e148.xyz * (0.315392f * (((3f * _e151) * _e154) - 1f)))) + (_e162.xyz * ((1.092548f * _e165) * _e168))) + (_e174.xyz * (0.546274f * ((_e177 * _e179) - (_e182 * _e184)))));
+ let _e191 = unnamed_1.u_ambient;
+ let _e193 = sh_2;
+ let _e196 = unnamed_1.u_envTint;
+ return (_e191.xyz + (max(_e193, vec3<f32>(0f, 0f, 0f)) * _e196.xyz));
+}
+
+fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b(albedo: ptr<function, vec3<f32>>, N_3: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec3<f32>>, V: ptr<function, vec3<f32>>, metallic: ptr<function, f32>, roughness_3: ptr<function, f32>, specular: ptr<function, f32>, ao: ptr<function, f32>) -> vec3<f32> {
var F0_1: vec3<f32>;
var a_4: f32;
var NdotV_2: f32;
var lit: vec3<f32>;
- var param_5: vec3<f32>;
+ var param_11: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
@@ -547,413 +608,426 @@ fn applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u0
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 param_12: vec4<f32>;
+ var param_13: vec4<f32>;
+ var param_14: vec3<f32>;
var dist_2: f32;
- var param_9: vec3<f32>;
+ var param_15: vec3<f32>;
var atten: f32;
- var param_10: f32;
- var param_11: f32;
- var param_12: vec4<f32>;
+ var param_16: f32;
+ var param_17: f32;
+ var param_18: vec4<f32>;
var L_1: vec3<f32>;
- var param_13: vec3<f32>;
- var param_14: vec3<f32>;
+ var param_19: vec3<f32>;
+ var param_20: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_15: vec4<f32>;
- var param_16: vec4<f32>;
- var param_17: 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_22: vec4<f32>;
var param_23: vec3<f32>;
- var param_24: vec4<f32>;
- var param_25: vec4<f32>;
- var param_26: vec3<f32>;
- var param_27: f32;
- var param_28: f32;
- var param_29: vec2<f32>;
- var sm: vec4<f32>;
- var param_30: vec3<f32>;
- var param_31: vec3<f32>;
+ var dist_3: f32;
+ var param_24: vec3<f32>;
+ var param_25: f32;
+ var param_26: f32;
+ var param_27: vec4<f32>;
+ var param_28: vec3<f32>;
+ var param_29: vec3<f32>;
+ var param_30: vec4<f32>;
+ var param_31: vec4<f32>;
var param_32: vec3<f32>;
- var param_33: vec2<f32>;
- var param_34: i32;
- var param_35: i32;
+ var param_33: f32;
+ var param_34: f32;
+ var param_35: vec2<f32>;
+ var param_36: f32;
+ var param_37: vec2<f32>;
+ var sm: vec4<f32>;
+ var param_38: vec3<f32>;
+ var param_39: vec3<f32>;
+ var param_40: vec3<f32>;
+ var param_41: vec2<f32>;
+ var param_42: i32;
+ var param_43: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_36: f32;
- var param_37: f32;
- var param_38: f32;
- var param_39: f32;
- var param_40: f32;
- 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_45: 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((&param_5));
- let _e172 = (*ao);
- lit = (_e171 * _e172);
+ var param_47: f32;
+ var param_48: f32;
+ var param_49: f32;
+ var param_50: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_51: f32;
+ var param_52: f32;
+ var param_53: vec3<f32>;
+ var param_54: f32;
+ var phi_886_: bool;
+ var phi_959_: bool;
+
+ let _e163 = (*albedo);
+ let _e164 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e163, vec3(_e164));
+ let _e167 = (*roughness_3);
+ let _e168 = (*roughness_3);
+ a_4 = max((_e167 * _e168), 0.001f);
+ let _e171 = (*N_3);
+ let _e172 = (*V);
+ NdotV_2 = max(dot(_e171, _e172), 0.0001f);
+ let _e175 = (*N_3);
+ param_11 = _e175;
+ let _e176 = envIrradiance_u0028_vf3_u003b((&param_11));
+ let _e177 = (*ao);
+ lit = (_e176 * _e177);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e174 = i;
- if (_e174 < 16i) {
- let _e176 = i;
- let _e180 = unnamed_1.u_lights[_e176].posDir;
- pd_1 = _e180;
+ let _e179 = i;
+ if (_e179 < 16i) {
let _e181 = i;
- let _e185 = unnamed_1.u_lights[_e181].color;
- col = _e185;
+ let _e185 = unnamed_1.u_lights[_e181].posDir;
+ pd_1 = _e185;
let _e186 = i;
- let _e190 = unnamed_1.u_lights[_e186].shadow;
- sh_3 = _e190;
+ let _e190 = unnamed_1.u_lights[_e186].color;
+ col = _e190;
let _e191 = i;
- let _e195 = unnamed_1.u_lights[_e191].falloff;
- fo_1 = _e195;
- let _e196 = pd_1;
- target_ = _e196.xy;
+ let _e195 = unnamed_1.u_lights[_e191].shadow;
+ sh_3 = _e195;
+ let _e196 = i;
+ let _e200 = unnamed_1.u_lights[_e196].falloff;
+ fo_1 = _e200;
+ let _e201 = pd_1;
+ target_ = _e201.xy;
castShadow = true;
- 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((&param_6), (&param_7), (&param_8));
- toL = _e204;
- let _e205 = toL;
- param_9 = _e205;
- let _e206 = lightDistance_u0028_vf3_u003b((&param_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((&param_10), (&param_11), (&param_12));
- atten = _e212;
- let _e213 = toL;
- param_13 = _e213;
- let _e214 = (*N_3);
- param_14 = _e214;
- let _e215 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_13), (&param_14));
- L_1 = _e215;
+ let _e204 = pd_1[2u];
+ if (_e204 < 0.5f) {
+ let _e206 = pd_1;
+ param_12 = _e206;
+ let _e207 = sh_3;
+ param_13 = _e207;
+ let _e208 = (*worldPos_5);
+ param_14 = _e208;
+ let _e209 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_12), (&param_13), (&param_14));
+ toL = _e209;
+ let _e210 = toL;
+ param_15 = _e210;
+ let _e211 = lightDistance_u0028_vf3_u003b((&param_15));
+ dist_2 = _e211;
+ let _e213 = pd_1[3u];
+ let _e215 = dist_2;
+ param_16 = _e215;
+ param_17 = max(_e213, 0.0001f);
+ let _e216 = fo_1;
+ param_18 = _e216;
+ let _e217 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_16), (&param_17), (&param_18));
+ atten = _e217;
+ let _e218 = toL;
+ param_19 = _e218;
+ let _e219 = (*N_3);
+ param_20 = _e219;
+ let _e220 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_19), (&param_20));
+ L_1 = _e220;
} else {
- let _e217 = pd_1[2u];
- if (_e217 < 1.5f) {
+ let _e222 = pd_1[2u];
+ if (_e222 < 1.5f) {
atten = 1f;
- let _e219 = pd_1;
- 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));
+ let _e224 = pd_1;
+ let _e225 = _e224.xy;
+ let _e227 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e225.x, _e225.y, _e227)));
+ let _e233 = pd_1;
+ let _e235 = pd_1;
+ if (dot(_e233.xy, _e235.xy) > 0.00000001f) {
+ let _e239 = pd_1;
+ local_7 = normalize(-(_e239.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e243 = local_7;
+ toLight_3 = _e243;
+ let _e245 = sh_3[1u];
+ let _e246 = (_e245 > 0f);
+ phi_886_ = _e246;
+ if _e246 {
+ let _e247 = toLight_3;
+ let _e248 = toLight_3;
+ phi_886_ = (dot(_e247, _e248) > 0.5f);
}
- let _e247 = phi_820_;
- castShadow = _e247;
- let _e248 = (*worldPos_3);
- let _e250 = toLight_3;
- let _e252 = sh_3[1u];
- target_ = (_e248.xy + (_e250 * _e252));
+ let _e252 = phi_886_;
+ castShadow = _e252;
+ let _e253 = (*worldPos_5);
+ let _e255 = toLight_3;
+ let _e257 = sh_3[1u];
+ target_ = (_e253.xy + (_e255 * _e257));
} else {
- 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((&param_15), (&param_16), (&param_17));
- toL_1 = _e263;
- let _e264 = toL_1;
- param_18 = _e264;
- let _e265 = lightDistance_u0028_vf3_u003b((&param_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((&param_19), (&param_20), (&param_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((&param_22), (&param_23));
- L_1 = _e274;
- let _e275 = sp_1;
- param_24 = _e275;
- let _e276 = sh_3;
- param_25 = _e276;
+ let _e260 = i;
+ let _e264 = unnamed_1.u_lights[_e260].spot;
+ sp_1 = _e264;
+ let _e265 = pd_1;
+ param_21 = _e265;
+ let _e266 = sh_3;
+ param_22 = _e266;
+ let _e267 = (*worldPos_5);
+ param_23 = _e267;
+ let _e268 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_21), (&param_22), (&param_23));
+ toL_1 = _e268;
+ let _e269 = toL_1;
+ param_24 = _e269;
+ let _e270 = lightDistance_u0028_vf3_u003b((&param_24));
+ dist_3 = _e270;
+ let _e272 = pd_1[3u];
+ let _e274 = dist_3;
+ param_25 = _e274;
+ param_26 = max(_e272, 0.0001f);
+ let _e275 = fo_1;
+ param_27 = _e275;
+ let _e276 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_25), (&param_26), (&param_27));
+ atten = _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((&param_24), (&param_25), (&param_26), (&param_27));
- let _e280 = atten;
- atten = (_e280 * _e279);
+ param_28 = _e277;
+ let _e278 = (*N_3);
+ param_29 = _e278;
+ let _e279 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_28), (&param_29));
+ L_1 = _e279;
+ let _e280 = sp_1;
+ param_30 = _e280;
+ let _e281 = sh_3;
+ param_31 = _e281;
+ let _e282 = toL_1;
+ param_32 = _e282;
+ let _e283 = dist_3;
+ param_33 = _e283;
+ let _e284 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_30), (&param_31), (&param_32), (&param_33));
+ let _e285 = atten;
+ atten = (_e285 * _e284);
}
}
- let _e282 = castShadow;
- phi_876_ = _e282;
- if _e282 {
- let _e284 = col[3u];
- phi_876_ = (_e284 > 0f);
+ let _e288 = col[3u];
+ let _e290 = atten;
+ if ((_e288 > 0f) && (_e290 > 0f)) {
+ let _e294 = fo_1[3u];
+ param_34 = _e294;
+ let _e295 = (*worldPos_5);
+ param_35 = _e295.xy;
+ let _e297 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_34), (&param_35));
+ let _e298 = atten;
+ atten = (_e298 * _e297);
+ }
+ let _e300 = castShadow;
+ phi_959_ = _e300;
+ if _e300 {
+ let _e302 = col[3u];
+ phi_959_ = (_e302 > 0f);
}
- 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((&param_28), (&param_29));
- let _e301 = fo_1[2u];
- let _e303 = atten;
- atten = (_e303 * mix(1f, _e299, _e301));
+ let _e305 = phi_959_;
+ let _e306 = atten;
+ if (_e305 && (_e306 > 0f)) {
+ let _e309 = i;
+ let _e314 = unnamed_1.u_lights[_e309].shadowMap[3u];
+ param_36 = _e314;
+ let _e315 = (*worldPos_5);
+ param_37 = _e315.xy;
+ let _e317 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_36), (&param_37));
+ let _e319 = fo_1[2u];
+ let _e321 = atten;
+ atten = (_e321 * mix(1f, _e317, _e319));
}
- 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((&param_30), (&param_31), (&param_32), (&param_33), (&param_34), (&param_35));
- let _e332 = fo_1[2u];
- let _e334 = atten;
- atten = (_e334 * mix(1f, _e330, _e332));
+ let _e323 = i;
+ let _e327 = unnamed_1.u_lights[_e323].shadowMap;
+ sm = _e327;
+ let _e329 = sm[1u];
+ let _e331 = atten;
+ if ((_e329 > 0f) && (_e331 > 0f)) {
+ let _e335 = sh_3[0u];
+ let _e337 = sm[2u];
+ let _e340 = sm[0u];
+ let _e343 = sm[1u];
+ let _e345 = (*worldPos_5);
+ param_38 = _e345;
+ let _e346 = (*N_3);
+ param_39 = _e346;
+ let _e347 = L_1;
+ param_40 = _e347;
+ param_41 = vec2<f32>(_e335, _e337);
+ param_42 = i32(_e340);
+ param_43 = i32(_e343);
+ let _e348 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_38), (&param_39), (&param_40), (&param_41), (&param_42), (&param_43));
+ let _e350 = fo_1[2u];
+ let _e352 = atten;
+ atten = (_e352 * mix(1f, _e348, _e350));
}
- 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((&param_36), (&param_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((&param_38), (&param_39), (&param_40));
- let _e369 = NdotV_2;
- let _e371 = ndotl;
- brdf = ((_e363 * _e367) / max(((4f * _e369) * _e371), 0.0001f));
- let _e375 = radiance;
- let _e376 = (*V);
+ let _e354 = (*N_3);
+ let _e355 = L_1;
+ ndotl = max(dot(_e354, _e355), 0f);
+ let _e358 = col;
+ let _e361 = col[3u];
+ let _e362 = ndotl;
+ let _e364 = atten;
+ radiance = (_e358.xyz * ((_e361 * _e362) * _e364));
+ let _e367 = radiance;
+ let _e368 = lit;
+ lit = (_e368 + _e367);
+ let _e370 = (*specular);
+ if (_e370 > 0f) {
+ let _e372 = L_1;
+ let _e373 = (*V);
+ H = normalize((_e372 + _e373));
+ let _e376 = (*N_3);
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((&param_41), (&param_42));
- let _e383 = brdf;
- let _e385 = (*specular);
- let _e388 = gloss;
- gloss = (_e388 + ((_e375 * _e381) * ((_e383 * 3.1415927f) * _e385)));
+ param_44 = max(dot(_e376, _e377), 0f);
+ let _e380 = a_4;
+ param_45 = _e380;
+ let _e381 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_44), (&param_45));
+ let _e382 = NdotV_2;
+ param_46 = _e382;
+ let _e383 = ndotl;
+ param_47 = _e383;
+ let _e384 = (*roughness_3);
+ param_48 = _e384;
+ let _e385 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_46), (&param_47), (&param_48));
+ let _e387 = NdotV_2;
+ let _e389 = ndotl;
+ brdf = ((_e381 * _e385) / max(((4f * _e387) * _e389), 0.0001f));
+ let _e393 = radiance;
+ let _e394 = (*V);
+ let _e395 = H;
+ param_49 = max(dot(_e394, _e395), 0f);
+ let _e398 = F0_1;
+ param_50 = _e398;
+ let _e399 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_49), (&param_50));
+ let _e401 = brdf;
+ let _e403 = (*specular);
+ let _e406 = gloss;
+ gloss = (_e406 + ((_e393 * _e399) * ((_e401 * 3.1415927f) * _e403)));
}
continue;
} else {
break;
}
continuing {
- let _e390 = i;
- i = (_e390 + 1i);
+ let _e408 = i;
+ i = (_e408 + 1i);
}
}
- let _e392 = NdotV_2;
- param_43 = _e392;
- let _e393 = (*roughness_3);
- param_44 = _e393;
- let _e394 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_43), (&param_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((&param_45), (&param_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> {
+ let _e410 = NdotV_2;
+ param_51 = _e410;
+ let _e411 = (*roughness_3);
+ param_52 = _e411;
+ let _e412 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_51), (&param_52));
+ ab = _e412;
+ let _e413 = (*V);
+ let _e415 = (*N_3);
+ param_53 = reflect(-(_e413), _e415);
+ let _e417 = (*roughness_3);
+ param_54 = _e417;
+ let _e418 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_53), (&param_54));
+ let _e419 = (*ao);
+ let _e420 = (*specular);
+ let _e423 = F0_1;
+ let _e425 = ab[0u];
+ let _e428 = ab[1u];
+ let _e432 = gloss;
+ gloss = (_e432 + ((_e418 * (_e419 * _e420)) * ((_e423 * _e425) + vec3(_e428))));
+ let _e434 = (*albedo);
+ let _e435 = (*metallic);
+ let _e438 = lit;
+ let _e440 = gloss;
+ return (((_e434 * (1f - _e435)) * _e438) + _e440);
+}
+
+fn viewDirection_u0028_vf3_u003b(worldPos_6: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_8: vec3<f32>;
- let _e85 = unnamed.u_camera[3u];
- if (_e85 > 0.5f) {
- let _e88 = unnamed.u_camera;
- let _e90 = (*worldPos_4);
- local_8 = normalize((_e88.xyz - _e90));
+ let _e88 = unnamed.u_camera[3u];
+ if (_e88 > 0.5f) {
+ let _e91 = unnamed.u_camera;
+ let _e93 = (*worldPos_6);
+ local_8 = normalize((_e91.xyz - _e93));
} else {
- let _e94 = unnamed.u_camera;
- local_8 = _e94.xyz;
+ let _e97 = unnamed.u_camera;
+ local_8 = _e97.xyz;
}
- let _e96 = local_8;
- return _e96;
+ let _e99 = local_8;
+ return _e99;
}
-fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_5: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_4: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<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_47 = _e99;
- let _e100 = viewDirection_u0028_vf3_u003b((&param_47));
- let _e101 = (*albedo_1);
- param_48 = _e101;
- let _e102 = (*N_4);
- param_49 = _e102;
- let _e103 = P;
- param_50 = _e103;
- param_51 = _e100;
- param_52 = 0f;
- param_53 = 1f;
- param_54 = 0f;
- let _e104 = (*ao_1);
- param_55 = _e104;
- let _e105 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_48), (&param_49), (&param_50), (&param_51), (&param_52), (&param_53), (&param_54), (&param_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_55: vec3<f32>;
var param_56: vec3<f32>;
var param_57: vec3<f32>;
- var param_58: vec2<f32>;
- var param_59: f32;
+ var param_58: vec3<f32>;
+ var param_59: vec3<f32>;
+ var param_60: f32;
+ var param_61: f32;
+ var param_62: f32;
+ var param_63: f32;
- let _e88 = (*albedo_2);
- param_56 = _e88;
- let _e89 = (*N_5);
- param_57 = _e89;
- let _e90 = (*worldPos_6);
- param_58 = _e90;
- param_59 = 1f;
- let _e91 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59));
- return _e91;
+ let _e98 = (*worldPos_7);
+ P = vec3<f32>(_e98.x, _e98.y, 0f);
+ let _e102 = P;
+ param_55 = _e102;
+ let _e103 = viewDirection_u0028_vf3_u003b((&param_55));
+ let _e104 = (*albedo_1);
+ param_56 = _e104;
+ let _e105 = (*N_4);
+ param_57 = _e105;
+ let _e106 = P;
+ param_58 = _e106;
+ param_59 = _e103;
+ param_60 = 0f;
+ param_61 = 1f;
+ param_62 = 0f;
+ let _e107 = (*ao_1);
+ param_63 = _e107;
+ let _e108 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_56), (&param_57), (&param_58), (&param_59), (&param_60), (&param_61), (&param_62), (&param_63));
+ return _e108;
+}
+
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_64: vec3<f32>;
+ var param_65: vec3<f32>;
+ var param_66: vec2<f32>;
+ var param_67: f32;
+
+ let _e91 = (*albedo_2);
+ param_64 = _e91;
+ let _e92 = (*N_5);
+ param_65 = _e92;
+ let _e93 = (*worldPos_8);
+ param_66 = _e93;
+ param_67 = 1f;
+ let _e94 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_64), (&param_65), (&param_66), (&param_67));
+ return _e94;
}
fn main_1() {
var base: vec4<f32>;
var N_6: vec3<f32>;
var lit_1: vec3<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);
- let _e89 = v_color_1;
- base = (_e88 * _e89);
+ var param_68: vec3<f32>;
+ var param_69: vec3<f32>;
+ var param_70: 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);
N_6 = vec3<f32>(0f, 0f, 1f);
- let _e91 = base;
- param_60 = _e91.xyz;
- let _e93 = N_6;
- param_61 = _e93;
- let _e94 = v_worldPos_1;
- param_62 = _e94;
- let _e95 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_60), (&param_61), (&param_62));
- lit_1 = _e95;
- let _e96 = lit_1;
- let _e98 = base[3u];
- fragColor = vec4<f32>(_e96.x, _e96.y, _e96.z, _e98);
+ let _e94 = base;
+ param_68 = _e94.xyz;
+ let _e96 = N_6;
+ param_69 = _e96;
+ let _e97 = v_worldPos_1;
+ param_70 = _e97;
+ let _e98 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_68), (&param_69), (&param_70));
+ lit_1 = _e98;
+ let _e99 = lit_1;
+ let _e101 = base[3u];
+ fragColor = vec4<f32>(_e99.x, _e99.y, _e99.z, _e101);
return;
}
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 26ea6f358..5a1569c22 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
```
-"e2362078463a35b5"
+"422d8d4f497e4e40"
```
## ANCHOR_AXES — const @experimental
@@ -4452,6 +4452,8 @@ BuiltinComponentDef<LightData>
## LightData — interface @experimental
```
color: Color
+cookie: number
+cookieSize: Vec2
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index a5e518c0d..a590ce1ad 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
```
-"e2362078463a35b5"
+"422d8d4f497e4e40"
```
## ANCHOR_AXES — const @experimental
@@ -4460,6 +4460,8 @@ BuiltinComponentDef<LightData>
## LightData — interface @experimental
```
color: Color
+cookie: number
+cookieSize: Vec2
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index bf9baa75d..74b97b57b 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -4447,6 +4447,8 @@ BuiltinComponentDef<LightData>
## LightData — interface @experimental
```
color: Color
+cookie: number
+cookieSize: Vec2
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index cd1be6f8d..fe66f7249 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -4447,6 +4447,8 @@ BuiltinComponentDef<LightData>
## LightData — interface @experimental
```
color: Color
+cookie: number
+cookieSize: Vec2
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index be6acfcfc..91ec5abc8 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -4454,6 +4454,8 @@ BuiltinComponentDef<LightData>
## LightData — interface @experimental
```
color: Color
+cookie: number
+cookieSize: Vec2
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index c5b24e56b..80bcd9e33 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -805,6 +805,8 @@ export interface LightPtrData {
innerRadius: number;
falloff: number;
shadowStrength: number;
+ cookie: number;
+ cookieSize: Vec2;
innerAngle: number;
outerAngle: number;
shadowSoftness: number;
@@ -829,17 +831,19 @@ export function fillLight(
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;
+ out.cookie = u32[(ptr + 40) >> 2];
+ const cookieSize_ = out.cookieSize; cookieSize_.x = f32[(ptr + 44) >> 2]; cookieSize_.y = f32[((ptr + 44) >> 2) + 1];
+ out.innerAngle = f32[(ptr + 52) >> 2];
+ out.outerAngle = f32[(ptr + 56) >> 2];
+ out.shadowSoftness = f32[(ptr + 60) >> 2];
+ out.sourceAngle = f32[(ptr + 64) >> 2];
+ out.shadowDistance = f32[(ptr + 68) >> 2];
+ out.meshShadows = u8[ptr + 72] !== 0;
+ out.shadowExtent = f32[(ptr + 76) >> 2];
+ out.environment = u32[(ptr + 80) >> 2];
+ out.environmentRotation = f32[(ptr + 84) >> 2];
+ out.drawEnvironment = u8[ptr + 88] !== 0;
+ out.enabled = u8[ptr + 89] !== 0;
}
export function writeLight(
@@ -853,17 +857,19 @@ export function writeLight(
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;
+ u32[(ptr + 40) >> 2] = data.cookie;
+ f32[(ptr + 44) >> 2] = data.cookieSize.x; f32[((ptr + 44) >> 2) + 1] = data.cookieSize.y;
+ f32[(ptr + 52) >> 2] = data.innerAngle;
+ f32[(ptr + 56) >> 2] = data.outerAngle;
+ f32[(ptr + 60) >> 2] = data.shadowSoftness;
+ f32[(ptr + 64) >> 2] = data.sourceAngle;
+ f32[(ptr + 68) >> 2] = data.shadowDistance;
+ u8[ptr + 72] = data.meshShadows ? 1 : 0;
+ f32[(ptr + 76) >> 2] = data.shadowExtent;
+ u32[(ptr + 80) >> 2] = data.environment;
+ f32[(ptr + 84) >> 2] = data.environmentRotation;
+ u8[ptr + 88] = data.drawEnvironment ? 1 : 0;
+ u8[ptr + 89] = data.enabled ? 1 : 0;
}
export function createLightData(): LightPtrData {
@@ -875,6 +881,8 @@ export function createLightData(): LightPtrData {
innerRadius: 0,
falloff: 0,
shadowStrength: 0,
+ cookie: 0,
+ cookieSize: { x: 0, y: 0 },
innerAngle: 0,
outerAngle: 0,
shadowSoftness: 0,
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index 8144f9165..1a23a1614 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 = 'e2362078463a35b5';
+export const ABI_LAYOUT_HASH = '422d8d4f497e4e40';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -459,6 +459,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
innerRadius: 0,
falloff: 1,
shadowStrength: 1,
+ cookie: 0,
+ cookieSize: { x: 0, y: 0 },
innerAngle: 30,
outerAngle: 45,
shadowSoftness: 0,
@@ -472,10 +474,10 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
enabled: true,
},
renderableField: 'enabled',
- assetFields: [{ field: 'environment', type: 'environment' as AssetFieldType }],
+ assetFields: [{ field: 'cookie', type: 'texture' as AssetFieldType }, { field: 'environment', type: 'environment' as AssetFieldType }],
entityFields: [],
colorFields: ['color'],
- animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerRadius', 'falloff', 'shadowStrength', 'innerAngle', 'outerAngle', 'shadowSoftness', 'sourceAngle', 'shadowDistance'],
+ animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerRadius', 'falloff', 'shadowStrength', 'cookieSize.x', 'cookieSize.y', '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." },
@@ -483,6 +485,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
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] } },
+ cookie: { tooltip: "A texture whose alpha shapes this light (a cookie).", shownWhen: { field: "type", values: [0, 3] } },
+ cookieSize: { min: 0, tooltip: "Cookie size in world units; 0 = the light's own reach.", shownWhen: { field: "type", values: [0, 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] } },
@@ -1350,6 +1354,8 @@ export interface LightData {
innerRadius: number;
falloff: number;
shadowStrength: number;
+ cookie: number;
+ cookieSize: Vec2;
innerAngle: number;
outerAngle: number;
shadowSoftness: number;
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index 32948c9c5..e4326432a 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -234,17 +234,19 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ 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 },
+ { name: 'cookie', type: 'u32', offset: 40 },
+ { name: 'cookieSize', type: 'vec2', offset: 44 },
+ { name: 'innerAngle', type: 'f32', offset: 52 },
+ { name: 'outerAngle', type: 'f32', offset: 56 },
+ { name: 'shadowSoftness', type: 'f32', offset: 60 },
+ { name: 'sourceAngle', type: 'f32', offset: 64 },
+ { name: 'shadowDistance', type: 'f32', offset: 68 },
+ { name: 'meshShadows', type: 'bool', offset: 72 },
+ { name: 'shadowExtent', type: 'f32', offset: 76 },
+ { name: 'environment', type: 'u32', offset: 80 },
+ { name: 'environmentRotation', type: 'f32', offset: 84 },
+ { name: 'drawEnvironment', type: 'bool', offset: 88 },
+ { name: 'enabled', type: 'bool', offset: 89 },
],
},
MeshCollider3D: {
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 4bec9add1..be5c33bdb 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -548,6 +548,8 @@ export interface Light {
innerRadius: number;
falloff: number;
shadowStrength: number;
+ cookie: number;
+ cookieSize: Vec2;
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.snap
index 9d7982f90..a1294b840 100644
--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
@@ -217,6 +217,27 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho
},
},
"Light": {
+ "cookie": {
+ "shownWhen": {
+ "field": "type",
+ "values": [
+ 0,
+ 3,
+ ],
+ },
+ "tooltip": "A texture whose alpha shapes this light (a cookie).",
+ },
+ "cookieSize": {
+ "min": 0,
+ "shownWhen": {
+ "field": "type",
+ "values": [
+ 0,
+ 3,
+ ],
+ },
+ "tooltip": "Cookie size in world units; 0 = the light's own reach.",
+ },
"drawEnvironment": {
"shownWhen": {
"field": "type",
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 93db1d7e9..dc264485f 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 cb3769144284aede
+ * @schema_hash aa777eab55be0aa1
*/
-#define ES_EDITOR_API_SCHEMA_HASH "cb3769144284aede"
+#define ES_EDITOR_API_SCHEMA_HASH "aa777eab55be0aa1"
#include <emscripten/bind.h>
#include <string>
@@ -332,6 +332,9 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"innerRadius","type":"float","group":"Light"},
{"key":"falloff","type":"float","group":"Light"},
{"key":"shadowStrength","type":"float","group":"Light"},
+ {"key":"cookie","type":"asset","group":"Light"},
+ {"key":"cookieSize.x","type":"float","group":"Light"},
+ {"key":"cookieSize.y","type":"float","group":"Light"},
{"key":"innerAngle","type":"float","group":"Light"},
{"key":"outerAngle","type":"float","group":"Light"},
{"key":"shadowSoftness","type":"float","group":"Light"},
@@ -1252,6 +1255,8 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
else if (field == "innerRadius") { c.innerRadius = value; }
else if (field == "falloff") { c.falloff = value; }
else if (field == "shadowStrength") { c.shadowStrength = value; }
+ else if (field == "cookieSize.x") { c.cookieSize.x = value; }
+ else if (field == "cookieSize.y") { c.cookieSize.y = value; }
else if (field == "innerAngle") { c.innerAngle = value; }
else if (field == "outerAngle") { c.outerAngle = value; }
else if (field == "shadowSoftness") { c.shadowSoftness = value; }
@@ -1736,6 +1741,8 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "innerRadius") { return c.innerRadius; }
else if (field == "falloff") { return c.falloff; }
else if (field == "shadowStrength") { return c.shadowStrength; }
+ else if (field == "cookieSize.x") { return c.cookieSize.x; }
+ else if (field == "cookieSize.y") { return c.cookieSize.y; }
else if (field == "innerAngle") { return c.innerAngle; }
else if (field == "outerAngle") { return c.outerAngle; }
else if (field == "shadowSoftness") { return c.shadowSoftness; }
@@ -2103,6 +2110,7 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::str
if (!reg.has<esengine::ecs::Light>(entity)) return false;
auto& c = reg.get<esengine::ecs::Light>(entity);
if (field == "type") { c.type = static_cast<i32>(value); }
+ else if (field == "cookie") { c.cookie = resource::TextureHandle(static_cast<u32>(value)); }
else if (field == "environment") { c.environment = resource::EnvironmentHandle(static_cast<u32>(value)); }
else { return false; }
return true;
@@ -2339,6 +2347,7 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::stri
if (!reg.has<esengine::ecs::Light>(entity)) return 0;
const auto& c = reg.get<esengine::ecs::Light>(entity);
if (field == "type") { return static_cast<i32>(c.type); }
+ else if (field == "cookie") { return static_cast<i32>(c.cookie.id()); }
else if (field == "environment") { return static_cast<i32>(c.environment.id()); }
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return 0;
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index 9e56bd413..f44e45d02 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -583,6 +583,8 @@ struct LightJS {
f32 innerRadius;
f32 falloff;
f32 shadowStrength;
+ u32 cookie;
+ glm::vec2 cookieSize;
f32 innerAngle;
f32 outerAngle;
f32 shadowSoftness;
@@ -604,6 +606,8 @@ void lightApplyJS(esengine::ecs::Light& c, const LightJS& js) {
c.innerRadius = js.innerRadius;
c.falloff = js.falloff;
c.shadowStrength = js.shadowStrength;
+ c.cookie = resource::TextureHandle(js.cookie);
+ c.cookieSize = js.cookieSize;
c.innerAngle = js.innerAngle;
c.outerAngle = js.outerAngle;
c.shadowSoftness = js.shadowSoftness;
@@ -632,6 +636,8 @@ LightJS lightToJS(const esengine::ecs::Light& c) {
js.innerRadius = c.innerRadius;
js.falloff = c.falloff;
js.shadowStrength = c.shadowStrength;
+ js.cookie = c.cookie.id();
+ js.cookieSize = c.cookieSize;
js.innerAngle = c.innerAngle;
js.outerAngle = c.outerAngle;
js.shadowSoftness = c.shadowSoftness;
@@ -1613,6 +1619,8 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("innerRadius", &LightJS::innerRadius)
.field("falloff", &LightJS::falloff)
.field("shadowStrength", &LightJS::shadowStrength)
+ .field("cookie", &LightJS::cookie)
+ .field("cookieSize", &LightJS::cookieSize)
.field("innerAngle", &LightJS::innerAngle)
.field("outerAngle", &LightJS::outerAngle)
.field("shadowSoftness", &LightJS::shadowSoftness)
@@ -3089,17 +3097,19 @@ static_assert(offsetof(esengine::ecs::Light, radius) == 24, "ABI offset drift: e
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::Light, cookie) == 40, "ABI offset drift: esengine::ecs::Light.cookie (EHT expected 40)");
+static_assert(offsetof(esengine::ecs::Light, cookieSize) == 44, "ABI offset drift: esengine::ecs::Light.cookieSize (EHT expected 44)");
+static_assert(offsetof(esengine::ecs::Light, innerAngle) == 52, "ABI offset drift: esengine::ecs::Light.innerAngle (EHT expected 52)");
+static_assert(offsetof(esengine::ecs::Light, outerAngle) == 56, "ABI offset drift: esengine::ecs::Light.outerAngle (EHT expected 56)");
+static_assert(offsetof(esengine::ecs::Light, shadowSoftness) == 60, "ABI offset drift: esengine::ecs::Light.shadowSoftness (EHT expected 60)");
+static_assert(offsetof(esengine::ecs::Light, sourceAngle) == 64, "ABI offset drift: esengine::ecs::Light.sourceAngle (EHT expected 64)");
+static_assert(offsetof(esengine::ecs::Light, shadowDistance) == 68, "ABI offset drift: esengine::ecs::Light.shadowDistance (EHT expected 68)");
+static_assert(offsetof(esengine::ecs::Light, meshShadows) == 72, "ABI offset drift: esengine::ecs::Light.meshShadows (EHT expected 72)");
+static_assert(offsetof(esengine::ecs::Light, shadowExtent) == 76, "ABI offset drift: esengine::ecs::Light.shadowExtent (EHT expected 76)");
+static_assert(offsetof(esengine::ecs::Light, environment) == 80, "ABI offset drift: esengine::ecs::Light.environment (EHT expected 80)");
+static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 84, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 84)");
+static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 88, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 88)");
+static_assert(offsetof(esengine::ecs::Light, enabled) == 89, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 89)");
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)");
@@ -3342,7 +3352,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "e2362078463a35b5";
+static const char* kEsAbiLayoutHash = "422d8d4f497e4e40";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/data/shaders/lightshape2d.esshader b/src/esengine/data/shaders/lightshape2d.esshader
new file mode 100644
index 000000000..6627d14ef
--- /dev/null
+++ b/src/esengine/data/shaders/lightshape2d.esshader
@@ -0,0 +1,78 @@
+#pragma shader "LightShape2D"
+#pragma version 300 es
+
+// The 2D light-shape mask: one channel per shaped light, carrying what that light's
+// own cookie covers. A quad per light, drawn where the light is and turned with it,
+// so a lantern's glow is the shape the artist drew rather than a circle.
+//
+// One draw per light rather than one for all four: each carries its own texture, and
+// a channel it does not name receives zero — which reads as "this light is not here".
+
+#pragma vertex
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec2 a_texCoord;
+layout(location = 2) in vec4 a_channel;
+
+out vec2 v_texCoord;
+out vec4 v_channel;
+
+void main() {
+ gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ v_texCoord = a_texCoord;
+ v_channel = a_channel;
+}
+#pragma end
+
+#pragma fragment
+precision highp float;
+
+in vec2 v_texCoord;
+in vec4 v_channel;
+
+uniform sampler2D u_cookie;
+
+out vec4 fragColor;
+
+void main() {
+ // Alpha alone: the shape is what the artist drew the edge of, and a colour here
+ // would be a second place a light's colour comes from.
+ fragColor = v_channel * texture(u_cookie, v_texCoord).a;
+}
+#pragma end
+
+#pragma vertex wgsl
+struct VSIn {
+ @location(0) a_position : vec2f,
+ @location(1) a_texCoord : vec2f,
+ @location(2) a_channel : vec4f,
+};
+struct VSOut {
+ @builtin(position) pos : vec4f,
+ @location(0) v_texCoord : vec2f,
+ @location(1) v_channel : vec4f,
+};
+
+@vertex fn vs_main(v : VSIn) -> VSOut {
+ var out : VSOut;
+ out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);
+ out.v_texCoord = v.a_texCoord;
+ out.v_channel = v.a_channel;
+ return out;
+}
+#pragma end
+
+#pragma fragment wgsl
+// The cookie, on the draw's own first slot — this pass binds one texture per light.
+@group(1) @binding(0) var t0 : texture_2d<f32>;
+@group(1) @binding(8) var s0 : sampler;
+
+struct VSOut {
+ @builtin(position) pos : vec4f,
+ @location(0) v_texCoord : vec2f,
+ @location(1) v_channel : vec4f,
+};
+
+@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {
+ return v.v_channel * textureSample(t0, s0, v.v_texCoord).a;
+}
+#pragma end
diff --git a/src/esengine/data/shaders/mesh.esshader b/src/esengine/data/shaders/mesh.esshader
index 00912955e..666cbf7ba 100644
--- a/src/esengine/data/shaders/mesh.esshader
+++ b/src/esengine/data/shaders/mesh.esshader
@@ -280,6 +280,9 @@ struct VSOut {
// lighting reads it for every Lit shader rather than behind a feature.
@group(1) @binding(7) var t7 : texture_2d<f32>;
@group(1) @binding(15) var s7 : sampler;
+// The light-shape mask, one unit below it, on the same terms.
+@group(1) @binding(6) var t6 : texture_2d<f32>;
+@group(1) @binding(14) var s6 : sampler;
struct VSOut {
@builtin(position) pos : vec4f,
diff --git a/src/esengine/data/shaders/sky.esshader b/src/esengine/data/shaders/sky.esshader
index d5412aca0..ef34b053d 100644
--- a/src/esengine/data/shaders/sky.esshader
+++ b/src/esengine/data/shaders/sky.esshader
@@ -63,6 +63,9 @@ struct VSOut {
// The 2D shadow mask, which the injected lighting reads for every Lit shader.
@group(1) @binding(7) var t7 : texture_2d<f32>;
@group(1) @binding(15) var s7 : sampler;
+// The light-shape mask, one unit below it, on the same terms.
+@group(1) @binding(6) var t6 : texture_2d<f32>;
+@group(1) @binding(14) var s6 : sampler;
// Declared again: each WGSL block is compiled on its own, so a struct defined in
// the vertex one is an undeclared name here — and that reaches anyone as an
diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hpp
index 5a85fe65f..3821897f0 100644
--- a/src/esengine/ecs/components/Light.hpp
+++ b/src/esengine/ecs/components/Light.hpp
@@ -96,6 +96,23 @@ struct Light {
tooltip="How much of this light its shadows remove (1 = all of it).")
f32 shadowStrength{1.0f};
+ /** @brief A texture whose ALPHA is this light's shape — a lantern's glow, a window's
+ * shaft. Drawn at the light's own place, turned by its Transform, and
+ * multiplied into what the light gives a pixel; the colour is not read,
+ * because a light's colour is the light's. Four shaped lights fit a frame,
+ * and past that a light lights without a shape. */
+ ES_PROPERTY(asset = texture, shown_when=type:Point|Spot,
+ tooltip="A texture whose alpha shapes this light (a cookie).")
+ resource::TextureHandle cookie;
+
+ /** @brief How big @ref cookie is drawn, in world units. 0 on an axis covers the
+ * light's own reach on it — a square of 2 × @ref radius — which is what a
+ * cookie drawn for this light almost always wants: a shape smaller than the
+ * reach cuts the light off, and one larger is trimmed by the falloff. */
+ ES_PROPERTY(animatable, min=0, shown_when=type:Point|Spot,
+ tooltip="Cookie size in world units; 0 = the light's own reach.")
+ glm::vec2 cookieSize{0.0f, 0.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/draw/DrawList.cpp b/src/esengine/renderer/draw/DrawList.cpp
index e536d7d5d..a35abf386 100644
--- a/src/esengine/renderer/draw/DrawList.cpp
+++ b/src/esengine/renderer/draw/DrawList.cpp
@@ -123,8 +123,8 @@ void DrawList::finalize(TransientBufferPool& pool) {
if (head.layout_id == LayoutId::Batch && commands_[i].texture_count >= 1) {
// Multi-texture: give this command's texture a slot in the head's set
// (or bail to a new draw if all 8 slots are taken), then stamp its verts.
- const u8 slotBudget = static_cast<u8>(
- shadow_2d_reserved_ ? MAX_CMD_TEXTURE_SLOTS - 1 : MAX_CMD_TEXTURE_SLOTS);
+ const u8 slotBudget =
+ static_cast<u8>(MAX_CMD_TEXTURE_SLOTS - mask_2d_slots_);
i32 slot = head.addTextureSlot(commands_[i].texture_ids[0], slotBudget);
if (slot >= 0) {
// Staging verts default to texIndex 0, so only a non-zero slot
@@ -239,10 +239,12 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,
// any pass. The fill is a STABLE white, so unused units cost no rebind.
if (cmd.texture_count > 0) {
for (u8 slot = 0; slot < MAX_CMD_TEXTURE_SLOTS; ++slot) {
- // The top unit is the frame's 2D shadow mask wherever one exists — the
- // merge was kept off it, so what a draw holds there is the fill.
- const bool masked = shadow_2d_reserved_ && slot == MAX_CMD_TEXTURE_SLOTS - 1;
- u32 tex = masked ? (shadow_2d_texture_ != 0 ? shadow_2d_texture_ : white_texture_id)
+ // The top units are the frame's screen-space light masks wherever one
+ // exists — the merge was kept off them, so what a draw holds there is
+ // the mask, or the fill where the pass drew nothing.
+ const bool masked = slot >= MAX_CMD_TEXTURE_SLOTS - mask_2d_slots_;
+ u32 tex = masked ? (mask_2d_textures_[slot] != 0 ? mask_2d_textures_[slot]
+ : white_texture_id)
: ((slot < cmd.texture_count) ? cmd.texture_ids[slot]
: white_texture_id);
device.bindTexture(slot, TextureHandle{tex});
diff --git a/src/esengine/renderer/draw/DrawList.hpp b/src/esengine/renderer/draw/DrawList.hpp
index 8f5ceb9a2..2290a86ff 100644
--- a/src/esengine/renderer/draw/DrawList.hpp
+++ b/src/esengine/renderer/draw/DrawList.hpp
@@ -9,6 +9,7 @@
#include "../frame/FrameCapture.hpp"
#include "../../math/Math.hpp"
+#include <algorithm>
#include <unordered_map>
#include <vector>
@@ -26,14 +27,16 @@ public:
// (hence the pool, whose staging it rewrites; call before upload()).
void finalize(TransientBufferPool& pool);
- /// Whether the frame keeps its top texture unit for a 2D shadow mask. Set BEFORE
- /// finalize: the merge spends slots there, and the mask's own texture does not
- /// exist until the pass that draws it has run.
- void reserveShadow2DSlot(bool reserved) { shadow_2d_reserved_ = reserved; }
+ /// How many of the frame's TOP texture units are screen-space light masks: one for
+ /// the shadow mask, two when a light also carries a shape. Set BEFORE finalize (the
+ /// merge spends slots) and reserved top-down, so a sampler's unit never moves.
+ void reserveMask2DSlots(u32 count) { mask_2d_slots_ = std::min(count, MAX_CMD_TEXTURE_SLOTS); }
- /// The mask itself, which every draw then binds on that unit. Zero leaves the unit
- /// filled with white, which reads as "nothing shadows anything".
- void setShadow2DTexture(u32 textureId) { shadow_2d_texture_ = textureId; }
+ /// A mask itself, which every draw then binds on its unit. Zero leaves the unit
+ /// filled with white — "nothing shadows anything", and "the shape covers all".
+ void setMask2DTexture(u32 unit, u32 textureId) {
+ if (unit < MAX_CMD_TEXTURE_SLOTS) mask_2d_textures_[unit] = textureId;
+ }
// Each merged command resolves to an immutable pipeline (program + layout + blend +
// depth + stencil + cull) bound via GfxDevice::setPipeline; per-draw dynamic state
@@ -175,10 +178,10 @@ private:
std::vector<SortEntry> sort_entries_;
std::vector<DrawCommand> sorted_scratch_; // reused across frames to avoid a
// per-frame heap alloc in finalize()
- /// @see setShadow2DTexture
- u32 shadow_2d_texture_ = 0;
- /// @see reserveShadow2DSlot
- bool shadow_2d_reserved_ = false;
+ /// @see setMask2DTexture — indexed by texture unit, 0 where that unit is not a mask.
+ u32 mask_2d_textures_[MAX_CMD_TEXTURE_SLOTS] = {};
+ /// @see reserveMask2DSlots
+ u32 mask_2d_slots_ = 0;
u32 merged_draw_calls_ = 0;
/// Members of a SortingGroup, by entity id — empty in the common frame.
std::unordered_map<u32, GroupIdentity> group_identities_;
diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cpp
index b8f767c01..37ca35fd1 100644
--- a/src/esengine/renderer/frame/RenderFrame.cpp
+++ b/src/esengine/renderer/frame/RenderFrame.cpp
@@ -187,6 +187,7 @@ void RenderFrame::shutdown() {
shadow_pool_.shutdown();
releaseShadowFrameUbos();
releaseShadow2DResources();
+ releaseShape2DResources();
releaseFrameTargets();
target_pool_.clear();
@@ -263,22 +264,23 @@ void RenderFrame::drawScene() {
// Where THIS camera's pixels sit inside the 2D shadow mask. Per camera because the
// mask is screen space: two cameras drew into two parts of one target, and a
// fragment has to read the part its own camera filled.
- if (shadow2DActive() && width_ > 0 && height_ > 0) {
+ if ((shadow2DActive() || shape2DActive()) && width_ > 0 && height_ > 0) {
const f32 w = static_cast<f32>(width_);
const f32 h = static_cast<f32>(height_);
// The height's SIGN carries which way this backend stores the rows it just drew.
// One shader source serves both backends — the WGSL a material runs is translated
// from the GLSL — so the convention travels as data rather than a #ifdef.
const f32 rows = device_.textureOriginTopLeft() ? -1.0f : 1.0f;
- context_.lights().setShadow2DRect(glm::vec4(
+ context_.lights().setMask2DRect(glm::vec4(
static_cast<f32>(std::max(scene_viewport_.x, 0)) / w,
static_cast<f32>(std::max(scene_viewport_.y, 0)) / h,
static_cast<f32>(scene_viewport_.w) / w,
static_cast<f32>(scene_viewport_.h) / h * rows));
} else {
- context_.lights().setShadow2DRect(glm::vec4(0.0f));
+ context_.lights().setMask2DRect(glm::vec4(0.0f));
}
- draw_list_.setShadow2DTexture(shadow_2d_texture_id_);
+ draw_list_.setMask2DTexture(SHADOW_2D_TEXTURE_UNIT, shadow_2d_texture_id_);
+ draw_list_.setMask2DTexture(SHAPE_2D_TEXTURE_UNIT, shape_2d_texture_id_);
// Here and not in flush(): the shadow pass runs before this one and decides
// which atlas tile each light reads, so the block has to go up after it.
context_.lights().uploadAndBind();
@@ -513,9 +515,12 @@ void RenderFrame::flush() {
// upload afterwards is its own clock and cannot be read off this one.
{
ES_PROFILE_SCOPE("render.finalize.drawList");
- // Before the merge, which spends texture slots: the mask needs the top one
- // and does not exist yet — its own pass has not run.
- draw_list_.reserveShadow2DSlot(shadow_2d_resource_ != rg::kNoResource);
+ // Before the merge, which spends texture slots: a mask needs a top one and
+ // does not exist yet. The shape mask sits below the shadow one, so a frame
+ // with a shape keeps both whether anything casts or not.
+ draw_list_.reserveMask2DSlots(
+ shape_2d_resource_ != rg::kNoResource ? 2u
+ : (shadow_2d_resource_ != rg::kNoResource ? 1u : 0u));
draw_list_.finalize(pool_);
}
{
@@ -588,6 +593,9 @@ void RenderFrame::end() {
}
// The same terms for the 2D mask: every Lit draw samples it through a pinned
// unit, so the graph owes the scene its ordering and its lifetime, not a bind.
+ if (shape_2d_resource_ != rg::kNoResource) {
+ scene.dependencies.push_back(shape_2d_resource_);
+ }
if (shadow_2d_resource_ != rg::kNoResource) {
scene.dependencies.push_back(shadow_2d_resource_);
}
@@ -1238,6 +1246,7 @@ void RenderFrame::collectLights(ecs::Registry& registry) {
// Last, because which lights the mask can carry is a question about the array the
// loop above just filled.
collectShadow2D(registry);
+ collectShape2D(registry);
}
bool RenderFrame::collectEnvironment(const ecs::Light& light, const glm::vec3& scale) {
@@ -1809,6 +1818,7 @@ void RenderFrame::collectAll(ecs::Registry& registry) {
{ ES_PROFILE_SCOPE("render.collect.shadowPlan"); buildShadowPlan(registry); }
{ ES_PROFILE_SCOPE("render.collect.shadowDeclare"); declareShadowPass(registry); }
{ ES_PROFILE_SCOPE("render.collect.shadow2dDeclare"); declareShadow2DPass(); }
+ { ES_PROFILE_SCOPE("render.collect.shape2dDeclare"); declareShape2DPass(); }
auto ctx = makeContext();
diff --git a/src/esengine/renderer/frame/RenderFrame.hpp b/src/esengine/renderer/frame/RenderFrame.hpp
index 6618ba965..d3400b61c 100644
--- a/src/esengine/renderer/frame/RenderFrame.hpp
+++ b/src/esengine/renderer/frame/RenderFrame.hpp
@@ -640,6 +640,29 @@ private:
/// binding both key off.
bool shadow2DActive() const { return shadow_2d_texture_id_ != 0; }
+ /**
+ * @brief Gathers the frame's SHAPED lights and hands each one a shape-mask channel.
+ *
+ * @details The sibling of collectShadow2D, in the same no-GPU phase: a light with a
+ * cookie gets a channel, and past the cap a light lights without a shape.
+ */
+ void collectShape2D(ecs::Registry& registry);
+
+ /// Declares the pass that draws the shape mask, ahead of the scene that samples it.
+ void declareShape2DPass();
+
+ /// The shape pass's body: one textured quad per shaped light, into its own channel.
+ void executeShape2DPass();
+
+ /// Frees the shape mask's own GPU objects. Called while the device is still valid.
+ void releaseShape2DResources();
+
+ /// Compiles the shape shader on first use, and says whether it is usable.
+ bool ensureShape2DShader();
+
+ /// Whether this frame drew a shape mask.
+ bool shape2DActive() const { return shape_2d_texture_id_ != 0; }
+
/// Grows the per-view frame-constant buffers to @p count and no further.
void ensureShadowFrameUbos(u32 count);
@@ -759,6 +782,28 @@ private:
resource::ShaderHandle shadow_2d_shader_{};
bool shadow_2d_shader_tried_ = false;
+ /** @brief A light whose shape the frame draws, and the mask channel it owns. */
+ struct Shape2DLight {
+ /// The quad's four world corners, in the order the two triangles take them.
+ glm::vec2 corners[4]{};
+ /// The cookie itself — one draw per light, because each binds its own.
+ u32 texture = 0;
+ /// Its slot in the light array, which is what the channel is recorded against.
+ u32 slot = 0;
+ };
+
+ std::vector<Shape2DLight> shape_2d_lights_;
+ /// The shape mask as a graph resource, read through its own pinned sampler unit.
+ rg::ResourceId shape_2d_resource_ = rg::kNoResource;
+ u32 shape_2d_texture_id_ = 0;
+ /// Interleaved (x, y, u, v, channel.rgba), six vertices per light.
+ std::vector<f32> shape_2d_vertices_;
+ BufferHandle shape_2d_vbo_ = BufferHandle::Invalid;
+ u32 shape_2d_vbo_bytes_ = 0;
+ VertexLayoutHandle shape_2d_layout_ = VertexLayoutHandle::Invalid;
+ resource::ShaderHandle shape_2d_shader_{};
+ bool shape_2d_shader_tried_ = false;
+
/// The atlas as a graph resource: the shadow pass writes it and the scene names
/// it, which is what orders the two. Borrowed from the pool every other target
/// comes from. kNoResource = no map this frame.
diff --git a/src/esengine/renderer/frame/RenderFrameShadow2D.cpp b/src/esengine/renderer/frame/RenderFrameShadow2D.cpp
index c2f561196..fe77f27da 100644
--- a/src/esengine/renderer/frame/RenderFrameShadow2D.cpp
+++ b/src/esengine/renderer/frame/RenderFrameShadow2D.cpp
@@ -12,6 +12,7 @@
#include "../../core/Log.hpp"
#include "../../ecs/components/Transform.hpp"
#include "../../ecs/components/ShadowCaster2D.hpp"
+#include "../../ecs/components/Light.hpp"
#include "../RenderTypePlugin.hpp"
#include "../../resource/ShaderParser.hpp"
#include "../rhi/ShaderEmbeds.generated.hpp"
@@ -28,6 +29,10 @@ namespace {
/// one-hot channel of the light it was cast from.
constexpr u32 kShadow2DFloats = 7;
+/// Floats one shape-mask vertex carries: position, the cookie's uv, and the one-hot
+/// channel of the light it belongs to.
+constexpr u32 kShape2DFloats = 8;
+
/// Samples across a source that has width. A penumbra made of samples IS banded,
/// and sixteen is where the bands stop reading as rays from the corner that threw
/// them — one silhouette each, over a scene with tens of occluders.
@@ -46,7 +51,7 @@ void RenderFrame::collectShadow2D(ecs::Registry& registry) {
shadow_2d_lights_.clear();
shadow_2d_resource_ = rg::kNoResource;
shadow_2d_texture_id_ = 0;
- context_.lights().setShadow2DRect(glm::vec4(0.0f));
+ context_.lights().setMask2DRect(glm::vec4(0.0f));
auto casters = registry.view<ecs::Transform, ecs::ShadowCaster2D>();
for (auto entity : casters) {
@@ -360,4 +365,193 @@ void RenderFrame::executeShadow2DPass() {
shadow_2d_texture_id_ = static_cast<u32>(graph_.textureOf(shadow_2d_resource_));
}
+
+// The shape mask — the same target as the shadow mask above, carrying the other half
+// of "how much of this light is here": what its own cookie covers.
+
+void RenderFrame::collectShape2D(ecs::Registry& registry) {
+ shape_2d_lights_.clear();
+ shape_2d_resource_ = rg::kNoResource;
+ shape_2d_texture_id_ = 0;
+
+ const LightConstants& lights = context_.lights().data();
+ auto view = registry.view<ecs::Transform, ecs::Light>();
+ for (auto entity : view) {
+ if (shape_2d_lights_.size() >= MAX_SHAPE_2D_LIGHTS) break;
+ const auto& light = view.get<ecs::Light>(entity);
+ if (!light.enabled || !light.cookie.isValid()) continue;
+ Texture* tex = resource_manager_.getTexture(light.cookie);
+ if (!tex || tex->getId() == 0) continue;
+
+ // The light's own slot, found by where it stands: the collect wrote the array,
+ // and a light the cap dropped has no slot to give a channel to.
+ const glm::vec3 p = [&] {
+ auto& transform = view.get<ecs::Transform>(entity);
+ transform.ensureDecomposed();
+ return transform.worldPosition;
+ }();
+ u32 slot = MAX_LIGHTS;
+ for (u32 i = 0; i < context_.lights().count(); ++i) {
+ const GpuLight& gpu = lights.lights[i];
+ if (gpu.posDir.z > 1.5f || gpu.posDir.z < 0.5f) {
+ if (std::abs(gpu.posDir.x - p.x) < 1e-3f && std::abs(gpu.posDir.y - p.y) < 1e-3f) {
+ slot = i;
+ break;
+ }
+ }
+ }
+ if (slot >= MAX_LIGHTS) continue;
+
+ // The light's own reach where the author named no size: a shape smaller than the
+ // reach cuts the light off, and one larger is trimmed by the falloff anyway.
+ const f32 reach = std::max(light.radius, 0.0f) * 2.0f;
+ const f32 w = light.cookieSize.x > 0.0f ? light.cookieSize.x : reach;
+ const f32 h = light.cookieSize.y > 0.0f ? light.cookieSize.y : reach;
+ if (w <= 0.0f || h <= 0.0f) continue;
+
+ auto& transform = view.get<ecs::Transform>(entity);
+ const glm::vec2 turn = flatTurnZ(transform.worldRotation);
+ const auto corner = [&](f32 sx, f32 sy) {
+ const f32 lx = sx * w * 0.5f;
+ const f32 ly = sy * h * 0.5f;
+ return glm::vec2{p.x + lx * turn.x - ly * turn.y, p.y + lx * turn.y + ly * turn.x};
+ };
+ Shape2DLight entry;
+ entry.corners[0] = corner(-1.0f, -1.0f);
+ entry.corners[1] = corner(1.0f, -1.0f);
+ entry.corners[2] = corner(1.0f, 1.0f);
+ entry.corners[3] = corner(-1.0f, 1.0f);
+ entry.texture = tex->getId();
+ entry.slot = slot;
+ shape_2d_lights_.push_back(entry);
+ }
+ if (shape_2d_lights_.empty()) return;
+
+ for (u32 i = 0; i < shape_2d_lights_.size(); ++i) {
+ context_.lights().setLightShape2DChannel(shape_2d_lights_[i].slot, i);
+ }
+
+ rg::TargetDesc desc;
+ desc.scale = 1.0f;
+ desc.format = GfxPixelFormat::RGBA8;
+ // Linear: a cookie is artwork, and its edge is meant to be soft. The shadow mask
+ // reads nearest for the opposite reason — there, a filtered read would blend in the
+ // neighbouring light's silhouette.
+ desc.linearFilter = true;
+ shape_2d_resource_ = graph_.createTarget(desc);
+}
+
+void RenderFrame::releaseShape2DResources() {
+ if (shape_2d_vbo_ != BufferHandle::Invalid) device_.deleteBuffer(shape_2d_vbo_);
+ if (shape_2d_layout_ != VertexLayoutHandle::Invalid) device_.deleteVertexLayout(shape_2d_layout_);
+ shape_2d_vbo_ = BufferHandle::Invalid;
+ shape_2d_vbo_bytes_ = 0;
+ shape_2d_layout_ = VertexLayoutHandle::Invalid;
+}
+
+bool RenderFrame::ensureShape2DShader() {
+ if (shape_2d_shader_.isValid()) return true;
+ if (shape_2d_shader_tried_) return false;
+ shape_2d_shader_tried_ = true;
+
+ auto& resources = resource_manager_;
+ const auto target = resources.preferredShaderTarget();
+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::LIGHTSHAPE2D);
+ shape_2d_shader_ = resources.createShader(
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex, "", {}, target),
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment, "", {}, target),
+ /*rewriteLoose=*/false, resources.preferredShaderLanguage());
+ if (!shape_2d_shader_.isValid()) {
+ ES_LOG_ERROR("RenderFrame: no 2D light-shape shader; shaped lights are off this run");
+ return false;
+ }
+
+ VertexLayoutDesc layout;
+ layout.attributeCount = 3;
+ layout.strides[0] = kShape2DFloats * sizeof(f32);
+ layout.attributes[0] = {0, 2, GfxDataType::Float, false, 0, 0};
+ layout.attributes[1] = {1, 2, GfxDataType::Float, false, 2 * sizeof(f32), 0};
+ layout.attributes[2] = {2, 4, GfxDataType::Float, false, 4 * sizeof(f32), 0};
+ shape_2d_layout_ = device_.createVertexLayout(layout);
+ return shape_2d_layout_ != VertexLayoutHandle::Invalid;
+}
+
+void RenderFrame::declareShape2DPass() {
+ if (shape_2d_resource_ == rg::kNoResource) return;
+
+ rg::PassDesc mask;
+ mask.name = "light-shape-2d";
+ mask.write = shape_2d_resource_;
+ mask.clear = true;
+ // Zero is "this light's shape does not reach here", which is what a frame whose
+ // quads come back empty has to read as.
+ mask.clearColor[0] = mask.clearColor[1] = mask.clearColor[2] = 0.0f;
+ mask.clearColor[3] = 0.0f;
+ mask.execute = [this](const rg::PassContext&) { executeShape2DPass(); };
+ graph_.addPass(std::move(mask));
+}
+
+void RenderFrame::executeShape2DPass() {
+ if (shape_2d_resource_ == rg::kNoResource) return;
+ if (!ensureShape2DShader()) return;
+
+ ES_PROFILE_SCOPE("render.lightshape2d");
+ ES_PROFILE_COUNTER("render.lightshape2d.lights", static_cast<u32>(shape_2d_lights_.size()));
+
+ shape_2d_vertices_.clear();
+ for (u32 i = 0; i < shape_2d_lights_.size(); ++i) {
+ const Shape2DLight& light = shape_2d_lights_[i];
+ const glm::vec2 uv[4] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}};
+ const u32 order[6] = {0, 1, 2, 0, 2, 3};
+ for (u32 k = 0; k < 6; ++k) {
+ const u32 c = order[k];
+ shape_2d_vertices_.push_back(light.corners[c].x);
+ shape_2d_vertices_.push_back(light.corners[c].y);
+ shape_2d_vertices_.push_back(uv[c].x);
+ shape_2d_vertices_.push_back(uv[c].y);
+ for (u32 ch = 0; ch < 4; ++ch) {
+ shape_2d_vertices_.push_back(ch == i ? 1.0f : 0.0f);
+ }
+ }
+ }
+ if (shape_2d_vertices_.empty()) return;
+
+ const u32 bytes = static_cast<u32>(shape_2d_vertices_.size() * sizeof(f32));
+ if (shape_2d_vbo_ == BufferHandle::Invalid || bytes > shape_2d_vbo_bytes_) {
+ if (shape_2d_vbo_ != BufferHandle::Invalid) device_.deleteBuffer(shape_2d_vbo_);
+ shape_2d_vbo_bytes_ = std::max(bytes * 2u, 1024u);
+ shape_2d_vbo_ = device_.createBuffer(
+ {GfxBufferUsage::Vertex, shape_2d_vbo_bytes_, /*dynamic=*/true}, nullptr);
+ if (shape_2d_vbo_ == BufferHandle::Invalid) return;
+ }
+ device_.updateBuffer(shape_2d_vbo_, 0, shape_2d_vertices_.data(), bytes);
+
+ Shader* shader = resource_manager_.getShader(shape_2d_shader_);
+ if (!shader) return;
+
+ PipelineDesc desc{};
+ desc.program = shader->handle();
+ desc.vertexLayout = shape_2d_layout_;
+ // Adding: the channels are independent, so what a quad writes lands only in its
+ // own — and two quads of one light are not a thing this pass builds.
+ desc.blend = BlendMode::PmaAdditive;
+ desc.blendEnabled = true;
+ desc.depthTest = false;
+ desc.depthWrite = false;
+ device_.setPipeline(device_.createPipeline(desc));
+ device_.setViewport(std::max(scene_viewport_.x, 0), std::max(scene_viewport_.y, 0),
+ static_cast<i32>(scene_viewport_.w), static_cast<i32>(scene_viewport_.h));
+ context_.updateCameraConstants(view_projection_);
+ device_.setVertexBuffer(0, shape_2d_vbo_, 0);
+ device_.setIndexBuffer(BufferHandle::Invalid);
+ // One draw per light: the cookie is the draw's own texture, which is what an atlas
+ // would exist to avoid — and four quads do not need one.
+ for (u32 i = 0; i < shape_2d_lights_.size(); ++i) {
+ device_.bindTexture(0, TextureHandle{shape_2d_lights_[i].texture});
+ device_.drawArrays(i * 6, 6);
+ }
+
+ shape_2d_texture_id_ = static_cast<u32>(graph_.textureOf(shape_2d_resource_));
+}
+
} // namespace esengine
diff --git a/src/esengine/renderer/rhi/Shader.cpp b/src/esengine/renderer/rhi/Shader.cpp
index 59c59b5ea..b623a9251 100644
--- a/src/esengine/renderer/rhi/Shader.cpp
+++ b/src/esengine/renderer/rhi/Shader.cpp
@@ -263,7 +263,7 @@ bool Shader::compile(const std::string& vertexSrc, const std::string& fragmentSr
// blocks above are: the header reaches every Lit shader, so a compile site that
// forgot the unit would sample slot 0 silently. GLSL ES 300 has no layout(binding).
if (hasUniform(SHADOW_MAP_SAMPLER) || hasUniform(ENV_MAP_SAMPLER)
- || hasUniform(SHADOW_2D_SAMPLER)) {
+ || hasUniform(SHADOW_2D_SAMPLER) || hasUniform(SHAPE_2D_SAMPLER)) {
bind();
if (hasUniform(SHADOW_MAP_SAMPLER)) {
setUniform(SHADOW_MAP_SAMPLER, static_cast<i32>(SHADOW_MAP_TEXTURE_UNIT));
@@ -274,6 +274,9 @@ bool Shader::compile(const std::string& vertexSrc, const std::string& fragmentSr
if (hasUniform(SHADOW_2D_SAMPLER)) {
setUniform(SHADOW_2D_SAMPLER, static_cast<i32>(SHADOW_2D_TEXTURE_UNIT));
}
+ if (hasUniform(SHAPE_2D_SAMPLER)) {
+ setUniform(SHAPE_2D_SAMPLER, static_cast<i32>(SHAPE_2D_TEXTURE_UNIT));
+ }
unbind();
}
diff --git a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp
index 6c96a8f4e..b56280059 100644
--- a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp
+++ b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp
@@ -273,6 +273,86 @@ void main() {
#pragma end
)esshader";
+inline constexpr const char* LIGHTSHAPE2D = R"esshader(#pragma shader "LightShape2D"
+#pragma version 300 es
+
+// The 2D light-shape mask: one channel per shaped light, carrying what that light's
+// own cookie covers. A quad per light, drawn where the light is and turned with it,
+// so a lantern's glow is the shape the artist drew rather than a circle.
+//
+// One draw per light rather than one for all four: each carries its own texture, and
+// a channel it does not name receives zero — which reads as "this light is not here".
+
+#pragma vertex
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec2 a_texCoord;
+layout(location = 2) in vec4 a_channel;
+
+out vec2 v_texCoord;
+out vec4 v_channel;
+
+void main() {
+ gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ v_texCoord = a_texCoord;
+ v_channel = a_channel;
+}
+#pragma end
+
+#pragma fragment
+precision highp float;
+
+in vec2 v_texCoord;
+in vec4 v_channel;
+
+uniform sampler2D u_cookie;
+
+out vec4 fragColor;
+
+void main() {
+ // Alpha alone: the shape is what the artist drew the edge of, and a colour here
+ // would be a second place a light's colour comes from.
+ fragColor = v_channel * texture(u_cookie, v_texCoord).a;
+}
+#pragma end
+
+#pragma vertex wgsl
+struct VSIn {
+ @location(0) a_position : vec2f,
+ @location(1) a_texCoord : vec2f,
+ @location(2) a_channel : vec4f,
+};
+struct VSOut {
+ @builtin(position) pos : vec4f,
+ @location(0) v_texCoord : vec2f,
+ @location(1) v_channel : vec4f,
+};
+
+@vertex fn vs_main(v : VSIn) -> VSOut {
+ var out : VSOut;
+ out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);
+ out.v_texCoord = v.a_texCoord;
+ out.v_channel = v.a_channel;
+ return out;
+}
+#pragma end
+
+#pragma fragment wgsl
+// The cookie, on the draw's own first slot — this pass binds one texture per light.
+@group(1) @binding(0) var t0 : texture_2d<f32>;
+@group(1) @binding(8) var s0 : sampler;
+
+struct VSOut {
+ @builtin(position) pos : vec4f,
+ @location(0) v_texCoord : vec2f,
+ @location(1) v_channel : vec4f,
+};
+
+@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {
+ return v.v_channel * textureSample(t0, s0, v.v_texCoord).a;
+}
+#pragma end
+)esshader";
+
inline constexpr const char* MESH = R"esshader(#pragma shader "Mesh"
#pragma version 300 es
// Lit domain for the LIGHTING it injects (LightConstants + applyLighting2D),
@@ -555,6 +635,9 @@ struct VSOut {
// lighting reads it for every Lit shader rather than behind a feature.
@group(1) @binding(7) var t7 : texture_2d<f32>;
@group(1) @binding(15) var s7 : sampler;
+// The light-shape mask, one unit below it, on the same terms.
+@group(1) @binding(6) var t6 : texture_2d<f32>;
+@group(1) @binding(14) var s6 : sampler;
struct VSOut {
@builtin(position) pos : vec4f,
@@ -889,6 +972,9 @@ struct VSOut {
// The 2D shadow mask, which the injected lighting reads for every Lit shader.
@group(1) @binding(7) var t7 : texture_2d<f32>;
@group(1) @binding(15) var s7 : sampler;
+// The light-shape mask, one unit below it, on the same terms.
+@group(1) @binding(6) var t6 : texture_2d<f32>;
+@group(1) @binding(14) var s6 : sampler;
// Declared again: each WGSL block is compiled on its own, so a struct defined in
// the vertex one is an undeclared name here — and that reaches anyone as an
diff --git a/src/esengine/renderer/store/LightConstants.hpp b/src/esengine/renderer/store/LightConstants.hpp
index e13749c5e..d9e5c7b0e 100644
--- a/src/esengine/renderer/store/LightConstants.hpp
+++ b/src/esengine/renderer/store/LightConstants.hpp
@@ -54,6 +54,19 @@ inline constexpr u32 MAX_LIGHTS = 16;
inline constexpr const char* SHADOW_2D_SAMPLER = "u_shadow2D";
inline constexpr u32 SHADOW_2D_TEXTURE_UNIT = 7;
+/**
+ * @brief The 2D light-shape mask, and the unit below the shadow mask's.
+ * @details The same target shape carrying the other half of "how much of this light is
+ * here": what its SHAPE covers, drawn as the light's own cookie. Two planes
+ * rather than one channel, because a fragment needs both numbers to multiply
+ * them — a single channel could only carry their sum.
+ */
+inline constexpr const char* SHAPE_2D_SAMPLER = "u_lightShape2D";
+inline constexpr u32 SHAPE_2D_TEXTURE_UNIT = 6;
+
+/** @brief Lights whose SHAPE one frame can carry — the shape mask's four channels. */
+inline constexpr u32 MAX_SHAPE_2D_LIGHTS = 4;
+
/**
* @brief Lights whose 2D shadows one frame can carry — the mask's four channels.
* @details A cap on CASTERS, not on lights: past it a light still lights the scene and
@@ -111,9 +124,9 @@ struct GpuLight {
/// 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};
+ /// out to, y = the power its ramp is raised to (1 = linear), z = how much a shadow
+ /// removes (1 = all), w = its shape-mask channel (-1 = unshaped). Defaults = linear.
+ glm::vec4 falloff{0.0f, 1.0f, 1.0f, -1.0f};
};
/**
@@ -125,10 +138,10 @@ struct GpuLight {
struct LightConstants {
glm::vec4 ambient{0.0f};
GpuLight lights[MAX_LIGHTS];
- /// Where the CAMERA NOW DRAWING lands in the 2D shadow mask: xy = its low corner,
- /// zw = its size, as fractions of the mask; zero width = no mask this frame. Per
- /// camera, because the mask is screen space and two cameras own two parts of it.
- glm::vec4 shadow2DRect{0.0f};
+ /// Where the CAMERA NOW DRAWING lands in a screen-space light mask: xy = its low
+ /// corner, zw = its size, as fractions of one; zero width = no mask this frame. One
+ /// rect for BOTH masks — same size, same viewport, so two would be two answers.
+ glm::vec4 mask2DRect{0.0f};
/// World -> tile i's clip space. Identity where a tile is unclaimed; which tiles
/// a light may read are the ones its own `shadowMap` names.
glm::mat4 shadowMatrix[MAX_SHADOW_TILES];
diff --git a/src/esengine/renderer/store/LightStore.hpp b/src/esengine/renderer/store/LightStore.hpp
index 17d5043a2..eddae969d 100644
--- a/src/esengine/renderer/store/LightStore.hpp
+++ b/src/esengine/renderer/store/LightStore.hpp
@@ -120,11 +120,19 @@ public:
dirty_ = true;
}
- /// Where the camera about to draw sits inside the mask (xy = low corner, zw = size,
- /// as fractions of it). A zero size says the frame has no mask; set per camera,
+ /// Gives light @p slot a channel of the frame's shape mask. A slot nobody names
+ /// keeps -1, which is a light with no shape of its own — it lights a full circle.
+ void setLightShape2DChannel(u32 slot, u32 channel) {
+ if (slot >= count_ || channel >= MAX_SHAPE_2D_LIGHTS) return;
+ data_.lights[slot].falloff.w = static_cast<f32>(channel);
+ dirty_ = true;
+ }
+
+ /// Where the camera about to draw sits inside the masks (xy = low corner, zw = size,
+ /// as fractions of one). A zero size says the frame has none; set per camera,
/// because two cameras read two different parts of one screen-space target.
- void setShadow2DRect(const glm::vec4& rect) {
- data_.shadow2DRect = rect;
+ void setMask2DRect(const glm::vec4& rect) {
+ data_.mask2DRect = rect;
dirty_ = true;
}
diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cpp
index 3d0f61ebc..1c64ef6c1 100644
--- a/src/esengine/resource/ShaderParser.cpp
+++ b/src/esengine/resource/ShaderParser.cpp
@@ -832,7 +832,7 @@ const char* kLitHeaderWGSL = R"(struct Light { posDir : vec4f, color : vec4f, sp
struct LightConstants {
u_ambient : vec4f,
u_lights : array<Light, 16>,
- u_shadow2DRect : vec4f,
+ u_mask2DRect : vec4f,
u_shadowMatrix : array<mat4x4f, 16>,
u_shadowTile : array<vec4f, 16>,
u_shadowParams : vec4f,
@@ -1004,25 +1004,39 @@ fn perturbNormal(N : vec3f, worldPos : vec3f, uv : vec2f, tangentNormal : vec3f)
let invmax = inverseSqrt(m);
return normalize(mat3x3f(T * invmax, B * invmax, N) * tangentNormal);
}
-// What the frame's 2D shadow mask says about this fragment, for the light holding
-// `channel` (negative = a light that casts none). Where a world point lands in the
-// mask is where this same camera puts it, measured on the plane the occluders are in.
-fn shadowFactor2D(channel : f32, worldPos : vec2f) -> f32 {
- if (channel < 0.0 || lc.u_shadow2DRect.z <= 0.0) { return 1.0; }
+// Where a world point lands in this camera's part of a screen-space mask: on the Z = 0
+// plane, which is the plane a 2D occluder hides things in, and through this same camera
+// so the landing agrees. Negative x = nothing to read.
+fn mask2DUv(worldPos : vec2f) -> vec2f {
let clip = frame.projection * vec4f(worldPos, 0.0, 1.0);
- if (clip.w <= 0.0) { return 1.0; }
+ if (clip.w <= 0.0) { return vec2f(-1.0, -1.0); }
// A negative height is the backend saying its texture rows run the other way.
let ndc = clip.xy / clip.w * 0.5 + 0.5;
- let v = select(ndc.y, 1.0 - ndc.y, lc.u_shadow2DRect.w < 0.0);
- let uv = lc.u_shadow2DRect.xy
- + vec2f(ndc.x * lc.u_shadow2DRect.z, v * abs(lc.u_shadow2DRect.w));
- let m = textureSampleLevel(t7, s7, uv, 0.0);
- var hidden = m.a;
- if (channel < 0.5) { hidden = m.r; }
- else if (channel < 1.5) { hidden = m.g; }
- else if (channel < 2.5) { hidden = m.b; }
+ let v = select(ndc.y, 1.0 - ndc.y, lc.u_mask2DRect.w < 0.0);
+ return lc.u_mask2DRect.xy
+ + vec2f(ndc.x * lc.u_mask2DRect.z, v * abs(lc.u_mask2DRect.w));
+}
+fn mask2DChannel(m : vec4f, channel : f32) -> f32 {
+ if (channel < 0.5) { return m.r; }
+ if (channel < 1.5) { return m.g; }
+ if (channel < 2.5) { return m.b; }
+ return m.a;
+}
+fn shadowFactor2D(channel : f32, worldPos : vec2f) -> f32 {
+ if (channel < 0.0 || lc.u_mask2DRect.z <= 0.0) { return 1.0; }
+ let uv = mask2DUv(worldPos);
+ if (uv.x < 0.0) { return 1.0; }
+ let hidden = mask2DChannel(textureSampleLevel(t7, s7, uv, 0.0), channel);
return 1.0 - min(hidden, 1.0);
}
+// What the light's own SHAPE covers here — its cookie, drawn into the shape mask at the
+// light's place. A light with no shape keeps the whole circle it always had.
+fn shapeFactor2D(channel : f32, worldPos : vec2f) -> f32 {
+ if (channel < 0.0 || lc.u_mask2DRect.z <= 0.0) { return 1.0; }
+ let uv = mask2DUv(worldPos);
+ if (uv.x < 0.0) { return 1.0; }
+ return min(mask2DChannel(textureSampleLevel(t6, s6, uv, 0.0), channel), 1.0);
+}
)"
// Split, not restructured: MSVC caps ONE string literal at 16380 bytes
// and this twin passed it. Adjacent literals concatenate with no cap, so
@@ -1175,6 +1189,9 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, meta
L = towardLight(toL, N);
atten *= spotCone(sp, sh, toL, dist);
}
+ if (col.a > 0.0 && atten > 0.0) {
+ atten *= shapeFactor2D(fo.w, worldPos.xy);
+ }
if (castShadow && col.a > 0.0 && atten > 0.0) {
atten *= mix(1.0, shadowFactor2D(lc.u_lights[i].shadowMap.w, worldPos.xy), fo.z);
}
@@ -1515,7 +1532,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
"layout(std140) uniform LightConstants {\n"
" highp vec4 u_ambient;\n"
" Light u_lights[16];\n"
- " highp vec4 u_shadow2DRect;\n" // xy = this camera's corner of the mask, zw its size
+ " highp vec4 u_mask2DRect;\n" // xy = this camera's corner of a mask, zw its size
" highp mat4 u_shadowMatrix[16];\n" // world -> each atlas tile's clip
" highp vec4 u_shadowTile[16];\n" // xy = origin, z = side, w = bias
" highp vec4 u_shadowParams;\n" // x = has map, y = one atlas texel
@@ -1532,10 +1549,11 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
"#ifdef ES_ENV_MAP\n"
"uniform highp sampler2D u_envMap;\n"
"#endif\n"
- // The 2D shadow mask, on the top slot of the batch stream's eight. Declared
- // for every Lit shader: a sprite receives 2D shadows, and a mesh standing in
- // the same scene receives the same ones.
+ // The 2D shadow mask, on the top slot of the batch stream's eight, and the
+ // light-shape mask one below it. Declared for every Lit shader: a sprite
+ // receives 2D shadows, and a mesh standing in the same scene receives them.
"uniform highp sampler2D u_shadow2D;\n"
+ "uniform highp sampler2D u_lightShape2D;\n"
// 24 bits of depth across RGB — an 8-bit target is what both backends have
// in common, and a metre of world depth does not survive 8 of them. The
// pair lives together: two files would be two chances to disagree.
@@ -1708,31 +1726,41 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
" highp float invmax = inversesqrt(m);\n"
" return normalize(mat3(T * invmax, B * invmax, N) * tangentNormal);\n"
"}\n"
- // What the frame's 2D shadow mask says about this fragment, for the light
- // holding `channel` (negative = a light that casts none). The rect is this
- // camera's own part of the mask, which is what serves a second camera.
- "highp float shadowFactor2D(in highp float channel, in highp vec2 worldPos) {\n"
- " if (channel < 0.0 || u_shadow2DRect.z <= 0.0) return 1.0;\n"
- // Measured on the Z = 0 plane, which is the plane a 2D occluder hides
- // things in — and drawn through this same camera, so the landing agrees.
+ // Where a world point lands in this camera's part of a screen-space mask.
+ // Measured on the Z = 0 plane, which is the plane a 2D occluder hides things
+ // in, and drawn through this same camera so the landing agrees.
+ "highp vec2 mask2DUv(in highp vec2 worldPos) {\n"
" highp vec4 clip = u_projection * vec4(worldPos, 0.0, 1.0);\n"
- " if (clip.w <= 0.0) return 1.0;\n"
+ " if (clip.w <= 0.0) return vec2(-1.0);\n"
// A negative height is the backend saying its texture rows run the other way.
" highp vec2 ndc = clip.xy / clip.w * 0.5 + 0.5;\n"
- " highp float v = u_shadow2DRect.w < 0.0 ? 1.0 - ndc.y : ndc.y;\n"
- " highp vec2 uv = u_shadow2DRect.xy\n"
- " + vec2(ndc.x * u_shadow2DRect.z, v * abs(u_shadow2DRect.w));\n"
- // An explicit level, not an implicit one: this is read inside the light loop,
- // where a twin's WGSL forbids a sampled derivative — and the mask has no
- // mip chain for one to choose from anyway.
- " highp vec4 m = textureLod(u_shadow2D, uv, 0.0);\n"
- // The mask holds how much of this light is hidden, summed over the samples
- // that make a source soft — clamped, because two walls over one pixel add
- // past one and a light cannot be hidden more than entirely.
- " highp float hidden = (channel < 0.5) ? m.r\n"
- " : (channel < 1.5) ? m.g : (channel < 2.5) ? m.b : m.a;\n"
+ " highp float v = u_mask2DRect.w < 0.0 ? 1.0 - ndc.y : ndc.y;\n"
+ " return u_mask2DRect.xy + vec2(ndc.x * u_mask2DRect.z, v * abs(u_mask2DRect.w));\n"
+ "}\n"
+ "highp float mask2DChannel(in highp vec4 m, in highp float channel) {\n"
+ " return (channel < 0.5) ? m.r : (channel < 1.5) ? m.g\n"
+ " : (channel < 2.5) ? m.b : m.a;\n"
+ "}\n"
+ // What the shadow mask says here, for the light holding `channel` (negative
+ // = one that casts none). An explicit LOD because this is read inside the
+ // light loop, where a twin's WGSL forbids a sampled derivative.
+ "highp float shadowFactor2D(in highp float channel, in highp vec2 worldPos) {\n"
+ " if (channel < 0.0 || u_mask2DRect.z <= 0.0) return 1.0;\n"
+ " highp vec2 uv = mask2DUv(worldPos);\n"
+ " if (uv.x < 0.0) return 1.0;\n"
+ // Clamped, because two walls over one pixel add past one and a light cannot
+ // be hidden more than entirely.
+ " highp float hidden = mask2DChannel(textureLod(u_shadow2D, uv, 0.0), channel);\n"
" return 1.0 - min(hidden, 1.0);\n"
"}\n"
+ // What the light's own SHAPE covers here — its cookie, drawn into the shape
+ // mask at the light's place. A light with no shape keeps its whole circle.
+ "highp float shapeFactor2D(in highp float channel, in highp vec2 worldPos) {\n"
+ " if (channel < 0.0 || u_mask2DRect.z <= 0.0) return 1.0;\n"
+ " highp vec2 uv = mask2DUv(worldPos);\n"
+ " if (uv.x < 0.0) return 1.0;\n"
+ " return min(mask2DChannel(textureLod(u_lightShape2D, uv, 0.0), channel), 1.0);\n"
+ "}\n"
// The microfacet terms: GGX distribution, Smith geometry (the direct-light k,
// off perceptual roughness), Schlick fresnel. Guarded denominators, because a
// specular weight of zero must multiply a finite number to reach exactly zero.
@@ -1916,6 +1944,9 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
" }\n"
// Only pay for the mask read when the light actually reaches this fragment (skips
// the zeroed/inactive slots and unlit fragments).
+ " if (col.a > 0.0 && atten > 0.0) {\n"
+ " atten *= shapeFactor2D(fo.w, worldPos.xy);\n"
+ " }\n"
" if (castShadow && col.a > 0.0 && atten > 0.0) {\n"
" atten *= mix(1.0, shadowFactor2D(u_lights[i].shadowMap.w, worldPos.xy), fo.z);\n"
" }\n"
diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.h
index c76158ad5..637c125eb 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 0x552e2aec43cbd107ULL
+#define ES_CONF_EXPECTED_CONTRACT_HASH 0xcfe06bb8128f6f6bULL
/* And which BUILD the artifact beside this one is. */
#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULL
diff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.c
index 38bcdb0aa..e4ae544d2 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 belongs
to the MACHINE, so it mixes in here rather than in the compiler and a
32-bit artifact cannot load into a 64-bit host. */
-#define ES_ABI_ENGINE_DIGEST 0x552e2aec43cbd107ULL
+#define ES_ABI_ENGINE_DIGEST 0xcfe06bb8128f6f6bULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/renderer/test_shader_device.cpp b/tests/renderer/test_shader_device.cpp
index 415db602b..abaec4d0a 100644
--- a/tests/renderer/test_shader_device.cpp
+++ b/tests/renderer/test_shader_device.cpp
@@ -32,14 +32,14 @@ int main() {
// compile() pins the engine-injected samplers to their units, so the counts
// the rest of this block asserts start from what that seeding left behind.
- // Three of them: the shadow map, the environment's reflection, the 2D mask.
- CHECK(d.setUniform1iCalls == 3
- && d.lastUniform1iVal == static_cast<i32>(SHADOW_2D_TEXTURE_UNIT),
+ // Four: the shadow map, the environment's reflection, and the two 2D masks.
+ CHECK(d.setUniform1iCalls == 4
+ && d.lastUniform1iVal == static_cast<i32>(SHAPE_2D_TEXTURE_UNIT),
"compile pins the injected samplers to their texture units");
CHECK(d.useProgramCalls == 2, "seeding them binds and unbinds the program once");
shader->setUniform("u_tex", 3);
- CHECK(d.setUniform1iCalls == 4, "setUniform(name,int) routes through device.setUniform1i");
+ CHECK(d.setUniform1iCalls == 5, "setUniform(name,int) routes through device.setUniform1i");
CHECK(d.lastUniform1iVal == 3, "uniform value forwarded");
shader->setUniform("u_color", glm::vec4(1, 0, 0, 1));
diff --git a/tools/check-gizmo-coverage.mjs b/tools/check-gizmo-coverage.mjs
index 5993f6676..353bfe0e1 100644
--- a/tools/check-gizmo-coverage.mjs
+++ b/tools/check-gizmo-coverage.mjs
@@ -76,6 +76,7 @@ const DISPOSITION = {
'Camera.orthoSize': 'extent',
'Light.radius': 'extent',
'Light.innerRadius': 'extent',
+ 'Light.cookieSize': 'extent',
'MeleeAttack.radius': 'extent',
'NavAgent.radius': 'extent',
'NavAgent.arriveRadius': 'extent',
diff --git a/tools/check-wgsl-twin.mjs b/tools/check-wgsl-twin.mjs
index 5b475b638..ebf487411 100644
--- a/tools/check-wgsl-twin.mjs
+++ b/tools/check-wgsl-twin.mjs
@@ -121,7 +121,10 @@ function embedded(file, text) {
}
const sources = [];
-for (const file of listed(['ls-files', '*.esshader'])) {
+// --others: a shader that is NEW is the one most likely to be missing a binding, and
+// a listing of only tracked files answers "clean" about the file nobody has read.
+for (const file of listed(['ls-files', '--cached', '--others', '--exclude-standard',
+ '*.esshader'])) {
sources.push({ label: file, text: readFileSync(path.join(ROOT, file), 'utf8') });
}
for (const file of listed(['grep', '-l', '-F', '#pragma fragment wgsl', '--', '*.ts'])) {
diff --git a/tools/gen-shader-twins.mjs b/tools/gen-shader-twins.mjs
index 49a5b89c5..b09fd1fdb 100644
--- a/tools/gen-shader-twins.mjs
+++ b/tools/gen-shader-twins.mjs
@@ -65,6 +65,7 @@ const ENGINE_SAMPLERS = [
{ name: 'u_shadowMap', unit: 2 },
{ name: 'u_envMap', unit: 3 },
{ name: 'u_shadow2D', unit: 7 },
+ { name: 'u_lightShape2D', unit: 6 },
];
// Group-1 unit map — mirrors WebGPUMappings textureBindingForUnit/samplerBindingForUnit.
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 3bbab00c8..3045d909d 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -392,6 +392,14 @@ 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}]" } },
+ // A light with a SHAPE of its own: its cookie is opaque in the image's top-left
+ // quadrant and nowhere else, so three of these four probes have to stay black.
+ // A cookie read any way up would light a different quadrant, not a dimmer one.
+ { id: "light-cookie", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/light-cookie.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/light-cookie.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.3333,\"y\":0.3333,\"rgb\":[0,155,0],\"tol\":35},{\"x\":0.6667,\"y\":0.3333,\"rgb\":[0,0,0],\"tol\":25},{\"x\":0.3333,\"y\":0.6667,\"rgb\":[0,0,0],\"tol\":25},{\"x\":0.6667,\"y\":0.6667,\"rgb\":[0,0,0],\"tol\":25}]" } },
+ // The same cookie with no size of its own, which covers the light's REACH: the lit
+ // quadrant runs 400 units out instead of 200. The first probe is the one that
+ // says so — it is outside the authored size and inside this one.
+ { id: "light-cookie-reach", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/light-cookie.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/light-cookie.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":2,\"component\":\"Light\",\"key\":\"cookieSize\",\"value\":[0,0]}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.1,\"y\":0.3333,\"rgb\":[0,76,0],\"tol\":30},{\"x\":0.4167,\"y\":0.4167,\"rgb\":[0,207,0],\"tol\":35},{\"x\":0.5833,\"y\":0.4167,\"rgb\":[0,0,0],\"tol\":25},{\"x\":0.1,\"y\":0.6667,\"rgb\":[0,0,0],\"tol\":25}]" } },
// 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.