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 thing that moves takes the light of the room it is in

esengined19d2f44a641
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2bd1005f2..d62832ca5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -29,7 +29,7 @@ env:
test_registry_ondestroy test_view_api_matrix
test_shader_device test_draw_params test_texture_fb test_buffer_device
test_compressed_format test_batch_builder test_boundary_span test_webgpu_device
- test_clip_depth test_sort_key test_sprite_mask_range test_shadow_atlas test_particle_shapes test_lod_selection test_hdr_format
+ test_clip_depth test_sort_key test_sprite_mask_range test_shadow_atlas test_particle_shapes test_lod_selection test_hdr_format test_probe_store
test_text_edit test_render_graph test_device_loss test_physics_interpolation
test_bitmap_font test_texture_cache test_mesh_recovery test_aot_host test_aot_conformance
test_touch_stream
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca6a43816..3338d275a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,49 @@ published separately; it ships inside the editor.
### Added
+- **Light probes: what lights a thing a bake cannot hold still.** A bake answers
+ "what light reaches this surface" for geometry that never moves, and nothing
+ answered it for a character — a figure walking out of a lit room kept the one
+ flat environment the whole scene shares. A `LightProbeVolume` is a box of that
+ answer solved on a grid: a draw standing inside takes its indirect light from
+ the eight probes around it, read trilinearly, instead of from the frame's
+ environment.
+
+ The grid is the same nine spherical-harmonic coefficients an `.esenv` already
+ carries, evaluated by the same expression — an environment is this field held
+ constant, and a volume is it sampled. That is why the two are one function and
+ not two: they differ in where the nine came from, not in what they mean.
+
+ Per DRAW and not per object, which is the opposite of a lightmap's rectangle
+ and for the reason that decides it: a rectangle belongs to an object, because
+ one mesh placed twice occupies two patches of one atlas, while irradiance is a
+ function of WHERE — and a batch of instances has only one position to speak of.
+ A draw standing in a volume is therefore its own draw.
+
+ A surface that reads its own atlas does not also read a volume: the bake
+ already holds every bounce that reached those texels, and taking both counts
+ them twice. Skinned meshes never take a bake, so they always take this.
+
+ The reading side goes first on purpose, as the lightmap's did: a grid written
+ by hand can falsify it, where a solver built first would have nothing to say
+ whether it solved the right thing. Baking one is the next step.
+
+### Fixed
+
+- **A per-draw block reaches the draw that wrote it.** The pose of a skinned
+ draw, the shapes of a morphed one and (now) the indirect light of a probe-lit
+ one shared one buffer each, rewritten immediately before the draw that reads
+ it. That is correct where an upload takes effect at the call, and wrong on a
+ backend that QUEUES them: on WebGPU the writes land together when the pass is
+ submitted, so every draw in that pass read whatever the LAST of them wrote —
+ one pose on every character in the room, one set of shapes on every face.
+
+ Every skin and morph gate in the suite drew a single object, so none of them
+ could see it. Each draw now takes a buffer of its own from a frame-scoped pool,
+ and a draw with nothing to say binds a zeroed block that is never written —
+ "none" as an object rather than an erasure someone has to remember to perform.
+ Two morphed draws in one frame, blended different amounts, is now a gate.
+
- **A room in the corpus is actually lit.** `physics-3d` — twenty-two boxes and
two lamps — now ships with its lighting baked: an atlas beside the scene, and a
`MeshLightmap` on every object saying where in it to read. It is the first
diff --git a/desktop b/desktop
index f0c0a1b16..a4027c7b0 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit f0c0a1b16a8d0da311a570368243bb5300a361db
+Subproject commit a4027c7b0ec4f30eb5bb6b446f04af831db35def
diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.json
index f1c5f4297..1fb2df77e 100644
--- a/docs/astro/src/data/apiStability.generated.json
+++ b/docs/astro/src/data/apiStability.generated.json
@@ -3,10 +3,10 @@
"counts": {
"public": 114,
"beta": 101,
- "experimental": 1890,
+ "experimental": 1892,
"deprecated": 3
},
- "total": 2105,
+ "total": 2107,
"subsystems": [
{
"id": "ecs",
diff --git a/docs/astro/src/data/componentDocs.ts b/docs/astro/src/data/componentDocs.ts
index bfb418f0e..ce3694b17 100644
--- a/docs/astro/src/data/componentDocs.ts
+++ b/docs/astro/src/data/componentDocs.ts
@@ -76,6 +76,7 @@ export const COMPONENT_DOCS: Record<string, ComponentDoc> = {
MeshSkin: { category: 'graphics', summary: 'The joint entities that deform a MeshRenderer — an imported skin, in the order its bind matrices are in.', doc: 'assets/models', anchor: 'skinning', anchorZh: '蒙皮' },
MeshMorph: { category: 'graphics', summary: 'How far a MeshRenderer is blended towards each of the shapes its mesh carries — one weight per morph target.', doc: 'assets/models', anchor: 'morph-targets', anchorZh: 'morph-target' },
MeshLightmap: { category: 'graphics', summary: 'Where a MeshRenderer\'s baked light comes from — the atlas, and the rectangle of it this object occupies.', doc: 'graphics/lighting', anchor: 'baked-light', anchorZh: '烘焙光照' },
+ LightProbeVolume: { category: 'graphics', summary: 'A box of baked irradiance on a grid — what lights the things a lightmap cannot hold still, characters included.', doc: 'graphics/lighting', anchor: 'baked-light', anchorZh: '烘焙光照' },
StreamedWorld: { category: 'world', summary: 'Declares the scene a streamed world and how big the cook cuts its cells.', doc: 'world/streaming', anchor: 'declaring-a-streamed-world', anchorZh: '声明一个流送世界' },
WorldPersistent: { category: 'world', summary: 'Keeps an entity\'s whole subtree out of the partition — it belongs to the persistent world.', doc: 'world/streaming', anchor: 'declaring-a-streamed-world', anchorZh: '声明一个流送世界' },
WorldStreamingSource: { category: 'world', summary: 'Asks for the places near it to exist; several sources are unioned.', doc: 'world/streaming', anchor: 'asking-for-places-streaming-sources', anchorZh: '请求地方存在流送源' },
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index f2210ef90..9177757c5 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -2049,6 +2049,30 @@
"shadowDistance"
]
},
+ {
+ "name": "LightProbeVolume",
+ "source": "cpp",
+ "fields": [
+ {
+ "key": "probes",
+ "type": "Asset<probeVolume>",
+ "default": "none",
+ "doc": "Baked probe grid (.esprobes) filling this box."
+ },
+ {
+ "key": "halfExtents",
+ "type": "Vec3",
+ "default": "(100, 100, 100)",
+ "doc": "Half the box this volume covers, from the entity's position.",
+ "range": "≥ 0"
+ },
+ {
+ "key": "enabled",
+ "type": "boolean",
+ "default": "true"
+ }
+ ]
+ },
{
"name": "Marker",
"source": "ts",
diff --git a/fixtures/scenes/mat-builtin-lit/lit.esshader b/fixtures/scenes/mat-builtin-lit/lit.esshader
index cb423b9cf..bd553d036 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: 1e59361273df4851
+// assembled-hash: 930c2164bd1ef964
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: 1e59361273df4851
+// assembled-hash: 930c2164bd1ef964
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -136,6 +136,10 @@ struct LightConstants {
u_envTint: vec4<f32>,
}
+struct ProbeConstants {
+ u_probeIrradiance: array<vec4<f32>, 9>,
+}
+
struct MaterialConstants {
u_tint: vec4<f32>,
}
@@ -157,6 +161,8 @@ var u_shadow2D_ess: sampler;
var u_lightShape2D_est: texture_2d<f32>;
@group(1) @binding(14)
var u_lightShape2D_ess: sampler;
+@group(0) @binding(7)
+var<uniform> unnamed_2: ProbeConstants;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -164,7 +170,7 @@ var es_bt0_ess: sampler;
var<private> v_texCoord_1: vec2<f32>;
var<private> v_color_1: vec4<f32>;
@group(0) @binding(1)
-var<uniform> unnamed_2: MaterialConstants;
+var<uniform> unnamed_3: MaterialConstants;
@group(1) @binding(16)
var u_normalMap_est: texture_2d<f32>;
@group(1) @binding(24)
@@ -172,7 +178,7 @@ var u_normalMap_ess: sampler;
var<private> fragColor: vec4<f32>;
var<private> v_worldPos_1: vec2<f32>;
@group(0) @binding(3)
-var<uniform> unnamed_3: TimeConstants;
+var<uniform> unnamed_4: TimeConstants;
@group(1) @binding(1)
var es_bt1_est: texture_2d<f32>;
@group(1) @binding(9)
@@ -216,94 +222,94 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e99 = unnamed_1.u_envParams[0u];
- if (_e99 < 0.5f) {
- let _e102 = unnamed_1.u_ambient;
- return _e102.xyz;
+ let _e100 = unnamed_1.u_envParams[0u];
+ if (_e100 < 0.5f) {
+ let _e103 = unnamed_1.u_ambient;
+ return _e103.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));
+ let _e105 = (*roughness);
+ let _e109 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e105, 0f, 1f) * _e109);
+ let _e111 = lod;
+ lo = floor(_e111);
+ let _e113 = (*R_1);
+ param = _e113;
+ let _e114 = lo;
+ param_1 = _e114;
+ let _e115 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e115;
+ let _e116 = lo;
+ let _e120 = unnamed_1.u_envParams[2u];
+ let _e122 = (*R_1);
+ param_2 = _e122;
+ param_3 = min((_e116 + 1f), _e120);
+ let _e123 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e123;
+ let _e125 = unnamed_1.u_ambient;
+ let _e127 = a;
+ let _e128 = b;
+ let _e129 = lod;
+ let _e130 = lo;
+ let _e135 = unnamed_1.u_envTint;
+ return (_e125.xyz + (mix(_e127, _e128, vec3((_e129 - _e130))) * _e135.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 _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);
+ let _e92 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e92) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e96 = r[0u];
+ let _e98 = r[0u];
+ let _e100 = (*NdotV);
+ let _e105 = r[0u];
+ let _e108 = r[1u];
+ a_1 = ((min((_e96 * _e98), exp2((-9.28f * _e100))) * _e105) + _e108);
+ let _e110 = a_1;
+ let _e112 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e110) + _e112.zw);
}
fn fresnelSchlick_u0028_f1_u003b_vf3_u003b(VdotH: ptr<function, f32>, F0_: ptr<function, vec3<f32>>) -> vec3<f32> {
- let _e89 = (*F0_);
let _e90 = (*F0_);
- let _e92 = (*VdotH);
- return (_e89 + ((vec3<f32>(1f, 1f, 1f) - _e90) * pow((1f - _e92), 5f)));
+ let _e91 = (*F0_);
+ let _e93 = (*VdotH);
+ return (_e90 + ((vec3<f32>(1f, 1f, 1f) - _e91) * pow((1f - _e93), 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 _e91 = (*roughness_2);
- let _e93 = (*roughness_2);
- k = (((_e91 + 1f) * (_e93 + 1f)) * 0.125f);
- let _e97 = (*NdotV_1);
+ let _e92 = (*roughness_2);
+ let _e94 = (*roughness_2);
+ k = (((_e92 + 1f) * (_e94 + 1f)) * 0.125f);
let _e98 = (*NdotV_1);
- let _e99 = k;
- let _e102 = k;
- let _e105 = (*NdotL);
+ let _e99 = (*NdotV_1);
+ let _e100 = k;
+ let _e103 = k;
let _e106 = (*NdotL);
- let _e107 = k;
- let _e110 = k;
- return ((_e97 / ((_e98 * (1f - _e99)) + _e102)) * (_e105 / ((_e106 * (1f - _e107)) + _e110)));
+ let _e107 = (*NdotL);
+ let _e108 = k;
+ let _e111 = k;
+ return ((_e98 / ((_e99 * (1f - _e100)) + _e103)) * (_e106 / ((_e107 * (1f - _e108)) + _e111)));
}
fn distributionGGX_u0028_f1_u003b_f1_u003b(NdotH: ptr<function, f32>, a_2: ptr<function, f32>) -> f32 {
var a2_: f32;
var d: f32;
- let _e91 = (*a_2);
let _e92 = (*a_2);
- a2_ = (_e91 * _e92);
- let _e94 = (*NdotH);
+ let _e93 = (*a_2);
+ a2_ = (_e92 * _e93);
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));
+ let _e96 = (*NdotH);
+ let _e98 = a2_;
+ d = (((_e95 * _e96) * (_e98 - 1f)) + 1f);
+ let _e102 = a2_;
+ let _e103 = d;
+ let _e105 = d;
+ return (_e102 / max(((3.1415927f * _e103) * _e105), 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 {
@@ -315,32 +321,32 @@ fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel:
var local_1: f32;
var local_2: f32;
- let _e92 = (*channel);
- if (_e92 < 0.5f) {
- let _e95 = (*m)[0u];
- local = _e95;
+ let _e93 = (*channel);
+ if (_e93 < 0.5f) {
+ let _e96 = (*m)[0u];
+ local = _e96;
} else {
- let _e96 = (*channel);
- if (_e96 < 1.5f) {
- let _e99 = (*m)[1u];
- local_1 = _e99;
+ let _e97 = (*channel);
+ if (_e97 < 1.5f) {
+ let _e100 = (*m)[1u];
+ local_1 = _e100;
} else {
- let _e100 = (*channel);
- if (_e100 < 2.5f) {
- let _e103 = (*m)[2u];
- local_2 = _e103;
+ let _e101 = (*channel);
+ if (_e101 < 2.5f) {
+ let _e104 = (*m)[2u];
+ local_2 = _e104;
} else {
- let _e105 = (*m)[3u];
- local_2 = _e105;
+ let _e106 = (*m)[3u];
+ local_2 = _e106;
}
- let _e106 = local_2;
- local_1 = _e106;
+ let _e107 = local_2;
+ local_1 = _e107;
}
- let _e107 = local_1;
- local = _e107;
+ let _e108 = local_1;
+ local = _e108;
}
- let _e108 = local;
- return _e108;
+ let _e109 = local;
+ return _e109;
}
fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
@@ -349,32 +355,32 @@ fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var v: 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) {
+ let _e94 = unnamed.u_projection;
+ let _e95 = (*worldPos_1);
+ clip = (_e94 * vec4<f32>(_e95.x, _e95.y, 0f, 1f));
+ let _e101 = clip[3u];
+ if (_e101 <= 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);
+ let _e103 = clip;
+ let _e106 = clip[3u];
+ ndc = (((_e103.xy / vec2(_e106)) * 0.5f) + vec2(0.5f));
+ let _e114 = unnamed_1.u_mask2DRect[3u];
+ if (_e114 < 0f) {
+ let _e117 = ndc[1u];
+ local_3 = (1f - _e117);
} else {
- let _e119 = ndc[1u];
- local_3 = _e119;
+ let _e120 = ndc[1u];
+ local_3 = _e120;
}
- 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))));
+ let _e121 = local_3;
+ v = _e121;
+ let _e123 = unnamed_1.u_mask2DRect;
+ let _e126 = ndc[0u];
+ let _e129 = unnamed_1.u_mask2DRect[2u];
+ let _e131 = v;
+ let _e134 = unnamed_1.u_mask2DRect[3u];
+ return (_e123.xy + vec2<f32>((_e126 * _e129), (_e131 * abs(_e134))));
}
fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
@@ -383,36 +389,36 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldP
var hidden: f32;
var param_5: vec4<f32>;
var param_6: f32;
- var phi_307_: bool;
+ var phi_317_: 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 _e95 = (*channel_1);
+ let _e96 = (_e95 < 0f);
+ phi_317_ = _e96;
+ if !(_e96) {
+ let _e100 = unnamed_1.u_mask2DRect[2u];
+ phi_317_ = (_e100 <= 0f);
}
- let _e102 = phi_307_;
- if _e102 {
+ let _e103 = phi_317_;
+ if _e103 {
return 1f;
}
- let _e103 = (*worldPos_2);
- param_4 = _e103;
- let _e104 = mask2DUv_u0028_vf2_u003b((&param_4));
- uv = _e104;
- let _e106 = uv[0u];
- if (_e106 < 0f) {
+ let _e104 = (*worldPos_2);
+ param_4 = _e104;
+ let _e105 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e105;
+ let _e107 = uv[0u];
+ if (_e107 < 0f) {
return 1f;
}
- 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));
+ let _e109 = uv;
+ let _e110 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e109, 0f);
+ param_5 = _e110;
+ let _e111 = (*channel_1);
+ param_6 = _e111;
+ let _e112 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e112;
+ let _e113 = hidden;
+ return (1f - min(_e113, 1f));
}
fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
@@ -420,34 +426,34 @@ fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPo
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);
+ var phi_356_: bool;
+
+ let _e94 = (*channel_2);
+ let _e95 = (_e94 < 0f);
+ phi_356_ = _e95;
+ if !(_e95) {
+ let _e99 = unnamed_1.u_mask2DRect[2u];
+ phi_356_ = (_e99 <= 0f);
}
- let _e101 = phi_346_;
- if _e101 {
+ let _e102 = phi_356_;
+ if _e102 {
return 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) {
+ let _e103 = (*worldPos_3);
+ param_7 = _e103;
+ let _e104 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e104;
+ let _e106 = uv_1[0u];
+ if (_e106 < 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);
+ let _e108 = uv_1;
+ let _e109 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e108, 0f);
+ param_8 = _e109;
+ let _e110 = (*channel_2);
+ param_9 = _e110;
+ let _e111 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e111, 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 {
@@ -456,74 +462,102 @@ 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 _e95 = (*sp);
- let _e97 = (*sp);
- if (dot(_e95.xy, _e97.xy) > 0.00000001f) {
- let _e101 = (*sp);
- local_4 = normalize(_e101.xy);
+ let _e96 = (*sp);
+ let _e98 = (*sp);
+ if (dot(_e96.xy, _e98.xy) > 0.00000001f) {
+ let _e102 = (*sp);
+ local_4 = normalize(_e102.xy);
} else {
local_4 = vec2<f32>(0f, -1f);
}
- 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));
+ let _e105 = local_4;
+ axis = _e105;
+ let _e106 = (*dist);
+ if (_e106 > 0.0001f) {
+ let _e108 = (*toLight);
+ let _e111 = (*dist);
+ local_5 = (-(_e108.xy) / vec2(_e111));
} else {
- let _e113 = axis;
- local_5 = _e113;
+ let _e114 = axis;
+ local_5 = _e114;
}
- 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));
+ let _e115 = local_5;
+ toFrag = _e115;
+ let _e117 = (*sp)[3u];
+ let _e119 = (*sp)[2u];
+ let _e120 = axis;
+ let _e121 = toFrag;
+ return smoothstep(_e117, _e119, dot(_e120, _e121));
}
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 _e90 = (*toLight_1);
let _e91 = (*toLight_1);
- if (dot(_e90, _e91) > 0.00000001f) {
- let _e94 = (*toLight_1);
- local_6 = normalize(_e94);
+ let _e92 = (*toLight_1);
+ if (dot(_e91, _e92) > 0.00000001f) {
+ let _e95 = (*toLight_1);
+ local_6 = normalize(_e95);
} else {
- let _e96 = (*N_1);
- local_6 = _e96;
+ let _e97 = (*N_1);
+ local_6 = _e97;
}
- let _e97 = local_6;
- return _e97;
+ let _e98 = local_6;
+ return _e98;
}
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 _e91 = (*reach);
- 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));
+ let _e92 = (*reach);
+ let _e93 = (*dist_1);
+ let _e95 = (*reach);
+ let _e97 = (*fo)[0u];
+ ramp = clamp(((_e92 - _e93) / max((_e95 - _e97), 0.0001f)), 0f, 1f);
+ let _e102 = ramp;
+ let _e104 = (*fo)[1u];
+ return pow(_e102, max(_e104, 0.001f));
}
fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {
- let _e88 = (*toLight_2);
- return length(_e88.xy);
+ let _e89 = (*toLight_2);
+ return length(_e89.xy);
}
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));
+ let _e91 = (*pd);
+ let _e93 = (*worldPos_4);
+ let _e95 = (_e91.xy - _e93.xy);
+ let _e97 = (*pd)[3u];
+ return vec3<f32>(_e95.x, _e95.y, max(_e97, 1f));
+}
+
+fn shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b(sh_2: ptr<function, array<vec4<f32>, 9>>, N_2: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e91 = (*sh_2)[0i];
+ let _e95 = (*sh_2)[1i];
+ let _e98 = (*N_2)[1u];
+ let _e103 = (*sh_2)[2i];
+ let _e106 = (*N_2)[2u];
+ let _e111 = (*sh_2)[3i];
+ let _e114 = (*N_2)[0u];
+ let _e119 = (*sh_2)[4i];
+ let _e122 = (*N_2)[0u];
+ let _e125 = (*N_2)[1u];
+ let _e130 = (*sh_2)[5i];
+ let _e133 = (*N_2)[1u];
+ let _e136 = (*N_2)[2u];
+ let _e141 = (*sh_2)[6i];
+ let _e144 = (*N_2)[2u];
+ let _e147 = (*N_2)[2u];
+ let _e154 = (*sh_2)[7i];
+ let _e157 = (*N_2)[0u];
+ let _e160 = (*N_2)[2u];
+ let _e165 = (*sh_2)[8i];
+ let _e168 = (*N_2)[0u];
+ let _e170 = (*N_2)[0u];
+ let _e173 = (*N_2)[1u];
+ let _e175 = (*N_2)[1u];
+ return (((((((((_e91.xyz * 0.282095f) + (_e95.xyz * (0.488603f * _e98))) + (_e103.xyz * (0.488603f * _e106))) + (_e111.xyz * (0.488603f * _e114))) + (_e119.xyz * ((1.092548f * _e122) * _e125))) + (_e130.xyz * ((1.092548f * _e133) * _e136))) + (_e141.xyz * (0.315392f * (((3f * _e144) * _e147) - 1f)))) + (_e154.xyz * ((1.092548f * _e157) * _e160))) + (_e165.xyz * (0.546274f * ((_e168 * _e170) - (_e173 * _e175)))));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -531,507 +565,523 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- 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)));
+ let _e94 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e94);
+ let _e96 = a_3;
+ s = sin(_e96);
+ let _e98 = a_3;
+ c = cos(_e98);
+ let _e100 = c;
+ let _e102 = (*d_1)[0u];
+ let _e104 = s;
+ let _e106 = (*d_1)[2u];
+ let _e110 = (*d_1)[1u];
+ let _e111 = s;
+ let _e114 = (*d_1)[0u];
+ let _e116 = c;
+ let _e118 = (*d_1)[2u];
+ return vec3<f32>(((_e100 * _e102) + (_e104 * _e106)), _e110, ((-(_e111) * _e114) + (_e116 * _e118)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
- var N_2: vec3<f32>;
+ var sh_3: vec3<f32>;
var param_10: vec3<f32>;
- var sh_2: vec3<f32>;
-
- 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 _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));
+ var param_11: array<vec4<f32>, 9>;
+ var param_12: vec3<f32>;
+
+ let _e93 = (*Nw);
+ param_10 = _e93;
+ let _e94 = envDirection_u0028_vf3_u003b((&param_10));
+ let _e96 = unnamed_1.u_envIrradiance;
+ param_11[0i] = _e96[0];
+ param_11[1i] = _e96[1];
+ param_11[2i] = _e96[2];
+ param_11[3i] = _e96[3];
+ param_11[4i] = _e96[4];
+ param_11[5i] = _e96[5];
+ param_11[6i] = _e96[6];
+ param_11[7i] = _e96[7];
+ param_11[8i] = _e96[8];
+ param_12 = _e94;
+ let _e115 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_11), (&param_12));
+ sh_3 = _e115;
+ let _e117 = unnamed_1.u_ambient;
+ let _e119 = sh_3;
+ let _e122 = unnamed_1.u_envTint;
+ return (_e117.xyz + (max(_e119, vec3<f32>(0f, 0f, 0f)) * _e122.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> {
+fn indirectIrradiance_u0028_vf3_u003b(N_3: ptr<function, vec3<f32>>) -> vec3<f32> {
+ var param_13: array<vec4<f32>, 9>;
+ var param_14: vec3<f32>;
+ var param_15: vec3<f32>;
+
+ let _e95 = unnamed_2.u_probeIrradiance[0i][3u];
+ if (_e95 > 0.5f) {
+ let _e98 = unnamed_2.u_probeIrradiance;
+ param_13[0i] = _e98[0];
+ param_13[1i] = _e98[1];
+ param_13[2i] = _e98[2];
+ param_13[3i] = _e98[3];
+ param_13[4i] = _e98[4];
+ param_13[5i] = _e98[5];
+ param_13[6i] = _e98[6];
+ param_13[7i] = _e98[7];
+ param_13[8i] = _e98[8];
+ let _e117 = (*N_3);
+ param_14 = _e117;
+ let _e118 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_13), (&param_14));
+ return max(_e118, vec3<f32>(0f, 0f, 0f));
+ }
+ let _e120 = (*N_3);
+ param_15 = _e120;
+ let _e121 = envIrradiance_u0028_vf3_u003b((&param_15));
+ return _e121;
+}
+
+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_4: 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_11: vec3<f32>;
+ var param_16: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
var col: vec4<f32>;
- var sh_3: vec4<f32>;
+ var sh_4: vec4<f32>;
var fo_1: vec4<f32>;
var target_: vec2<f32>;
var castShadow: bool;
var toL: vec3<f32>;
- var param_12: vec4<f32>;
- var param_13: vec4<f32>;
- var param_14: vec3<f32>;
- var dist_2: f32;
- var param_15: vec3<f32>;
- var atten: f32;
- var param_16: f32;
- var param_17: f32;
+ var param_17: vec4<f32>;
var param_18: vec4<f32>;
- var L_1: vec3<f32>;
var param_19: vec3<f32>;
+ var dist_2: f32;
var param_20: vec3<f32>;
+ var atten: f32;
+ var param_21: f32;
+ var param_22: f32;
+ var param_23: vec4<f32>;
+ var L_1: vec3<f32>;
+ var param_24: vec3<f32>;
+ var param_25: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_21: vec4<f32>;
- var param_22: vec4<f32>;
- var param_23: vec3<f32>;
- var dist_3: f32;
- var param_24: vec3<f32>;
- var param_25: f32;
- var param_26: f32;
+ var param_26: vec4<f32>;
var param_27: vec4<f32>;
var param_28: vec3<f32>;
+ var dist_3: f32;
var param_29: vec3<f32>;
- var param_30: vec4<f32>;
- var param_31: vec4<f32>;
- var param_32: vec3<f32>;
- var param_33: f32;
- var param_34: f32;
- var param_35: vec2<f32>;
- var param_36: f32;
- var param_37: vec2<f32>;
+ var param_30: f32;
+ var param_31: f32;
+ var param_32: vec4<f32>;
+ var param_33: vec3<f32>;
+ var param_34: vec3<f32>;
+ var param_35: vec4<f32>;
+ var param_36: vec4<f32>;
+ var param_37: vec3<f32>;
+ var param_38: f32;
+ var param_39: f32;
+ var param_40: vec2<f32>;
+ var param_41: f32;
+ var param_42: 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 param_43: vec3<f32>;
+ var param_44: vec3<f32>;
+ var param_45: vec3<f32>;
+ var param_46: vec2<f32>;
+ var param_47: i32;
+ var param_48: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_44: f32;
- var param_45: f32;
- var param_46: f32;
- var param_47: f32;
- var param_48: f32;
var param_49: f32;
- var param_50: vec3<f32>;
- var ab: vec2<f32>;
+ var param_50: f32;
var param_51: f32;
var param_52: f32;
- var param_53: vec3<f32>;
+ var param_53: f32;
var param_54: f32;
- var phi_905_: bool;
- var phi_978_: bool;
+ var param_55: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_56: f32;
+ var param_57: f32;
+ var param_58: vec3<f32>;
+ var param_59: f32;
+ var phi_981_: bool;
+ var phi_1054_: 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 _e167 = (*albedo);
+ let _e168 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e167, vec3(_e168));
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);
+ let _e172 = (*roughness_3);
+ a_4 = max((_e171 * _e172), 0.001f);
+ let _e175 = (*N_4);
+ let _e176 = (*V);
+ NdotV_2 = max(dot(_e175, _e176), 0.0001f);
+ let _e179 = (*N_4);
+ param_16 = _e179;
+ let _e180 = indirectIrradiance_u0028_vf3_u003b((&param_16));
+ let _e181 = (*ao);
+ lit = (_e180 * _e181);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e182 = i;
- if (_e182 < 16i) {
- let _e184 = i;
- let _e188 = unnamed_1.u_lights[_e184].posDir;
- pd_1 = _e188;
- let _e189 = i;
- let _e193 = unnamed_1.u_lights[_e189].color;
- col = _e193;
- let _e194 = i;
- 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;
+ let _e183 = i;
+ if (_e183 < 16i) {
+ let _e185 = i;
+ let _e189 = unnamed_1.u_lights[_e185].posDir;
+ pd_1 = _e189;
+ let _e190 = i;
+ let _e194 = unnamed_1.u_lights[_e190].color;
+ col = _e194;
+ let _e195 = i;
+ let _e199 = unnamed_1.u_lights[_e195].shadow;
+ sh_4 = _e199;
+ let _e200 = i;
+ let _e204 = unnamed_1.u_lights[_e200].falloff;
+ fo_1 = _e204;
+ let _e205 = pd_1;
+ target_ = _e205.xy;
castShadow = true;
- 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;
+ let _e208 = pd_1[2u];
+ if (_e208 < 0.5f) {
+ let _e210 = pd_1;
+ param_17 = _e210;
+ let _e211 = sh_4;
+ param_18 = _e211;
+ let _e212 = (*worldPos_5);
+ param_19 = _e212;
+ let _e213 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_17), (&param_18), (&param_19));
+ toL = _e213;
+ let _e214 = toL;
+ param_20 = _e214;
+ let _e215 = lightDistance_u0028_vf3_u003b((&param_20));
+ dist_2 = _e215;
+ let _e217 = pd_1[3u];
+ let _e219 = dist_2;
+ param_21 = _e219;
+ param_22 = max(_e217, 0.0001f);
+ let _e220 = fo_1;
+ param_23 = _e220;
+ let _e221 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_21), (&param_22), (&param_23));
+ atten = _e221;
+ let _e222 = toL;
+ param_24 = _e222;
+ let _e223 = (*N_4);
+ param_25 = _e223;
+ let _e224 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_24), (&param_25));
+ L_1 = _e224;
} else {
- let _e225 = pd_1[2u];
- if (_e225 < 1.5f) {
+ let _e226 = pd_1[2u];
+ if (_e226 < 1.5f) {
atten = 1f;
- 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));
+ let _e228 = pd_1;
+ let _e229 = _e228.xy;
+ let _e231 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e229.x, _e229.y, _e231)));
+ let _e237 = pd_1;
+ let _e239 = pd_1;
+ if (dot(_e237.xy, _e239.xy) > 0.00000001f) {
+ let _e243 = pd_1;
+ local_7 = normalize(-(_e243.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e247 = local_7;
+ toLight_3 = _e247;
+ let _e249 = sh_4[1u];
+ let _e250 = (_e249 > 0f);
+ phi_981_ = _e250;
+ if _e250 {
let _e251 = toLight_3;
- phi_905_ = (dot(_e250, _e251) > 0.5f);
+ let _e252 = toLight_3;
+ phi_981_ = (dot(_e251, _e252) > 0.5f);
}
- let _e255 = phi_905_;
- castShadow = _e255;
- let _e256 = (*worldPos_5);
- let _e258 = toLight_3;
- let _e260 = sh_3[1u];
- target_ = (_e256.xy + (_e258 * _e260));
+ let _e256 = phi_981_;
+ castShadow = _e256;
+ let _e257 = (*worldPos_5);
+ let _e259 = toLight_3;
+ let _e261 = sh_4[1u];
+ target_ = (_e257.xy + (_e259 * _e261));
} else {
- 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_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 _e264 = i;
+ let _e268 = unnamed_1.u_lights[_e264].spot;
+ sp_1 = _e268;
+ let _e269 = pd_1;
+ param_26 = _e269;
+ let _e270 = sh_4;
+ param_27 = _e270;
+ let _e271 = (*worldPos_5);
+ param_28 = _e271;
+ let _e272 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_26), (&param_27), (&param_28));
+ toL_1 = _e272;
+ let _e273 = toL_1;
+ param_29 = _e273;
+ let _e274 = lightDistance_u0028_vf3_u003b((&param_29));
+ dist_3 = _e274;
+ let _e276 = pd_1[3u];
+ let _e278 = dist_3;
+ param_30 = _e278;
+ param_31 = max(_e276, 0.0001f);
+ let _e279 = fo_1;
+ param_32 = _e279;
+ let _e280 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_30), (&param_31), (&param_32));
+ atten = _e280;
+ let _e281 = toL_1;
+ param_33 = _e281;
+ let _e282 = (*N_4);
+ param_34 = _e282;
+ let _e283 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_33), (&param_34));
+ L_1 = _e283;
+ let _e284 = sp_1;
+ param_35 = _e284;
+ let _e285 = sh_4;
+ param_36 = _e285;
+ let _e286 = toL_1;
+ param_37 = _e286;
+ let _e287 = dist_3;
+ param_38 = _e287;
+ let _e288 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_35), (&param_36), (&param_37), (&param_38));
+ let _e289 = atten;
+ atten = (_e289 * _e288);
}
}
- 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 _e292 = col[3u];
+ let _e294 = atten;
+ if ((_e292 > 0f) && (_e294 > 0f)) {
+ let _e298 = fo_1[3u];
+ param_39 = _e298;
+ let _e299 = (*worldPos_5);
+ param_40 = _e299.xy;
+ let _e301 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_39), (&param_40));
+ let _e302 = atten;
+ atten = (_e302 * _e301);
}
- let _e303 = castShadow;
- phi_978_ = _e303;
- if _e303 {
- let _e305 = col[3u];
- phi_978_ = (_e305 > 0f);
+ let _e304 = castShadow;
+ phi_1054_ = _e304;
+ if _e304 {
+ let _e306 = col[3u];
+ phi_1054_ = (_e306 > 0f);
}
- 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 _e309 = phi_1054_;
+ let _e310 = atten;
+ if (_e309 && (_e310 > 0f)) {
+ let _e313 = i;
+ let _e318 = unnamed_1.u_lights[_e313].shadowMap[3u];
+ param_41 = _e318;
+ let _e319 = (*worldPos_5);
+ param_42 = _e319.xy;
+ let _e321 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_41), (&param_42));
+ let _e323 = fo_1[2u];
+ let _e325 = atten;
+ atten = (_e325 * mix(1f, _e321, _e323));
}
- 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 _e327 = i;
+ let _e331 = unnamed_1.u_lights[_e327].shadowMap;
+ sm = _e331;
+ let _e333 = sm[1u];
+ let _e335 = atten;
+ if ((_e333 > 0f) && (_e335 > 0f)) {
+ let _e339 = sh_4[0u];
+ let _e341 = sm[2u];
+ let _e344 = sm[0u];
+ let _e347 = sm[1u];
+ let _e349 = (*worldPos_5);
+ param_43 = _e349;
+ let _e350 = (*N_4);
+ param_44 = _e350;
+ let _e351 = L_1;
+ param_45 = _e351;
+ param_46 = vec2<f32>(_e339, _e341);
+ param_47 = i32(_e344);
+ param_48 = i32(_e347);
+ let _e352 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_43), (&param_44), (&param_45), (&param_46), (&param_47), (&param_48));
+ let _e354 = fo_1[2u];
+ let _e356 = atten;
+ atten = (_e356 * mix(1f, _e352, _e354));
}
- 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_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)));
+ let _e358 = (*N_4);
+ let _e359 = L_1;
+ ndotl = max(dot(_e358, _e359), 0f);
+ let _e362 = col;
+ let _e365 = col[3u];
+ let _e366 = ndotl;
+ let _e368 = atten;
+ radiance = (_e362.xyz * ((_e365 * _e366) * _e368));
+ let _e371 = radiance;
+ let _e372 = lit;
+ lit = (_e372 + _e371);
+ let _e374 = (*specular);
+ if (_e374 > 0f) {
+ let _e376 = L_1;
+ let _e377 = (*V);
+ H = normalize((_e376 + _e377));
+ let _e380 = (*N_4);
+ let _e381 = H;
+ param_49 = max(dot(_e380, _e381), 0f);
+ let _e384 = a_4;
+ param_50 = _e384;
+ let _e385 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_49), (&param_50));
+ let _e386 = NdotV_2;
+ param_51 = _e386;
+ let _e387 = ndotl;
+ param_52 = _e387;
+ let _e388 = (*roughness_3);
+ param_53 = _e388;
+ let _e389 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_51), (&param_52), (&param_53));
+ let _e391 = NdotV_2;
+ let _e393 = ndotl;
+ brdf = ((_e385 * _e389) / max(((4f * _e391) * _e393), 0.0001f));
+ let _e397 = radiance;
+ let _e398 = (*V);
+ let _e399 = H;
+ param_54 = max(dot(_e398, _e399), 0f);
+ let _e402 = F0_1;
+ param_55 = _e402;
+ let _e403 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_54), (&param_55));
+ let _e405 = brdf;
+ let _e407 = (*specular);
+ let _e410 = gloss;
+ gloss = (_e410 + ((_e397 * _e403) * ((_e405 * 3.1415927f) * _e407)));
}
continue;
} else {
break;
}
continuing {
- let _e411 = i;
- i = (_e411 + 1i);
+ let _e412 = i;
+ i = (_e412 + 1i);
}
}
- 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);
+ let _e414 = NdotV_2;
+ param_56 = _e414;
+ let _e415 = (*roughness_3);
+ param_57 = _e415;
+ let _e416 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_56), (&param_57));
+ ab = _e416;
+ let _e417 = (*V);
+ let _e419 = (*N_4);
+ param_58 = reflect(-(_e417), _e419);
+ let _e421 = (*roughness_3);
+ param_59 = _e421;
+ let _e422 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_58), (&param_59));
+ let _e423 = (*ao);
+ let _e424 = (*specular);
+ let _e427 = F0_1;
+ let _e429 = ab[0u];
+ let _e432 = ab[1u];
+ let _e436 = gloss;
+ gloss = (_e436 + ((_e422 * (_e423 * _e424)) * ((_e427 * _e429) + vec3(_e432))));
+ let _e438 = (*albedo);
+ let _e439 = (*metallic);
+ let _e442 = lit;
+ let _e444 = gloss;
+ return (((_e438 * (1f - _e439)) * _e442) + _e444);
}
fn viewDirection_u0028_vf3_u003b(worldPos_6: ptr<function, vec3<f32>>) -> vec3<f32> {
var local_8: vec3<f32>;
- 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));
+ let _e92 = unnamed.u_camera[3u];
+ if (_e92 > 0.5f) {
+ let _e95 = unnamed.u_camera;
+ let _e97 = (*worldPos_6);
+ local_8 = normalize((_e95.xyz - _e97));
} else {
- let _e100 = unnamed.u_camera;
- local_8 = _e100.xyz;
+ let _e101 = unnamed.u_camera;
+ local_8 = _e101.xyz;
}
- let _e102 = local_8;
- return _e102;
+ let _e103 = local_8;
+ return _e103;
}
-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> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<f32>;
- var param_55: vec3<f32>;
- var param_56: vec3<f32>;
- var param_57: vec3<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 _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);
+ var param_60: vec3<f32>;
+ var param_61: vec3<f32>;
+ var param_62: vec3<f32>;
+ var param_63: vec3<f32>;
+ var param_64: vec3<f32>;
+ var param_65: f32;
+ var param_66: f32;
+ var param_67: f32;
+ var param_68: f32;
+
+ let _e102 = (*worldPos_7);
+ P = vec3<f32>(_e102.x, _e102.y, 0f);
+ let _e106 = P;
+ param_60 = _e106;
+ let _e107 = viewDirection_u0028_vf3_u003b((&param_60));
+ let _e108 = (*albedo_1);
+ param_61 = _e108;
+ let _e109 = (*N_5);
+ param_62 = _e109;
+ let _e110 = P;
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;
+ param_64 = _e107;
+ param_65 = 0f;
+ param_66 = 1f;
+ param_67 = 0f;
+ let _e111 = (*ao_1);
+ param_68 = _e111;
+ let _e112 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_61), (&param_62), (&param_63), (&param_64), (&param_65), (&param_66), (&param_67), (&param_68));
+ return _e112;
}
-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;
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_6: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+ var param_72: 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;
+ let _e95 = (*albedo_2);
+ param_69 = _e95;
+ let _e96 = (*N_6);
+ param_70 = _e96;
+ let _e97 = (*worldPos_8);
+ param_71 = _e97;
+ param_72 = 1f;
+ let _e98 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_69), (&param_70), (&param_71), (&param_72));
+ return _e98;
}
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)));
+ let _e91 = (*uv_2);
+ let _e92 = textureSample(map_est, map_ess, _e91);
+ return normalize(((_e92.xyz * 2f) - vec3(1f)));
}
fn main_1() {
var base: vec4<f32>;
- var N_6: vec3<f32>;
- var param_68: vec2<f32>;
- var param_69: vec3<f32>;
- var param_70: vec3<f32>;
- var param_71: vec2<f32>;
+ var N_7: vec3<f32>;
+ var param_73: vec2<f32>;
+ var param_74: vec3<f32>;
+ var param_75: vec3<f32>;
+ var param_76: 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);
+ let _e94 = v_texCoord_1;
+ let _e95 = textureSample(es_bt0_est, es_bt0_ess, _e94);
+ let _e96 = v_color_1;
+ let _e99 = unnamed_3.u_tint;
+ base = ((_e95 * _e96) * _e99);
+ let _e101 = v_texCoord_1;
+ param_73 = _e101;
+ let _e102 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normalMap_est, u_normalMap_ess, (&param_73));
+ N_7 = _e102;
+ let _e103 = base;
+ param_74 = _e103.xyz;
+ let _e105 = N_7;
+ param_75 = _e105;
+ let _e106 = v_worldPos_1;
+ param_76 = _e106;
+ let _e107 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_74), (&param_75), (&param_76));
+ let _e109 = base[3u];
+ fragColor = vec4<f32>(_e107.x, _e107.y, _e107.z, _e109);
return;
}
diff --git a/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader b/fixtures/scenes/mat-lit-flatnormal/lit-fn.esshader
index 59012c9e4..499f6393c 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: 0be517726802c71e
+// assembled-hash: a265a182b28a5246
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: 0be517726802c71e
+// assembled-hash: a265a182b28a5246
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -148,6 +148,10 @@ struct LightConstants {
u_envTint: vec4<f32>,
}
+struct ProbeConstants {
+ u_probeIrradiance: array<vec4<f32>, 9>,
+}
+
struct TimeConstants {
u_time: vec4<f32>,
u_viewport: vec4<f32>,
@@ -165,6 +169,8 @@ var u_shadow2D_ess: sampler;
var u_lightShape2D_est: texture_2d<f32>;
@group(1) @binding(14)
var u_lightShape2D_ess: sampler;
+@group(0) @binding(7)
+var<uniform> unnamed_2: ProbeConstants;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -178,7 +184,7 @@ var u_normal_ess: sampler;
var<private> v_worldPos_1: vec2<f32>;
var<private> fragColor: vec4<f32>;
@group(0) @binding(3)
-var<uniform> unnamed_2: TimeConstants;
+var<uniform> unnamed_3: TimeConstants;
@group(1) @binding(1)
var es_bt1_est: texture_2d<f32>;
@group(1) @binding(9)
@@ -222,94 +228,94 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e98 = unnamed_1.u_envParams[0u];
- if (_e98 < 0.5f) {
- let _e101 = unnamed_1.u_ambient;
- return _e101.xyz;
+ let _e99 = unnamed_1.u_envParams[0u];
+ if (_e99 < 0.5f) {
+ let _e102 = unnamed_1.u_ambient;
+ return _e102.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));
+ 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 _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);
+ 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 _e88 = (*F0_);
let _e89 = (*F0_);
- let _e91 = (*VdotH);
- return (_e88 + ((vec3<f32>(1f, 1f, 1f) - _e89) * pow((1f - _e91), 5f)));
+ 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 _e90 = (*roughness_2);
- let _e92 = (*roughness_2);
- k = (((_e90 + 1f) * (_e92 + 1f)) * 0.125f);
- let _e96 = (*NdotV_1);
+ let _e91 = (*roughness_2);
+ let _e93 = (*roughness_2);
+ k = (((_e91 + 1f) * (_e93 + 1f)) * 0.125f);
let _e97 = (*NdotV_1);
- let _e98 = k;
- let _e101 = k;
- let _e104 = (*NdotL);
+ let _e98 = (*NdotV_1);
+ let _e99 = k;
+ let _e102 = k;
let _e105 = (*NdotL);
- let _e106 = k;
- let _e109 = k;
- return ((_e96 / ((_e97 * (1f - _e98)) + _e101)) * (_e104 / ((_e105 * (1f - _e106)) + _e109)));
+ let _e106 = (*NdotL);
+ let _e107 = k;
+ 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 _e90 = (*a_2);
let _e91 = (*a_2);
- a2_ = (_e90 * _e91);
- let _e93 = (*NdotH);
+ let _e92 = (*a_2);
+ a2_ = (_e91 * _e92);
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));
+ 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 {
@@ -321,32 +327,32 @@ fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel:
var local_1: f32;
var local_2: f32;
- let _e91 = (*channel);
- if (_e91 < 0.5f) {
- let _e94 = (*m)[0u];
- local = _e94;
+ let _e92 = (*channel);
+ if (_e92 < 0.5f) {
+ let _e95 = (*m)[0u];
+ local = _e95;
} else {
- let _e95 = (*channel);
- if (_e95 < 1.5f) {
- let _e98 = (*m)[1u];
- local_1 = _e98;
+ let _e96 = (*channel);
+ if (_e96 < 1.5f) {
+ let _e99 = (*m)[1u];
+ local_1 = _e99;
} else {
- let _e99 = (*channel);
- if (_e99 < 2.5f) {
- let _e102 = (*m)[2u];
- local_2 = _e102;
+ let _e100 = (*channel);
+ if (_e100 < 2.5f) {
+ let _e103 = (*m)[2u];
+ local_2 = _e103;
} else {
- let _e104 = (*m)[3u];
- local_2 = _e104;
+ let _e105 = (*m)[3u];
+ local_2 = _e105;
}
- let _e105 = local_2;
- local_1 = _e105;
+ let _e106 = local_2;
+ local_1 = _e106;
}
- let _e106 = local_1;
- local = _e106;
+ let _e107 = local_1;
+ local = _e107;
}
- let _e107 = local;
- return _e107;
+ let _e108 = local;
+ return _e108;
}
fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
@@ -355,32 +361,32 @@ fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var v: 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) {
+ 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 _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);
+ 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 _e118 = ndc[1u];
- local_3 = _e118;
+ let _e119 = ndc[1u];
+ local_3 = _e119;
}
- 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))));
+ 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 {
@@ -389,36 +395,36 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldP
var hidden: f32;
var param_5: vec4<f32>;
var param_6: f32;
- var phi_307_: bool;
+ var phi_317_: 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 _e94 = (*channel_1);
+ let _e95 = (_e94 < 0f);
+ phi_317_ = _e95;
+ if !(_e95) {
+ let _e99 = unnamed_1.u_mask2DRect[2u];
+ phi_317_ = (_e99 <= 0f);
}
- let _e101 = phi_307_;
- if _e101 {
+ let _e102 = phi_317_;
+ if _e102 {
return 1f;
}
- let _e102 = (*worldPos_2);
- param_4 = _e102;
- let _e103 = mask2DUv_u0028_vf2_u003b((&param_4));
- uv = _e103;
- let _e105 = uv[0u];
- if (_e105 < 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 _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));
+ 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 {
@@ -426,34 +432,34 @@ fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPo
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);
+ var phi_356_: bool;
+
+ let _e93 = (*channel_2);
+ let _e94 = (_e93 < 0f);
+ phi_356_ = _e94;
+ if !(_e94) {
+ let _e98 = unnamed_1.u_mask2DRect[2u];
+ phi_356_ = (_e98 <= 0f);
}
- let _e100 = phi_346_;
- if _e100 {
+ let _e101 = phi_356_;
+ if _e101 {
return 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) {
+ 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 _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);
+ 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 {
@@ -462,74 +468,102 @@ 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 _e94 = (*sp);
- let _e96 = (*sp);
- if (dot(_e94.xy, _e96.xy) > 0.00000001f) {
- let _e100 = (*sp);
- local_4 = normalize(_e100.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 _e103 = local_4;
- axis = _e103;
- let _e104 = (*dist);
- if (_e104 > 0.0001f) {
- let _e106 = (*toLight);
- let _e109 = (*dist);
- local_5 = (-(_e106.xy) / vec2(_e109));
+ 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 _e112 = axis;
- local_5 = _e112;
+ let _e113 = axis;
+ local_5 = _e113;
}
- 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));
+ 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 _e89 = (*toLight_1);
let _e90 = (*toLight_1);
- if (dot(_e89, _e90) > 0.00000001f) {
- let _e93 = (*toLight_1);
- local_6 = normalize(_e93);
+ let _e91 = (*toLight_1);
+ if (dot(_e90, _e91) > 0.00000001f) {
+ let _e94 = (*toLight_1);
+ local_6 = normalize(_e94);
} else {
- let _e95 = (*N_1);
- local_6 = _e95;
+ let _e96 = (*N_1);
+ local_6 = _e96;
}
- let _e96 = local_6;
- return _e96;
+ 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 _e90 = (*reach);
- 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));
+ let _e91 = (*reach);
+ 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 _e87 = (*toLight_2);
- return length(_e87.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_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));
+ 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 shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b(sh_2: ptr<function, array<vec4<f32>, 9>>, N_2: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e90 = (*sh_2)[0i];
+ let _e94 = (*sh_2)[1i];
+ let _e97 = (*N_2)[1u];
+ let _e102 = (*sh_2)[2i];
+ let _e105 = (*N_2)[2u];
+ let _e110 = (*sh_2)[3i];
+ let _e113 = (*N_2)[0u];
+ let _e118 = (*sh_2)[4i];
+ let _e121 = (*N_2)[0u];
+ let _e124 = (*N_2)[1u];
+ let _e129 = (*sh_2)[5i];
+ let _e132 = (*N_2)[1u];
+ let _e135 = (*N_2)[2u];
+ let _e140 = (*sh_2)[6i];
+ let _e143 = (*N_2)[2u];
+ let _e146 = (*N_2)[2u];
+ let _e153 = (*sh_2)[7i];
+ let _e156 = (*N_2)[0u];
+ let _e159 = (*N_2)[2u];
+ let _e164 = (*sh_2)[8i];
+ let _e167 = (*N_2)[0u];
+ let _e169 = (*N_2)[0u];
+ let _e172 = (*N_2)[1u];
+ let _e174 = (*N_2)[1u];
+ return (((((((((_e90.xyz * 0.282095f) + (_e94.xyz * (0.488603f * _e97))) + (_e102.xyz * (0.488603f * _e105))) + (_e110.xyz * (0.488603f * _e113))) + (_e118.xyz * ((1.092548f * _e121) * _e124))) + (_e129.xyz * ((1.092548f * _e132) * _e135))) + (_e140.xyz * (0.315392f * (((3f * _e143) * _e146) - 1f)))) + (_e153.xyz * ((1.092548f * _e156) * _e159))) + (_e164.xyz * (0.546274f * ((_e167 * _e169) - (_e172 * _e174)))));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -537,509 +571,525 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- 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)));
+ 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 sh_3: vec3<f32>;
var param_10: vec3<f32>;
- var sh_2: vec3<f32>;
-
- 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 _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));
+ var param_11: array<vec4<f32>, 9>;
+ var param_12: vec3<f32>;
+
+ let _e92 = (*Nw);
+ param_10 = _e92;
+ let _e93 = envDirection_u0028_vf3_u003b((&param_10));
+ let _e95 = unnamed_1.u_envIrradiance;
+ param_11[0i] = _e95[0];
+ param_11[1i] = _e95[1];
+ param_11[2i] = _e95[2];
+ param_11[3i] = _e95[3];
+ param_11[4i] = _e95[4];
+ param_11[5i] = _e95[5];
+ param_11[6i] = _e95[6];
+ param_11[7i] = _e95[7];
+ param_11[8i] = _e95[8];
+ param_12 = _e93;
+ let _e114 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_11), (&param_12));
+ sh_3 = _e114;
+ let _e116 = unnamed_1.u_ambient;
+ let _e118 = sh_3;
+ let _e121 = unnamed_1.u_envTint;
+ return (_e116.xyz + (max(_e118, vec3<f32>(0f, 0f, 0f)) * _e121.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> {
+fn indirectIrradiance_u0028_vf3_u003b(N_3: ptr<function, vec3<f32>>) -> vec3<f32> {
+ var param_13: array<vec4<f32>, 9>;
+ var param_14: vec3<f32>;
+ var param_15: vec3<f32>;
+
+ let _e94 = unnamed_2.u_probeIrradiance[0i][3u];
+ if (_e94 > 0.5f) {
+ let _e97 = unnamed_2.u_probeIrradiance;
+ param_13[0i] = _e97[0];
+ param_13[1i] = _e97[1];
+ param_13[2i] = _e97[2];
+ param_13[3i] = _e97[3];
+ param_13[4i] = _e97[4];
+ param_13[5i] = _e97[5];
+ param_13[6i] = _e97[6];
+ param_13[7i] = _e97[7];
+ param_13[8i] = _e97[8];
+ let _e116 = (*N_3);
+ param_14 = _e116;
+ let _e117 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_13), (&param_14));
+ return max(_e117, vec3<f32>(0f, 0f, 0f));
+ }
+ let _e119 = (*N_3);
+ param_15 = _e119;
+ let _e120 = envIrradiance_u0028_vf3_u003b((&param_15));
+ return _e120;
+}
+
+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_4: 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_11: vec3<f32>;
+ var param_16: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
var col: vec4<f32>;
- var sh_3: vec4<f32>;
+ var sh_4: vec4<f32>;
var fo_1: vec4<f32>;
var target_: vec2<f32>;
var castShadow: bool;
var toL: vec3<f32>;
- var param_12: vec4<f32>;
- var param_13: vec4<f32>;
- var param_14: vec3<f32>;
- var dist_2: f32;
- var param_15: vec3<f32>;
- var atten: f32;
- var param_16: f32;
- var param_17: f32;
+ var param_17: vec4<f32>;
var param_18: vec4<f32>;
- var L_1: vec3<f32>;
var param_19: vec3<f32>;
+ var dist_2: f32;
var param_20: vec3<f32>;
+ var atten: f32;
+ var param_21: f32;
+ var param_22: f32;
+ var param_23: vec4<f32>;
+ var L_1: vec3<f32>;
+ var param_24: vec3<f32>;
+ var param_25: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_21: vec4<f32>;
- var param_22: vec4<f32>;
- var param_23: vec3<f32>;
- var dist_3: f32;
- var param_24: vec3<f32>;
- var param_25: f32;
- var param_26: f32;
+ var param_26: vec4<f32>;
var param_27: vec4<f32>;
var param_28: vec3<f32>;
+ var dist_3: f32;
var param_29: vec3<f32>;
- var param_30: vec4<f32>;
- var param_31: vec4<f32>;
- var param_32: vec3<f32>;
- var param_33: f32;
- var param_34: f32;
- var param_35: vec2<f32>;
- var param_36: f32;
- var param_37: vec2<f32>;
+ var param_30: f32;
+ var param_31: f32;
+ var param_32: vec4<f32>;
+ var param_33: vec3<f32>;
+ var param_34: vec3<f32>;
+ var param_35: vec4<f32>;
+ var param_36: vec4<f32>;
+ var param_37: vec3<f32>;
+ var param_38: f32;
+ var param_39: f32;
+ var param_40: vec2<f32>;
+ var param_41: f32;
+ var param_42: 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 param_43: vec3<f32>;
+ var param_44: vec3<f32>;
+ var param_45: vec3<f32>;
+ var param_46: vec2<f32>;
+ var param_47: i32;
+ var param_48: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_44: f32;
- var param_45: f32;
- var param_46: f32;
- var param_47: f32;
- var param_48: f32;
var param_49: f32;
- var param_50: vec3<f32>;
- var ab: vec2<f32>;
+ var param_50: f32;
var param_51: f32;
var param_52: f32;
- var param_53: vec3<f32>;
+ var param_53: f32;
var param_54: f32;
- var phi_905_: bool;
- var phi_978_: bool;
+ var param_55: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_56: f32;
+ var param_57: f32;
+ var param_58: vec3<f32>;
+ var param_59: f32;
+ var phi_981_: bool;
+ var phi_1054_: 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 _e166 = (*albedo);
+ let _e167 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e166, vec3(_e167));
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);
+ let _e171 = (*roughness_3);
+ a_4 = max((_e170 * _e171), 0.001f);
+ let _e174 = (*N_4);
+ let _e175 = (*V);
+ NdotV_2 = max(dot(_e174, _e175), 0.0001f);
+ let _e178 = (*N_4);
+ param_16 = _e178;
+ let _e179 = indirectIrradiance_u0028_vf3_u003b((&param_16));
+ let _e180 = (*ao);
+ lit = (_e179 * _e180);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e181 = i;
- if (_e181 < 16i) {
- let _e183 = i;
- let _e187 = unnamed_1.u_lights[_e183].posDir;
- pd_1 = _e187;
- let _e188 = i;
- let _e192 = unnamed_1.u_lights[_e188].color;
- col = _e192;
- let _e193 = i;
- 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;
+ let _e182 = i;
+ if (_e182 < 16i) {
+ let _e184 = i;
+ let _e188 = unnamed_1.u_lights[_e184].posDir;
+ pd_1 = _e188;
+ let _e189 = i;
+ let _e193 = unnamed_1.u_lights[_e189].color;
+ col = _e193;
+ let _e194 = i;
+ let _e198 = unnamed_1.u_lights[_e194].shadow;
+ sh_4 = _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 _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;
+ let _e207 = pd_1[2u];
+ if (_e207 < 0.5f) {
+ let _e209 = pd_1;
+ param_17 = _e209;
+ let _e210 = sh_4;
+ param_18 = _e210;
+ let _e211 = (*worldPos_5);
+ param_19 = _e211;
+ let _e212 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_17), (&param_18), (&param_19));
+ toL = _e212;
+ let _e213 = toL;
+ param_20 = _e213;
+ let _e214 = lightDistance_u0028_vf3_u003b((&param_20));
+ dist_2 = _e214;
+ let _e216 = pd_1[3u];
+ let _e218 = dist_2;
+ param_21 = _e218;
+ param_22 = max(_e216, 0.0001f);
+ let _e219 = fo_1;
+ param_23 = _e219;
+ let _e220 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_21), (&param_22), (&param_23));
+ atten = _e220;
+ let _e221 = toL;
+ param_24 = _e221;
+ let _e222 = (*N_4);
+ param_25 = _e222;
+ let _e223 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_24), (&param_25));
+ L_1 = _e223;
} else {
- let _e224 = pd_1[2u];
- if (_e224 < 1.5f) {
+ let _e225 = pd_1[2u];
+ if (_e225 < 1.5f) {
atten = 1f;
- 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));
+ 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 _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 _e246 = local_7;
+ toLight_3 = _e246;
+ let _e248 = sh_4[1u];
+ let _e249 = (_e248 > 0f);
+ phi_981_ = _e249;
+ if _e249 {
let _e250 = toLight_3;
- phi_905_ = (dot(_e249, _e250) > 0.5f);
+ let _e251 = toLight_3;
+ phi_981_ = (dot(_e250, _e251) > 0.5f);
}
- let _e254 = phi_905_;
- castShadow = _e254;
- let _e255 = (*worldPos_5);
- let _e257 = toLight_3;
- let _e259 = sh_3[1u];
- target_ = (_e255.xy + (_e257 * _e259));
+ let _e255 = phi_981_;
+ castShadow = _e255;
+ let _e256 = (*worldPos_5);
+ let _e258 = toLight_3;
+ let _e260 = sh_4[1u];
+ target_ = (_e256.xy + (_e258 * _e260));
} else {
- 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_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 _e263 = i;
+ let _e267 = unnamed_1.u_lights[_e263].spot;
+ sp_1 = _e267;
+ let _e268 = pd_1;
+ param_26 = _e268;
+ let _e269 = sh_4;
+ param_27 = _e269;
+ let _e270 = (*worldPos_5);
+ param_28 = _e270;
+ let _e271 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_26), (&param_27), (&param_28));
+ toL_1 = _e271;
+ let _e272 = toL_1;
+ param_29 = _e272;
+ let _e273 = lightDistance_u0028_vf3_u003b((&param_29));
+ dist_3 = _e273;
+ let _e275 = pd_1[3u];
+ let _e277 = dist_3;
+ param_30 = _e277;
+ param_31 = max(_e275, 0.0001f);
+ let _e278 = fo_1;
+ param_32 = _e278;
+ let _e279 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_30), (&param_31), (&param_32));
+ atten = _e279;
+ let _e280 = toL_1;
+ param_33 = _e280;
+ let _e281 = (*N_4);
+ param_34 = _e281;
+ let _e282 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_33), (&param_34));
+ L_1 = _e282;
+ let _e283 = sp_1;
+ param_35 = _e283;
+ let _e284 = sh_4;
+ param_36 = _e284;
+ let _e285 = toL_1;
+ param_37 = _e285;
+ let _e286 = dist_3;
+ param_38 = _e286;
+ let _e287 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_35), (&param_36), (&param_37), (&param_38));
+ let _e288 = atten;
+ atten = (_e288 * _e287);
}
}
- 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 _e291 = col[3u];
+ let _e293 = atten;
+ if ((_e291 > 0f) && (_e293 > 0f)) {
+ let _e297 = fo_1[3u];
+ param_39 = _e297;
+ let _e298 = (*worldPos_5);
+ param_40 = _e298.xy;
+ let _e300 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_39), (&param_40));
+ let _e301 = atten;
+ atten = (_e301 * _e300);
}
- let _e302 = castShadow;
- phi_978_ = _e302;
- if _e302 {
- let _e304 = col[3u];
- phi_978_ = (_e304 > 0f);
+ let _e303 = castShadow;
+ phi_1054_ = _e303;
+ if _e303 {
+ let _e305 = col[3u];
+ phi_1054_ = (_e305 > 0f);
}
- 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 _e308 = phi_1054_;
+ let _e309 = atten;
+ if (_e308 && (_e309 > 0f)) {
+ let _e312 = i;
+ let _e317 = unnamed_1.u_lights[_e312].shadowMap[3u];
+ param_41 = _e317;
+ let _e318 = (*worldPos_5);
+ param_42 = _e318.xy;
+ let _e320 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_41), (&param_42));
+ let _e322 = fo_1[2u];
+ let _e324 = atten;
+ atten = (_e324 * mix(1f, _e320, _e322));
}
- 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 _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_4[0u];
+ let _e340 = sm[2u];
+ let _e343 = sm[0u];
+ let _e346 = sm[1u];
+ let _e348 = (*worldPos_5);
+ param_43 = _e348;
+ let _e349 = (*N_4);
+ param_44 = _e349;
+ let _e350 = L_1;
+ param_45 = _e350;
+ param_46 = vec2<f32>(_e338, _e340);
+ param_47 = i32(_e343);
+ param_48 = i32(_e346);
+ let _e351 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_43), (&param_44), (&param_45), (&param_46), (&param_47), (&param_48));
+ let _e353 = fo_1[2u];
+ let _e355 = atten;
+ atten = (_e355 * mix(1f, _e351, _e353));
}
- 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_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)));
+ let _e357 = (*N_4);
+ 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_4);
+ let _e380 = H;
+ param_49 = max(dot(_e379, _e380), 0f);
+ let _e383 = a_4;
+ param_50 = _e383;
+ let _e384 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_49), (&param_50));
+ let _e385 = NdotV_2;
+ param_51 = _e385;
+ let _e386 = ndotl;
+ param_52 = _e386;
+ let _e387 = (*roughness_3);
+ param_53 = _e387;
+ let _e388 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_51), (&param_52), (&param_53));
+ 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_54 = max(dot(_e397, _e398), 0f);
+ let _e401 = F0_1;
+ param_55 = _e401;
+ let _e402 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_54), (&param_55));
+ let _e404 = brdf;
+ let _e406 = (*specular);
+ let _e409 = gloss;
+ gloss = (_e409 + ((_e396 * _e402) * ((_e404 * 3.1415927f) * _e406)));
}
continue;
} else {
break;
}
continuing {
- let _e410 = i;
- i = (_e410 + 1i);
+ let _e411 = i;
+ i = (_e411 + 1i);
}
}
- 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);
+ let _e413 = NdotV_2;
+ param_56 = _e413;
+ let _e414 = (*roughness_3);
+ param_57 = _e414;
+ let _e415 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_56), (&param_57));
+ ab = _e415;
+ let _e416 = (*V);
+ let _e418 = (*N_4);
+ param_58 = reflect(-(_e416), _e418);
+ let _e420 = (*roughness_3);
+ param_59 = _e420;
+ let _e421 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_58), (&param_59));
+ 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 _e90 = unnamed.u_camera[3u];
- if (_e90 > 0.5f) {
- let _e93 = unnamed.u_camera;
- let _e95 = (*worldPos_6);
- local_8 = normalize((_e93.xyz - _e95));
+ 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 _e99 = unnamed.u_camera;
- local_8 = _e99.xyz;
+ let _e100 = unnamed.u_camera;
+ local_8 = _e100.xyz;
}
- let _e101 = local_8;
- return _e101;
+ 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_7: 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_5: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<f32>;
- var param_55: vec3<f32>;
- var param_56: vec3<f32>;
- var param_57: vec3<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 _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);
+ var param_60: vec3<f32>;
+ var param_61: vec3<f32>;
+ var param_62: vec3<f32>;
+ var param_63: vec3<f32>;
+ var param_64: vec3<f32>;
+ var param_65: f32;
+ var param_66: f32;
+ var param_67: f32;
+ var param_68: f32;
+
+ let _e101 = (*worldPos_7);
+ P = vec3<f32>(_e101.x, _e101.y, 0f);
+ let _e105 = P;
+ param_60 = _e105;
+ let _e106 = viewDirection_u0028_vf3_u003b((&param_60));
+ let _e107 = (*albedo_1);
+ param_61 = _e107;
+ let _e108 = (*N_5);
+ param_62 = _e108;
+ let _e109 = P;
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;
+ param_64 = _e106;
+ param_65 = 0f;
+ param_66 = 1f;
+ param_67 = 0f;
+ let _e110 = (*ao_1);
+ param_68 = _e110;
+ let _e111 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_61), (&param_62), (&param_63), (&param_64), (&param_65), (&param_66), (&param_67), (&param_68));
+ return _e111;
}
-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;
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_6: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+ var param_72: 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;
+ let _e94 = (*albedo_2);
+ param_69 = _e94;
+ let _e95 = (*N_6);
+ param_70 = _e95;
+ let _e96 = (*worldPos_8);
+ param_71 = _e96;
+ param_72 = 1f;
+ let _e97 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_69), (&param_70), (&param_71), (&param_72));
+ 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 _e89 = (*uv_2);
- let _e90 = textureSample(map_est, map_ess, _e89);
- return normalize(((_e90.xyz * 2f) - vec3(1f)));
+ 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_68: vec2<f32>;
+ var N_7: vec3<f32>;
+ var param_73: vec2<f32>;
var lit_1: vec3<f32>;
- var param_69: vec3<f32>;
- var param_70: vec3<f32>;
- var param_71: vec2<f32>;
+ var param_74: vec3<f32>;
+ var param_75: vec3<f32>;
+ var param_76: 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);
+ let _e94 = v_texCoord_1;
+ let _e95 = textureSample(es_bt0_est, es_bt0_ess, _e94);
+ let _e96 = v_color_1;
+ base = (_e95 * _e96);
+ let _e98 = v_texCoord_1;
+ param_73 = _e98;
+ let _e99 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_73));
+ N_7 = _e99;
+ let _e100 = base;
+ param_74 = _e100.xyz;
+ let _e102 = N_7;
+ param_75 = _e102;
+ let _e103 = v_worldPos_1;
+ param_76 = _e103;
+ let _e104 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_74), (&param_75), (&param_76));
+ lit_1 = _e104;
+ let _e105 = lit_1;
+ let _e107 = base[3u];
+ fragColor = vec4<f32>(_e105.x, _e105.y, _e105.z, _e107);
return;
}
diff --git a/fixtures/scenes/mat-lit-normal/lit-normal.esshader b/fixtures/scenes/mat-lit-normal/lit-normal.esshader
index e870166ef..0139f548b 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: db03d794334dafe3
+// assembled-hash: 185007bc3459c021
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: db03d794334dafe3
+// assembled-hash: 185007bc3459c021
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -148,6 +148,10 @@ struct LightConstants {
u_envTint: vec4<f32>,
}
+struct ProbeConstants {
+ u_probeIrradiance: array<vec4<f32>, 9>,
+}
+
struct TimeConstants {
u_time: vec4<f32>,
u_viewport: vec4<f32>,
@@ -165,6 +169,8 @@ var u_shadow2D_ess: sampler;
var u_lightShape2D_est: texture_2d<f32>;
@group(1) @binding(14)
var u_lightShape2D_ess: sampler;
+@group(0) @binding(7)
+var<uniform> unnamed_2: ProbeConstants;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -178,7 +184,7 @@ var u_normal_ess: sampler;
var<private> v_worldPos_1: vec2<f32>;
var<private> fragColor: vec4<f32>;
@group(0) @binding(3)
-var<uniform> unnamed_2: TimeConstants;
+var<uniform> unnamed_3: TimeConstants;
@group(1) @binding(1)
var es_bt1_est: texture_2d<f32>;
@group(1) @binding(9)
@@ -222,94 +228,94 @@ fn envRadiance_u0028_vf3_u003b_f1_u003b(R_1: ptr<function, vec3<f32>>, roughness
var param_2: vec3<f32>;
var param_3: f32;
- let _e98 = unnamed_1.u_envParams[0u];
- if (_e98 < 0.5f) {
- let _e101 = unnamed_1.u_ambient;
- return _e101.xyz;
+ let _e99 = unnamed_1.u_envParams[0u];
+ if (_e99 < 0.5f) {
+ let _e102 = unnamed_1.u_ambient;
+ return _e102.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));
+ 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 _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);
+ 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 _e88 = (*F0_);
let _e89 = (*F0_);
- let _e91 = (*VdotH);
- return (_e88 + ((vec3<f32>(1f, 1f, 1f) - _e89) * pow((1f - _e91), 5f)));
+ 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 _e90 = (*roughness_2);
- let _e92 = (*roughness_2);
- k = (((_e90 + 1f) * (_e92 + 1f)) * 0.125f);
- let _e96 = (*NdotV_1);
+ let _e91 = (*roughness_2);
+ let _e93 = (*roughness_2);
+ k = (((_e91 + 1f) * (_e93 + 1f)) * 0.125f);
let _e97 = (*NdotV_1);
- let _e98 = k;
- let _e101 = k;
- let _e104 = (*NdotL);
+ let _e98 = (*NdotV_1);
+ let _e99 = k;
+ let _e102 = k;
let _e105 = (*NdotL);
- let _e106 = k;
- let _e109 = k;
- return ((_e96 / ((_e97 * (1f - _e98)) + _e101)) * (_e104 / ((_e105 * (1f - _e106)) + _e109)));
+ let _e106 = (*NdotL);
+ let _e107 = k;
+ 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 _e90 = (*a_2);
let _e91 = (*a_2);
- a2_ = (_e90 * _e91);
- let _e93 = (*NdotH);
+ let _e92 = (*a_2);
+ a2_ = (_e91 * _e92);
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));
+ 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 {
@@ -321,32 +327,32 @@ fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel:
var local_1: f32;
var local_2: f32;
- let _e91 = (*channel);
- if (_e91 < 0.5f) {
- let _e94 = (*m)[0u];
- local = _e94;
+ let _e92 = (*channel);
+ if (_e92 < 0.5f) {
+ let _e95 = (*m)[0u];
+ local = _e95;
} else {
- let _e95 = (*channel);
- if (_e95 < 1.5f) {
- let _e98 = (*m)[1u];
- local_1 = _e98;
+ let _e96 = (*channel);
+ if (_e96 < 1.5f) {
+ let _e99 = (*m)[1u];
+ local_1 = _e99;
} else {
- let _e99 = (*channel);
- if (_e99 < 2.5f) {
- let _e102 = (*m)[2u];
- local_2 = _e102;
+ let _e100 = (*channel);
+ if (_e100 < 2.5f) {
+ let _e103 = (*m)[2u];
+ local_2 = _e103;
} else {
- let _e104 = (*m)[3u];
- local_2 = _e104;
+ let _e105 = (*m)[3u];
+ local_2 = _e105;
}
- let _e105 = local_2;
- local_1 = _e105;
+ let _e106 = local_2;
+ local_1 = _e106;
}
- let _e106 = local_1;
- local = _e106;
+ let _e107 = local_1;
+ local = _e107;
}
- let _e107 = local;
- return _e107;
+ let _e108 = local;
+ return _e108;
}
fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
@@ -355,32 +361,32 @@ fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var v: 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) {
+ 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 _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);
+ 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 _e118 = ndc[1u];
- local_3 = _e118;
+ let _e119 = ndc[1u];
+ local_3 = _e119;
}
- 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))));
+ 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 {
@@ -389,36 +395,36 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldP
var hidden: f32;
var param_5: vec4<f32>;
var param_6: f32;
- var phi_307_: bool;
+ var phi_317_: 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 _e94 = (*channel_1);
+ let _e95 = (_e94 < 0f);
+ phi_317_ = _e95;
+ if !(_e95) {
+ let _e99 = unnamed_1.u_mask2DRect[2u];
+ phi_317_ = (_e99 <= 0f);
}
- let _e101 = phi_307_;
- if _e101 {
+ let _e102 = phi_317_;
+ if _e102 {
return 1f;
}
- let _e102 = (*worldPos_2);
- param_4 = _e102;
- let _e103 = mask2DUv_u0028_vf2_u003b((&param_4));
- uv = _e103;
- let _e105 = uv[0u];
- if (_e105 < 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 _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));
+ 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 {
@@ -426,34 +432,34 @@ fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPo
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);
+ var phi_356_: bool;
+
+ let _e93 = (*channel_2);
+ let _e94 = (_e93 < 0f);
+ phi_356_ = _e94;
+ if !(_e94) {
+ let _e98 = unnamed_1.u_mask2DRect[2u];
+ phi_356_ = (_e98 <= 0f);
}
- let _e100 = phi_346_;
- if _e100 {
+ let _e101 = phi_356_;
+ if _e101 {
return 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) {
+ 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 _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);
+ 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 {
@@ -462,74 +468,102 @@ 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 _e94 = (*sp);
- let _e96 = (*sp);
- if (dot(_e94.xy, _e96.xy) > 0.00000001f) {
- let _e100 = (*sp);
- local_4 = normalize(_e100.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 _e103 = local_4;
- axis = _e103;
- let _e104 = (*dist);
- if (_e104 > 0.0001f) {
- let _e106 = (*toLight);
- let _e109 = (*dist);
- local_5 = (-(_e106.xy) / vec2(_e109));
+ 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 _e112 = axis;
- local_5 = _e112;
+ let _e113 = axis;
+ local_5 = _e113;
}
- 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));
+ 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 _e89 = (*toLight_1);
let _e90 = (*toLight_1);
- if (dot(_e89, _e90) > 0.00000001f) {
- let _e93 = (*toLight_1);
- local_6 = normalize(_e93);
+ let _e91 = (*toLight_1);
+ if (dot(_e90, _e91) > 0.00000001f) {
+ let _e94 = (*toLight_1);
+ local_6 = normalize(_e94);
} else {
- let _e95 = (*N_1);
- local_6 = _e95;
+ let _e96 = (*N_1);
+ local_6 = _e96;
}
- let _e96 = local_6;
- return _e96;
+ 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 _e90 = (*reach);
- 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));
+ let _e91 = (*reach);
+ 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 _e87 = (*toLight_2);
- return length(_e87.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_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));
+ 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 shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b(sh_2: ptr<function, array<vec4<f32>, 9>>, N_2: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e90 = (*sh_2)[0i];
+ let _e94 = (*sh_2)[1i];
+ let _e97 = (*N_2)[1u];
+ let _e102 = (*sh_2)[2i];
+ let _e105 = (*N_2)[2u];
+ let _e110 = (*sh_2)[3i];
+ let _e113 = (*N_2)[0u];
+ let _e118 = (*sh_2)[4i];
+ let _e121 = (*N_2)[0u];
+ let _e124 = (*N_2)[1u];
+ let _e129 = (*sh_2)[5i];
+ let _e132 = (*N_2)[1u];
+ let _e135 = (*N_2)[2u];
+ let _e140 = (*sh_2)[6i];
+ let _e143 = (*N_2)[2u];
+ let _e146 = (*N_2)[2u];
+ let _e153 = (*sh_2)[7i];
+ let _e156 = (*N_2)[0u];
+ let _e159 = (*N_2)[2u];
+ let _e164 = (*sh_2)[8i];
+ let _e167 = (*N_2)[0u];
+ let _e169 = (*N_2)[0u];
+ let _e172 = (*N_2)[1u];
+ let _e174 = (*N_2)[1u];
+ return (((((((((_e90.xyz * 0.282095f) + (_e94.xyz * (0.488603f * _e97))) + (_e102.xyz * (0.488603f * _e105))) + (_e110.xyz * (0.488603f * _e113))) + (_e118.xyz * ((1.092548f * _e121) * _e124))) + (_e129.xyz * ((1.092548f * _e132) * _e135))) + (_e140.xyz * (0.315392f * (((3f * _e143) * _e146) - 1f)))) + (_e153.xyz * ((1.092548f * _e156) * _e159))) + (_e164.xyz * (0.546274f * ((_e167 * _e169) - (_e172 * _e174)))));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -537,509 +571,525 @@ fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
var s: f32;
var c: f32;
- 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)));
+ 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 sh_3: vec3<f32>;
var param_10: vec3<f32>;
- var sh_2: vec3<f32>;
-
- 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 _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));
+ var param_11: array<vec4<f32>, 9>;
+ var param_12: vec3<f32>;
+
+ let _e92 = (*Nw);
+ param_10 = _e92;
+ let _e93 = envDirection_u0028_vf3_u003b((&param_10));
+ let _e95 = unnamed_1.u_envIrradiance;
+ param_11[0i] = _e95[0];
+ param_11[1i] = _e95[1];
+ param_11[2i] = _e95[2];
+ param_11[3i] = _e95[3];
+ param_11[4i] = _e95[4];
+ param_11[5i] = _e95[5];
+ param_11[6i] = _e95[6];
+ param_11[7i] = _e95[7];
+ param_11[8i] = _e95[8];
+ param_12 = _e93;
+ let _e114 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_11), (&param_12));
+ sh_3 = _e114;
+ let _e116 = unnamed_1.u_ambient;
+ let _e118 = sh_3;
+ let _e121 = unnamed_1.u_envTint;
+ return (_e116.xyz + (max(_e118, vec3<f32>(0f, 0f, 0f)) * _e121.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> {
+fn indirectIrradiance_u0028_vf3_u003b(N_3: ptr<function, vec3<f32>>) -> vec3<f32> {
+ var param_13: array<vec4<f32>, 9>;
+ var param_14: vec3<f32>;
+ var param_15: vec3<f32>;
+
+ let _e94 = unnamed_2.u_probeIrradiance[0i][3u];
+ if (_e94 > 0.5f) {
+ let _e97 = unnamed_2.u_probeIrradiance;
+ param_13[0i] = _e97[0];
+ param_13[1i] = _e97[1];
+ param_13[2i] = _e97[2];
+ param_13[3i] = _e97[3];
+ param_13[4i] = _e97[4];
+ param_13[5i] = _e97[5];
+ param_13[6i] = _e97[6];
+ param_13[7i] = _e97[7];
+ param_13[8i] = _e97[8];
+ let _e116 = (*N_3);
+ param_14 = _e116;
+ let _e117 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_13), (&param_14));
+ return max(_e117, vec3<f32>(0f, 0f, 0f));
+ }
+ let _e119 = (*N_3);
+ param_15 = _e119;
+ let _e120 = envIrradiance_u0028_vf3_u003b((&param_15));
+ return _e120;
+}
+
+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_4: 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_11: vec3<f32>;
+ var param_16: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
var col: vec4<f32>;
- var sh_3: vec4<f32>;
+ var sh_4: vec4<f32>;
var fo_1: vec4<f32>;
var target_: vec2<f32>;
var castShadow: bool;
var toL: vec3<f32>;
- var param_12: vec4<f32>;
- var param_13: vec4<f32>;
- var param_14: vec3<f32>;
- var dist_2: f32;
- var param_15: vec3<f32>;
- var atten: f32;
- var param_16: f32;
- var param_17: f32;
+ var param_17: vec4<f32>;
var param_18: vec4<f32>;
- var L_1: vec3<f32>;
var param_19: vec3<f32>;
+ var dist_2: f32;
var param_20: vec3<f32>;
+ var atten: f32;
+ var param_21: f32;
+ var param_22: f32;
+ var param_23: vec4<f32>;
+ var L_1: vec3<f32>;
+ var param_24: vec3<f32>;
+ var param_25: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_21: vec4<f32>;
- var param_22: vec4<f32>;
- var param_23: vec3<f32>;
- var dist_3: f32;
- var param_24: vec3<f32>;
- var param_25: f32;
- var param_26: f32;
+ var param_26: vec4<f32>;
var param_27: vec4<f32>;
var param_28: vec3<f32>;
+ var dist_3: f32;
var param_29: vec3<f32>;
- var param_30: vec4<f32>;
- var param_31: vec4<f32>;
- var param_32: vec3<f32>;
- var param_33: f32;
- var param_34: f32;
- var param_35: vec2<f32>;
- var param_36: f32;
- var param_37: vec2<f32>;
+ var param_30: f32;
+ var param_31: f32;
+ var param_32: vec4<f32>;
+ var param_33: vec3<f32>;
+ var param_34: vec3<f32>;
+ var param_35: vec4<f32>;
+ var param_36: vec4<f32>;
+ var param_37: vec3<f32>;
+ var param_38: f32;
+ var param_39: f32;
+ var param_40: vec2<f32>;
+ var param_41: f32;
+ var param_42: 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 param_43: vec3<f32>;
+ var param_44: vec3<f32>;
+ var param_45: vec3<f32>;
+ var param_46: vec2<f32>;
+ var param_47: i32;
+ var param_48: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_44: f32;
- var param_45: f32;
- var param_46: f32;
- var param_47: f32;
- var param_48: f32;
var param_49: f32;
- var param_50: vec3<f32>;
- var ab: vec2<f32>;
+ var param_50: f32;
var param_51: f32;
var param_52: f32;
- var param_53: vec3<f32>;
+ var param_53: f32;
var param_54: f32;
- var phi_905_: bool;
- var phi_978_: bool;
+ var param_55: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_56: f32;
+ var param_57: f32;
+ var param_58: vec3<f32>;
+ var param_59: f32;
+ var phi_981_: bool;
+ var phi_1054_: 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 _e166 = (*albedo);
+ let _e167 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e166, vec3(_e167));
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);
+ let _e171 = (*roughness_3);
+ a_4 = max((_e170 * _e171), 0.001f);
+ let _e174 = (*N_4);
+ let _e175 = (*V);
+ NdotV_2 = max(dot(_e174, _e175), 0.0001f);
+ let _e178 = (*N_4);
+ param_16 = _e178;
+ let _e179 = indirectIrradiance_u0028_vf3_u003b((&param_16));
+ let _e180 = (*ao);
+ lit = (_e179 * _e180);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e181 = i;
- if (_e181 < 16i) {
- let _e183 = i;
- let _e187 = unnamed_1.u_lights[_e183].posDir;
- pd_1 = _e187;
- let _e188 = i;
- let _e192 = unnamed_1.u_lights[_e188].color;
- col = _e192;
- let _e193 = i;
- 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;
+ let _e182 = i;
+ if (_e182 < 16i) {
+ let _e184 = i;
+ let _e188 = unnamed_1.u_lights[_e184].posDir;
+ pd_1 = _e188;
+ let _e189 = i;
+ let _e193 = unnamed_1.u_lights[_e189].color;
+ col = _e193;
+ let _e194 = i;
+ let _e198 = unnamed_1.u_lights[_e194].shadow;
+ sh_4 = _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 _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;
+ let _e207 = pd_1[2u];
+ if (_e207 < 0.5f) {
+ let _e209 = pd_1;
+ param_17 = _e209;
+ let _e210 = sh_4;
+ param_18 = _e210;
+ let _e211 = (*worldPos_5);
+ param_19 = _e211;
+ let _e212 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_17), (&param_18), (&param_19));
+ toL = _e212;
+ let _e213 = toL;
+ param_20 = _e213;
+ let _e214 = lightDistance_u0028_vf3_u003b((&param_20));
+ dist_2 = _e214;
+ let _e216 = pd_1[3u];
+ let _e218 = dist_2;
+ param_21 = _e218;
+ param_22 = max(_e216, 0.0001f);
+ let _e219 = fo_1;
+ param_23 = _e219;
+ let _e220 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_21), (&param_22), (&param_23));
+ atten = _e220;
+ let _e221 = toL;
+ param_24 = _e221;
+ let _e222 = (*N_4);
+ param_25 = _e222;
+ let _e223 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_24), (&param_25));
+ L_1 = _e223;
} else {
- let _e224 = pd_1[2u];
- if (_e224 < 1.5f) {
+ let _e225 = pd_1[2u];
+ if (_e225 < 1.5f) {
atten = 1f;
- 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));
+ 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 _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 _e246 = local_7;
+ toLight_3 = _e246;
+ let _e248 = sh_4[1u];
+ let _e249 = (_e248 > 0f);
+ phi_981_ = _e249;
+ if _e249 {
let _e250 = toLight_3;
- phi_905_ = (dot(_e249, _e250) > 0.5f);
+ let _e251 = toLight_3;
+ phi_981_ = (dot(_e250, _e251) > 0.5f);
}
- let _e254 = phi_905_;
- castShadow = _e254;
- let _e255 = (*worldPos_5);
- let _e257 = toLight_3;
- let _e259 = sh_3[1u];
- target_ = (_e255.xy + (_e257 * _e259));
+ let _e255 = phi_981_;
+ castShadow = _e255;
+ let _e256 = (*worldPos_5);
+ let _e258 = toLight_3;
+ let _e260 = sh_4[1u];
+ target_ = (_e256.xy + (_e258 * _e260));
} else {
- 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_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 _e263 = i;
+ let _e267 = unnamed_1.u_lights[_e263].spot;
+ sp_1 = _e267;
+ let _e268 = pd_1;
+ param_26 = _e268;
+ let _e269 = sh_4;
+ param_27 = _e269;
+ let _e270 = (*worldPos_5);
+ param_28 = _e270;
+ let _e271 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_26), (&param_27), (&param_28));
+ toL_1 = _e271;
+ let _e272 = toL_1;
+ param_29 = _e272;
+ let _e273 = lightDistance_u0028_vf3_u003b((&param_29));
+ dist_3 = _e273;
+ let _e275 = pd_1[3u];
+ let _e277 = dist_3;
+ param_30 = _e277;
+ param_31 = max(_e275, 0.0001f);
+ let _e278 = fo_1;
+ param_32 = _e278;
+ let _e279 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_30), (&param_31), (&param_32));
+ atten = _e279;
+ let _e280 = toL_1;
+ param_33 = _e280;
+ let _e281 = (*N_4);
+ param_34 = _e281;
+ let _e282 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_33), (&param_34));
+ L_1 = _e282;
+ let _e283 = sp_1;
+ param_35 = _e283;
+ let _e284 = sh_4;
+ param_36 = _e284;
+ let _e285 = toL_1;
+ param_37 = _e285;
+ let _e286 = dist_3;
+ param_38 = _e286;
+ let _e287 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_35), (&param_36), (&param_37), (&param_38));
+ let _e288 = atten;
+ atten = (_e288 * _e287);
}
}
- 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 _e291 = col[3u];
+ let _e293 = atten;
+ if ((_e291 > 0f) && (_e293 > 0f)) {
+ let _e297 = fo_1[3u];
+ param_39 = _e297;
+ let _e298 = (*worldPos_5);
+ param_40 = _e298.xy;
+ let _e300 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_39), (&param_40));
+ let _e301 = atten;
+ atten = (_e301 * _e300);
}
- let _e302 = castShadow;
- phi_978_ = _e302;
- if _e302 {
- let _e304 = col[3u];
- phi_978_ = (_e304 > 0f);
+ let _e303 = castShadow;
+ phi_1054_ = _e303;
+ if _e303 {
+ let _e305 = col[3u];
+ phi_1054_ = (_e305 > 0f);
}
- 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 _e308 = phi_1054_;
+ let _e309 = atten;
+ if (_e308 && (_e309 > 0f)) {
+ let _e312 = i;
+ let _e317 = unnamed_1.u_lights[_e312].shadowMap[3u];
+ param_41 = _e317;
+ let _e318 = (*worldPos_5);
+ param_42 = _e318.xy;
+ let _e320 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_41), (&param_42));
+ let _e322 = fo_1[2u];
+ let _e324 = atten;
+ atten = (_e324 * mix(1f, _e320, _e322));
}
- 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 _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_4[0u];
+ let _e340 = sm[2u];
+ let _e343 = sm[0u];
+ let _e346 = sm[1u];
+ let _e348 = (*worldPos_5);
+ param_43 = _e348;
+ let _e349 = (*N_4);
+ param_44 = _e349;
+ let _e350 = L_1;
+ param_45 = _e350;
+ param_46 = vec2<f32>(_e338, _e340);
+ param_47 = i32(_e343);
+ param_48 = i32(_e346);
+ let _e351 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_43), (&param_44), (&param_45), (&param_46), (&param_47), (&param_48));
+ let _e353 = fo_1[2u];
+ let _e355 = atten;
+ atten = (_e355 * mix(1f, _e351, _e353));
}
- 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_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)));
+ let _e357 = (*N_4);
+ 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_4);
+ let _e380 = H;
+ param_49 = max(dot(_e379, _e380), 0f);
+ let _e383 = a_4;
+ param_50 = _e383;
+ let _e384 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_49), (&param_50));
+ let _e385 = NdotV_2;
+ param_51 = _e385;
+ let _e386 = ndotl;
+ param_52 = _e386;
+ let _e387 = (*roughness_3);
+ param_53 = _e387;
+ let _e388 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_51), (&param_52), (&param_53));
+ 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_54 = max(dot(_e397, _e398), 0f);
+ let _e401 = F0_1;
+ param_55 = _e401;
+ let _e402 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_54), (&param_55));
+ let _e404 = brdf;
+ let _e406 = (*specular);
+ let _e409 = gloss;
+ gloss = (_e409 + ((_e396 * _e402) * ((_e404 * 3.1415927f) * _e406)));
}
continue;
} else {
break;
}
continuing {
- let _e410 = i;
- i = (_e410 + 1i);
+ let _e411 = i;
+ i = (_e411 + 1i);
}
}
- 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);
+ let _e413 = NdotV_2;
+ param_56 = _e413;
+ let _e414 = (*roughness_3);
+ param_57 = _e414;
+ let _e415 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_56), (&param_57));
+ ab = _e415;
+ let _e416 = (*V);
+ let _e418 = (*N_4);
+ param_58 = reflect(-(_e416), _e418);
+ let _e420 = (*roughness_3);
+ param_59 = _e420;
+ let _e421 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_58), (&param_59));
+ 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 _e90 = unnamed.u_camera[3u];
- if (_e90 > 0.5f) {
- let _e93 = unnamed.u_camera;
- let _e95 = (*worldPos_6);
- local_8 = normalize((_e93.xyz - _e95));
+ 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 _e99 = unnamed.u_camera;
- local_8 = _e99.xyz;
+ let _e100 = unnamed.u_camera;
+ local_8 = _e100.xyz;
}
- let _e101 = local_8;
- return _e101;
+ 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_7: 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_5: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<f32>;
- var param_55: vec3<f32>;
- var param_56: vec3<f32>;
- var param_57: vec3<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 _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);
+ var param_60: vec3<f32>;
+ var param_61: vec3<f32>;
+ var param_62: vec3<f32>;
+ var param_63: vec3<f32>;
+ var param_64: vec3<f32>;
+ var param_65: f32;
+ var param_66: f32;
+ var param_67: f32;
+ var param_68: f32;
+
+ let _e101 = (*worldPos_7);
+ P = vec3<f32>(_e101.x, _e101.y, 0f);
+ let _e105 = P;
+ param_60 = _e105;
+ let _e106 = viewDirection_u0028_vf3_u003b((&param_60));
+ let _e107 = (*albedo_1);
+ param_61 = _e107;
+ let _e108 = (*N_5);
+ param_62 = _e108;
+ let _e109 = P;
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;
+ param_64 = _e106;
+ param_65 = 0f;
+ param_66 = 1f;
+ param_67 = 0f;
+ let _e110 = (*ao_1);
+ param_68 = _e110;
+ let _e111 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_61), (&param_62), (&param_63), (&param_64), (&param_65), (&param_66), (&param_67), (&param_68));
+ return _e111;
}
-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;
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_6: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+ var param_72: 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;
+ let _e94 = (*albedo_2);
+ param_69 = _e94;
+ let _e95 = (*N_6);
+ param_70 = _e95;
+ let _e96 = (*worldPos_8);
+ param_71 = _e96;
+ param_72 = 1f;
+ let _e97 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_69), (&param_70), (&param_71), (&param_72));
+ 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 _e89 = (*uv_2);
- let _e90 = textureSample(map_est, map_ess, _e89);
- return normalize(((_e90.xyz * 2f) - vec3(1f)));
+ 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_68: vec2<f32>;
+ var N_7: vec3<f32>;
+ var param_73: vec2<f32>;
var lit_1: vec3<f32>;
- var param_69: vec3<f32>;
- var param_70: vec3<f32>;
- var param_71: vec2<f32>;
+ var param_74: vec3<f32>;
+ var param_75: vec3<f32>;
+ var param_76: 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);
+ let _e94 = v_texCoord_1;
+ let _e95 = textureSample(es_bt0_est, es_bt0_ess, _e94);
+ let _e96 = v_color_1;
+ base = (_e95 * _e96);
+ let _e98 = v_texCoord_1;
+ param_73 = _e98;
+ let _e99 = sampleNormal_u0028_t21_u003b_p1_u003b_vf2_u003b(u_normal_est, u_normal_ess, (&param_73));
+ N_7 = _e99;
+ let _e100 = base;
+ param_74 = _e100.xyz;
+ let _e102 = N_7;
+ param_75 = _e102;
+ let _e103 = v_worldPos_1;
+ param_76 = _e103;
+ let _e104 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_74), (&param_75), (&param_76));
+ lit_1 = _e104;
+ let _e105 = lit_1;
+ let _e107 = base[3u];
+ fragColor = vec4<f32>(_e105.x, _e105.y, _e105.z, _e107);
return;
}
diff --git a/fixtures/scenes/mat-lit/lit.esshader b/fixtures/scenes/mat-lit/lit.esshader
index 31414fd51..7dde547bb 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: 87933b753dc5e053
+// assembled-hash: 33b20ac4c01f0223
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: 87933b753dc5e053
+// assembled-hash: 33b20ac4c01f0223
struct FrameConstants {
u_projection: mat4x4<f32>,
u_camera: vec4<f32>,
@@ -150,6 +150,10 @@ struct LightConstants {
u_envTint: vec4<f32>,
}
+struct ProbeConstants {
+ u_probeIrradiance: array<vec4<f32>, 9>,
+}
+
struct TimeConstants {
u_time: vec4<f32>,
u_viewport: vec4<f32>,
@@ -167,6 +171,8 @@ var u_shadow2D_ess: sampler;
var u_lightShape2D_est: texture_2d<f32>;
@group(1) @binding(14)
var u_lightShape2D_ess: sampler;
+@group(0) @binding(7)
+var<uniform> unnamed_2: ProbeConstants;
@group(1) @binding(0)
var es_bt0_est: texture_2d<f32>;
@group(1) @binding(8)
@@ -176,7 +182,7 @@ var<private> v_color_1: vec4<f32>;
var<private> v_worldPos_1: vec2<f32>;
var<private> fragColor: vec4<f32>;
@group(0) @binding(3)
-var<uniform> unnamed_2: TimeConstants;
+var<uniform> unnamed_3: TimeConstants;
@group(1) @binding(1)
var es_bt1_est: texture_2d<f32>;
@group(1) @binding(9)
@@ -220,94 +226,94 @@ 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 _e97 = unnamed_1.u_envParams[0u];
+ if (_e97 < 0.5f) {
+ let _e100 = unnamed_1.u_ambient;
+ return _e100.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 _e102 = (*roughness);
+ let _e106 = unnamed_1.u_envParams[2u];
+ lod = (clamp(_e102, 0f, 1f) * _e106);
+ let _e108 = lod;
+ lo = floor(_e108);
+ let _e110 = (*R_1);
+ param = _e110;
+ let _e111 = lo;
+ param_1 = _e111;
+ let _e112 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param), (&param_1));
+ a = _e112;
+ let _e113 = lo;
+ let _e117 = unnamed_1.u_envParams[2u];
+ let _e119 = (*R_1);
+ param_2 = _e119;
+ param_3 = min((_e113 + 1f), _e117);
+ let _e120 = envSampleMip_u0028_vf3_u003b_f1_u003b((&param_2), (&param_3));
+ b = _e120;
+ let _e122 = unnamed_1.u_ambient;
+ let _e124 = a;
+ let _e125 = b;
+ let _e126 = lod;
+ let _e127 = lo;
+ let _e132 = unnamed_1.u_envTint;
+ return (_e122.xyz + (mix(_e124, _e125, vec3((_e126 - _e127))) * _e132.xyz));
}
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 _e89 = (*roughness_1);
+ r = ((vec4<f32>(-1f, -0.0275f, -0.572f, 0.022f) * _e89) + vec4<f32>(1f, 0.0425f, 1.04f, -0.04f));
+ let _e93 = r[0u];
+ let _e95 = r[0u];
+ let _e97 = (*NdotV);
+ let _e102 = r[0u];
+ let _e105 = r[1u];
+ a_1 = ((min((_e93 * _e95), exp2((-9.28f * _e97))) * _e102) + _e105);
+ let _e107 = a_1;
+ let _e109 = r;
+ return ((vec2<f32>(-1.04f, 1.04f) * _e107) + _e109.zw);
}
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 _e88 = (*F0_);
+ let _e90 = (*VdotH);
+ return (_e87 + ((vec3<f32>(1f, 1f, 1f) - _e88) * pow((1f - _e90), 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 _e89 = (*roughness_2);
+ let _e91 = (*roughness_2);
+ k = (((_e89 + 1f) * (_e91 + 1f)) * 0.125f);
let _e95 = (*NdotV_1);
- let _e96 = k;
- let _e99 = k;
- let _e102 = (*NdotL);
+ let _e96 = (*NdotV_1);
+ let _e97 = k;
+ let _e100 = k;
let _e103 = (*NdotL);
- let _e104 = k;
- let _e107 = k;
- return ((_e94 / ((_e95 * (1f - _e96)) + _e99)) * (_e102 / ((_e103 * (1f - _e104)) + _e107)));
+ let _e104 = (*NdotL);
+ let _e105 = k;
+ let _e108 = k;
+ return ((_e95 / ((_e96 * (1f - _e97)) + _e100)) * (_e103 / ((_e104 * (1f - _e105)) + _e108)));
}
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 _e90 = (*a_2);
+ a2_ = (_e89 * _e90);
let _e92 = (*NdotH);
- let _e94 = a2_;
- d = (((_e91 * _e92) * (_e94 - 1f)) + 1f);
- let _e98 = a2_;
- let _e99 = d;
- let _e101 = d;
- return (_e98 / max(((3.1415927f * _e99) * _e101), 0.0000001f));
+ let _e93 = (*NdotH);
+ let _e95 = a2_;
+ d = (((_e92 * _e93) * (_e95 - 1f)) + 1f);
+ let _e99 = a2_;
+ let _e100 = d;
+ let _e102 = d;
+ return (_e99 / max(((3.1415927f * _e100) * _e102), 0.0000001f));
}
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 {
@@ -319,32 +325,32 @@ fn mask2DChannel_u0028_vf4_u003b_f1_u003b(m: ptr<function, vec4<f32>>, channel:
var local_1: f32;
var local_2: f32;
- let _e89 = (*channel);
- if (_e89 < 0.5f) {
- let _e92 = (*m)[0u];
- local = _e92;
+ let _e90 = (*channel);
+ if (_e90 < 0.5f) {
+ let _e93 = (*m)[0u];
+ local = _e93;
} else {
- let _e93 = (*channel);
- if (_e93 < 1.5f) {
- let _e96 = (*m)[1u];
- local_1 = _e96;
+ let _e94 = (*channel);
+ if (_e94 < 1.5f) {
+ let _e97 = (*m)[1u];
+ local_1 = _e97;
} else {
- let _e97 = (*channel);
- if (_e97 < 2.5f) {
- let _e100 = (*m)[2u];
- local_2 = _e100;
+ let _e98 = (*channel);
+ if (_e98 < 2.5f) {
+ let _e101 = (*m)[2u];
+ local_2 = _e101;
} else {
- let _e102 = (*m)[3u];
- local_2 = _e102;
+ let _e103 = (*m)[3u];
+ local_2 = _e103;
}
- let _e103 = local_2;
- local_1 = _e103;
+ let _e104 = local_2;
+ local_1 = _e104;
}
- let _e104 = local_1;
- local = _e104;
+ let _e105 = local_1;
+ local = _e105;
}
- let _e105 = local;
- return _e105;
+ let _e106 = local;
+ return _e106;
}
fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
@@ -353,32 +359,32 @@ fn mask2DUv_u0028_vf2_u003b(worldPos_1: ptr<function, vec2<f32>>) -> vec2<f32> {
var v: 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) {
+ let _e91 = unnamed.u_projection;
+ let _e92 = (*worldPos_1);
+ clip = (_e91 * vec4<f32>(_e92.x, _e92.y, 0f, 1f));
+ let _e98 = clip[3u];
+ if (_e98 <= 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);
+ let _e100 = clip;
+ let _e103 = clip[3u];
+ ndc = (((_e100.xy / vec2(_e103)) * 0.5f) + vec2(0.5f));
+ let _e111 = unnamed_1.u_mask2DRect[3u];
+ if (_e111 < 0f) {
+ let _e114 = ndc[1u];
+ local_3 = (1f - _e114);
} else {
- let _e116 = ndc[1u];
- local_3 = _e116;
+ let _e117 = ndc[1u];
+ local_3 = _e117;
}
- 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))));
+ let _e118 = local_3;
+ v = _e118;
+ let _e120 = unnamed_1.u_mask2DRect;
+ let _e123 = ndc[0u];
+ let _e126 = unnamed_1.u_mask2DRect[2u];
+ let _e128 = v;
+ let _e131 = unnamed_1.u_mask2DRect[3u];
+ return (_e120.xy + vec2<f32>((_e123 * _e126), (_e128 * abs(_e131))));
}
fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldPos_2: ptr<function, vec2<f32>>) -> f32 {
@@ -387,36 +393,36 @@ fn shadowFactor2D_u0028_f1_u003b_vf2_u003b(channel_1: ptr<function, f32>, worldP
var hidden: f32;
var param_5: vec4<f32>;
var param_6: f32;
- var phi_283_: bool;
+ var phi_293_: 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 _e92 = (*channel_1);
+ let _e93 = (_e92 < 0f);
+ phi_293_ = _e93;
+ if !(_e93) {
+ let _e97 = unnamed_1.u_mask2DRect[2u];
+ phi_293_ = (_e97 <= 0f);
}
- let _e99 = phi_283_;
- if _e99 {
+ let _e100 = phi_293_;
+ if _e100 {
return 1f;
}
- let _e100 = (*worldPos_2);
- param_4 = _e100;
- let _e101 = mask2DUv_u0028_vf2_u003b((&param_4));
- uv = _e101;
- let _e103 = uv[0u];
- if (_e103 < 0f) {
+ let _e101 = (*worldPos_2);
+ param_4 = _e101;
+ let _e102 = mask2DUv_u0028_vf2_u003b((&param_4));
+ uv = _e102;
+ let _e104 = uv[0u];
+ if (_e104 < 0f) {
return 1f;
}
- 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));
+ let _e106 = uv;
+ let _e107 = textureSampleLevel(u_shadow2D_est, u_shadow2D_ess, _e106, 0f);
+ param_5 = _e107;
+ let _e108 = (*channel_1);
+ param_6 = _e108;
+ let _e109 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_5), (&param_6));
+ hidden = _e109;
+ let _e110 = hidden;
+ return (1f - min(_e110, 1f));
}
fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPos_3: ptr<function, vec2<f32>>) -> f32 {
@@ -424,34 +430,34 @@ fn shapeFactor2D_u0028_f1_u003b_vf2_u003b(channel_2: ptr<function, f32>, worldPo
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);
+ var phi_337_: bool;
+
+ let _e91 = (*channel_2);
+ let _e92 = (_e91 < 0f);
+ phi_337_ = _e92;
+ if !(_e92) {
+ let _e96 = unnamed_1.u_mask2DRect[2u];
+ phi_337_ = (_e96 <= 0f);
}
- let _e98 = phi_327_;
- if _e98 {
+ let _e99 = phi_337_;
+ if _e99 {
return 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) {
+ let _e100 = (*worldPos_3);
+ param_7 = _e100;
+ let _e101 = mask2DUv_u0028_vf2_u003b((&param_7));
+ uv_1 = _e101;
+ let _e103 = uv_1[0u];
+ if (_e103 < 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);
+ let _e105 = uv_1;
+ let _e106 = textureSampleLevel(u_lightShape2D_est, u_lightShape2D_ess, _e105, 0f);
+ param_8 = _e106;
+ let _e107 = (*channel_2);
+ param_9 = _e107;
+ let _e108 = mask2DChannel_u0028_vf4_u003b_f1_u003b((&param_8), (&param_9));
+ return min(_e108, 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 {
@@ -460,74 +466,102 @@ 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 _e93 = (*sp);
+ let _e95 = (*sp);
+ if (dot(_e93.xy, _e95.xy) > 0.00000001f) {
+ let _e99 = (*sp);
+ local_4 = normalize(_e99.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 _e102 = local_4;
+ axis = _e102;
+ let _e103 = (*dist);
+ if (_e103 > 0.0001f) {
+ let _e105 = (*toLight);
+ let _e108 = (*dist);
+ local_5 = (-(_e105.xy) / vec2(_e108));
} else {
- let _e110 = axis;
- local_5 = _e110;
+ let _e111 = axis;
+ local_5 = _e111;
}
- 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 _e112 = local_5;
+ toFrag = _e112;
+ let _e114 = (*sp)[3u];
+ let _e116 = (*sp)[2u];
+ let _e117 = axis;
+ let _e118 = toFrag;
+ return smoothstep(_e114, _e116, dot(_e117, _e118));
}
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 _e89 = (*toLight_1);
+ if (dot(_e88, _e89) > 0.00000001f) {
+ let _e92 = (*toLight_1);
+ local_6 = normalize(_e92);
} else {
- let _e93 = (*N_1);
- local_6 = _e93;
+ let _e94 = (*N_1);
+ local_6 = _e94;
}
- let _e94 = local_6;
- return _e94;
+ let _e95 = local_6;
+ return _e95;
}
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 _e89 = (*reach);
+ let _e90 = (*dist_1);
+ let _e92 = (*reach);
+ let _e94 = (*fo)[0u];
+ ramp = clamp(((_e89 - _e90) / max((_e92 - _e94), 0.0001f)), 0f, 1f);
+ let _e99 = ramp;
+ let _e101 = (*fo)[1u];
+ return pow(_e99, max(_e101, 0.001f));
}
fn lightDistance_u0028_vf3_u003b(toLight_2: ptr<function, vec3<f32>>) -> f32 {
- let _e85 = (*toLight_2);
- return length(_e85.xy);
+ let _e86 = (*toLight_2);
+ return length(_e86.xy);
}
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));
+ let _e88 = (*pd);
+ let _e90 = (*worldPos_4);
+ let _e92 = (_e88.xy - _e90.xy);
+ let _e94 = (*pd)[3u];
+ return vec3<f32>(_e92.x, _e92.y, max(_e94, 1f));
+}
+
+fn shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b(sh_2: ptr<function, array<vec4<f32>, 9>>, N_2: ptr<function, vec3<f32>>) -> vec3<f32> {
+ let _e88 = (*sh_2)[0i];
+ let _e92 = (*sh_2)[1i];
+ let _e95 = (*N_2)[1u];
+ let _e100 = (*sh_2)[2i];
+ let _e103 = (*N_2)[2u];
+ let _e108 = (*sh_2)[3i];
+ let _e111 = (*N_2)[0u];
+ let _e116 = (*sh_2)[4i];
+ let _e119 = (*N_2)[0u];
+ let _e122 = (*N_2)[1u];
+ let _e127 = (*sh_2)[5i];
+ let _e130 = (*N_2)[1u];
+ let _e133 = (*N_2)[2u];
+ let _e138 = (*sh_2)[6i];
+ let _e141 = (*N_2)[2u];
+ let _e144 = (*N_2)[2u];
+ let _e151 = (*sh_2)[7i];
+ let _e154 = (*N_2)[0u];
+ let _e157 = (*N_2)[2u];
+ let _e162 = (*sh_2)[8i];
+ let _e165 = (*N_2)[0u];
+ let _e167 = (*N_2)[0u];
+ let _e170 = (*N_2)[1u];
+ let _e172 = (*N_2)[1u];
+ return (((((((((_e88.xyz * 0.282095f) + (_e92.xyz * (0.488603f * _e95))) + (_e100.xyz * (0.488603f * _e103))) + (_e108.xyz * (0.488603f * _e111))) + (_e116.xyz * ((1.092548f * _e119) * _e122))) + (_e127.xyz * ((1.092548f * _e130) * _e133))) + (_e138.xyz * (0.315392f * (((3f * _e141) * _e144) - 1f)))) + (_e151.xyz * ((1.092548f * _e154) * _e157))) + (_e162.xyz * (0.546274f * ((_e165 * _e167) - (_e170 * _e172)))));
}
fn envDirection_u0028_vf3_u003b(d_1: ptr<function, vec3<f32>>) -> vec3<f32> {
@@ -535,499 +569,515 @@ 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 _e91 = unnamed_1.u_envTint[3u];
+ a_3 = -(_e91);
+ let _e93 = a_3;
+ s = sin(_e93);
+ let _e95 = a_3;
+ c = cos(_e95);
+ let _e97 = c;
+ let _e99 = (*d_1)[0u];
+ let _e101 = s;
+ let _e103 = (*d_1)[2u];
+ let _e107 = (*d_1)[1u];
+ let _e108 = s;
+ let _e111 = (*d_1)[0u];
+ let _e113 = c;
+ let _e115 = (*d_1)[2u];
+ return vec3<f32>(((_e97 * _e99) + (_e101 * _e103)), _e107, ((-(_e108) * _e111) + (_e113 * _e115)));
}
fn envIrradiance_u0028_vf3_u003b(Nw: ptr<function, vec3<f32>>) -> vec3<f32> {
- var N_2: vec3<f32>;
+ var sh_3: vec3<f32>;
var param_10: vec3<f32>;
- var sh_2: vec3<f32>;
-
- 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 _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));
+ var param_11: array<vec4<f32>, 9>;
+ var param_12: vec3<f32>;
+
+ let _e90 = (*Nw);
+ param_10 = _e90;
+ let _e91 = envDirection_u0028_vf3_u003b((&param_10));
+ let _e93 = unnamed_1.u_envIrradiance;
+ param_11[0i] = _e93[0];
+ param_11[1i] = _e93[1];
+ param_11[2i] = _e93[2];
+ param_11[3i] = _e93[3];
+ param_11[4i] = _e93[4];
+ param_11[5i] = _e93[5];
+ param_11[6i] = _e93[6];
+ param_11[7i] = _e93[7];
+ param_11[8i] = _e93[8];
+ param_12 = _e91;
+ let _e112 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_11), (&param_12));
+ sh_3 = _e112;
+ let _e114 = unnamed_1.u_ambient;
+ let _e116 = sh_3;
+ let _e119 = unnamed_1.u_envTint;
+ return (_e114.xyz + (max(_e116, vec3<f32>(0f, 0f, 0f)) * _e119.xyz));
+}
+
+fn indirectIrradiance_u0028_vf3_u003b(N_3: ptr<function, vec3<f32>>) -> vec3<f32> {
+ var param_13: array<vec4<f32>, 9>;
+ var param_14: vec3<f32>;
+ var param_15: vec3<f32>;
+
+ let _e92 = unnamed_2.u_probeIrradiance[0i][3u];
+ if (_e92 > 0.5f) {
+ let _e95 = unnamed_2.u_probeIrradiance;
+ param_13[0i] = _e95[0];
+ param_13[1i] = _e95[1];
+ param_13[2i] = _e95[2];
+ param_13[3i] = _e95[3];
+ param_13[4i] = _e95[4];
+ param_13[5i] = _e95[5];
+ param_13[6i] = _e95[6];
+ param_13[7i] = _e95[7];
+ param_13[8i] = _e95[8];
+ let _e114 = (*N_3);
+ param_14 = _e114;
+ let _e115 = shIrradiance_u0028_vf4_u005b_9_u005d_u003b_vf3_u003b((&param_13), (&param_14));
+ return max(_e115, vec3<f32>(0f, 0f, 0f));
+ }
+ let _e117 = (*N_3);
+ param_15 = _e117;
+ let _e118 = envIrradiance_u0028_vf3_u003b((&param_15));
+ return _e118;
}
-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> {
+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_4: 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_11: vec3<f32>;
+ var param_16: vec3<f32>;
var gloss: vec3<f32>;
var i: i32;
var pd_1: vec4<f32>;
var col: vec4<f32>;
- var sh_3: vec4<f32>;
+ var sh_4: vec4<f32>;
var fo_1: vec4<f32>;
var target_: vec2<f32>;
var castShadow: bool;
var toL: vec3<f32>;
- var param_12: vec4<f32>;
- var param_13: vec4<f32>;
- var param_14: vec3<f32>;
- var dist_2: f32;
- var param_15: vec3<f32>;
- var atten: f32;
- var param_16: f32;
- var param_17: f32;
+ var param_17: vec4<f32>;
var param_18: vec4<f32>;
- var L_1: vec3<f32>;
var param_19: vec3<f32>;
+ var dist_2: f32;
var param_20: vec3<f32>;
+ var atten: f32;
+ var param_21: f32;
+ var param_22: f32;
+ var param_23: vec4<f32>;
+ var L_1: vec3<f32>;
+ var param_24: vec3<f32>;
+ var param_25: vec3<f32>;
var toLight_3: vec2<f32>;
var local_7: vec2<f32>;
var sp_1: vec4<f32>;
var toL_1: vec3<f32>;
- var param_21: vec4<f32>;
- var param_22: vec4<f32>;
- var param_23: vec3<f32>;
- var dist_3: f32;
- var param_24: vec3<f32>;
- var param_25: f32;
- var param_26: f32;
+ var param_26: vec4<f32>;
var param_27: vec4<f32>;
var param_28: vec3<f32>;
+ var dist_3: f32;
var param_29: vec3<f32>;
- var param_30: vec4<f32>;
- var param_31: vec4<f32>;
- var param_32: vec3<f32>;
- var param_33: f32;
- var param_34: f32;
- var param_35: vec2<f32>;
- var param_36: f32;
- var param_37: vec2<f32>;
+ var param_30: f32;
+ var param_31: f32;
+ var param_32: vec4<f32>;
+ var param_33: vec3<f32>;
+ var param_34: vec3<f32>;
+ var param_35: vec4<f32>;
+ var param_36: vec4<f32>;
+ var param_37: vec3<f32>;
+ var param_38: f32;
+ var param_39: f32;
+ var param_40: vec2<f32>;
+ var param_41: f32;
+ var param_42: 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 param_43: vec3<f32>;
+ var param_44: vec3<f32>;
+ var param_45: vec3<f32>;
+ var param_46: vec2<f32>;
+ var param_47: i32;
+ var param_48: i32;
var ndotl: f32;
var radiance: vec3<f32>;
var H: vec3<f32>;
var brdf: f32;
- var param_44: f32;
- var param_45: f32;
- var param_46: f32;
- var param_47: f32;
- var param_48: f32;
var param_49: f32;
- var param_50: vec3<f32>;
- var ab: vec2<f32>;
+ var param_50: f32;
var param_51: f32;
var param_52: f32;
- var param_53: vec3<f32>;
+ var param_53: f32;
var param_54: f32;
- var phi_886_: bool;
- var phi_959_: bool;
+ var param_55: vec3<f32>;
+ var ab: vec2<f32>;
+ var param_56: f32;
+ var param_57: f32;
+ var param_58: vec3<f32>;
+ var param_59: f32;
+ var phi_962_: bool;
+ var phi_1035_: 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 _e164 = (*albedo);
+ let _e165 = (*metallic);
+ F0_1 = mix(vec3<f32>(0.04f, 0.04f, 0.04f), _e164, vec3(_e165));
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);
+ let _e169 = (*roughness_3);
+ a_4 = max((_e168 * _e169), 0.001f);
+ let _e172 = (*N_4);
+ let _e173 = (*V);
+ NdotV_2 = max(dot(_e172, _e173), 0.0001f);
+ let _e176 = (*N_4);
+ param_16 = _e176;
+ let _e177 = indirectIrradiance_u0028_vf3_u003b((&param_16));
+ let _e178 = (*ao);
+ lit = (_e177 * _e178);
gloss = vec3<f32>(0f, 0f, 0f);
i = 0i;
loop {
- let _e179 = i;
- if (_e179 < 16i) {
- let _e181 = i;
- let _e185 = unnamed_1.u_lights[_e181].posDir;
- pd_1 = _e185;
- let _e186 = i;
- let _e190 = unnamed_1.u_lights[_e186].color;
- col = _e190;
- let _e191 = i;
- 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;
+ let _e180 = i;
+ if (_e180 < 16i) {
+ let _e182 = i;
+ let _e186 = unnamed_1.u_lights[_e182].posDir;
+ pd_1 = _e186;
+ let _e187 = i;
+ let _e191 = unnamed_1.u_lights[_e187].color;
+ col = _e191;
+ let _e192 = i;
+ let _e196 = unnamed_1.u_lights[_e192].shadow;
+ sh_4 = _e196;
+ let _e197 = i;
+ let _e201 = unnamed_1.u_lights[_e197].falloff;
+ fo_1 = _e201;
+ let _e202 = pd_1;
+ target_ = _e202.xy;
castShadow = true;
- 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;
+ let _e205 = pd_1[2u];
+ if (_e205 < 0.5f) {
+ let _e207 = pd_1;
+ param_17 = _e207;
+ let _e208 = sh_4;
+ param_18 = _e208;
+ let _e209 = (*worldPos_5);
+ param_19 = _e209;
+ let _e210 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_17), (&param_18), (&param_19));
+ toL = _e210;
+ let _e211 = toL;
+ param_20 = _e211;
+ let _e212 = lightDistance_u0028_vf3_u003b((&param_20));
+ dist_2 = _e212;
+ let _e214 = pd_1[3u];
+ let _e216 = dist_2;
+ param_21 = _e216;
+ param_22 = max(_e214, 0.0001f);
+ let _e217 = fo_1;
+ param_23 = _e217;
+ let _e218 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_21), (&param_22), (&param_23));
+ atten = _e218;
+ let _e219 = toL;
+ param_24 = _e219;
+ let _e220 = (*N_4);
+ param_25 = _e220;
+ let _e221 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_24), (&param_25));
+ L_1 = _e221;
} else {
- let _e222 = pd_1[2u];
- if (_e222 < 1.5f) {
+ let _e223 = pd_1[2u];
+ if (_e223 < 1.5f) {
atten = 1f;
- 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));
+ let _e225 = pd_1;
+ let _e226 = _e225.xy;
+ let _e228 = pd_1[3u];
+ L_1 = normalize(-(vec3<f32>(_e226.x, _e226.y, _e228)));
+ let _e234 = pd_1;
+ let _e236 = pd_1;
+ if (dot(_e234.xy, _e236.xy) > 0.00000001f) {
+ let _e240 = pd_1;
+ local_7 = normalize(-(_e240.xy));
} else {
local_7 = vec2<f32>(0f, 0f);
}
- 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 _e244 = local_7;
+ toLight_3 = _e244;
+ let _e246 = sh_4[1u];
+ let _e247 = (_e246 > 0f);
+ phi_962_ = _e247;
+ if _e247 {
let _e248 = toLight_3;
- phi_886_ = (dot(_e247, _e248) > 0.5f);
+ let _e249 = toLight_3;
+ phi_962_ = (dot(_e248, _e249) > 0.5f);
}
- let _e252 = phi_886_;
- castShadow = _e252;
- let _e253 = (*worldPos_5);
- let _e255 = toLight_3;
- let _e257 = sh_3[1u];
- target_ = (_e253.xy + (_e255 * _e257));
+ let _e253 = phi_962_;
+ castShadow = _e253;
+ let _e254 = (*worldPos_5);
+ let _e256 = toLight_3;
+ let _e258 = sh_4[1u];
+ target_ = (_e254.xy + (_e256 * _e258));
} else {
- 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_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 _e261 = i;
+ let _e265 = unnamed_1.u_lights[_e261].spot;
+ sp_1 = _e265;
+ let _e266 = pd_1;
+ param_26 = _e266;
+ let _e267 = sh_4;
+ param_27 = _e267;
+ let _e268 = (*worldPos_5);
+ param_28 = _e268;
+ let _e269 = lightVector_u0028_vf4_u003b_vf4_u003b_vf3_u003b((&param_26), (&param_27), (&param_28));
+ toL_1 = _e269;
+ let _e270 = toL_1;
+ param_29 = _e270;
+ let _e271 = lightDistance_u0028_vf3_u003b((&param_29));
+ dist_3 = _e271;
+ let _e273 = pd_1[3u];
+ let _e275 = dist_3;
+ param_30 = _e275;
+ param_31 = max(_e273, 0.0001f);
+ let _e276 = fo_1;
+ param_32 = _e276;
+ let _e277 = distanceFalloff_u0028_f1_u003b_f1_u003b_vf4_u003b((&param_30), (&param_31), (&param_32));
+ atten = _e277;
+ let _e278 = toL_1;
+ param_33 = _e278;
+ let _e279 = (*N_4);
+ param_34 = _e279;
+ let _e280 = towardLight_u0028_vf3_u003b_vf3_u003b((&param_33), (&param_34));
+ L_1 = _e280;
+ let _e281 = sp_1;
+ param_35 = _e281;
+ let _e282 = sh_4;
+ param_36 = _e282;
+ let _e283 = toL_1;
+ param_37 = _e283;
+ let _e284 = dist_3;
+ param_38 = _e284;
+ let _e285 = spotCone_u0028_vf4_u003b_vf4_u003b_vf3_u003b_f1_u003b((&param_35), (&param_36), (&param_37), (&param_38));
+ let _e286 = atten;
+ atten = (_e286 * _e285);
}
}
- 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 _e289 = col[3u];
+ let _e291 = atten;
+ if ((_e289 > 0f) && (_e291 > 0f)) {
+ let _e295 = fo_1[3u];
+ param_39 = _e295;
+ let _e296 = (*worldPos_5);
+ param_40 = _e296.xy;
+ let _e298 = shapeFactor2D_u0028_f1_u003b_vf2_u003b((&param_39), (&param_40));
+ let _e299 = atten;
+ atten = (_e299 * _e298);
}
- let _e300 = castShadow;
- phi_959_ = _e300;
- if _e300 {
- let _e302 = col[3u];
- phi_959_ = (_e302 > 0f);
+ let _e301 = castShadow;
+ phi_1035_ = _e301;
+ if _e301 {
+ let _e303 = col[3u];
+ phi_1035_ = (_e303 > 0f);
}
- 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 _e306 = phi_1035_;
+ let _e307 = atten;
+ if (_e306 && (_e307 > 0f)) {
+ let _e310 = i;
+ let _e315 = unnamed_1.u_lights[_e310].shadowMap[3u];
+ param_41 = _e315;
+ let _e316 = (*worldPos_5);
+ param_42 = _e316.xy;
+ let _e318 = shadowFactor2D_u0028_f1_u003b_vf2_u003b((&param_41), (&param_42));
+ let _e320 = fo_1[2u];
+ let _e322 = atten;
+ atten = (_e322 * mix(1f, _e318, _e320));
}
- 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 _e324 = i;
+ let _e328 = unnamed_1.u_lights[_e324].shadowMap;
+ sm = _e328;
+ let _e330 = sm[1u];
+ let _e332 = atten;
+ if ((_e330 > 0f) && (_e332 > 0f)) {
+ let _e336 = sh_4[0u];
+ let _e338 = sm[2u];
+ let _e341 = sm[0u];
+ let _e344 = sm[1u];
+ let _e346 = (*worldPos_5);
+ param_43 = _e346;
+ let _e347 = (*N_4);
+ param_44 = _e347;
+ let _e348 = L_1;
+ param_45 = _e348;
+ param_46 = vec2<f32>(_e336, _e338);
+ param_47 = i32(_e341);
+ param_48 = i32(_e344);
+ let _e349 = shadowFactor3D_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf2_u003b_i1_u003b_i1_u003b((&param_43), (&param_44), (&param_45), (&param_46), (&param_47), (&param_48));
+ let _e351 = fo_1[2u];
+ let _e353 = atten;
+ atten = (_e353 * mix(1f, _e349, _e351));
}
- 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_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)));
+ let _e355 = (*N_4);
+ let _e356 = L_1;
+ ndotl = max(dot(_e355, _e356), 0f);
+ let _e359 = col;
+ let _e362 = col[3u];
+ let _e363 = ndotl;
+ let _e365 = atten;
+ radiance = (_e359.xyz * ((_e362 * _e363) * _e365));
+ let _e368 = radiance;
+ let _e369 = lit;
+ lit = (_e369 + _e368);
+ let _e371 = (*specular);
+ if (_e371 > 0f) {
+ let _e373 = L_1;
+ let _e374 = (*V);
+ H = normalize((_e373 + _e374));
+ let _e377 = (*N_4);
+ let _e378 = H;
+ param_49 = max(dot(_e377, _e378), 0f);
+ let _e381 = a_4;
+ param_50 = _e381;
+ let _e382 = distributionGGX_u0028_f1_u003b_f1_u003b((&param_49), (&param_50));
+ let _e383 = NdotV_2;
+ param_51 = _e383;
+ let _e384 = ndotl;
+ param_52 = _e384;
+ let _e385 = (*roughness_3);
+ param_53 = _e385;
+ let _e386 = geometrySmith_u0028_f1_u003b_f1_u003b_f1_u003b((&param_51), (&param_52), (&param_53));
+ let _e388 = NdotV_2;
+ let _e390 = ndotl;
+ brdf = ((_e382 * _e386) / max(((4f * _e388) * _e390), 0.0001f));
+ let _e394 = radiance;
+ let _e395 = (*V);
+ let _e396 = H;
+ param_54 = max(dot(_e395, _e396), 0f);
+ let _e399 = F0_1;
+ param_55 = _e399;
+ let _e400 = fresnelSchlick_u0028_f1_u003b_vf3_u003b((&param_54), (&param_55));
+ let _e402 = brdf;
+ let _e404 = (*specular);
+ let _e407 = gloss;
+ gloss = (_e407 + ((_e394 * _e400) * ((_e402 * 3.1415927f) * _e404)));
}
continue;
} else {
break;
}
continuing {
- let _e408 = i;
- i = (_e408 + 1i);
+ let _e409 = i;
+ i = (_e409 + 1i);
}
}
- 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);
+ let _e411 = NdotV_2;
+ param_56 = _e411;
+ let _e412 = (*roughness_3);
+ param_57 = _e412;
+ let _e413 = envBRDFApprox_u0028_f1_u003b_f1_u003b((&param_56), (&param_57));
+ ab = _e413;
+ let _e414 = (*V);
+ let _e416 = (*N_4);
+ param_58 = reflect(-(_e414), _e416);
+ let _e418 = (*roughness_3);
+ param_59 = _e418;
+ let _e419 = envRadiance_u0028_vf3_u003b_f1_u003b((&param_58), (&param_59));
+ let _e420 = (*ao);
+ let _e421 = (*specular);
+ let _e424 = F0_1;
+ let _e426 = ab[0u];
+ let _e429 = ab[1u];
+ let _e433 = gloss;
+ gloss = (_e433 + ((_e419 * (_e420 * _e421)) * ((_e424 * _e426) + vec3(_e429))));
+ let _e435 = (*albedo);
+ let _e436 = (*metallic);
+ let _e439 = lit;
+ let _e441 = gloss;
+ return (((_e435 * (1f - _e436)) * _e439) + _e441);
}
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_6);
- local_8 = normalize((_e91.xyz - _e93));
+ let _e89 = unnamed.u_camera[3u];
+ if (_e89 > 0.5f) {
+ let _e92 = unnamed.u_camera;
+ let _e94 = (*worldPos_6);
+ local_8 = normalize((_e92.xyz - _e94));
} else {
- let _e97 = unnamed.u_camera;
- local_8 = _e97.xyz;
+ let _e98 = unnamed.u_camera;
+ local_8 = _e98.xyz;
}
- let _e99 = local_8;
- return _e99;
+ let _e100 = local_8;
+ return _e100;
}
-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> {
+fn applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b(albedo_1: ptr<function, vec3<f32>>, N_5: ptr<function, vec3<f32>>, worldPos_7: ptr<function, vec2<f32>>, ao_1: ptr<function, f32>) -> vec3<f32> {
var P: vec3<f32>;
- var param_55: vec3<f32>;
- var param_56: vec3<f32>;
- var param_57: vec3<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 _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);
+ var param_60: vec3<f32>;
+ var param_61: vec3<f32>;
+ var param_62: vec3<f32>;
+ var param_63: vec3<f32>;
+ var param_64: vec3<f32>;
+ var param_65: f32;
+ var param_66: f32;
+ var param_67: f32;
+ var param_68: f32;
+
+ let _e99 = (*worldPos_7);
+ P = vec3<f32>(_e99.x, _e99.y, 0f);
+ let _e103 = P;
+ param_60 = _e103;
+ let _e104 = viewDirection_u0028_vf3_u003b((&param_60));
+ let _e105 = (*albedo_1);
+ param_61 = _e105;
+ let _e106 = (*N_5);
+ param_62 = _e106;
+ let _e107 = P;
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;
+ param_64 = _e104;
+ param_65 = 0f;
+ param_66 = 1f;
+ param_67 = 0f;
+ let _e108 = (*ao_1);
+ param_68 = _e108;
+ let _e109 = applyLightingPBR_u0028_vf3_u003b_vf3_u003b_vf3_u003b_vf3_u003b_f1_u003b_f1_u003b_f1_u003b_f1_u003b((&param_61), (&param_62), (&param_63), (&param_64), (&param_65), (&param_66), (&param_67), (&param_68));
+ return _e109;
}
-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;
+fn applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b(albedo_2: ptr<function, vec3<f32>>, N_6: ptr<function, vec3<f32>>, worldPos_8: ptr<function, vec2<f32>>) -> vec3<f32> {
+ var param_69: vec3<f32>;
+ var param_70: vec3<f32>;
+ var param_71: vec2<f32>;
+ var param_72: 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;
+ let _e92 = (*albedo_2);
+ param_69 = _e92;
+ let _e93 = (*N_6);
+ param_70 = _e93;
+ let _e94 = (*worldPos_8);
+ param_71 = _e94;
+ param_72 = 1f;
+ let _e95 = applyLighting2DAO_u0028_vf3_u003b_vf3_u003b_vf2_u003b_f1_u003b((&param_69), (&param_70), (&param_71), (&param_72));
+ return _e95;
}
fn main_1() {
var base: vec4<f32>;
- var N_6: vec3<f32>;
+ var N_7: vec3<f32>;
var lit_1: vec3<f32>;
- 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 _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);
+ var param_73: vec3<f32>;
+ var param_74: vec3<f32>;
+ var param_75: vec2<f32>;
+
+ let _e91 = v_texCoord_1;
+ let _e92 = textureSample(es_bt0_est, es_bt0_ess, _e91);
+ let _e93 = v_color_1;
+ base = (_e92 * _e93);
+ N_7 = vec3<f32>(0f, 0f, 1f);
+ let _e95 = base;
+ param_73 = _e95.xyz;
+ let _e97 = N_7;
+ param_74 = _e97;
+ let _e98 = v_worldPos_1;
+ param_75 = _e98;
+ let _e99 = applyLighting2D_u0028_vf3_u003b_vf3_u003b_vf2_u003b((&param_73), (&param_74), (&param_75));
+ lit_1 = _e99;
+ let _e100 = lit_1;
+ let _e102 = base[3u];
+ fragColor = vec4<f32>(_e100.x, _e100.y, _e100.z, _e102);
return;
}
diff --git a/fixtures/scenes/mesh-morph-two.esscene b/fixtures/scenes/mesh-morph-two.esscene
new file mode 100644
index 000000000..644e9c5a4
--- /dev/null
+++ b/fixtures/scenes/mesh-morph-two.esscene
@@ -0,0 +1,114 @@
+{
+ "version": 4,
+ "name": "MeshMorphTwo",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 100,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Quarter",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 50,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/morph-quad.esmesh",
+ "color": {
+ "r": 0,
+ "g": 1,
+ "b": 0,
+ "a": 1
+ },
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshMorph",
+ "data": {
+ "weights": [
+ 0.25
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Whole",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": -50,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/morph-quad.esmesh",
+ "color": {
+ "r": 0,
+ "g": 1,
+ "b": 0,
+ "a": 1
+ },
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshMorph",
+ "data": {
+ "weights": [
+ 1
+ ]
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/probe-blend.esscene b/fixtures/scenes/probe-blend.esscene
new file mode 100644
index 000000000..74414a26c
--- /dev/null
+++ b/fixtures/scenes/probe-blend.esscene
@@ -0,0 +1,182 @@
+{
+ "version": 4,
+ "name": "ProbeBlend",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 300,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Probes",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "LightProbeVolume",
+ "data": {
+ "probes": "/scenes/probe-ends.esprobes",
+ "halfExtents": {
+ "x": 120,
+ "y": 400,
+ "z": 400
+ },
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Left",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -120,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 0.2,
+ "y": 0.2,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Middle",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 0.2,
+ "y": 0.2,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Right",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 120,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 0.2,
+ "y": 0.2,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/probe-blend.textures.json b/fixtures/scenes/probe-blend.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/fixtures/scenes/probe-blend.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/fixtures/scenes/probe-blue.esprobes b/fixtures/scenes/probe-blue.esprobes
new file mode 100644
index 000000000..17f4d62b7
--- /dev/null
+++ b/fixtures/scenes/probe-blue.esprobes
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "resolution": [1,1,1],
+ "irradiance": [0,0,3.544905085166345,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+}
diff --git a/fixtures/scenes/probe-ends.esprobes b/fixtures/scenes/probe-ends.esprobes
new file mode 100644
index 000000000..7c59ae697
--- /dev/null
+++ b/fixtures/scenes/probe-ends.esprobes
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "resolution": [2,1,1],
+ "irradiance": [3.544905085166345,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.544905085166345,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+}
diff --git a/fixtures/scenes/probe-facing.esprobes b/fixtures/scenes/probe-facing.esprobes
new file mode 100644
index 000000000..44643f54a
--- /dev/null
+++ b/fixtures/scenes/probe-facing.esprobes
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "resolution": [1,1,1],
+ "irradiance": [1.7724525425831725,1.7724525425831725,1.7724525425831725,0,0,0,0,0,0,1.0233256856793758,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+}
diff --git a/fixtures/scenes/probe-facing.esscene b/fixtures/scenes/probe-facing.esscene
new file mode 100644
index 000000000..9b65261da
--- /dev/null
+++ b/fixtures/scenes/probe-facing.esscene
@@ -0,0 +1,104 @@
+{
+ "version": 4,
+ "name": "ProbeFacing",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 300,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Probes",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "LightProbeVolume",
+ "data": {
+ "probes": "/scenes/probe-facing.esprobes",
+ "halfExtents": {
+ "x": 400,
+ "y": 400,
+ "z": 400
+ },
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "LitTriangles",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/probe-facing.textures.json b/fixtures/scenes/probe-facing.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/fixtures/scenes/probe-facing.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/fixtures/scenes/probe-lightmap.esscene b/fixtures/scenes/probe-lightmap.esscene
new file mode 100644
index 000000000..cf9b9f1a1
--- /dev/null
+++ b/fixtures/scenes/probe-lightmap.esscene
@@ -0,0 +1,155 @@
+{
+ "version": 4,
+ "name": "ProbeLightmap",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 300,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Probes",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "LightProbeVolume",
+ "data": {
+ "probes": "/scenes/probe-blue.esprobes",
+ "halfExtents": {
+ "x": 400,
+ "y": 400,
+ "z": 400
+ },
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Baked",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -150,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lightmap-quad.esmesh"
+ }
+ },
+ {
+ "type": "MeshLightmap",
+ "data": {
+ "lightmap": "@uuid:bbbbbbbb-1111-2222-3333-555555555555",
+ "scaleOffset": {
+ "x": 1,
+ "y": 1,
+ "z": 0,
+ "w": 0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Probed",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 150,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 0.5,
+ "y": 0.5,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/probe-lightmap.textures.json b/fixtures/scenes/probe-lightmap.textures.json
new file mode 100644
index 000000000..51ecee5bf
--- /dev/null
+++ b/fixtures/scenes/probe-lightmap.textures.json
@@ -0,0 +1,3 @@
+{
+ "bbbbbbbb-1111-2222-3333-555555555555": "/scenes/lightmap-atlas.png"
+}
diff --git a/fixtures/scenes/probe-lit.esscene b/fixtures/scenes/probe-lit.esscene
new file mode 100644
index 000000000..d92581ab6
--- /dev/null
+++ b/fixtures/scenes/probe-lit.esscene
@@ -0,0 +1,104 @@
+{
+ "version": 4,
+ "name": "ProbeLit",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 300,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Probes",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "LightProbeVolume",
+ "data": {
+ "probes": "/scenes/probe-red.esprobes",
+ "halfExtents": {
+ "x": 400,
+ "y": 400,
+ "z": 400
+ },
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "LitTriangles",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "layer": 0,
+ "enabled": true,
+ "lit": true,
+ "mesh": "/scenes/lit-triangles.esmesh"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/probe-lit.textures.json b/fixtures/scenes/probe-lit.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/fixtures/scenes/probe-lit.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/fixtures/scenes/probe-red.esprobes b/fixtures/scenes/probe-red.esprobes
new file mode 100644
index 000000000..f6987291e
--- /dev/null
+++ b/fixtures/scenes/probe-red.esprobes
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "resolution": [1,1,1],
+ "irradiance": [3.544905085166345,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+}
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index bdb5b6a46..2715dd9b6 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,11 +1,11 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1729 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1731 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"ca7cd852d3bc316f"
+"cccf3c7425936b84"
```
## ANCHOR_AXES — const @experimental
@@ -823,7 +823,7 @@ type: AssetFieldType
## AssetFieldType — type @public
```
-'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment'
+'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume'
```
## AssetGroupDef — interface @experimental
@@ -4591,6 +4591,18 @@ sourceAngle: number
type: LightType
```
+## LightProbeVolume — const @experimental
+```
+BuiltinComponentDef<LightProbeVolumeData>
+```
+
+## LightProbeVolumeData — interface @experimental
+```
+enabled: boolean
+halfExtents: Vec3
+probes: number
+```
+
## LightStatus — interface @experimental
```
accepted: boolean
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index bfa98022c..6c0e932ee 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,11 +1,11 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 99 beta · 1748 experimental · 3 deprecated
+Symbols: 114 public · 99 beta · 1750 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"ca7cd852d3bc316f"
+"cccf3c7425936b84"
```
## ANCHOR_AXES — const @experimental
@@ -823,7 +823,7 @@ type: AssetFieldType
## AssetFieldType — type @public
```
-'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment'
+'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume'
```
## AssetGroupDef — interface @experimental
@@ -4599,6 +4599,18 @@ sourceAngle: number
type: LightType
```
+## LightProbeVolume — const @experimental
+```
+BuiltinComponentDef<LightProbeVolumeData>
+```
+
+## LightProbeVolumeData — interface @experimental
+```
+enabled: boolean
+halfExtents: Vec3
+probes: number
+```
+
## LightStatus — interface @experimental
```
accepted: boolean
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index cf1d23960..e64d74330 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 96 beta · 1728 experimental · 3 deprecated
+Symbols: 114 public · 96 beta · 1730 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -818,7 +818,7 @@ type: AssetFieldType
## AssetFieldType — type @public
```
-'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment'
+'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume'
```
## AssetGroupDef — interface @experimental
@@ -4586,6 +4586,18 @@ sourceAngle: number
type: LightType
```
+## LightProbeVolume — const @experimental
+```
+BuiltinComponentDef<LightProbeVolumeData>
+```
+
+## LightProbeVolumeData — interface @experimental
+```
+enabled: boolean
+halfExtents: Vec3
+probes: number
+```
+
## LightStatus — interface @experimental
```
accepted: boolean
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index eb80293c2..e3665e953 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1750 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1752 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -818,7 +818,7 @@ type: AssetFieldType
## AssetFieldType — type @public
```
-'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment'
+'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume'
```
## AssetGroupDef — interface @experimental
@@ -4586,6 +4586,18 @@ sourceAngle: number
type: LightType
```
+## LightProbeVolume — const @experimental
+```
+BuiltinComponentDef<LightProbeVolumeData>
+```
+
+## LightProbeVolumeData — interface @experimental
+```
+enabled: boolean
+halfExtents: Vec3
+probes: number
+```
+
## LightStatus — interface @experimental
```
accepted: boolean
diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.md
index 76e76f30f..783274f7a 100644
--- a/sdk/etc/wasm.api.md
+++ b/sdk/etc/wasm.api.md
@@ -30,6 +30,7 @@ addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLODGroup: (entity: Entity, component: LODGroup) => void
addLight: (entity: Entity, component: Light) => void
+addLightProbeVolume: (entity: Entity, component: LightProbeVolume) => void
addMeshCollider3D: (entity: Entity, component: MeshCollider3D) => void
addMeshLightmap: (entity: Entity, component: MeshLightmap) => void
addMeshMorph: (entity: Entity, component: MeshMorph) => void
@@ -78,6 +79,7 @@ getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLODGroup: (entity: Entity) => LODGroup
getLight: (entity: Entity) => Light
+getLightProbeVolume: (entity: Entity) => LightProbeVolume
getMeshCollider3D: (entity: Entity) => MeshCollider3D
getMeshLightmap: (entity: Entity) => MeshLightmap
getMeshMorph: (entity: Entity) => MeshMorph
@@ -122,6 +124,7 @@ hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLODGroup: (entity: Entity) => boolean
hasLight: (entity: Entity) => boolean
+hasLightProbeVolume: (entity: Entity) => boolean
hasMeshCollider3D: (entity: Entity) => boolean
hasMeshLightmap: (entity: Entity) => boolean
hasMeshMorph: (entity: Entity) => boolean
@@ -167,6 +170,7 @@ removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLODGroup: (entity: Entity) => void
removeLight: (entity: Entity) => void
+removeLightProbeVolume: (entity: Entity) => void
removeMeshCollider3D: (entity: Entity) => void
removeMeshLightmap: (entity: Entity) => void
removeMeshMorph: (entity: Entity) => void
@@ -368,6 +372,8 @@ postprocess_setScreenUniformVec4: (passName: string, uniform: string, x: number,
postprocess_setUniformFloat: (passName: string, uniform: string, value: number) => void
postprocess_setUniformVec4: (passName: string, uniform: string, x: number, y: number, z: number, w: number) => void
postprocess_shutdown: () => void
+probe_volume_create: ((resX: number, resY: number, resZ: number, shPtr: number) => number) | undefined
+probe_volume_release: ((volumeHandle: number) => void) | undefined
provideReplacementDevice: (() => boolean) | undefined
recoverDevice: (() => boolean) | undefined
registryLayoutEpoch: (registry: CppRegistry) => number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 0823c7e29..007f55151 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1740 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1742 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -818,7 +818,7 @@ type: AssetFieldType
## AssetFieldType — type @public
```
-'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment'
+'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume'
```
## AssetGroupDef — interface @experimental
@@ -4593,6 +4593,18 @@ sourceAngle: number
type: LightType
```
+## LightProbeVolume — const @experimental
+```
+BuiltinComponentDef<LightProbeVolumeData>
+```
+
+## LightProbeVolumeData — interface @experimental
+```
+enabled: boolean
+halfExtents: Vec3
+probes: number
+```
+
## LightStatus — interface @experimental
```
accepted: boolean
diff --git a/sdk/src/asset/Assets.ts b/sdk/src/asset/Assets.ts
index 3646c4c4a..f4ca6d3fe 100644
--- a/sdk/src/asset/Assets.ts
+++ b/sdk/src/asset/Assets.ts
@@ -32,6 +32,7 @@ import { MeshAssetLoader, type MeshResult } from './loaders/MeshAssetLoader';
import { nativeEngineApi, type EngineApi } from '../ecs/bridge/engineApi';
import { isBuiltinMeshRef } from './builtinMeshes';
import { EnvironmentAssetLoader } from './loaders/EnvironmentAssetLoader';
+import { ProbeVolumeAssetLoader } from './loaders/ProbeVolumeAssetLoader';
import { FontAssetLoader } from './loaders/FontAssetLoader';
import { AudioAssetLoader } from './loaders/AudioAssetLoader';
import { AnimClipAssetLoader } from './loaders/AnimClipAssetLoader';
@@ -280,6 +281,7 @@ export interface SceneAssetResult {
fontHandles: Map<string, number>;
meshHandles: Map<string, number>;
environmentHandles: Map<string, number>;
+ probeVolumeHandles: Map<string, number>;
releaseCallbacks: ReleaseCallback[];
/**
* What this preload actually acquired. Release side reads THIS rather than
@@ -1304,6 +1306,7 @@ export class Assets {
const avatarPaths = discovered.byType.get('avatar') ?? new Set<string>();
const meshPaths = discovered.byType.get('mesh') ?? new Set<string>();
const environmentPaths = discovered.byType.get('environment') ?? new Set<string>();
+ const probeVolumePaths = discovered.byType.get('probeVolume') ?? new Set<string>();
const spinePairs = discovered.spines;
const textureHandles = new Map<string, number>();
@@ -1311,6 +1314,7 @@ export class Assets {
const fontHandles = new Map<string, number>();
const meshHandles = new Map<string, number>();
const environmentHandles = new Map<string, number>();
+ const probeVolumeHandles = new Map<string, number>();
const releaseCallbacks: ReleaseCallback[] = [];
const scope = new AssetScope();
@@ -1377,6 +1381,8 @@ export class Assets {
'mesh', meshHandles);
pushAcquire(environmentPaths, p => this.acquireTyped<{ handle: number }>('environment', p),
'environment', environmentHandles);
+ pushAcquire(probeVolumePaths, p => this.acquireTyped<{ handle: number }>('probeVolume', p),
+ 'probeVolume', probeVolumeHandles);
// A pair, so not `pushAcquire` (which keys by one path); the receipt is
// the scene's exactly as every other one is. The runtime scene loader
// opts out: its second phase binds to entities that do not exist yet.
@@ -1415,12 +1421,12 @@ export class Assets {
});
return { textureHandles, materialHandles, fontHandles, meshHandles, environmentHandles,
- releaseCallbacks, scope, missing };
+ probeVolumeHandles, releaseCallbacks, scope, missing };
}
resolveSceneAssetPaths(sceneData: SceneData, result: SceneAssetResult): void {
const { textureHandles, materialHandles, fontHandles, meshHandles,
- environmentHandles } = result;
+ environmentHandles, probeVolumeHandles } = result;
const counter = this.refCounter_;
for (const entity of sceneData.entities) {
@@ -1498,6 +1504,10 @@ export class Assets {
comp.data[field] = environmentHandles.get(path) ?? 0;
break;
}
+ case 'probeVolume': {
+ comp.data[field] = probeVolumeHandles.get(path) ?? 0;
+ break;
+ }
}
}
}
@@ -2218,6 +2228,7 @@ export class Assets {
const core = (): EngineApi | null => this.module_ ?? nativeEngineApi();
this.register(new MeshAssetLoader(core));
this.register(new EnvironmentAssetLoader(core));
+ this.register(new ProbeVolumeAssetLoader(core));
// The audio loader needs the AudioAPI outside load() too (unload /
// invalidate have no LoadContext), so it shares Assets' lazy accessor.
this.register(new AudioAssetLoader(() => this.getAudio_()));
diff --git a/sdk/src/asset/loaders/ProbeVolumeAssetLoader.ts b/sdk/src/asset/loaders/ProbeVolumeAssetLoader.ts
new file mode 100644
index 000000000..b32c0be68
--- /dev/null
+++ b/sdk/src/asset/loaders/ProbeVolumeAssetLoader.ts
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import type { AssetLoader, LoadContext } from '../AssetLoader';
+import type { EngineApi } from '../../ecs/bridge/engineApi';
+import { marshallingCore } from './engineCore';
+import { withScratch } from '../../wasm/wasmScratch';
+
+/** The `.esprobes` document, as a bake wrote it. */
+interface ProbeVolumeAssetData {
+ version: number;
+ /** Probes along x, y and z. */
+ resolution: [number, number, number];
+ /** Nine RGB coefficients per probe, x fastest then y then z. */
+ irradiance: number[];
+}
+
+/** A baked probe grid, named by the handle a LightProbeVolume references. */
+export interface ProbeVolumeResult {
+ handle: number;
+}
+
+/**
+ * Loads `.esprobes` — irradiance solved at a grid of points.
+ *
+ * The same nine coefficients an `.esenv` carries, at every probe instead of once:
+ * an environment is this field held constant. Where the grid stands is NOT here —
+ * the component's box says that, so one bake can be read at a second placement.
+ */
+export class ProbeVolumeAssetLoader implements AssetLoader<ProbeVolumeResult> {
+ readonly type = 'probeVolume';
+ readonly extensions = ['.esprobes'];
+
+ /** Lazy like the environment loader's: the module arrives after construction. */
+ constructor(private readonly core_: () => EngineApi | null) {}
+
+ async load(path: string, ctx: LoadContext): Promise<ProbeVolumeResult> {
+ const text = await ctx.loadText(ctx.catalog.getBuildPath(path));
+ const data = JSON.parse(text) as ProbeVolumeAssetData;
+ const res = data.resolution;
+ if (!Array.isArray(res) || res.length !== 3 || res.some((n) => !Number.isInteger(n) || n < 1)) {
+ throw new Error(`${path}: a probe volume is three positive probe counts, got `
+ + `${JSON.stringify(data.resolution)}`);
+ }
+ const want = res[0] * res[1] * res[2] * 27;
+ if (!Array.isArray(data.irradiance) || data.irradiance.length !== want) {
+ throw new Error(`${path}: ${res[0]}x${res[1]}x${res[2]} probes want ${want} `
+ + `coefficients, got ${data.irradiance?.length ?? 0}`);
+ }
+ const m = marshallingCore(this.core_());
+ if (!m?.probe_volume_create) {
+ throw new Error('this engine build carries no probe_volume_create');
+ }
+
+ const handle = withScratch(m, (alloc) => {
+ const shPtr = alloc(want * 4);
+ m.HEAPF32.set(Float32Array.from(data.irradiance), shPtr >> 2);
+ return m.probe_volume_create!(res[0], res[1], res[2], shPtr);
+ });
+
+ if (!handle) {
+ throw new Error(`the engine rejected the probe volume in ${path}`);
+ }
+ return { handle };
+ }
+
+ unload(asset: ProbeVolumeResult): void {
+ this.core_()?.probe_volume_release?.(asset.handle);
+ }
+}
diff --git a/sdk/src/assetTypes.ts b/sdk/src/assetTypes.ts
index 85875018e..cf8be43e4 100644
--- a/sdk/src/assetTypes.ts
+++ b/sdk/src/assetTypes.ts
@@ -89,6 +89,9 @@ const ASSET_TYPE_REGISTRY: readonly AssetTypeEntry[] = [
// of the octahedral atlas they were baked beside — hence the transitive dep,
// without which the cook ships the document and culls the image it is half of.
{ extensions: ['esenv'], contentType: 'json', editorType: 'json', addressableType: 'json', wechatPackInclude: true, hasTransitiveDeps: true },
+ // Baked probe grid: the same nine coefficients an `.esenv` carries, at every
+ // point of a grid instead of once. No transitive dep — a volume names no image.
+ { extensions: ['esprobes'], contentType: 'json', editorType: 'json', addressableType: 'json', wechatPackInclude: true, hasTransitiveDeps: false },
];
const MIME_MAP: Record<string, string> = {
@@ -128,6 +131,7 @@ const MIME_MAP: Record<string, string> = {
esanimator: 'application/json',
esbt: 'application/json',
esenv: 'application/json',
+ esprobes: 'application/json',
bmfont: 'application/json',
fnt: 'text/plain',
};
diff --git a/sdk/src/core-runtime.ts b/sdk/src/core-runtime.ts
index 8e469fcd6..90e813e46 100644
--- a/sdk/src/core-runtime.ts
+++ b/sdk/src/core-runtime.ts
@@ -95,6 +95,8 @@ export {
LightType,
SpriteMaskInteraction,
ShadowCaster2D,
+ LightProbeVolume,
+ type LightProbeVolumeData,
SortingGroup,
SpriteMask,
TrailRenderer,
diff --git a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts b/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
index 179f624b6..bae30a432 100644
--- a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
+++ b/sdk/src/ecs/bridge/nativeEngineApi.generated.ts
@@ -114,6 +114,8 @@ export interface NativeEngineApi {
postprocess_setUniformFloat?(passName: string, uniform: string, value: number): void;
postprocess_setUniformVec4?(passName: string, uniform: string, x: number, y: number, z: number, w: number): void;
postprocess_shutdown?(): void;
+ probe_volume_create?(resX: number, resY: number, resZ: number, shPtr: number): number;
+ probe_volume_release?(volumeHandle: number): void;
registry_batchSyncPhysicsTransforms?(registry: unknown, bufferPtr: number, count: number, ppu: number): void;
registry_getCanvasEntity?(registry: unknown): number;
registry_getGeneration?(registry: unknown, entity: number): number;
@@ -378,6 +380,8 @@ export function createNativeEngineApi(
bind('postprocess_setUniformFloat', 'es_postprocess_setUniformFloat', false);
bind('postprocess_setUniformVec4', 'es_postprocess_setUniformVec4', false);
bind('postprocess_shutdown', 'es_postprocess_shutdown', false);
+ bind('probe_volume_create', 'es_probe_volume_create', false);
+ bind('probe_volume_release', 'es_probe_volume_release', false);
bind('registry_batchSyncPhysicsTransforms', 'es_registry_batchSyncPhysicsTransforms', true);
bind('registry_getCanvasEntity', 'es_registry_getCanvasEntity', true);
bind('registry_getGeneration', 'es_registry_getGeneration', true);
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index aaa08960a..26d67a31d 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -897,6 +897,38 @@ export function createLightData(): LightPtrData {
};
}
+export interface LightProbeVolumePtrData {
+ probes: number;
+ halfExtents: Vec3;
+ enabled: boolean;
+}
+
+export function fillLightProbeVolume(
+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,
+ ptr: number, out: LightProbeVolumePtrData,
+): void {
+ out.probes = u32[ptr >> 2];
+ const halfExtents_ = out.halfExtents; halfExtents_.x = f32[(ptr + 4) >> 2]; halfExtents_.y = f32[((ptr + 4) >> 2) + 1]; halfExtents_.z = f32[((ptr + 4) >> 2) + 2];
+ out.enabled = u8[ptr + 16] !== 0;
+}
+
+export function writeLightProbeVolume(
+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,
+ ptr: number, data: LightProbeVolumePtrData,
+): void {
+ u32[ptr >> 2] = data.probes;
+ f32[(ptr + 4) >> 2] = data.halfExtents.x; f32[((ptr + 4) >> 2) + 1] = data.halfExtents.y; f32[((ptr + 4) >> 2) + 2] = data.halfExtents.z;
+ u8[ptr + 16] = data.enabled ? 1 : 0;
+}
+
+export function createLightProbeVolumeData(): LightProbeVolumePtrData {
+ return {
+ probes: 0,
+ halfExtents: { x: 0, y: 0, z: 0 },
+ enabled: false,
+ };
+}
+
export interface MeshCollider3DPtrData {
mesh: number;
friction: number;
@@ -2352,6 +2384,7 @@ export const PTR_ACCESSORS: Record<string, PtrAccessor<any>> = {
Interactable: { fill: fillInteractable, write: writeInteractable, create: createInteractableData },
LODGroup: { fill: fillLODGroup, write: writeLODGroup, create: createLODGroupData },
Light: { fill: fillLight, write: writeLight, create: createLightData },
+ LightProbeVolume: { fill: fillLightProbeVolume, write: writeLightProbeVolume, create: createLightProbeVolumeData },
MeshCollider3D: { fill: fillMeshCollider3D, write: writeMeshCollider3D, create: createMeshCollider3DData },
MeshLightmap: { fill: fillMeshLightmap, write: writeMeshLightmap, create: createMeshLightmapData },
MeshRenderer: { fill: fillMeshRenderer, write: writeMeshRenderer, create: createMeshRendererData },
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index 823cdabdf..fba5cf96a 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 = 'ca7cd852d3bc316f';
+export const ABI_LAYOUT_HASH = 'cccf3c7425936b84';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -506,6 +506,21 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
drawEnvironment: { tooltip: "Draw this environment as the sky behind the scene.", shownWhen: { field: "type", values: [2] } },
},
},
+ LightProbeVolume: {
+ defaults: {
+ probes: 0,
+ halfExtents: { x: 100, y: 100, z: 100 },
+ enabled: true,
+ },
+ assetFields: [{ field: 'probes', type: 'probeVolume' as AssetFieldType }],
+ entityFields: [],
+ colorFields: [],
+ animatableFields: [],
+ fields: {
+ probes: { tooltip: "Baked probe grid (.esprobes) filling this box." },
+ halfExtents: { min: 0, tooltip: "Half the box this volume covers, from the entity's position." },
+ },
+ },
MeshCollider3D: {
defaults: {
mesh: 0,
@@ -1404,6 +1419,12 @@ export interface LightData {
enabled: boolean;
}
+export interface LightProbeVolumeData {
+ probes: number;
+ halfExtents: Vec3;
+ enabled: boolean;
+}
+
export interface MeshCollider3DData {
mesh: number;
friction: number;
diff --git a/sdk/src/ecs/component.ts b/sdk/src/ecs/component.ts
index e6685596f..2700bdad1 100644
--- a/sdk/src/ecs/component.ts
+++ b/sdk/src/ecs/component.ts
@@ -15,7 +15,7 @@ export type { AssetFieldMeta, SkeletalFieldMeta };
// extending the generated base.
import type {
TransformData, SpriteData, ShapeRendererData, LightData, ShadowCaster2DData, DraggableData,
- SortingGroupData, SpriteMaskData,
+ SortingGroupData, SpriteMaskData, LightProbeVolumeData,
CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,
TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,
CameraData as CameraDataCpp, ParticleEmitterData as ParticleEmitterDataCpp,
@@ -805,7 +805,7 @@ export type ScaleMode = (typeof ScaleMode)[keyof typeof ScaleMode];
// automatically; tsc then enforces every consumer matches.
export type {
TransformData, SpriteData, ShapeRendererData, LightData, ShadowCaster2DData, DraggableData,
- SortingGroupData, SpriteMaskData,
+ SortingGroupData, SpriteMaskData, LightProbeVolumeData,
CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,
TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,
};
@@ -921,6 +921,13 @@ export const ShadowCaster2D = defineBuiltin<ShadowCaster2DData>('ShadowCaster2D'
metaDefaults<ShadowCaster2DData>('ShadowCaster2D')
);
+// A box of baked irradiance: what lights the things a lightmap cannot hold still.
+// Typed because the viewport outlines it — a region of world nothing renders is a
+// box a creator would otherwise place blind.
+export const LightProbeVolume = defineBuiltin<LightProbeVolumeData>('LightProbeVolume',
+ metaDefaults<LightProbeVolumeData>('LightProbeVolume')
+);
+
/**
* Turns this entity's `Sprite` into a stencil: the sprites drawn AFTER it that ask to be
* masked (`Sprite.maskInteraction`) are cut by its shape. The mask's own sprite is not
diff --git a/sdk/src/scene/scene.ts b/sdk/src/scene/scene.ts
index 395aa0d66..fb798b996 100644
--- a/sdk/src/scene/scene.ts
+++ b/sdk/src/scene/scene.ts
@@ -151,7 +151,7 @@ export class MissingAssetsError extends Error {
*
* @public
*/
-export type AssetFieldType = 'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment';
+export type AssetFieldType = 'texture' | 'material' | 'font' | 'anim-clip' | 'audio' | 'video' | 'tilemap' | 'tileset' | 'timeline' | 'statemachine' | 'behaviortree' | 'animatorcontroller' | 'avatar' | 'mesh' | 'environment' | 'probeVolume';
// =============================================================================
// Component Query Helpers (read from self-describing ComponentDef)
diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.ts
index 5b5021f85..c811059cd 100644
--- a/sdk/src/wasm.ts
+++ b/sdk/src/wasm.ts
@@ -315,6 +315,14 @@ export interface ESEngineModule {
mipCount: number, maxRange: number): number;
/** Release an environment; its atlas is an ordinary texture and outlives it. */
environment_release?(environmentHandle: number): void;
+ /**
+ * Register a grid of baked irradiance: `resX*resY*resZ*27` floats, nine RGB
+ * coefficients per probe with x varying fastest. The same nine an environment
+ * carries, at points instead of once — which is what lights a thing that moves.
+ */
+ probe_volume_create?(resX: number, resY: number, resZ: number, shPtr: number): number;
+ /** Release a probe volume. */
+ probe_volume_release?(volumeHandle: number): void;
/** The same for every MeshRenderer in the world; returns how many were frozen. */
meshRenderer_makeAllResident?(registry: CppRegistry): number;
/**
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index 719fbbb31..e02d67129 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -249,6 +249,14 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ name: 'enabled', type: 'bool', offset: 89 },
],
},
+ LightProbeVolume: {
+ ptrFn: 'getLightProbeVolumePtr',
+ fields: [
+ { name: 'probes', type: 'u32', offset: 0 },
+ { name: 'halfExtents', type: 'vec3', offset: 4 },
+ { name: 'enabled', type: 'bool', offset: 16 },
+ ],
+ },
MeshCollider3D: {
ptrFn: 'getMeshCollider3DPtr',
fields: [
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 4bf908ac6..6611914b8 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -571,6 +571,12 @@ export interface Light {
enabled: boolean;
}
+export interface LightProbeVolume {
+ probes: number;
+ halfExtents: Vec3;
+ enabled: boolean;
+}
+
export interface MeshCollider3D {
mesh: number;
friction: number;
@@ -973,6 +979,10 @@ export interface Registry {
getLight(entity: Entity): Light;
addLight(entity: Entity, component: Light): void;
removeLight(entity: Entity): void;
+ hasLightProbeVolume(entity: Entity): boolean;
+ getLightProbeVolume(entity: Entity): LightProbeVolume;
+ addLightProbeVolume(entity: Entity, component: LightProbeVolume): void;
+ removeLightProbeVolume(entity: Entity): void;
hasMeshCollider3D(entity: Entity): boolean;
getMeshCollider3D(entity: Entity): MeshCollider3D;
addMeshCollider3D(entity: Entity, component: MeshCollider3D): void;
@@ -1112,6 +1122,7 @@ export interface ESEngineModule {
Interactable: new () => Interactable;
LODGroup: new () => LODGroup;
Light: new () => Light;
+ LightProbeVolume: new () => LightProbeVolume;
MeshCollider3D: new () => MeshCollider3D;
MeshLightmap: new () => MeshLightmap;
MeshMorph: new () => MeshMorph;
diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
index a1294b840..63a523011 100644
--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
@@ -422,6 +422,15 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho
"tooltip": "Point, Directional, Ambient, or Spot.",
},
},
+ "LightProbeVolume": {
+ "halfExtents": {
+ "min": 0,
+ "tooltip": "Half the box this volume covers, from the entity's position.",
+ },
+ "probes": {
+ "tooltip": "Baked probe grid (.esprobes) filling this box.",
+ },
+ },
"Marker": {
"properties": {
"map": true,
diff --git a/sdk/tests/asset-refcounter-integration.test.ts b/sdk/tests/asset-refcounter-integration.test.ts
index 8c4fab9c9..352685cfb 100644
--- a/sdk/tests/asset-refcounter-integration.test.ts
+++ b/sdk/tests/asset-refcounter-integration.test.ts
@@ -16,6 +16,7 @@ import { AssetRefCounter } from '../src/asset/AssetRefCounter';
import type { Backend } from '../src/asset/Backend';
import type { SceneData } from '../src/scene/scene';
import type { SceneAssetResult } from '../src/asset/Assets';
+import { AssetScope } from '../src/asset/AssetLease';
vi.mock('../src/wasm/resourceManager', () => ({
requireResourceManager: () => ({ releaseTexture: vi.fn() }),
@@ -53,7 +54,11 @@ function emptyResult(): SceneAssetResult {
textureHandles: new Map(),
materialHandles: new Map(),
fontHandles: new Map(),
+ meshHandles: new Map(),
+ environmentHandles: new Map(),
+ probeVolumeHandles: new Map(),
releaseCallbacks: [],
+ scope: new AssetScope(),
missing: [],
};
}
diff --git a/src/esengine/aot/AotComponents.generated.cpp b/src/esengine/aot/AotComponents.generated.cpp
index fefb50fee..2105192ec 100644
--- a/src/esengine/aot/AotComponents.generated.cpp
+++ b/src/esengine/aot/AotComponents.generated.cpp
@@ -147,6 +147,11 @@ ComponentAt engineComponentAt(ecs::Registry& registry, const char* name) {
return registry.tryGet<esengine::ecs::Light>(Entity::fromRaw(raw));
};
}
+ if (std::strcmp(name, "LightProbeVolume") == 0) {
+ return [&registry](std::uint32_t raw) -> void* {
+ return registry.tryGet<esengine::ecs::LightProbeVolume>(Entity::fromRaw(raw));
+ };
+ }
if (std::strcmp(name, "MeshCollider3D") == 0) {
return [&registry](std::uint32_t raw) -> void* {
return registry.tryGet<esengine::ecs::MeshCollider3D>(Entity::fromRaw(raw));
@@ -371,6 +376,11 @@ CandidatesOf engineComponentCandidates(ecs::Registry& registry, const char* name
return denseAsIds(registry.entitiesWith<esengine::ecs::Light>());
};
}
+ if (std::strcmp(name, "LightProbeVolume") == 0) {
+ return [&registry]() -> Candidates {
+ return denseAsIds(registry.entitiesWith<esengine::ecs::LightProbeVolume>());
+ };
+ }
if (std::strcmp(name, "MeshCollider3D") == 0) {
return [&registry]() -> Candidates {
return denseAsIds(registry.entitiesWith<esengine::ecs::MeshCollider3D>());
@@ -527,6 +537,7 @@ bool isEngineComponent(const char* name) {
if (std::strcmp(name, "Interactable") == 0) return true;
if (std::strcmp(name, "LODGroup") == 0) return true;
if (std::strcmp(name, "Light") == 0) return true;
+ if (std::strcmp(name, "LightProbeVolume") == 0) return true;
if (std::strcmp(name, "MeshCollider3D") == 0) return true;
if (std::strcmp(name, "MeshLightmap") == 0) return true;
if (std::strcmp(name, "MeshMorph") == 0) return true;
diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.h
index ae4a0f873..9c9e3d3af 100644
--- a/src/esengine/aot/EngineDigest.generated.h
+++ b/src/esengine/aot/EngineDigest.generated.h
@@ -6,7 +6,7 @@
/* One per address width, because the width is IN the digest: a host that
took the other one would refuse every module built for it. */
-#define ES_ENGINE_ABI_DIGEST_32 0x5b011e67b82556a7ULL
-#define ES_ENGINE_ABI_DIGEST_64 0xb6ad0af24d9719e3ULL
+#define ES_ENGINE_ABI_DIGEST_32 0x9bb0ddbb653544d3ULL
+#define ES_ENGINE_ABI_DIGEST_64 0x30739b8914679e3fULL
#define ES_ENGINE_ABI_DIGEST \
(sizeof(es_addr_t) == 8 ? ES_ENGINE_ABI_DIGEST_64 : ES_ENGINE_ABI_DIGEST_32)
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index b244ed71b..e75fb0202 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 8de736341610664c
+ * @schema_hash 5ad35780ad9d857a
*/
-#define ES_EDITOR_API_SCHEMA_HASH "8de736341610664c"
+#define ES_EDITOR_API_SCHEMA_HASH "5ad35780ad9d857a"
#include <emscripten/bind.h>
#include <string>
@@ -81,6 +81,7 @@ std::vector<std::string> editor_getComponentNames() {
"Interactable",
"LODGroup",
"Light",
+ "LightProbeVolume",
"MeshCollider3D",
"MeshLightmap",
"MeshMorph",
@@ -349,6 +350,14 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"drawEnvironment","type":"bool","group":"Light"},
{"key":"enabled","type":"bool","group":"Light"}
])JSON";
+ } else if (name == "LightProbeVolume") {
+ return R"JSON([
+ {"key":"probes","type":"asset","group":"LightProbeVolume"},
+ {"key":"halfExtents.x","type":"float","group":"LightProbeVolume"},
+ {"key":"halfExtents.y","type":"float","group":"LightProbeVolume"},
+ {"key":"halfExtents.z","type":"float","group":"LightProbeVolume"},
+ {"key":"enabled","type":"bool","group":"LightProbeVolume"}
+ ])JSON";
} else if (name == "MeshCollider3D") {
return R"JSON([
{"key":"mesh","type":"asset","group":"MeshCollider3D"},
@@ -816,6 +825,9 @@ bool editor_addComponent(Registry& reg, u32 e, const std::string& name) {
} else if (name == "Light") {
if (!reg.has<esengine::ecs::Light>(entity)) reg.emplace<esengine::ecs::Light>(entity);
return true;
+ } else if (name == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) reg.emplace<esengine::ecs::LightProbeVolume>(entity);
+ return true;
} else if (name == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) reg.emplace<esengine::ecs::MeshCollider3D>(entity);
return true;
@@ -941,6 +953,8 @@ bool editor_removeComponent(Registry& reg, u32 e, const std::string& name) {
if (reg.has<esengine::ecs::LODGroup>(entity)) { reg.remove<esengine::ecs::LODGroup>(entity); return true; }
} else if (name == "Light") {
if (reg.has<esengine::ecs::Light>(entity)) { reg.remove<esengine::ecs::Light>(entity); return true; }
+ } else if (name == "LightProbeVolume") {
+ if (reg.has<esengine::ecs::LightProbeVolume>(entity)) { reg.remove<esengine::ecs::LightProbeVolume>(entity); return true; }
} else if (name == "MeshCollider3D") {
if (reg.has<esengine::ecs::MeshCollider3D>(entity)) { reg.remove<esengine::ecs::MeshCollider3D>(entity); return true; }
} else if (name == "MeshLightmap") {
@@ -1019,6 +1033,7 @@ bool editor_hasComponent(Registry& reg, u32 e, const std::string& name) {
if (name == "Interactable") return reg.has<esengine::ecs::Interactable>(entity);
if (name == "LODGroup") return reg.has<esengine::ecs::LODGroup>(entity);
if (name == "Light") return reg.has<esengine::ecs::Light>(entity);
+ if (name == "LightProbeVolume") return reg.has<esengine::ecs::LightProbeVolume>(entity);
if (name == "MeshCollider3D") return reg.has<esengine::ecs::MeshCollider3D>(entity);
if (name == "MeshLightmap") return reg.has<esengine::ecs::MeshLightmap>(entity);
if (name == "MeshMorph") return reg.has<esengine::ecs::MeshMorph>(entity);
@@ -1072,6 +1087,7 @@ std::vector<std::string> editor_getComponents(Registry& reg, u32 e) {
if (reg.has<esengine::ecs::Interactable>(entity)) result.push_back("Interactable");
if (reg.has<esengine::ecs::LODGroup>(entity)) result.push_back("LODGroup");
if (reg.has<esengine::ecs::Light>(entity)) result.push_back("Light");
+ if (reg.has<esengine::ecs::LightProbeVolume>(entity)) result.push_back("LightProbeVolume");
if (reg.has<esengine::ecs::MeshCollider3D>(entity)) result.push_back("MeshCollider3D");
if (reg.has<esengine::ecs::MeshLightmap>(entity)) result.push_back("MeshLightmap");
if (reg.has<esengine::ecs::MeshMorph>(entity)) result.push_back("MeshMorph");
@@ -1293,6 +1309,14 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
else if (field == "environmentRotation") { c.environmentRotation = value; }
else { return false; }
return true;
+ } else if (comp == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "halfExtents.x") { c.halfExtents.x = value; }
+ else if (field == "halfExtents.y") { c.halfExtents.y = value; }
+ else if (field == "halfExtents.z") { c.halfExtents.z = value; }
+ else { return false; }
+ return true;
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return false;
auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
@@ -1786,6 +1810,12 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "shadowDistance") { return c.shadowDistance; }
else if (field == "shadowExtent") { return c.shadowExtent; }
else if (field == "environmentRotation") { return c.environmentRotation; }
+ } else if (comp == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return 0.0f;
+ const auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "halfExtents.x") { return c.halfExtents.x; }
+ else if (field == "halfExtents.y") { return c.halfExtents.y; }
+ else if (field == "halfExtents.z") { return c.halfExtents.z; }
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return 0.0f;
const auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
@@ -2157,6 +2187,12 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::str
else if (field == "environment") { c.environment = resource::EnvironmentHandle(static_cast<u32>(value)); }
else { return false; }
return true;
+ } else if (comp == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "probes") { c.probes = resource::ProbeVolumeHandle(static_cast<u32>(value)); }
+ else { return false; }
+ return true;
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return false;
auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
@@ -2398,6 +2434,10 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::stri
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 == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return 0;
+ const auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "probes") { return static_cast<i32>(c.probes.id()); }
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return 0;
const auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
@@ -2638,6 +2678,12 @@ bool editor_setBool(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "enabled") { c.enabled = value; }
else { return false; }
return true;
+ } else if (comp == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "enabled") { c.enabled = value; }
+ else { return false; }
+ return true;
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return false;
auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
@@ -2873,6 +2919,10 @@ bool editor_getBool(Registry& reg, u32 e, const std::string& comp, const std::st
if (field == "meshShadows") { return c.meshShadows; }
else if (field == "drawEnvironment") { return c.drawEnvironment; }
else if (field == "enabled") { return c.enabled; }
+ } else if (comp == "LightProbeVolume") {
+ if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return false;
+ const auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);
+ if (field == "enabled") { return c.enabled; }
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return false;
const auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
diff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cpp
index 607241936..0321d8bb2 100644
--- a/src/esengine/bindings/RendererBindings.cpp
+++ b/src/esengine/bindings/RendererBindings.cpp
@@ -430,6 +430,30 @@ void environment_release(u32 environmentHandle) {
}
}
+/**
+ * @brief Registers a grid of baked irradiance — an environment sampled at points.
+ * @param shPtr `resX*resY*resZ*27` floats: nine RGB coefficients per probe, in
+ * grid order with x varying fastest.
+ */
+u32 probe_volume_create(i32 resX, i32 resY, i32 resZ, uintptr_t shPtr) {
+ auto* rm = ctx().tryGet<resource::ResourceManager>();
+ if (!rm) return 0;
+ if (resX <= 0 || resY <= 0 || resZ <= 0) return 0;
+ const u64 want = static_cast<u64>(resX) * static_cast<u64>(resY)
+ * static_cast<u64>(resZ) * 27u;
+ const f32* sh = boundarySpan<f32>(shPtr, want, "probe_volume_create.irradiance");
+ if (!sh) return 0;
+ return rm->createProbeVolume({resX, resY, resZ},
+ ConstSpan<f32>(sh, static_cast<usize>(want))).id();
+}
+
+/** @brief Releases a probe volume. */
+void probe_volume_release(u32 volumeHandle) {
+ if (auto* rm = ctx().tryGet<resource::ResourceManager>()) {
+ rm->releaseProbeVolume(resource::ProbeVolumeHandle(volumeHandle));
+ }
+}
+
namespace {
// Freezes a MeshRenderer's inline geometry onto the GPU: the same vertices, uploaded
// once and drawn with a per-object transform. The inline payload is cleared, so
diff --git a/src/esengine/bindings/RendererBindings.hpp b/src/esengine/bindings/RendererBindings.hpp
index fc50fa4f4..4fb550f6b 100644
--- a/src/esengine/bindings/RendererBindings.hpp
+++ b/src/esengine/bindings/RendererBindings.hpp
@@ -101,6 +101,12 @@ u32 environment_create(uintptr_t shPtr, u32 specularHandle, f32 faceSize, u32 mi
/** @brief Releases an environment; its atlas is an ordinary texture and outlives it. */
void environment_release(u32 environmentHandle);
+
+/** @brief Registers a grid of baked irradiance: `x*y*z*27` floats, x fastest. */
+u32 probe_volume_create(i32 resX, i32 resY, i32 resZ, uintptr_t shPtr);
+
+/** @brief Releases a probe volume. */
+void probe_volume_release(u32 volumeHandle);
/** @brief Freezes every MeshRenderer in the world; returns how many were frozen. */
u32 meshRenderer_makeAllResident(ecs::Registry& registry);
/** @brief Points every MeshRenderer at one resident mesh; returns how many. */
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index 8a24bc5d1..657bace48 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -652,6 +652,32 @@ LightJS lightToJS(const esengine::ecs::Light& c) {
return js;
}
+struct LightProbeVolumeJS {
+ u32 probes;
+ glm::vec3 halfExtents;
+ bool enabled;
+};
+
+void lightprobevolumeApplyJS(esengine::ecs::LightProbeVolume& c, const LightProbeVolumeJS& js) {
+ c.probes = resource::ProbeVolumeHandle(js.probes);
+ c.halfExtents = js.halfExtents;
+ c.enabled = js.enabled;
+}
+
+esengine::ecs::LightProbeVolume lightprobevolumeFromJS(const LightProbeVolumeJS& js) {
+ esengine::ecs::LightProbeVolume c;
+ lightprobevolumeApplyJS(c, js);
+ return c;
+}
+
+LightProbeVolumeJS lightprobevolumeToJS(const esengine::ecs::LightProbeVolume& c) {
+ LightProbeVolumeJS js;
+ js.probes = c.probes.id();
+ js.halfExtents = c.halfExtents;
+ js.enabled = c.enabled;
+ return js;
+}
+
struct MeshCollider3DJS {
u32 mesh;
f32 friction;
@@ -1658,6 +1684,11 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("drawEnvironment", &LightJS::drawEnvironment)
.field("enabled", &LightJS::enabled);
+ value_object<LightProbeVolumeJS>("LightProbeVolume")
+ .field("probes", &LightProbeVolumeJS::probes)
+ .field("halfExtents", &LightProbeVolumeJS::halfExtents)
+ .field("enabled", &LightProbeVolumeJS::enabled);
+
value_object<MeshCollider3DJS>("MeshCollider3D")
.field("mesh", &MeshCollider3DJS::mesh)
.field("friction", &MeshCollider3DJS::friction)
@@ -2360,6 +2391,30 @@ EMSCRIPTEN_BINDINGS(esengine_registry) {
r.remove<esengine::ecs::Light>(entity);
}))
+ // LightProbeVolume
+ .function("hasLightProbeVolume", optional_override([](Registry& r, u32 e) {
+ return r.has<esengine::ecs::LightProbeVolume>(static_cast<Entity>(e));
+ }))
+ .function("getLightProbeVolume", optional_override([](Registry& r, u32 e) {
+ auto entity = static_cast<Entity>(e);
+ if (!r.valid(entity) || !r.has<esengine::ecs::LightProbeVolume>(entity)) return LightProbeVolumeJS{};
+ return lightprobevolumeToJS(r.get<esengine::ecs::LightProbeVolume>(entity));
+ }))
+ .function("addLightProbeVolume", optional_override([](Registry& r, u32 e, const LightProbeVolumeJS& js) {
+ auto entity = static_cast<Entity>(e);
+ if (!r.valid(entity)) return;
+ if (auto* existing = r.tryGet<esengine::ecs::LightProbeVolume>(entity)) {
+ lightprobevolumeApplyJS(*existing, js);
+ return;
+ }
+ r.emplaceOrReplace<esengine::ecs::LightProbeVolume>(entity, lightprobevolumeFromJS(js));
+ }))
+ .function("removeLightProbeVolume", optional_override([](Registry& r, u32 e) {
+ auto entity = static_cast<Entity>(e);
+ if (!r.valid(entity) || !r.has<esengine::ecs::LightProbeVolume>(entity)) return;
+ r.remove<esengine::ecs::LightProbeVolume>(entity);
+ }))
+
// MeshCollider3D
.function("hasMeshCollider3D", optional_override([](Registry& r, u32 e) {
return r.has<esengine::ecs::MeshCollider3D>(static_cast<Entity>(e));
@@ -3006,6 +3061,7 @@ emscripten::val esengineGetBuiltinComponentNames() {
arr.set(i++, val(std::string("Interactable")));
arr.set(i++, val(std::string("LODGroup")));
arr.set(i++, val(std::string("Light")));
+ arr.set(i++, val(std::string("LightProbeVolume")));
arr.set(i++, val(std::string("MeshCollider3D")));
arr.set(i++, val(std::string("MeshLightmap")));
arr.set(i++, val(std::string("MeshMorph")));
@@ -3189,6 +3245,9 @@ static_assert(offsetof(esengine::ecs::Light, environment) == 80, "ABI offset dri
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::LightProbeVolume, probes) == 0, "ABI offset drift: esengine::ecs::LightProbeVolume.probes (EHT expected 0)");
+static_assert(offsetof(esengine::ecs::LightProbeVolume, halfExtents) == 4, "ABI offset drift: esengine::ecs::LightProbeVolume.halfExtents (EHT expected 4)");
+static_assert(offsetof(esengine::ecs::LightProbeVolume, enabled) == 16, "ABI offset drift: esengine::ecs::LightProbeVolume.enabled (EHT expected 16)");
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)");
@@ -3433,7 +3492,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "ca7cd852d3bc316f";
+static const char* kEsAbiLayoutHash = "cccf3c7425936b84";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index a1a1b66d7..1289541cb 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -530,6 +530,8 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {
emscripten::function("mesh_release", &esengine::mesh_release);
emscripten::function("environment_create", &esengine::environment_create);
emscripten::function("environment_release", &esengine::environment_release);
+ emscripten::function("probe_volume_create", &esengine::probe_volume_create);
+ emscripten::function("probe_volume_release", &esengine::probe_volume_release);
emscripten::function("meshRenderer_localBounds", &esengine::meshRenderer_localBounds);
emscripten::function("meshRenderer_makeAllResident", &esengine::meshRenderer_makeAllResident);
emscripten::function("meshRenderer_setMeshAll", &esengine::meshRenderer_setMeshAll);
diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hpp
index 3821897f0..521c53e48 100644
--- a/src/esengine/ecs/components/Light.hpp
+++ b/src/esengine/ecs/components/Light.hpp
@@ -189,4 +189,28 @@ struct Light {
bool enabled{true};
};
+/**
+ * @brief A box of baked irradiance: the light for what a bake cannot hold still.
+ *
+ * @details A draw standing inside takes its indirect light from the eight probes
+ * around it rather than from the frame's one environment. The box is
+ * AXIS-ALIGNED on the entity's world position; rotation and scale are not
+ * read, because a grid solved on world axes cannot be sampled on others.
+ */
+ES_COMPONENT()
+struct LightProbeVolume {
+ /** @brief The grid this box is read through. Invalid = nothing baked yet, which
+ * leaves everything inside lit exactly as it was. */
+ ES_PROPERTY(asset = probeVolume, tooltip="Baked probe grid (.esprobes) filling this box.")
+ resource::ProbeVolumeHandle probes;
+
+ /** @brief Half the box's size, in world units, from the entity's position. */
+ ES_PROPERTY(min=0, tooltip="Half the box this volume covers, from the entity's position.")
+ glm::vec3 halfExtents{100.0f, 100.0f, 100.0f};
+
+ /** @brief Disabled volumes are skipped during collection. */
+ ES_PROPERTY()
+ bool enabled{true};
+};
+
} // namespace esengine::ecs
diff --git a/src/esengine/renderer/draw/BatchBuilder.cpp b/src/esengine/renderer/draw/BatchBuilder.cpp
index 2b5cada1b..0b73d8b3a 100644
--- a/src/esengine/renderer/draw/BatchBuilder.cpp
+++ b/src/esengine/renderer/draw/BatchBuilder.cpp
@@ -110,6 +110,7 @@ void pushBatchDraw(DrawList& drawList, const ClipState& clips,
cmd.skin_offset = key.skinOffset;
cmd.skin_count = key.skinCount;
cmd.morph_index = key.morphIndex;
+ cmd.probe_index = key.probeIndex;
cmd.shader_id = key.shaderId;
cmd.blend_mode = key.blend;
cmd.layout_id = key.layoutId;
diff --git a/src/esengine/renderer/draw/BatchBuilder.hpp b/src/esengine/renderer/draw/BatchBuilder.hpp
index e69a9f771..ae22bcf13 100644
--- a/src/esengine/renderer/draw/BatchBuilder.hpp
+++ b/src/esengine/renderer/draw/BatchBuilder.hpp
@@ -140,6 +140,10 @@ struct BatchDrawKey {
// (1-based, 0 = none) and the mesh's own delta texture behind it.
u32 morphIndex = 0;
u32 morphTextureId = 0;
+ /// The indirect light where this draw stands: 1 + its block in the frame's
+ /// pool (0 = no volume holds it). Not part of the key — a volume does not
+ /// change what program or buffer a draw needs, only what it reads.
+ u32 probeIndex = 0;
/// The baked atlas this draw reads, on the last slot a draw's own stream has.
/// Part of the key and not only of the command: two objects sharing a mesh but
/// baked into different atlases are two draws.
diff --git a/src/esengine/renderer/draw/DrawCommand.hpp b/src/esengine/renderer/draw/DrawCommand.hpp
index 802214c88..02d0381dd 100644
--- a/src/esengine/renderer/draw/DrawCommand.hpp
+++ b/src/esengine/renderer/draw/DrawCommand.hpp
@@ -150,6 +150,11 @@ struct DrawCommand {
// 0 means the geometry is in the shape it was authored in.
u32 morph_index = 0;
+ // The indirect light where this draw stands: 1 + where its block sits in the
+ // frame's pool, so 0 means no volume holds it and the frame's environment
+ // answers instead.
+ u32 probe_index = 0;
+
bool hasPersistentGeometry() const { return vertex_buffer != BufferHandle::Invalid; }
// Vertices owned by this command (from vertex_byte_offset). Needed so the merge pass
@@ -326,6 +331,10 @@ struct DrawCommand {
if (skin_count != 0 || next.skin_count != 0) return false;
// Same reason: one draw can only be in one shape.
if (morph_index != 0 || next.morph_index != 0) return false;
+ // And one draw can only be in one PLACE, which is what a probe volume is
+ // asked about. Instancing is the claim that a record per object says
+ // everything that differs between them; irradiance is not in that record.
+ if (probe_index != 0 || next.probe_index != 0) return false;
// BOTH, not just this one: an opaque head asked about a draw whose
// result depends on when it happens would otherwise swallow it and
// paint it with the head's own state.
diff --git a/src/esengine/renderer/draw/DrawList.cpp b/src/esengine/renderer/draw/DrawList.cpp
index 00e58a919..f4fd68c61 100644
--- a/src/esengine/renderer/draw/DrawList.cpp
+++ b/src/esengine/renderer/draw/DrawList.cpp
@@ -3,6 +3,7 @@
#include "./DrawList.hpp"
#include "./BatchVertex.hpp"
#include "../store/MaterialStore.hpp"
+#include "../store/SkinConstants.hpp"
#include "../../core/FrameProfiler.hpp"
#include <glm/glm.hpp>
@@ -46,6 +47,7 @@ void DrawList::clear() {
sort_entries_.clear();
skin_matrices_.clear();
morph_shapes_.clear();
+ probes_.clear();
merged_draw_calls_ = 0;
depth_required_ = false;
}
@@ -61,6 +63,11 @@ u32 DrawList::addMorphShapes(const MorphConstants& shapes) {
return static_cast<u32>(morph_shapes_.size());
}
+u32 DrawList::addProbe(const ProbeConstants& probe) {
+ probes_.push_back(probe);
+ return static_cast<u32>(probes_.size());
+}
+
void DrawList::push(const DrawCommand& cmd) {
// Accumulated where commands ENTER, not scanned where the answer is wanted:
// push is the one funnel every render path goes through, so a path added
@@ -179,11 +186,10 @@ void DrawList::finalize(TransientBufferPool& pool) {
void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,
MaterialStore& materials, u32 white_texture_id,
- FrameCapture* capture, BufferHandle skin_ubo, BufferHandle morph_ubo) {
+ FrameCapture* capture, PerDrawBlocks* skin_blocks,
+ PerDrawBlocks* morph_blocks, PerDrawBlocks* probe_blocks) {
PipelineDesc lastDesc{};
PipelineHandle lastHandle = PipelineHandle::Invalid;
- /// Whether the block still holds a morphed draw's shapes — see the upload below.
- bool morph_live = false;
for (u32 i = 0; i < merged_draw_calls_; ++i) {
const auto& cmd = commands_[i];
@@ -224,27 +230,35 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,
materials.bindForDraw(cmd.material_id);
}
- // The pose, for a draw that has one. Written immediately before the draw
- // that reads it: one draw's bones are in flight at a time, which is what
- // lets a single block serve every skinned mesh in the frame.
- if (cmd.skin_count > 0 && skin_ubo != BufferHandle::Invalid) {
- device.updateBuffer(skin_ubo, 0, skin_matrices_.data() + cmd.skin_offset,
- cmd.skin_count * sizeof(glm::mat4));
+ // The pose, for a draw that has one — in a buffer of this draw's own. A
+ // block shared between two draws of one pass is read by both with what
+ // the last wrote, which is a room of characters in one pose.
+ if (cmd.skin_count > 0 && skin_blocks) {
+ device.setUniformBuffer(
+ SKIN_CONSTANTS_BINDING,
+ skin_blocks->write(skin_matrices_.data() + cmd.skin_offset,
+ cmd.skin_count * static_cast<u32>(sizeof(glm::mat4))));
}
- // The shapes, the same way. Cleared on the way OUT of a morphed draw
- // rather than written before every other one: a mesh with none would
- // otherwise be deformed by whatever the last morphed draw left behind.
- if (morph_ubo != BufferHandle::Invalid) {
- if (cmd.morph_index > 0) {
- device.updateBuffer(morph_ubo, 0, &morph_shapes_[cmd.morph_index - 1],
- sizeof(MorphConstants));
- morph_live = true;
- } else if (morph_live) {
- const MorphConstants none{};
- device.updateBuffer(morph_ubo, 0, &none, sizeof(MorphConstants));
- morph_live = false;
- }
+ // The shapes, the same way — and a draw with none binds the zeroed block
+ // rather than erasing the last one's, so "unshaped" is an object instead
+ // of an erasure someone has to remember to perform.
+ if (morph_blocks) {
+ device.setUniformBuffer(MORPH_CONSTANTS_BINDING,
+ cmd.morph_index > 0
+ ? morph_blocks->write(&morph_shapes_[cmd.morph_index - 1],
+ sizeof(MorphConstants))
+ : morph_blocks->zero());
+ }
+
+ // The indirect light, on exactly those terms: a draw standing in no volume
+ // binds zeroes, and reads the frame's environment because of them.
+ if (probe_blocks) {
+ device.setUniformBuffer(PROBE_CONSTANTS_BINDING,
+ cmd.probe_index > 0
+ ? probe_blocks->write(&probes_[cmd.probe_index - 1],
+ sizeof(ProbeConstants))
+ : probe_blocks->zero());
}
// Dynamic per-draw state (sorted+merged draws already group these coarsely).
diff --git a/src/esengine/renderer/draw/DrawList.hpp b/src/esengine/renderer/draw/DrawList.hpp
index 368ad5814..f3c75f365 100644
--- a/src/esengine/renderer/draw/DrawList.hpp
+++ b/src/esengine/renderer/draw/DrawList.hpp
@@ -8,6 +8,8 @@
#include "../rhi/TransientBufferPool.hpp"
#include "../frame/FrameCapture.hpp"
#include "../store/MorphConstants.hpp"
+#include "../store/ProbeConstants.hpp"
+#include "../rhi/PerDrawBlocks.hpp"
#include "../../math/Math.hpp"
#include <algorithm>
@@ -50,8 +52,9 @@ public:
void execute(GfxDevice& device, TransientBufferPool& buffers,
MaterialStore& materials, u32 white_texture_id = 0,
FrameCapture* capture = nullptr,
- BufferHandle skin_ubo = BufferHandle::Invalid,
- BufferHandle morph_ubo = BufferHandle::Invalid);
+ PerDrawBlocks* skin_blocks = nullptr,
+ PerDrawBlocks* morph_blocks = nullptr,
+ PerDrawBlocks* probe_blocks = nullptr);
/** Append one draw's bone matrices; returns where they start. Frame-scoped,
* like the vertex pool: a command references an offset, not a copy. */
@@ -62,6 +65,10 @@ public:
* available for "this draw is in the shape it was authored in". */
u32 addMorphShapes(const MorphConstants& shapes);
+ /** Append one draw's indirect light; returns 1 + where it sits, so that 0
+ * stays available for "no volume holds this draw". */
+ u32 addProbe(const ProbeConstants& probe);
+
u32 commandCount() const { return static_cast<u32>(commands_.size()); }
u32 mergedDrawCallCount() const { return merged_draw_calls_; }
@@ -182,6 +189,7 @@ private:
/// Every skinned draw's bone matrices for this frame, indexed by skin_offset.
std::vector<glm::mat4> skin_matrices_;
std::vector<MorphConstants> morph_shapes_;
+ std::vector<ProbeConstants> probes_;
std::vector<SortEntry> sort_entries_;
std::vector<DrawCommand> sorted_scratch_; // reused across frames to avoid a
// per-frame heap alloc in finalize()
diff --git a/src/esengine/renderer/frame/RenderContext.cpp b/src/esengine/renderer/frame/RenderContext.cpp
index 8024d7e9b..60ede67d6 100644
--- a/src/esengine/renderer/frame/RenderContext.cpp
+++ b/src/esengine/renderer/frame/RenderContext.cpp
@@ -17,6 +17,7 @@
#include "../draw/DrawParams.hpp"
#include "../store/SkinConstants.hpp"
#include "../store/MorphConstants.hpp"
+#include "../store/ProbeConstants.hpp"
#include "../../core/Log.hpp"
#include <cmath>
@@ -145,22 +146,16 @@ void RenderContext::initFrameUbo() {
{GfxBufferUsage::Uniform, DRAW_PARAMS_FALLBACK_SIZE, /*dynamic=*/false}, zeros.data());
device_.setUniformBuffer(DRAW_PARAMS_BINDING, drawParamsFallback_);
- // A skinned draw's pose. Bound once and rewritten per draw: only one draw's
- // bones are ever in flight, and a mesh with none never reads the block.
- const std::vector<u8> bones(sizeof(SkinConstants), 0);
- skinUbo_ = device_.createBuffer(
- {GfxBufferUsage::Uniform, static_cast<u32>(sizeof(SkinConstants)), /*dynamic=*/true},
- bones.data());
- device_.setUniformBuffer(SKIN_CONSTANTS_BINDING, skinUbo_);
-
- // The shapes one draw is blended towards. Bound once like the pose above,
- // but read by EVERY mesh draw: a mesh with no shapes finds a zeroed block,
- // which is the same statement as having none. See MorphConstants.hpp.
- const std::vector<u8> shapes(sizeof(MorphConstants), 0);
- morphUbo_ = device_.createBuffer(
- {GfxBufferUsage::Uniform, static_cast<u32>(sizeof(MorphConstants)), /*dynamic=*/true},
- shapes.data());
- device_.setUniformBuffer(MORPH_CONSTANTS_BINDING, morphUbo_);
+ // A pose, a set of shapes, and the indirect light where a draw stands. A POOL
+ // each and not one buffer each, because a block rewritten between two draws of
+ // one pass is read by both — see PerDrawBlocks.
+ skinBlocks_.init(device_, static_cast<u32>(sizeof(SkinConstants)));
+ morphBlocks_.init(device_, static_cast<u32>(sizeof(MorphConstants)));
+ probeBlocks_.init(device_, static_cast<u32>(sizeof(ProbeConstants)));
+ // What a draw with no shapes and no volume reads. A pose has no zero: geometry
+ // without one is drawn by a shader that does not declare the block.
+ device_.setUniformBuffer(MORPH_CONSTANTS_BINDING, morphBlocks_.zero());
+ device_.setUniformBuffer(PROBE_CONSTANTS_BINDING, probeBlocks_.zero());
ES_LOG_DEBUG("FrameConstants UBO created (handle: {})", static_cast<u32>(frameUbo_));
}
diff --git a/src/esengine/renderer/frame/RenderContext.hpp b/src/esengine/renderer/frame/RenderContext.hpp
index 0e114be1d..e5ed1f60f 100644
--- a/src/esengine/renderer/frame/RenderContext.hpp
+++ b/src/esengine/renderer/frame/RenderContext.hpp
@@ -23,6 +23,8 @@
#include "../rhi/Buffer.hpp"
#include "../rhi/GfxEnums.hpp"
#include "../store/LightStore.hpp"
+#include "../store/ProbeStore.hpp"
+#include "../rhi/PerDrawBlocks.hpp"
#include "../store/MaterialStore.hpp"
#include "../rhi/Shader.hpp"
@@ -193,6 +195,11 @@ public:
LightStore& lights() { return lights_; }
const LightStore& lights() const { return lights_; }
+ /** @brief The frame's probe volumes. Gathered beside the lights, because it
+ * answers the same question at the points a light cannot be asked. */
+ ProbeStore& probes() { return probes_; }
+ const ProbeStore& probes() const { return probes_; }
+
private:
void initDefaultTextures();
TextureHandle make1x1Texture(u32 rgba);
@@ -209,21 +216,26 @@ private:
BufferHandle frameUbo_ = BufferHandle::Invalid;
BufferHandle timeUbo_ = BufferHandle::Invalid;
BufferHandle drawParamsFallback_ = BufferHandle::Invalid;
- /// One skinned draw's bone matrices, rewritten immediately before that draw.
- BufferHandle skinUbo_ = BufferHandle::Invalid;
- /// One morphed draw's shape weights, on the same terms.
- BufferHandle morphUbo_ = BufferHandle::Invalid;
+ /// A bone-matrix block per skinned draw, a shape-weight block per morphed one,
+ /// and an indirect-light block per draw standing in a volume. One buffer EACH
+ /// and not one shared: see PerDrawBlocks.
+ PerDrawBlocks skinBlocks_;
+ PerDrawBlocks morphBlocks_;
+ PerDrawBlocks probeBlocks_;
public:
- /** @brief The per-draw bone-matrix block a skinned draw writes into. */
- BufferHandle skinUbo() const { return skinUbo_; }
- /** @brief The per-draw shape-weight block a morphed draw writes into. */
- BufferHandle morphUbo() const { return morphUbo_; }
+ /** @brief The pool a skinned draw takes its pose buffer from. */
+ PerDrawBlocks& skinBlocks() { return skinBlocks_; }
+ /** @brief The pool a morphed draw takes its shape buffer from. */
+ PerDrawBlocks& morphBlocks() { return morphBlocks_; }
+ /** @brief The pool a draw inside a probe volume takes its light buffer from. */
+ PerDrawBlocks& probeBlocks() { return probeBlocks_; }
private:
f32 lastElapsed_ = 0.0f;
MaterialStore materials_;
LightStore lights_;
+ ProbeStore probes_;
GfxDevice& device_;
bool initialized_ = false;
diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cpp
index 96242d387..5abc90994 100644
--- a/src/esengine/renderer/frame/RenderFrame.cpp
+++ b/src/esengine/renderer/frame/RenderFrame.cpp
@@ -288,7 +288,8 @@ void RenderFrame::drawScene() {
{
ES_PROFILE_SCOPE("render.submit");
draw_list_.execute(device_, pool_, context_.materials(), context_.getWhiteTextureId(),
- &frame_capture_, context_.skinUbo(), context_.morphUbo());
+ &frame_capture_, &context_.skinBlocks(), &context_.morphBlocks(),
+ &context_.probeBlocks());
}
// Handed over to whatever the graph runs next. Blend/depth/colour-mask come
@@ -328,6 +329,13 @@ void RenderFrame::beginFrame() {
// that they can differ is the whole claim.
lod_counts_ = {};
lod_view_state_.beginFrame();
+
+ // The per-draw blocks go back at the FRAME boundary and not at each pass's:
+ // a frame reaches the device as several passes with one submission behind
+ // them, so a buffer reused between two of them is read by both.
+ context_.skinBlocks().beginFrame();
+ context_.morphBlocks().beginFrame();
+ context_.probeBlocks().beginFrame();
}
void RenderFrame::applySceneDepthNeed() {
@@ -677,7 +685,8 @@ void RenderFrame::replayToDrawCall(i32 stopAtDrawCall) {
context_.updateCameraConstants(view_projection_);
context_.lights().uploadAndBind();
draw_list_.execute(device_, pool_, context_.materials(), context_.getWhiteTextureId(),
- &frame_capture_, context_.skinUbo(), context_.morphUbo());
+ &frame_capture_, &context_.skinBlocks(), &context_.morphBlocks(),
+ &context_.probeBlocks());
// Leave scissor disabled for whatever renders next; invalidate so the next
// setPipeline re-applies its full state (stencil included).
@@ -750,7 +759,8 @@ void RenderFrame::renderSurface(ecs::Registry& registry, const glm::mat4& viewPr
context_.updateCameraConstants(viewProjection);
context_.lights().uploadAndBind();
draw_list_.execute(device_, pool_, context_.materials(), context_.getWhiteTextureId(),
- &frame_capture_, context_.skinUbo(), context_.morphUbo());
+ &frame_capture_, &context_.skinBlocks(), &context_.morphBlocks(),
+ &context_.probeBlocks());
frame_capture_.endCapture();
rt->unbind();
@@ -1101,6 +1111,33 @@ static glm::vec3 lightForward(ecs::Transform* transform) {
return transform->worldRotation * glm::vec3(0.0f, 0.0f, -1.0f);
}
+/**
+ * @brief Gathers the frame's probe volumes: a world box each, and the grid inside it.
+ *
+ * @details A volume BORROWS its coefficients from the resource manager rather than
+ * copying them — the store is filled and read within one collect, and a
+ * grid is kilobytes an every-frame copy would spend nothing to gain.
+ */
+void RenderFrame::collectProbes(ecs::Registry& registry) {
+ ProbeStore& probes = context_.probes();
+ probes.clear();
+
+ auto view = registry.view<ecs::LightProbeVolume>();
+ for (auto entity : view) {
+ const auto& volume = view.get(entity);
+ if (!volume.enabled) continue;
+ const ProbeVolume* grid = resource_manager_.getProbeVolume(volume.probes);
+ if (!grid) continue;
+ // The box is axis-aligned around the entity's world position: a grid was
+ // solved on world axes, so a turned volume would be read along axes it
+ // never had. Scale is not read for the same reason.
+ const auto* transform = registry.tryGet<ecs::Transform>(entity);
+ const glm::vec3 centre = transform ? glm::vec3(transform->worldPosition) : glm::vec3(0.0f);
+ const glm::vec3 half = glm::abs(volume.halfExtents);
+ probes.add(centre - half, centre + half, grid);
+ }
+}
+
void RenderFrame::collectLights(ecs::Registry& registry) {
LightStore& lights = context_.lights();
lights.clear();
@@ -1711,8 +1748,8 @@ void RenderFrame::executeShadowPass(ecs::Registry& registry) {
// nothing — the whole pass came back empty for exactly this.
context_.lights().uploadAndBind();
list.execute(device_, shadow_pool_, context_.materials(),
- context_.getWhiteTextureId(), nullptr, context_.skinUbo(),
- context_.morphUbo());
+ context_.getWhiteTextureId(), nullptr, &context_.skinBlocks(),
+ &context_.morphBlocks(), &context_.probeBlocks());
++shadowTiles;
shadowDraws += list.mergedDrawCallCount();
}
@@ -1813,6 +1850,9 @@ void RenderFrame::collectAll(ecs::Registry& registry) {
// After the groups, because a mask's reach is stated in the order a group may own.
{ ES_PROFILE_SCOPE("render.collect.spriteMasks"); buildSpriteMasks(registry); }
{ ES_PROFILE_SCOPE("render.collect.lights"); collectLights(registry); }
+ // Beside the lights and for the same reason: this answers what reaches a point
+ // that no light can be asked about, and the mesh collect below reads both.
+ { ES_PROFILE_SCOPE("render.collect.probes"); collectProbes(registry); }
// Decided here, drawn by the graph. Nothing in this function may touch the
// device: the frame reaches the host as several calls with its own draws
// between them, and a pass opened here would swallow them.
diff --git a/src/esengine/renderer/frame/RenderFrame.hpp b/src/esengine/renderer/frame/RenderFrame.hpp
index d3400b61c..be6287bbd 100644
--- a/src/esengine/renderer/frame/RenderFrame.hpp
+++ b/src/esengine/renderer/frame/RenderFrame.hpp
@@ -583,6 +583,9 @@ private:
/// flush() uploads + binds the result so Lit material shaders read it.
void collectLights(ecs::Registry& registry);
+ /** @brief Gathers the frame's LightProbeVolume components into the ProbeStore. */
+ void collectProbes(ecs::Registry& registry);
+
/// Makes this ambient light the frame's environment, when it names one that is
/// loaded. `scale` is the light's colour times its intensity, folded into the
/// coefficients — an environment is what the light casts, not a second source.
diff --git a/src/esengine/renderer/frame/RenderFrameOverlay.cpp b/src/esengine/renderer/frame/RenderFrameOverlay.cpp
index 203175650..2ec913946 100644
--- a/src/esengine/renderer/frame/RenderFrameOverlay.cpp
+++ b/src/esengine/renderer/frame/RenderFrameOverlay.cpp
@@ -80,7 +80,8 @@ void RenderFrame::drawScreenOverlay() {
{
ES_PROFILE_SCOPE("render.overlay.submit");
draw_list_.execute(device_, pool_, context_.materials(), context_.getWhiteTextureId(),
- &frame_capture_, context_.skinUbo(), context_.morphUbo());
+ &frame_capture_, &context_.skinBlocks(), &context_.morphBlocks(),
+ &context_.probeBlocks());
}
device_.invalidatePipelineCache();
device_.setScissorTest(false);
diff --git a/src/esengine/renderer/plugins/MeshPlugin.cpp b/src/esengine/renderer/plugins/MeshPlugin.cpp
index 6d4cb9fd0..646097e1a 100644
--- a/src/esengine/renderer/plugins/MeshPlugin.cpp
+++ b/src/esengine/renderer/plugins/MeshPlugin.cpp
@@ -4,6 +4,7 @@
#include "../draw/BatchBuilder.hpp"
#include "../store/MaterialStore.hpp"
#include "../store/MorphConstants.hpp"
+#include "../store/ProbeConstants.hpp"
#include "../frame/RenderFrame.hpp"
#include "../frame/RenderContext.hpp"
#include "../rhi/Texture.hpp"
@@ -712,6 +713,16 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {
}
}
+ // A draw reading its own atlas does not ask: the bake holds the
+ // bounces that reached those texels. The ENTITY's position, not its
+ // vertices' — bones place a skinned mesh, a Transform says where.
+ if (!shadowDepth && key.lightmapTextureId == 0) {
+ ProbeConstants probe;
+ if (ctx.render_context.probes().sample(position, probe)) {
+ key.probeIndex = draw_list.addProbe(probe);
+ }
+ }
+
// A material's default program is built for the BATCH vertex
// source and would draw this at its local origin, so ask for the
// one compiled for THIS source; a failed variant falls back.
diff --git a/src/esengine/renderer/rhi/PerDrawBlocks.hpp b/src/esengine/renderer/rhi/PerDrawBlocks.hpp
new file mode 100644
index 000000000..1c165f7a7
--- /dev/null
+++ b/src/esengine/renderer/rhi/PerDrawBlocks.hpp
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file PerDrawBlocks.hpp
+ * @brief A uniform buffer per draw, so two draws never write into one block.
+ *
+ * @details A queue write lands where the pass is SUBMITTED, not where it was
+ * called, so a block shared between two draws is read by both with what
+ * the last wrote. Buffers are handed out per FRAME and not per pass: one
+ * submission stands behind a frame's several passes.
+ */
+#pragma once
+
+#include "../../core/Types.hpp"
+#include "./GfxDevice.hpp"
+
+#include <vector>
+
+namespace esengine {
+
+class PerDrawBlocks {
+public:
+ /** @brief Claims the pool for blocks of @p blockSize bytes, plus the zero one.
+ * Also what a device loss runs: old handles are DROPPED, not deleted,
+ * since freeing an id would read metadata the backend just wiped. */
+ void init(GfxDevice& device, u32 blockSize) {
+ device_ = &device;
+ blockSize_ = blockSize;
+ pool_.clear();
+ used_ = 0;
+ const std::vector<u8> zeros(blockSize, 0);
+ zero_ = device.createBuffer({GfxBufferUsage::Uniform, blockSize, /*dynamic=*/false},
+ zeros.data());
+ }
+
+ /** @brief Hands every buffer back. Called once per FRAME — see the file note. */
+ void beginFrame() { used_ = 0; }
+
+ /** @brief A buffer of this frame's holding @p size bytes of @p bytes. Grows
+ * rather than wraps: wrapping hands one buffer to two draws. */
+ BufferHandle write(const void* bytes, u32 size) {
+ if (!device_ || !bytes || size == 0 || size > blockSize_) return BufferHandle::Invalid;
+ if (used_ == pool_.size()) {
+ const std::vector<u8> zeros(blockSize_, 0);
+ pool_.push_back(device_->createBuffer(
+ {GfxBufferUsage::Uniform, blockSize_, /*dynamic=*/true}, zeros.data()));
+ }
+ const BufferHandle handle = pool_[used_++];
+ if (handle != BufferHandle::Invalid) device_->updateBuffer(handle, 0, bytes, size);
+ return handle;
+ }
+
+ /** @brief What a draw with nothing to say reads: zeroed once and never
+ * written, so "none" is an object rather than an erasure. */
+ BufferHandle zero() const { return zero_; }
+
+ /** @brief Buffers this frame has handed out — a per-frame cost, for the profile. */
+ u32 used() const { return used_; }
+
+private:
+ GfxDevice* device_ = nullptr;
+ u32 blockSize_ = 0;
+ std::vector<BufferHandle> pool_;
+ u32 used_ = 0;
+ BufferHandle zero_ = BufferHandle::Invalid;
+};
+
+} // namespace esengine
diff --git a/src/esengine/renderer/rhi/Shader.cpp b/src/esengine/renderer/rhi/Shader.cpp
index 41961b19a..a44c40eb5 100644
--- a/src/esengine/renderer/rhi/Shader.cpp
+++ b/src/esengine/renderer/rhi/Shader.cpp
@@ -21,6 +21,7 @@
#include "../store/SkinConstants.hpp"
#include "../store/LightConstants.hpp"
#include "../store/MorphConstants.hpp"
+#include "../store/ProbeConstants.hpp"
#include "../../core/Log.hpp"
#include <cstring>
@@ -260,6 +261,14 @@ bool Shader::compile(const std::string& vertexSrc, const std::string& fragmentSr
device_->uniformBlockBinding(program_, morphBlock, MORPH_CONSTANTS_BINDING);
}
+ // And the indirect light where this draw stands, which DrawList rewrites per
+ // draw. Every Lit fragment stage declares it — whether a draw STANDS in a
+ // volume is a number in the block, not a variant.
+ u32 probeBlock = device_->getUniformBlockIndex(program_, PROBE_CONSTANTS_BLOCK);
+ if (probeBlock != GFX_INVALID_UNIFORM_BLOCK) {
+ device_->uniformBlockBinding(program_, probeBlock, PROBE_CONSTANTS_BINDING);
+ }
+
// Same for the per-draw params block (rewriteLooseUniforms generates it for
// shaders whose loose uniforms were lifted); commitParams binds the UBO.
u32 drawParamsBlock = device_->getUniformBlockIndex(program_, DRAW_PARAMS_BLOCK);
diff --git a/src/esengine/renderer/store/ProbeConstants.hpp b/src/esengine/renderer/store/ProbeConstants.hpp
new file mode 100644
index 000000000..3fbe75848
--- /dev/null
+++ b/src/esengine/renderer/store/ProbeConstants.hpp
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file ProbeConstants.hpp
+ * @brief The indirect light where ONE draw stands, when a grid was baked for it.
+ *
+ * @details Per DRAW and rewritten immediately before it, the way @ref SkinConstants
+ * and @ref MorphConstants are. A draw and not an object: a bake's rectangle
+ * belongs to an object, because one mesh placed twice occupies two patches,
+ * but irradiance is a function of WHERE, and a batch of instances has only
+ * one position to speak of. So a draw that stands in a volume is its own.
+ *
+ * Nine coefficients and not four: this is the same shape
+ * LightConstants::envIrradiance carries, evaluated by the same expression.
+ * An environment is that field held constant; a volume is it sampled.
+ */
+#pragma once
+
+#include "../../core/Types.hpp"
+
+#include <glm/glm.hpp>
+
+namespace esengine {
+
+/** @brief Indexed UBO binding point for the per-draw ProbeConstants block. */
+inline constexpr u32 PROBE_CONSTANTS_BINDING = 7;
+
+/** @brief GLSL block name; must match the injected Lit header + Shader::compile lookup. */
+inline constexpr const char* PROBE_CONSTANTS_BLOCK = "ProbeConstants";
+
+/** @brief std140 mirror of the block. */
+struct ProbeConstants {
+ /// SH9, rgb in xyz. `[0].w` is 1 where this draw stands in a volume — a flag
+ /// and not the absence of coefficients, since zeroes ARE an answer here: a
+ /// probe in the dark.
+ glm::vec4 irradiance[9]{};
+};
+
+static_assert(sizeof(ProbeConstants) == 16 * 9,
+ "ProbeConstants must be a tight array of vec4 to match std140");
+
+} // namespace esengine
diff --git a/src/esengine/renderer/store/ProbeStore.hpp b/src/esengine/renderer/store/ProbeStore.hpp
new file mode 100644
index 000000000..79f7b1254
--- /dev/null
+++ b/src/esengine/renderer/store/ProbeStore.hpp
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file ProbeStore.hpp
+ * @brief Which baked grid a point stands in, and what it says there.
+ *
+ * @details The frame's LightProbeVolume components, as bounds plus the grid each
+ * one reads. Filled during collection and read during collection — a
+ * volume is borrowed, not copied, so nothing here outlives the frame
+ * that gathered it.
+ */
+#pragma once
+
+#include "../../core/Types.hpp"
+#include "../../resource/ProbeVolume.hpp"
+#include "./ProbeConstants.hpp"
+
+#include <cmath>
+#include <glm/glm.hpp>
+#include <vector>
+
+namespace esengine {
+
+/** @brief The frame's probe volumes, and the trilinear read through them. */
+class ProbeStore {
+public:
+ /** @brief One volume: a world box, and the grid solved inside it. */
+ struct Volume {
+ glm::vec3 min{0.0f};
+ glm::vec3 max{0.0f};
+ const ProbeVolume* grid = nullptr;
+ };
+
+ void clear() { volumes_.clear(); }
+
+ /** @brief Takes a volume, or ignores one no point can be inside. A grid whose
+ * coefficients do not match its resolution is not half-usable. */
+ void add(const glm::vec3& min, const glm::vec3& max, const ProbeVolume* grid) {
+ if (!grid || !grid->isValid()) return;
+ if (max.x <= min.x || max.y <= min.y || max.z <= min.z) return;
+ volumes_.push_back({min, max, grid});
+ }
+
+ bool empty() const { return volumes_.empty(); }
+ u32 count() const { return static_cast<u32>(volumes_.size()); }
+
+ /**
+ * @brief The irradiance at @p p, read trilinearly. False = no volume holds it.
+ * @details Probes sit on the box's CORNERS, so a volume's own bounds are
+ * covered by its own probes and a read never extrapolates. Where two
+ * volumes overlap the SMALLER wins: a room inside a hall was baked to
+ * say something the hall's spacing could not.
+ */
+ bool sample(const glm::vec3& p, ProbeConstants& out) const {
+ const Volume* best = nullptr;
+ f32 bestSize = 0.0f;
+ for (const Volume& v : volumes_) {
+ if (p.x < v.min.x || p.x > v.max.x || p.y < v.min.y || p.y > v.max.y
+ || p.z < v.min.z || p.z > v.max.z) continue;
+ const glm::vec3 e = v.max - v.min;
+ const f32 size = e.x * e.y * e.z;
+ if (!best || size < bestSize) { best = &v; bestSize = size; }
+ }
+ if (!best) return false;
+
+ const ProbeVolume& g = *best->grid;
+ i32 low[3] = {0, 0, 0};
+ i32 high[3] = {0, 0, 0};
+ f32 frac[3] = {0.0f, 0.0f, 0.0f};
+ for (u32 a = 0; a < 3; ++a) {
+ const i32 n = g.resolution[static_cast<int>(a)];
+ if (n <= 1) continue;
+ const f32 span = best->max[static_cast<int>(a)] - best->min[static_cast<int>(a)];
+ f32 u = (p[static_cast<int>(a)] - best->min[static_cast<int>(a)]) / span
+ * static_cast<f32>(n - 1);
+ u = std::fmin(std::fmax(u, 0.0f), static_cast<f32>(n - 1));
+ i32 i0 = static_cast<i32>(std::floor(u));
+ if (i0 > n - 2) i0 = n - 2;
+ low[a] = i0;
+ high[a] = i0 + 1;
+ frac[a] = u - static_cast<f32>(i0);
+ }
+
+ const i32 strideY = g.resolution.x;
+ const i32 strideZ = g.resolution.x * g.resolution.y;
+ out = ProbeConstants{};
+ for (u32 corner = 0; corner < 8; ++corner) {
+ const f32 w = ((corner & 1u) ? frac[0] : 1.0f - frac[0])
+ * ((corner & 2u) ? frac[1] : 1.0f - frac[1])
+ * ((corner & 4u) ? frac[2] : 1.0f - frac[2]);
+ if (w <= 0.0f) continue;
+ const i32 x = (corner & 1u) ? high[0] : low[0];
+ const i32 y = (corner & 2u) ? high[1] : low[1];
+ const i32 z = (corner & 4u) ? high[2] : low[2];
+ const usize base = static_cast<usize>(x + y * strideY + z * strideZ) * 9;
+ for (u32 c = 0; c < 9; ++c) {
+ const glm::vec3& sh = g.irradiance[base + c];
+ out.irradiance[c].x += sh.x * w;
+ out.irradiance[c].y += sh.y * w;
+ out.irradiance[c].z += sh.z * w;
+ }
+ }
+ out.irradiance[0].w = 1.0f;
+ return true;
+ }
+
+private:
+ std::vector<Volume> volumes_;
+};
+
+} // namespace esengine
diff --git a/src/esengine/resource/Handle.hpp b/src/esengine/resource/Handle.hpp
index b82397f61..71985d19a 100644
--- a/src/esengine/resource/Handle.hpp
+++ b/src/esengine/resource/Handle.hpp
@@ -189,6 +189,7 @@ namespace esengine {
class IndexBuffer;
class Mesh;
class Environment;
+ class ProbeVolume;
}
// Forward-declared only — the native spine runtime was removed (spine is fully
@@ -227,6 +228,9 @@ using MeshHandle = Handle<esengine::Mesh>;
/** @brief Handle to a baked environment (irradiance + prefiltered reflection) */
using EnvironmentHandle = Handle<esengine::Environment>;
+/** @brief Handle to a grid of baked irradiance */
+using ProbeVolumeHandle = Handle<esengine::ProbeVolume>;
+
/** @brief Handle to a Spine skeleton data resource (vestigial — see fwd decl) */
using SpineDataHandle = Handle<esengine::spine::SpineSkeletonData>;
diff --git a/src/esengine/resource/ProbeVolume.hpp b/src/esengine/resource/ProbeVolume.hpp
new file mode 100644
index 000000000..bbfd89661
--- /dev/null
+++ b/src/esengine/resource/ProbeVolume.hpp
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file ProbeVolume.hpp
+ * @brief A baked environment sampled on a grid, rather than held at one value.
+ */
+#pragma once
+
+#include "../core/Types.hpp"
+#include "../math/Math.hpp"
+
+#include <vector>
+
+namespace esengine {
+
+/**
+ * @brief Irradiance at a grid of points — an @ref Environment sampled, not held.
+ *
+ * @details The same nine coefficients per probe, running x fastest then y then z:
+ * the order a bake writes and a trilinear read assumes. Where the grid
+ * STANDS is the component's, so moving a volume moves the light it holds
+ * and one bake can be read at a second placement.
+ */
+class ProbeVolume {
+public:
+ /** @brief Probes along each axis. One on an axis is a constant along it —
+ * which is what an Environment already is — so a flat volume is the
+ * same case and not a second one. */
+ glm::ivec3 resolution{0};
+
+ /** @brief Nine RGB coefficients per probe, in grid order. */
+ std::vector<glm::vec3> irradiance;
+
+ u32 probeCount() const {
+ if (resolution.x <= 0 || resolution.y <= 0 || resolution.z <= 0) return 0;
+ return static_cast<u32>(resolution.x) * static_cast<u32>(resolution.y)
+ * static_cast<u32>(resolution.z);
+ }
+
+ bool isValid() const {
+ const u32 probes = probeCount();
+ return probes > 0 && irradiance.size() == static_cast<usize>(probes) * 9;
+ }
+};
+
+} // namespace esengine
diff --git a/src/esengine/resource/ResourceManager.cpp b/src/esengine/resource/ResourceManager.cpp
index 77aab7246..781a48bc1 100644
--- a/src/esengine/resource/ResourceManager.cpp
+++ b/src/esengine/resource/ResourceManager.cpp
@@ -854,6 +854,35 @@ void ResourceManager::releaseEnvironment(EnvironmentHandle handle) {
environments_.release(handle.id());
}
+ProbeVolumeHandle ResourceManager::createProbeVolume(const glm::ivec3& resolution,
+ ConstSpan<f32> irradiance) {
+ auto volume = std::make_unique<ProbeVolume>();
+ volume->resolution = resolution;
+ const usize want = static_cast<usize>(volume->probeCount()) * 27;
+ if (want == 0 || irradiance.size() != want) {
+ ES_LOG_ERROR("createProbeVolume: {}x{}x{} probes want {} coefficients, got {}",
+ resolution.x, resolution.y, resolution.z, want, irradiance.size());
+ return ProbeVolumeHandle();
+ }
+ volume->irradiance.resize(want / 3);
+ for (usize i = 0; i < volume->irradiance.size(); ++i) {
+ volume->irradiance[i] = {irradiance[i * 3], irradiance[i * 3 + 1], irradiance[i * 3 + 2]};
+ }
+ return probeVolumes_.add(std::move(volume));
+}
+
+ProbeVolume* ResourceManager::getProbeVolume(ProbeVolumeHandle handle) {
+ return probeVolumes_.get(handle);
+}
+
+const ProbeVolume* ResourceManager::getProbeVolume(ProbeVolumeHandle handle) const {
+ return probeVolumes_.get(handle);
+}
+
+void ResourceManager::releaseProbeVolume(ProbeVolumeHandle handle) {
+ probeVolumes_.release(handle.id());
+}
+
// =============================================================================
// Index Buffer Resources
// =============================================================================
diff --git a/src/esengine/resource/ResourceManager.hpp b/src/esengine/resource/ResourceManager.hpp
index dccb41086..80ee0609f 100644
--- a/src/esengine/resource/ResourceManager.hpp
+++ b/src/esengine/resource/ResourceManager.hpp
@@ -29,6 +29,7 @@
#include "../renderer/rhi/Buffer.hpp"
#include "Mesh.hpp"
#include "Environment.hpp"
+#include "ProbeVolume.hpp"
#include "../text/BitmapFont.hpp"
// Standard library
@@ -551,6 +552,20 @@ public:
* its own lifetime, so it is NOT released here. */
void releaseEnvironment(EnvironmentHandle handle);
+ /**
+ * @brief Registers a grid of baked irradiance.
+ * @param resolution Probes along x, y and z.
+ * @param irradiance Nine RGB coefficients per probe, x fastest then y then z.
+ */
+ ProbeVolumeHandle createProbeVolume(const glm::ivec3& resolution, ConstSpan<f32> irradiance);
+
+ /** @brief The probe volume a handle names, or null. */
+ ProbeVolume* getProbeVolume(ProbeVolumeHandle handle);
+ const ProbeVolume* getProbeVolume(ProbeVolumeHandle handle) const;
+
+ /** @brief Releases a probe volume. */
+ void releaseProbeVolume(ProbeVolumeHandle handle);
+
/**
* @brief Gets a vertex buffer by handle
* @param handle The buffer handle
@@ -691,6 +706,7 @@ private:
ResourcePool<IndexBuffer> indexBuffers_;
ResourcePool<Mesh> meshes_;
ResourcePool<Environment> environments_;
+ ResourcePool<ProbeVolume> probeVolumes_;
ResourcePool<text::BitmapFont> fonts_;
/// Handles whose GPU texture died with the device, still showing the
/// placeholder. Empty means the content is whole again.
diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cpp
index 14367b0e7..8028075af 100644
--- a/src/esengine/resource/ShaderParser.cpp
+++ b/src/esengine/resource/ShaderParser.cpp
@@ -970,6 +970,8 @@ struct LightConstants {
u_envTint : vec4f,
};
@group(0) @binding(2) var<uniform> lc : LightConstants;
+struct ProbeConstants { u_probeIrradiance : array<vec4f, 9> };
+@group(0) @binding(7) var<uniform> pc : ProbeConstants;
fn packDepth(d : f32) -> vec3f {
let enc = fract(d * vec3f(1.0, 255.0, 65025.0));
return enc - enc.yzz * vec3f(1.0 / 255.0, 1.0 / 255.0, 0.0);
@@ -1197,19 +1199,30 @@ fn envDirection(d : vec3f) -> vec3f {
let c = cos(a);
return vec3f(c * d.x + s * d.z, d.y, -s * d.x + c * d.z);
}
+fn shIrradiance(sh : array<vec4f, 9>, N : vec3f) -> vec3f {
+ return sh[0].rgb * 0.282095
+ + sh[1].rgb * (0.488603 * N.y)
+ + sh[2].rgb * (0.488603 * N.z)
+ + sh[3].rgb * (0.488603 * N.x)
+ + sh[4].rgb * (1.092548 * N.x * N.y)
+ + sh[5].rgb * (1.092548 * N.y * N.z)
+ + sh[6].rgb * (0.315392 * (3.0 * N.z * N.z - 1.0))
+ + sh[7].rgb * (1.092548 * N.x * N.z)
+ + sh[8].rgb * (0.546274 * (N.x * N.x - N.y * N.y));
+}
fn envIrradiance(Nw : vec3f) -> vec3f {
- let N = envDirection(Nw);
- let sh = lc.u_envIrradiance[0].rgb * 0.282095
- + lc.u_envIrradiance[1].rgb * (0.488603 * N.y)
- + lc.u_envIrradiance[2].rgb * (0.488603 * N.z)
- + lc.u_envIrradiance[3].rgb * (0.488603 * N.x)
- + lc.u_envIrradiance[4].rgb * (1.092548 * N.x * N.y)
- + lc.u_envIrradiance[5].rgb * (1.092548 * N.y * N.z)
- + lc.u_envIrradiance[6].rgb * (0.315392 * (3.0 * N.z * N.z - 1.0))
- + lc.u_envIrradiance[7].rgb * (1.092548 * N.x * N.z)
- + lc.u_envIrradiance[8].rgb * (0.546274 * (N.x * N.x - N.y * N.y));
+ let sh = shIrradiance(lc.u_envIrradiance, envDirection(Nw));
return lc.u_ambient.rgb + max(sh, vec3f(0.0)) * lc.u_envTint.rgb;
}
+// The GLSL twin's indirectIrradiance: a volume replaces the environment, because a
+// surface has one indirect term and a volume already holds every light and bounce
+// that reached the point.
+fn indirectIrradiance(N : vec3f) -> vec3f {
+ if (pc.u_probeIrradiance[0].w > 0.5) {
+ return max(shIrradiance(pc.u_probeIrradiance, N), vec3f(0.0));
+ }
+ return envIrradiance(N);
+}
fn octEncode(d : vec3f) -> vec2f {
var p = d.xz / max(abs(d.x) + abs(d.y) + abs(d.z), 1e-6);
if (d.y < 0.0) {
@@ -1287,7 +1300,7 @@ fn applyLightingPBR(albedo : vec3f, N : vec3f, worldPos : vec3f, V : vec3f, meta
let F0 = mix(vec3f(0.04), albedo, vec3f(metallic));
let a = max(roughness * roughness, 1e-3);
let NdotV = max(dot(N, V), 1e-4);
- var lit = envIrradiance(N) * ao;
+ var lit = indirectIrradiance(N) * ao;
var gloss = vec3f(0.0);
for (var i = 0; i < 16; i++) {
let pd = lc.u_lights[i].posDir;
@@ -1672,6 +1685,12 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
" highp vec4 u_envParams;\n" // x = has map, y = range, z = maxLod, w = face
" highp vec4 u_envTint;\n" // the ambient light's colour, scaling both halves
"};\n"
+ // Where THIS draw stands, when a grid was baked around it. The flag in
+ // w is the only way a fragment tells "no volume" from "a probe in the
+ // dark" — zeroed coefficients are an answer, not an absence.
+ "layout(std140) uniform ProbeConstants {\n"
+ " highp vec4 u_probeIrradiance[9];\n"
+ "};\n"
// The shadow map rides the draw's third texture slot, behind the feature the
// MESH vertex sources set: the batch stream owns 0..7 as a per-vertex merge
// product, so a sampler pinned to slot 2 there would read someone's sprite.
@@ -1925,22 +1944,35 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
" highp float c = cos(a);\n"
" return vec3(c * d.x + s * d.z, d.y, -s * d.x + c * d.z);\n"
"}\n"
- // The environment's diffuse half. With no environment the coefficients are
- // zero and this IS the flat ambient term, which is what keeps every existing
+ // Nine coefficients at a normal. One expression: an environment and a
+ // probe volume differ in where the nine came from, not in what they mean.
+ "highp vec3 shIrradiance(in highp vec4 sh[9], in highp vec3 N) {\n"
+ " return sh[0].rgb * 0.282095\n"
+ " + sh[1].rgb * (0.488603 * N.y)\n"
+ " + sh[2].rgb * (0.488603 * N.z)\n"
+ " + sh[3].rgb * (0.488603 * N.x)\n"
+ " + sh[4].rgb * (1.092548 * N.x * N.y)\n"
+ " + sh[5].rgb * (1.092548 * N.y * N.z)\n"
+ " + sh[6].rgb * (0.315392 * (3.0 * N.z * N.z - 1.0))\n"
+ " + sh[7].rgb * (1.092548 * N.x * N.z)\n"
+ " + sh[8].rgb * (0.546274 * (N.x * N.x - N.y * N.y));\n"
+ "}\n"
+ // The environment's diffuse half. With no environment the coefficients
+ // are zero and this IS the flat ambient term, which keeps every existing
// scene pixel-identical rather than merely close.
"highp vec3 envIrradiance(in highp vec3 Nw) {\n"
- " highp vec3 N = envDirection(Nw);\n"
- " highp vec3 sh = u_envIrradiance[0].rgb * 0.282095\n"
- " + u_envIrradiance[1].rgb * (0.488603 * N.y)\n"
- " + u_envIrradiance[2].rgb * (0.488603 * N.z)\n"
- " + u_envIrradiance[3].rgb * (0.488603 * N.x)\n"
- " + u_envIrradiance[4].rgb * (1.092548 * N.x * N.y)\n"
- " + u_envIrradiance[5].rgb * (1.092548 * N.y * N.z)\n"
- " + u_envIrradiance[6].rgb * (0.315392 * (3.0 * N.z * N.z - 1.0))\n"
- " + u_envIrradiance[7].rgb * (1.092548 * N.x * N.z)\n"
- " + u_envIrradiance[8].rgb * (0.546274 * (N.x * N.x - N.y * N.y));\n"
+ " highp vec3 sh = shIrradiance(u_envIrradiance, envDirection(Nw));\n"
" return u_ambient.rgb + max(sh, vec3(0.0)) * u_envTint.rgb;\n"
"}\n"
+ // The indirect term every lit surface starts from. A volume REPLACES the
+ // environment rather than adding to it — a surface has one indirect term
+ // — and its nine are world-space, so neither rotation nor tint applies.
+ "highp vec3 indirectIrradiance(in highp vec3 N) {\n"
+ " if (u_probeIrradiance[0].w > 0.5) {\n"
+ " return max(shIrradiance(u_probeIrradiance, N), vec3(0.0));\n"
+ " }\n"
+ " return envIrradiance(N);\n"
+ "}\n"
// Direction -> the octahedral unit square, +Y at the centre. The importer's
// octEncode, in the shading language; the two must agree texel for texel.
"highp vec2 octEncode(in highp vec3 d) {\n"
@@ -2039,7 +2071,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p
" highp float NdotV = max(dot(N, V), 1e-4);\n"
// Occlusion darkens the light that arrives from everywhere, which is the
// environment; a surface's own lights are unobstructed by it.
- " highp vec3 lit = envIrradiance(N) * ao;\n"
+ " highp vec3 lit = indirectIrradiance(N) * ao;\n"
" highp vec3 gloss = vec3(0.0);\n"
// A Light has no third coordinate, so distance stays in the plane and a
// point light's height is its radius. Normal and view are the 3D part.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f7b1a96e2..e086b6232 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -234,6 +234,17 @@ target_include_directories(test_lod_selection PRIVATE
)
add_test(NAME test_lod_selection COMMAND test_lod_selection)
+# Which volume holds a point, and what it says there. Header-only, so it runs
+# without a device — the pixel gates say a draw came out the wrong colour, this
+# says whether the read left the box, took the wrong volume, or accepted a grid
+# too short to fill it.
+add_executable(test_probe_store renderer/test_probe_store.cpp)
+target_include_directories(test_probe_store PRIVATE
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/third_party/glm
+)
+add_test(NAME test_probe_store COMMAND test_probe_store)
+
add_executable(test_shadow_atlas renderer/test_shadow_atlas.cpp)
target_include_directories(test_shadow_atlas PRIVATE
${CMAKE_SOURCE_DIR}/src
diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.h
index 67307cd6a..0d77274ee 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 0xb6ad0af24d9719e3ULL
+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x30739b8914679e3fULL
/* 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 0330e98d1..b40eb6ef4 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 0xb6ad0af24d9719e3ULL
+#define ES_ABI_ENGINE_DIGEST 0x30739b8914679e3fULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_decl.c b/tests/aot/generated/move_system_decl.c
index 57ae0ebb4..17e3325a3 100644
--- a/tests/aot/generated/move_system_decl.c
+++ b/tests/aot/generated/move_system_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 0xb6ad0af24d9719e3ULL
+#define ES_ABI_ENGINE_DIGEST 0x30739b8914679e3fULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_hash.h b/tests/aot/generated/move_system_hash.h
index f4ab3e09e..f6e674722 100644
--- a/tests/aot/generated/move_system_hash.h
+++ b/tests/aot/generated/move_system_hash.h
@@ -1,6 +1,6 @@
/* GENERATED by @estella/compiler — do not edit. */
/* The contract half of the handshake. The width half is the harness. */
-#define ES_EXPECTED_CONTRACT_HASH 0xb6ad0af24d9719e3ULL
+#define ES_EXPECTED_CONTRACT_HASH 0x30739b8914679e3fULL
/* And which BUILD the artifact beside this one is, which the sidecar
written with it has to carry too. */
#define ES_EXPECTED_MODULE_CONTRACT 0x10bf77bb714ea1e3ULL
diff --git a/tests/renderer/test_probe_store.cpp b/tests/renderer/test_probe_store.cpp
new file mode 100644
index 000000000..5f57023bb
--- /dev/null
+++ b/tests/renderer/test_probe_store.cpp
@@ -0,0 +1,130 @@
+// What a probe volume answers at a point, without a device. A pixel gate says a
+// draw came out wrong; only this says whether the read left the box, took the
+// wrong volume, or accepted a grid too short to fill it.
+
+#include "esengine/renderer/store/ProbeStore.hpp"
+
+#include <cmath>
+#include <cstdio>
+
+using namespace esengine;
+
+static int g_failures = 0;
+#define CHECK(cond, msg) \
+ do { \
+ if (!(cond)) { std::printf("FAIL: %s\n", msg); ++g_failures; } \
+ else { std::printf("ok: %s\n", msg); } \
+ } while (0)
+
+static bool near(f32 a, f32 b, f32 eps = 1e-4f) { return std::fabs(a - b) < eps; }
+
+/** A grid whose FIRST coefficient runs from `a` to `b` along one axis. */
+static ProbeVolume ramp(const glm::ivec3& resolution, const glm::vec3& a, const glm::vec3& b) {
+ ProbeVolume v;
+ v.resolution = resolution;
+ const u32 probes = resolution.x * resolution.y * resolution.z;
+ v.irradiance.assign(static_cast<usize>(probes) * 9, glm::vec3(0.0f));
+ for (u32 i = 0; i < probes; ++i) {
+ const f32 t = probes > 1 ? static_cast<f32>(i) / static_cast<f32>(probes - 1) : 0.0f;
+ v.irradiance[static_cast<usize>(i) * 9] = a + (b - a) * t;
+ }
+ return v;
+}
+
+/** A point inside a one-probe volume reads that probe, and a point outside reads
+ * nothing at all — which is not the same as reading a probe that happens to be
+ * black, and is the distinction a pixel cannot draw. */
+static void testInsideAndOutside() {
+ ProbeVolume v = ramp({1, 1, 1}, {2.0f, 0.0f, 0.0f}, {2.0f, 0.0f, 0.0f});
+ ProbeStore store;
+ store.add({-10.0f, -10.0f, -10.0f}, {10.0f, 10.0f, 10.0f}, &v);
+
+ ProbeConstants out{};
+ CHECK(store.sample({0.0f, 0.0f, 0.0f}, out), "a point in the box is held by it");
+ CHECK(near(out.irradiance[0].x, 2.0f), "one probe is a constant field");
+ CHECK(near(out.irradiance[0].w, 1.0f), "the flag says a volume answered");
+
+ ProbeConstants outside{};
+ CHECK(!store.sample({11.0f, 0.0f, 0.0f}, outside), "a point past the box is held by nothing");
+ CHECK(near(outside.irradiance[0].w, 0.0f), "and nothing was written into the block");
+}
+
+/** The corners carry the ends, so a read at either end is exactly that probe and
+ * a read between them is a mixture — never the nearer of the two. */
+static void testTrilinearOnEachAxis() {
+ const glm::vec3 lo{1.0f, 0.0f, 0.0f};
+ const glm::vec3 hi{0.0f, 0.0f, 1.0f};
+ const struct { glm::ivec3 res; int axis; } cases[] = {
+ {{2, 1, 1}, 0}, {{1, 2, 1}, 1}, {{1, 1, 2}, 2},
+ };
+ for (const auto& c : cases) {
+ ProbeVolume v = ramp(c.res, lo, hi);
+ ProbeStore store;
+ store.add({-100.0f, -100.0f, -100.0f}, {100.0f, 100.0f, 100.0f}, &v);
+
+ glm::vec3 at{0.0f};
+ ProbeConstants out{};
+ at[c.axis] = -100.0f;
+ CHECK(store.sample(at, out) && near(out.irradiance[0].x, 1.0f)
+ && near(out.irradiance[0].z, 0.0f), "the low corner reads the first probe");
+ at[c.axis] = 100.0f;
+ CHECK(store.sample(at, out) && near(out.irradiance[0].x, 0.0f)
+ && near(out.irradiance[0].z, 1.0f), "the high corner reads the last probe");
+ at[c.axis] = 0.0f;
+ CHECK(store.sample(at, out) && near(out.irradiance[0].x, 0.5f)
+ && near(out.irradiance[0].z, 0.5f), "halfway reads half of each");
+ }
+}
+
+/** A room baked inside a hall was baked to say something the hall's spacing could
+ * not, so where both hold a point the smaller one answers. */
+static void testSmallestVolumeWins() {
+ ProbeVolume hall = ramp({1, 1, 1}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f});
+ ProbeVolume room = ramp({1, 1, 1}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f});
+ ProbeStore store;
+ store.add({-100.0f, -100.0f, -100.0f}, {100.0f, 100.0f, 100.0f}, &hall);
+ store.add({-10.0f, -10.0f, -10.0f}, {10.0f, 10.0f, 10.0f}, &room);
+
+ ProbeConstants out{};
+ CHECK(store.sample({0.0f, 0.0f, 0.0f}, out) && near(out.irradiance[0].z, 1.0f),
+ "inside both, the smaller volume answers");
+ CHECK(store.sample({50.0f, 0.0f, 0.0f}, out) && near(out.irradiance[0].x, 1.0f),
+ "outside the smaller one, the larger still does");
+
+ // Order must not decide it: the same two added the other way round agree.
+ ProbeStore reversed;
+ reversed.add({-10.0f, -10.0f, -10.0f}, {10.0f, 10.0f, 10.0f}, &room);
+ reversed.add({-100.0f, -100.0f, -100.0f}, {100.0f, 100.0f, 100.0f}, &hall);
+ CHECK(reversed.sample({0.0f, 0.0f, 0.0f}, out) && near(out.irradiance[0].z, 1.0f),
+ "and the order they were collected in does not change that");
+}
+
+/** A grid that cannot be read is refused whole. Half a volume would light part of
+ * a room and read past its own coefficients for the rest. */
+static void testMalformedGridsRefused() {
+ ProbeStore store;
+ ProbeVolume shortOfCoefficients;
+ shortOfCoefficients.resolution = {2, 2, 2};
+ shortOfCoefficients.irradiance.assign(9, glm::vec3(0.0f)); // one probe's worth of eight
+ store.add({-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}, &shortOfCoefficients);
+ CHECK(store.empty(), "a grid short of coefficients is not taken");
+
+ ProbeVolume fine = ramp({1, 1, 1}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f});
+ store.add({1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, &fine);
+ CHECK(store.empty(), "a box with no inside is not taken either");
+ store.add({-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}, nullptr);
+ CHECK(store.empty(), "and neither is a volume with no grid");
+
+ store.add({-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}, &fine);
+ CHECK(store.count() == 1, "the one that can be read is");
+}
+
+int main() {
+ testInsideAndOutside();
+ testTrilinearOnEachAxis();
+ testSmallestVolumeWins();
+ testMalformedGridsRefused();
+ std::printf(g_failures ? "\n%d failure(s)\n" : "\nall probe store claims hold\n",
+ g_failures);
+ return g_failures ? 1 : 0;
+}
diff --git a/tools/baselines/sdk-test-types.json b/tools/baselines/sdk-test-types.json
index 65c9a32fd..31615088b 100644
--- a/tools/baselines/sdk-test-types.json
+++ b/tools/baselines/sdk-test-types.json
@@ -36,9 +36,6 @@
"tests/api-baseline-rules.test.ts": {
"TS7016|Could not find a declaration file for module '../../tools/lib/apiSnapshot.mjs'. 'tools/lib/apiSnapshot.mjs' implicitly has an 'any' type.": 1
},
- "tests/asset-refcounter-integration.test.ts": {
- "TS2739|Type '{ textureHandles: Map<any, any>; materialHandles: Map<any, any>; fontHandles: Map<any, any>; releaseCallbacks: never[]; missing: never[]; }' is missing the following properties from type 'SceneAssetResult': meshHandles, environmentHandles, scope": 1
- },
"tests/assets-invalidate-event.test.ts": {
"TS2673|Constructor of class 'Assets' is private and only accessible within the class declaration.": 1
},
diff --git a/tools/check-corpus-authoring.mjs b/tools/check-corpus-authoring.mjs
index a48acc0a4..22122d476 100644
--- a/tools/check-corpus-authoring.mjs
+++ b/tools/check-corpus-authoring.mjs
@@ -119,6 +119,7 @@ const DISPOSITION = {
// — owed: a creator-facing component nothing in the shipped corpus authors.
// Each reason names where the coverage belongs. —
+ LightProbeVolume: ['owed', 'the reading side is in and a grid written by hand falsifies it, but nothing SOLVES one yet; a corpus scene can carry a volume once a bake can fill it'],
};
diff --git a/tools/check-gizmo-coverage.mjs b/tools/check-gizmo-coverage.mjs
index f60d2e324..8a4a7cfee 100644
--- a/tools/check-gizmo-coverage.mjs
+++ b/tools/check-gizmo-coverage.mjs
@@ -77,6 +77,7 @@ const DISPOSITION = {
'Light.radius': 'extent',
'Light.innerRadius': 'extent',
'Light.cookieSize': 'extent',
+ 'LightProbeVolume.halfExtents': 'extent',
'MeleeAttack.radius': 'extent',
'AudioSource.minDistance': 'extent',
'AudioSource.maxDistance': 'extent',
diff --git a/tools/check-shader-blocks.mjs b/tools/check-shader-blocks.mjs
index 5e6c6b6b2..e8681d0d3 100644
--- a/tools/check-shader-blocks.mjs
+++ b/tools/check-shader-blocks.mjs
@@ -109,13 +109,19 @@ function glslBlock(name) {
.map((f) => `${bare(f[1])}${f[2] ? `[${f[2]}]` : ''}`);
}
+/**
+ * Commas BETWEEN things, which the ones inside `array<T, N>` are not. One rule
+ * for the two readers that need it: a struct's fields, and a function's
+ * arguments — where counting an array's length as an argument makes the same
+ * helper look like it takes one more on WGSL than it does on GLSL.
+ */
+const BETWEEN = /,(?![^<]*>)/;
+
/** WGSL: `struct Name { a : vec4f, b : array<T, 16> };` */
function wgslBlock(name) {
const m = new RegExp(`struct\\s+${name}\\s*\\{([^}]*)\\}`, 'm').exec(text);
if (!m) return null;
- // Split on the commas BETWEEN fields, which the ones inside `array<T, N>`
- // are not — reading a field as "up to the next comma" loses every length.
- return m[1].split(/,(?![^<]*>)/).map((f) => f.trim()).filter(Boolean).map((f) => {
+ return m[1].split(BETWEEN).map((f) => f.trim()).filter(Boolean).map((f) => {
const [, name, type] = /^(\w+)\s*:\s*([\s\S]+)$/.exec(f) ?? [];
if (!name) return '';
const count = /array\s*<[^,>]+,\s*(\d+)\s*>/.exec(type);
@@ -187,7 +193,7 @@ function helpers(pattern) {
for (const m of text.matchAll(pattern)) {
const args = m[2].trim();
const counts = out.get(m[1]) ?? [];
- counts.push(args === '' ? 0 : args.split(',').length);
+ counts.push(args === '' ? 0 : args.split(BETWEEN).length);
out.set(m[1], counts.sort());
}
return out;
diff --git a/tools/gen-shader-twins.mjs b/tools/gen-shader-twins.mjs
index f80a12279..33e220a7b 100644
--- a/tools/gen-shader-twins.mjs
+++ b/tools/gen-shader-twins.mjs
@@ -56,8 +56,19 @@ const BLOCK_BINDINGS = {
MaterialConstants: 1,
LightConstants: 2,
TimeConstants: 3,
+ // The indirect light where a draw stands, which the injected Lit header
+ // declares for every Lit fragment stage — see ProbeConstants.hpp.
+ ProbeConstants: 7,
};
+/** The blocks above, as the pattern that finds them. Derived and not spelled a
+ * second time: a block added to the table but missing from a hand-written
+ * alternation is one glslang refuses for want of a binding. */
+const BLOCK_DECLARATION = new RegExp(
+ String.raw`layout\s*\(\s*std140\s*\)\s*uniform\s+(${Object.keys(BLOCK_BINDINGS).join('|')})\b`,
+ 'g',
+);
+
// The samplers the Lit-2D header declares, on the units it pins them to. Mirrors
// LightConstants.hpp, which is where a unit is decided: a twin generated against a
// stale copy binds the wrong texture and says nothing.
@@ -109,7 +120,7 @@ function adaptGlsl(glsl, textures) {
// Engine UBO slots as explicit bindings (SPIR-V descriptor set 0 = WGSL group 0).
out = out.replace(
- /layout\s*\(\s*std140\s*\)\s*uniform\s+(FrameConstants|MaterialConstants|LightConstants|TimeConstants)\b/g,
+ BLOCK_DECLARATION,
(m, name) => `layout(std140, binding = ${BLOCK_BINDINGS[name]}) uniform ${name}`,
);
diff --git a/tools/make-probe-fixture.mjs b/tools/make-probe-fixture.mjs
new file mode 100644
index 000000000..5b9364200
--- /dev/null
+++ b/tools/make-probe-fixture.mjs
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * Regenerate the light-probe fixtures: four grids solved by hand, as the INVERSE
+ * of the shader's basis — irradiance `c` everywhere means a constant term of
+ * `c / 0.282095`. That is what lets a gate name an exact pixel.
+ *
+ * node tools/make-probe-fixture.mjs
+ */
+import { writeFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const OUT = path.join(ROOT, 'fixtures', 'scenes');
+
+/** The shader's basis at order zero and at the +X lobe — ShaderParser's numbers. */
+const Y00 = 0.282095;
+const Y11 = 0.488603;
+
+/** Nine RGB coefficients whose irradiance is `rgb` from every direction. */
+function constant(rgb) {
+ const sh = new Array(27).fill(0);
+ for (let c = 0; c < 3; c++) sh[c] = rgb[c] / Y00;
+ return sh;
+}
+
+/** The same, plus `rgb` more wherever the normal points along +X. */
+function alongX(base, rgb) {
+ const sh = constant(base);
+ for (let c = 0; c < 3; c++) sh[9 + c] = rgb[c] / Y11;
+ return sh;
+}
+
+const RED = [1, 0, 0];
+const BLUE = [0, 0, 1];
+const GREY = [0.5, 0.5, 0.5];
+
+const FIXTURES = {
+ // One probe: a volume may be a constant field, and that is the case a grid of
+ // one exercises — including the read, which must not divide by a zero span.
+ 'probe-red.esprobes': { resolution: [1, 1, 1], irradiance: constant(RED) },
+ 'probe-blue.esprobes': { resolution: [1, 1, 1], irradiance: constant(BLUE) },
+ // Grey everywhere, red only where a surface faces +X. The fixture mesh's two
+ // triangles face +Z and +X, so one draw shows both halves of the claim.
+ 'probe-facing.esprobes': { resolution: [1, 1, 1], irradiance: alongX(GREY, [0.5, 0, 0]) },
+ // Red at one end, blue at the other: what stands between them must be neither.
+ 'probe-ends.esprobes': {
+ resolution: [2, 1, 1],
+ irradiance: [...constant(RED), ...constant(BLUE)],
+ },
+};
+
+for (const [name, data] of Object.entries(FIXTURES)) {
+ const doc = { version: 1, resolution: data.resolution, irradiance: data.irradiance };
+ // One line per member: a grid is hundreds of numbers, and a diff of it is
+ // worth reading only if the numbers stay where they were.
+ const text = `{\n "version": ${doc.version},\n`
+ + ` "resolution": ${JSON.stringify(doc.resolution)},\n`
+ + ` "irradiance": ${JSON.stringify(doc.irradiance)}\n}\n`;
+ writeFileSync(path.join(OUT, name), text);
+ console.log(`wrote ${name}: ${data.resolution.join('x')} probes`);
+}
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index d44b330c5..48bbc0b6d 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,11 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'feat(render): a thing that moves takes the light of the room it is in':
+ { note: 'Light probes: what lights a thing a bake cannot hold still.' },
+ 'feat(lighting): a probe volume is a box a creator can see and place':
+ { note: 'Light probes: what lights a thing a bake cannot hold still.' },
+
'fix(sdk): a reloaded bundle addresses the world it is reloading into':
{ note: 'A hot reload no longer empties the running game of every resource' },
'feat(sdk): an app says what its resources are called':
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 967ff2e92..87df1d6ea 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -127,6 +127,25 @@ export const SCENES = [
// the two objects drawn from them read different halves of it. A rectangle
// that belonged to the mesh would paint these two the same colour.
{ id: "lightmap-atlas", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/lightmap-atlas-share.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/lightmap-atlas-share.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.25,\"y\":0.4,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.25,\"y\":0.6,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.75,\"y\":0.4,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.75,\"y\":0.6,\"rgb\":[0,0,255],\"tol\":30}]" } },
+ // TWO morphed draws in one pass, a quarter of the way and all of it. A per-draw
+ // block they SHARE is written twice before either draws on a backend that queues
+ // uploads, so both wear the last weight — invisible to a single-object scene.
+ { id: "mesh-morph-two", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/mesh-morph-two.esscene", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.375,\"y\":0.25,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.25,\"rgb\":[0,0,0],\"tol\":20},{\"x\":0.75,\"y\":0.75,\"rgb\":[0,255,0],\"tol\":30}]" } },
+ // WHAT LIGHTS A THING THAT MOVES. There is no light in this scene at all: the
+ // only thing that can colour these triangles is the grid the volume holds.
+ { id: "probe-lit", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/probe-lit.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/probe-lit.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.3,\"y\":0.556,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.7,\"y\":0.556,\"rgb\":[255,0,0],\"tol\":30}]" } },
+ // The nine coefficients carry a DIRECTION, not just an amount. The fixture's
+ // two triangles face +Z and +X, and the grid is grey with red along +X — so a
+ // volume flattened to its constant term paints these two the same grey.
+ { id: "probe-facing", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/probe-facing.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/probe-facing.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.3,\"y\":0.556,\"rgb\":[128,128,128],\"tol\":30},{\"x\":0.7,\"y\":0.556,\"rgb\":[255,128,128],\"tol\":30}]" } },
+ // Red at one end of the box, blue at the other. The object in the MIDDLE is the
+ // claim: nearest-probe would paint it one of the two, and only a read that
+ // interpolates can put it between them.
+ { id: "probe-blend", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/probe-blend.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/probe-blend.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.26,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.46,\"y\":0.5,\"rgb\":[128,0,128],\"tol\":30},{\"x\":0.66,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":30}]" } },
+ // A baked surface and a probe-lit one inside ONE volume. The bake already holds
+ // every bounce that reached it, so the atlas half must stay red: a draw taking
+ // both would come out purple, and only a frame with both in it can say so.
+ { id: "probe-lightmap", tier: "pr", webgpu: true, env: { "ESTELLA_VERIFY_SCENE": "/scenes/probe-lightmap.esscene", "ESTELLA_VERIFY_MANIFEST": "/scenes/probe-lightmap.textures.json", "ESTELLA_VERIFY_W": "256", "ESTELLA_VERIFY_H": "256", "ESTELLA_VERIFY_STEPS": "2", "ESTELLA_VERIFY_EXPECT": "[{\"x\":0.25,\"y\":0.5667,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.85,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":30}]" } },
// A clip driving the weight, which is what an imported `weights` channel
// becomes. The shape has to cross the boundary as a LIST — a weight written
// into a component the runtime hands back as an embind vector goes nowhere.