@forgeax/engine-shader 0.1.7 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/ShaderRegistry.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/dist/material-schemas.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/ShaderRegistry.ts +50 -0
- package/src/__tests__/bloom-fxaa-tonemap.unit.test.ts +86 -12
- package/src/__tests__/default-standard-pbr-transmission.unit.test.ts +185 -0
- package/src/__tests__/fog-oracle.unit.test.ts +110 -114
- package/src/__tests__/fog-orthographic-ray.unit.test.ts +12 -37
- package/src/__tests__/fog-producer-matrix.integration.test.ts +16 -51
- package/src/__tests__/lighting-point-spot-volume.unit.test.ts +48 -0
- package/src/__tests__/lighting-punctual.unit.test.ts +1 -1
- package/src/__tests__/lighting-spot-volume-attenuation.unit.test.ts +26 -0
- package/src/__tests__/lighting-spot-volume.unit.test.ts +25 -0
- package/src/__tests__/material-builtins.unit.test.ts +38 -1
- package/src/__tests__/material-contract.unit.test.ts +123 -0
- package/src/__tests__/motion-blur.unit.test.ts +44 -0
- package/src/__tests__/scene-temporal.unit.test.ts +23 -5
- package/src/__tests__/shader-manifest-transmission.unit.test.ts +75 -0
- package/src/__tests__/shader.unit.test.ts +44 -3
- package/src/__tests__/sprite-variants.unit.test.ts +20 -0
- package/src/__tests__/taa-resolve.unit.test.ts +75 -3
- package/src/__tests__/transmission-thickness-scale.unit.test.ts +19 -0
- package/src/common.wgsl +34 -65
- package/src/default-standard-pbr-skin.wgsl +29 -28
- package/src/default-standard-pbr.wgsl +257 -57
- package/src/fxaa.wgsl +5 -6
- package/src/hdrp-cluster-forward.wgsl +41 -3
- package/src/hdrp-deferred-lighting.wgsl +3 -27
- package/src/index.ts +3 -0
- package/src/lighting-attenuation.wgsl +58 -0
- package/src/lighting-directional.wgsl +31 -3
- package/src/lighting-punctual.wgsl +57 -12
- package/src/material-schemas.ts +7 -0
- package/src/motion-blur.wgsl +77 -0
- package/src/msdf-text.wgsl +4 -23
- package/src/pbr-temporal.wgsl +15 -2
- package/src/scene-temporal.wgsl +54 -0
- package/src/shadow-pcf.wgsl +31 -10
- package/src/shadow_caster.wgsl +27 -2
- package/src/skybox.wgsl +2 -7
- package/src/sprite-lit.wgsl +7 -25
- package/src/sprite.wgsl +7 -25
- package/src/taa-resolve.wgsl +76 -81
- package/src/tonemap.wgsl +7 -9
- package/src/unlit.wgsl +7 -28
- package/src/volume/volume-composite.wgsl +113 -0
- package/src/volume/volume-inject.wgsl +249 -0
- package/src/volume/volume-integrate.wgsl +342 -0
- package/src/volume/volume-temporal.wgsl +70 -0
- package/dist/__tests__/atmosphere-background.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-background.test.d.ts.map +0 -1
- package/dist/__tests__/atmosphere-cubemap-orientation.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-cubemap-orientation.test.d.ts.map +0 -1
- package/dist/__tests__/atmosphere-preetham-numeric.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-preetham-numeric.test.d.ts.map +0 -1
- package/dist/__tests__/atmosphere-preetham-red.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-preetham-red.test.d.ts.map +0 -1
- package/dist/__tests__/atmosphere-preetham.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-preetham.test.d.ts.map +0 -1
- package/dist/__tests__/atmosphere-three-r184-reference.test.d.ts +0 -2
- package/dist/__tests__/atmosphere-three-r184-reference.test.d.ts.map +0 -1
- package/dist/__tests__/bloom-fxaa-tonemap.unit.test.d.ts +0 -2
- package/dist/__tests__/bloom-fxaa-tonemap.unit.test.d.ts.map +0 -1
- package/dist/__tests__/builtin-texture-sampling-contract.test.d.ts +0 -2
- package/dist/__tests__/builtin-texture-sampling-contract.test.d.ts.map +0 -1
- package/dist/__tests__/default-standard-pbr-alpha.unit.test.d.ts +0 -2
- package/dist/__tests__/default-standard-pbr-alpha.unit.test.d.ts.map +0 -1
- package/dist/__tests__/deferred-lighting-ssao.test.d.ts +0 -2
- package/dist/__tests__/deferred-lighting-ssao.test.d.ts.map +0 -1
- package/dist/__tests__/fog-oracle.unit.test.d.ts +0 -2
- package/dist/__tests__/fog-oracle.unit.test.d.ts.map +0 -1
- package/dist/__tests__/fog-orthographic-ray.unit.test.d.ts +0 -2
- package/dist/__tests__/fog-orthographic-ray.unit.test.d.ts.map +0 -1
- package/dist/__tests__/fog-producer-matrix.integration.test.d.ts +0 -2
- package/dist/__tests__/fog-producer-matrix.integration.test.d.ts.map +0 -1
- package/dist/__tests__/hdrp-ssao-compile.test.d.ts +0 -2
- package/dist/__tests__/hdrp-ssao-compile.test.d.ts.map +0 -1
- package/dist/__tests__/ibl-irradiance.unit.test.d.ts +0 -2
- package/dist/__tests__/ibl-irradiance.unit.test.d.ts.map +0 -1
- package/dist/__tests__/ibl-sampling.unit.test.d.ts +0 -2
- package/dist/__tests__/ibl-sampling.unit.test.d.ts.map +0 -1
- package/dist/__tests__/lighting-punctual.unit.test.d.ts +0 -2
- package/dist/__tests__/lighting-punctual.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-artifact-dedup.unit.test.d.ts +0 -2
- package/dist/__tests__/material-artifact-dedup.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-builtins.unit.test.d.ts +0 -2
- package/dist/__tests__/material-builtins.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-contract.unit.test.d.ts +0 -2
- package/dist/__tests__/material-contract.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-derived-builtins.integration.test.d.ts +0 -2
- package/dist/__tests__/material-derived-builtins.integration.test.d.ts.map +0 -1
- package/dist/__tests__/points-lines-shader.unit.test.d.ts +0 -2
- package/dist/__tests__/points-lines-shader.unit.test.d.ts.map +0 -1
- package/dist/__tests__/public-surface.unit.test.d.ts +0 -2
- package/dist/__tests__/public-surface.unit.test.d.ts.map +0 -1
- package/dist/__tests__/scene-temporal.unit.test.d.ts +0 -2
- package/dist/__tests__/scene-temporal.unit.test.d.ts.map +0 -1
- package/dist/__tests__/shader-registry-transaction.unit.test.d.ts +0 -2
- package/dist/__tests__/shader-registry-transaction.unit.test.d.ts.map +0 -1
- package/dist/__tests__/shader.unit.test.d.ts +0 -2
- package/dist/__tests__/shader.unit.test.d.ts.map +0 -1
- package/dist/__tests__/sprite-lit-shader.test.d.ts +0 -2
- package/dist/__tests__/sprite-lit-shader.test.d.ts.map +0 -1
- package/dist/__tests__/sprite-variants.unit.test.d.ts +0 -2
- package/dist/__tests__/sprite-variants.unit.test.d.ts.map +0 -1
- package/dist/__tests__/taa-resolve.unit.test.d.ts +0 -2
- package/dist/__tests__/taa-resolve.unit.test.d.ts.map +0 -1
- package/dist/__tests__/transparent-pbr.unit.test.d.ts +0 -2
- package/dist/__tests__/transparent-pbr.unit.test.d.ts.map +0 -1
- package/dist/__tests__/vertex-color-variant.unit.test.d.ts +0 -2
- package/dist/__tests__/vertex-color-variant.unit.test.d.ts.map +0 -1
package/src/common.wgsl
CHANGED
|
@@ -24,6 +24,9 @@ fn sampleMaterialTexture(
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Shared linear-LDR -> display-sRGB OETF for raw swap-chain storage writes.
|
|
27
|
+
// The high branch deliberately locks Three.js r184's reference literal
|
|
28
|
+
// (`0.41666`) instead of spelling the mathematically exact `1.0 / 2.4`.
|
|
29
|
+
// That literal is part of the byte-level parity contract at 8-bit boundaries.
|
|
27
30
|
// sRGB texture views perform this conversion on attachment writes, but the
|
|
28
31
|
// native output and FXAA passes intentionally target the non-sRGB storage view.
|
|
29
32
|
fn linearToSrgbOetf(color : vec3<f32>) -> vec3<f32> {
|
|
@@ -73,8 +76,7 @@ fn linearToSrgbOetf(color : vec3<f32>) -> vec3<f32> {
|
|
|
73
76
|
// array fold (feat-20260625 w25) removes the standalone @group(0) binding 9
|
|
74
77
|
// uniform buffer so the WebGL2 fallback fragment uniform-buffer count returns
|
|
75
78
|
// to 11 (GLES 3.0 max).
|
|
76
|
-
// temporal projection facts
|
|
77
|
-
// total = 960 B.
|
|
79
|
+
// temporal projection facts append after the spot matrix; total = 960 B.
|
|
78
80
|
//
|
|
79
81
|
// Field order must stay byte-for-byte identical to every prior release
|
|
80
82
|
// (charter P4 consistent abstraction); new fields append at the tail.
|
|
@@ -125,19 +127,6 @@ fn linearToSrgbOetf(color : vec3<f32>) -> vec3<f32> {
|
|
|
125
127
|
// 960 (renderer-factory.ts) and writes the full 240 f32
|
|
126
128
|
// payload (render-system-record.ts). Lane N = the spot with `shadowAtlasTile
|
|
127
129
|
// === N` (cap = 4); `evalSpotShadowed` reads `view.spotLightViewProj[tile]`.
|
|
128
|
-
struct FogViewParams {
|
|
129
|
-
color : vec3<f32>,
|
|
130
|
-
density : f32,
|
|
131
|
-
heightFalloff : f32,
|
|
132
|
-
maxOpacity : f32,
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
struct FogRay {
|
|
136
|
-
origin : vec3<f32>,
|
|
137
|
-
direction : vec3<f32>,
|
|
138
|
-
distance : f32,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
130
|
struct View {
|
|
142
131
|
worldViewProj : mat4x4<f32>,
|
|
143
132
|
lightDir : vec3<f32>,
|
|
@@ -164,7 +153,9 @@ struct View {
|
|
|
164
153
|
temporalPreviousViewProj : mat4x4<f32>,
|
|
165
154
|
// x = near, y = far, z = 1 for orthographic and 0 for perspective.
|
|
166
155
|
temporalProjection : vec4<f32>,
|
|
167
|
-
|
|
156
|
+
// Accepted camera origin at the previous submitted frame. This occupies
|
|
157
|
+
// the existing tail padding and keeps temporal reprojection on one SSOT.
|
|
158
|
+
temporalPreviousCameraPos : vec4<f32>,
|
|
168
159
|
};
|
|
169
160
|
|
|
170
161
|
// Per-instance mesh slot (feat-20260518-pbr-direct-lighting-mvp M2 / w8.5,
|
|
@@ -199,7 +190,7 @@ struct Mesh {
|
|
|
199
190
|
// color * intensity so the shader avoids the per-fragment mul)
|
|
200
191
|
// [ 7 ] pad f32 = 0
|
|
201
192
|
//
|
|
202
|
-
// SpotLight (
|
|
193
|
+
// SpotLight (80 B / 20 floats):
|
|
203
194
|
// [ 0..2 ] position vec3<f32>
|
|
204
195
|
// [ 3 ] invRangeSquared f32
|
|
205
196
|
// [ 4..6 ] colorTimesIntensity vec3<f32>
|
|
@@ -208,9 +199,11 @@ struct Mesh {
|
|
|
208
199
|
// [ 8..10] direction vec3<f32> (raw outgoing vector; shader reads
|
|
209
200
|
// via dot(L, -direction) for cone angle test)
|
|
210
201
|
// [ 11 ] cosOuter f32
|
|
211
|
-
// [12
|
|
202
|
+
// [12] depthBias f32, [13] normalBias f32, [14] pcfKernelSize f32
|
|
212
203
|
// [ 15 ] shadowAtlasTile i32 (sentinel -1 = unassigned/clipped,
|
|
213
204
|
// 0..3 = spot atlas tile index; feat-20260625 M2/M3 D-4)
|
|
205
|
+
// [ 16 ] shadowIntensity f32 (fraction of sampled shadow to apply)
|
|
206
|
+
// [17..19] alignment tail padding
|
|
214
207
|
//
|
|
215
208
|
// WGSL std430 alignment audit: vec3<f32> alignof=16 / sizeof=12. The
|
|
216
209
|
// f32 lane wedged immediately after each vec3 fills the 4 B remainder
|
|
@@ -218,10 +211,10 @@ struct Mesh {
|
|
|
218
211
|
// prev.size, this.alignof) - for f32 alignof=4 the round-up is a
|
|
219
212
|
// no-op, so position[3] / color[3] / direction[3] sit at byte
|
|
220
213
|
// offsets 12 / 28 / 44 with zero internal padding). PointLight stays
|
|
221
|
-
// 32 B; SpotLight grows
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
//
|
|
214
|
+
// 32 B; SpotLight grows from 64 B (feat-20260625 M2/M3 D-4) for the three
|
|
215
|
+
// receiver controls plus `shadowAtlasTile: i32`, then to 80 B for the
|
|
216
|
+
// parity-only `shadowIntensity` lane at byte 64. These struct sizes match the
|
|
217
|
+
// host packers (packPointLight 32 B / packSpotLight 80 B) exactly.
|
|
225
218
|
//
|
|
226
219
|
// Header `count: u32` lives in a wrapper struct with the trailing
|
|
227
220
|
// runtime-sized array. Array-of-vec4-aligned-struct alignof = 16, so
|
|
@@ -252,19 +245,14 @@ struct SpotLight {
|
|
|
252
245
|
direction : vec3<f32>,
|
|
253
246
|
cosOuter : f32,
|
|
254
247
|
// feat-20260625-spot-light-shadow-mapping M3 / w13 (plan-strategy D-4):
|
|
255
|
-
// The
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
// `shadowAtlasTile >= 0` (evalSpotShadowed vs evalSpot). Field names are
|
|
262
|
-
// unique across the composed module surface so naga_oil writeback
|
|
263
|
-
// substitution does not collide with prior `pad0` members. (naga_oil
|
|
264
|
-
// reserves the `__` identifier prefix, so the pad lane is `spotPad`, not
|
|
265
|
-
// `__pad`.)
|
|
266
|
-
spotPad : vec3<f32>,
|
|
248
|
+
// The trailing vec4 transports receiver controls and the tile identity.
|
|
249
|
+
// Host packSpotLight writes slots 12..14 from the same snapshot; slot 15 is
|
|
250
|
+
// the i32 shadow tile sentinel and slot 16 carries shadowIntensity.
|
|
251
|
+
depthBias : f32,
|
|
252
|
+
normalBias : f32,
|
|
253
|
+
pcfKernelSize : f32,
|
|
267
254
|
shadowAtlasTile : i32,
|
|
255
|
+
shadowIntensity : f32,
|
|
268
256
|
};
|
|
269
257
|
|
|
270
258
|
struct PointLightsArray {
|
|
@@ -278,6 +266,7 @@ struct SpotLightsArray {
|
|
|
278
266
|
};
|
|
279
267
|
|
|
280
268
|
@group(0) @binding(0) var<uniform> view : View;
|
|
269
|
+
|
|
281
270
|
#if STORAGE_BUFFER_AVAILABLE == true
|
|
282
271
|
@group(0) @binding(1) var<storage, read> pointLightsBuffer : PointLightsArray;
|
|
283
272
|
@group(0) @binding(2) var<storage, read> spotLightsBuffer : SpotLightsArray;
|
|
@@ -391,7 +380,17 @@ struct ShadowCasterCascade {
|
|
|
391
380
|
// — folded there in feat-20260625 w25 (scope-amend) to keep the WebGL2 fallback
|
|
392
381
|
// fragment uniform-buffer count <= 11; binding 8 is the last view-BG binding.
|
|
393
382
|
@group(0) @binding(8) var spotShadowMap : texture_depth_2d;
|
|
394
|
-
|
|
383
|
+
// Optional authored SpotLight projector. Surface and volume bind the same
|
|
384
|
+
// accepted TextureAsset view and linear-clamp sampler; an unprojected spot
|
|
385
|
+
// receives the renderer-owned white fallback. The declaration is capability
|
|
386
|
+
// gated because the complete HDRP PBR view/material ABI reaches the WebGPU
|
|
387
|
+
// minimum of 16 sampled textures without this optional cookie. Devices that
|
|
388
|
+
// cannot expose the 17th sampled texture select the matching white-projector
|
|
389
|
+
// shader variant and omit these resources from the view BGL.
|
|
390
|
+
#ifdef PROJECTOR_AVAILABLE
|
|
391
|
+
@group(0) @binding(11) var projectorTexture : texture_2d<f32>;
|
|
392
|
+
@group(0) @binding(12) var projectorSampler : sampler;
|
|
393
|
+
#endif
|
|
395
394
|
#if STORAGE_BUFFER_AVAILABLE == true
|
|
396
395
|
@group(2) @binding(0) var<storage, read> meshes : array<Mesh>;
|
|
397
396
|
#else
|
|
@@ -445,36 +444,6 @@ struct InstanceData {
|
|
|
445
444
|
#endif
|
|
446
445
|
};
|
|
447
446
|
|
|
448
|
-
fn sceneTemporalUv(clip : vec4<f32>) -> vec2<f32> {
|
|
449
|
-
let safeW = select(1e-6, clip.w, abs(clip.w) >= 1e-6);
|
|
450
|
-
let ndc = clip.xy / safeW;
|
|
451
|
-
return vec2<f32>(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
fn sceneTemporalViewDepth(clip : vec4<f32>) -> f32 {
|
|
455
|
-
let perspectiveDepth = max(clip.w, 0.0);
|
|
456
|
-
let ndcDepth = clip.z / max(abs(clip.w), 1e-6);
|
|
457
|
-
let orthographicDepth = view.temporalProjection.x +
|
|
458
|
-
ndcDepth * (view.temporalProjection.y - view.temporalProjection.x);
|
|
459
|
-
let viewDepth = select(
|
|
460
|
-
perspectiveDepth,
|
|
461
|
-
max(orthographicDepth, 0.0),
|
|
462
|
-
view.temporalProjection.z >= 0.5,
|
|
463
|
-
);
|
|
464
|
-
return log2(1.0 + viewDepth);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
fn packSceneTemporal(
|
|
468
|
-
currentClip : vec4<f32>,
|
|
469
|
-
previousClip : vec4<f32>,
|
|
470
|
-
reactive : f32,
|
|
471
|
-
) -> vec4<f32> {
|
|
472
|
-
return vec4<f32>(
|
|
473
|
-
sceneTemporalUv(currentClip) - sceneTemporalUv(previousClip),
|
|
474
|
-
sceneTemporalViewDepth(currentClip),
|
|
475
|
-
clamp(reactive, 0.0, 1.0),
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
447
|
#if STORAGE_BUFFER_AVAILABLE == true
|
|
479
448
|
@group(3) @binding(0) var<storage, read> instances : array<InstanceData>;
|
|
480
449
|
#else
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
#import forgeax_view::common::{View,
|
|
1
|
+
#import forgeax_view::common::{View, Mesh, InstanceData, view, meshes, instances, PointLight, SpotLight, pointLightsBuffer, spotLightsBuffer, shadowMap, shadowSampler, sampleMaterialTexture}
|
|
2
2
|
#import forgeax_pbr::temporal::{projectPbrSceneTemporal}
|
|
3
3
|
#import forgeax_pbr::brdf::{f_schlick, v_smith, d_ggx}
|
|
4
4
|
#import forgeax_pbr::ibl_sampling::{sampleIblDiffuse, sampleIblSpecular}
|
|
5
5
|
#import forgeax_pbr::tbn::{decodeTangentSpaceNormalRg, scaleTangentSpaceNormal, applyTBN}
|
|
6
6
|
#import forgeax_pbr::lighting_directional::{evalDirectionalNoShadow, evalDirectionalShadowFactor}
|
|
7
7
|
#import forgeax_pbr::lighting_punctual::{evalPoint, evalSpot}
|
|
8
|
-
#import forgeax_view::fog::{apply_fog}
|
|
9
8
|
#ifdef POINT_SHADOW_AVAILABLE
|
|
10
9
|
#import forgeax_pbr::lighting_punctual::{evalPointShadowed}
|
|
11
10
|
#import forgeax_view::common::{shadowParams}
|
|
@@ -88,6 +87,11 @@ struct Material {
|
|
|
88
87
|
clearcoatRoughness : f32,
|
|
89
88
|
specularTint : vec3<f32>,
|
|
90
89
|
normalScale : f32,
|
|
90
|
+
transmission : f32,
|
|
91
|
+
ior : f32,
|
|
92
|
+
thickness : f32,
|
|
93
|
+
attenuationColor : vec3<f32>,
|
|
94
|
+
attenuationDistance : f32,
|
|
91
95
|
baseColorTextureCoordinatesTransform : vec4<f32>,
|
|
92
96
|
baseColorTextureCoordinatesMetadata : vec4<f32>,
|
|
93
97
|
metallicRoughnessTextureCoordinatesTransform : vec4<f32>,
|
|
@@ -100,6 +104,10 @@ struct Material {
|
|
|
100
104
|
emissiveTextureCoordinatesMetadata : vec4<f32>,
|
|
101
105
|
occlusionTextureCoordinatesTransform : vec4<f32>,
|
|
102
106
|
occlusionTextureCoordinatesMetadata : vec4<f32>,
|
|
107
|
+
transmissionTextureCoordinatesTransform : vec4<f32>,
|
|
108
|
+
transmissionTextureCoordinatesMetadata : vec4<f32>,
|
|
109
|
+
thicknessTextureCoordinatesTransform : vec4<f32>,
|
|
110
|
+
thicknessTextureCoordinatesMetadata : vec4<f32>,
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
@group(1) @binding(0) var<uniform> material : Material;
|
|
@@ -115,6 +123,10 @@ struct Material {
|
|
|
115
123
|
@group(1) @binding(10) var emissiveTexture : texture_2d<f32>;
|
|
116
124
|
@group(1) @binding(11) var occlusionSampler : sampler;
|
|
117
125
|
@group(1) @binding(12) var occlusionTexture : texture_2d<f32>;
|
|
126
|
+
@group(1) @binding(13) var transmissionSampler : sampler;
|
|
127
|
+
@group(1) @binding(14) var transmissionTexture : texture_2d<f32>;
|
|
128
|
+
@group(1) @binding(15) var thicknessSampler : sampler;
|
|
129
|
+
@group(1) @binding(16) var thicknessTexture : texture_2d<f32>;
|
|
118
130
|
|
|
119
131
|
// Preserve filtering reflection for resources passed to the shared sampler.
|
|
120
132
|
fn materialTextureFilteringWitness() {
|
|
@@ -124,12 +136,16 @@ fn materialTextureFilteringWitness() {
|
|
|
124
136
|
let specularTint = specularTintTexture;
|
|
125
137
|
let emissive = emissiveTexture;
|
|
126
138
|
let occlusion = occlusionTexture;
|
|
139
|
+
let transmission = transmissionTexture;
|
|
140
|
+
let thickness = thicknessTexture;
|
|
127
141
|
let baseWitness = textureSample(base, baseColorSampler, vec2<f32>(0.0));
|
|
128
142
|
let metallicRoughnessWitness = textureSample(metallicRoughness, metallicRoughnessSampler, vec2<f32>(0.0));
|
|
129
143
|
let normalWitness = textureSample(normal, normalSampler, vec2<f32>(0.0));
|
|
130
144
|
let specularTintWitness = textureSample(specularTint, specularTintSampler, vec2<f32>(0.0));
|
|
131
145
|
let emissiveWitness = textureSample(emissive, emissiveSampler, vec2<f32>(0.0));
|
|
132
146
|
let occlusionWitness = textureSample(occlusion, occlusionSampler, vec2<f32>(0.0));
|
|
147
|
+
let transmissionWitness = textureSample(transmission, transmissionSampler, vec2<f32>(0.0));
|
|
148
|
+
let thicknessWitness = textureSample(thickness, thicknessSampler, vec2<f32>(0.0));
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
struct SkylightUniforms {
|
|
@@ -146,13 +162,13 @@ struct SkylightUniforms {
|
|
|
146
162
|
colorB : f32,
|
|
147
163
|
rotation : vec4<f32>,
|
|
148
164
|
};
|
|
149
|
-
@group(1) @binding(
|
|
150
|
-
@group(1) @binding(
|
|
151
|
-
@group(1) @binding(
|
|
152
|
-
@group(1) @binding(
|
|
153
|
-
@group(1) @binding(
|
|
154
|
-
@group(1) @binding(
|
|
155
|
-
@group(1) @binding(
|
|
165
|
+
@group(1) @binding(17) var irradianceMap : texture_cube<f32>;
|
|
166
|
+
@group(1) @binding(18) var irradianceSampler : sampler;
|
|
167
|
+
@group(1) @binding(19) var prefilterMap : texture_cube<f32>;
|
|
168
|
+
@group(1) @binding(20) var prefilterSampler : sampler;
|
|
169
|
+
@group(1) @binding(21) var brdfLut : texture_2d<f32>;
|
|
170
|
+
@group(1) @binding(22) var brdfLutSampler : sampler;
|
|
171
|
+
@group(1) @binding(23) var<uniform> skylight : SkylightUniforms;
|
|
156
172
|
|
|
157
173
|
#if STORAGE_BUFFER_AVAILABLE == true
|
|
158
174
|
@group(2) @binding(1) var<storage, read> palette : array<mat4x4<f32>>;
|
|
@@ -213,22 +229,6 @@ fn pick_channel(rgba : vec4<f32>, channelIndex : u32) -> f32 {
|
|
|
213
229
|
}
|
|
214
230
|
}
|
|
215
231
|
|
|
216
|
-
fn applySceneFog(viewParams : View, color : vec3<f32>, alpha : f32, worldPos : vec3<f32>) -> vec4<f32> {
|
|
217
|
-
var origin = viewParams.cameraPos;
|
|
218
|
-
var direction = normalize(worldPos - origin);
|
|
219
|
-
var rayDistance = length(worldPos - origin);
|
|
220
|
-
if (viewParams.temporalProjection.z >= 0.5) {
|
|
221
|
-
let nearH = viewParams.inverseViewProj * vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
|
222
|
-
let farH = viewParams.inverseViewProj * vec4<f32>(0.0, 0.0, 1.0, 1.0);
|
|
223
|
-
let nearPoint = nearH.xyz / nearH.w;
|
|
224
|
-
let farPoint = farH.xyz / farH.w;
|
|
225
|
-
direction = normalize(farPoint - nearPoint);
|
|
226
|
-
origin = worldPos - direction * dot(worldPos - viewParams.cameraPos, direction);
|
|
227
|
-
rayDistance = max(dot(worldPos - origin, direction), 0.0);
|
|
228
|
-
}
|
|
229
|
-
return apply_fog(viewParams.fog, FogRay(origin, direction, rayDistance), vec4<f32>(color, alpha));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
232
|
@vertex
|
|
233
233
|
fn vs_main(in : VsIn, @builtin(instance_index) idx : u32) -> VsOut {
|
|
234
234
|
// 4-bone weighted skinning (plan-strategy D-3 / D-3a).
|
|
@@ -456,7 +456,7 @@ fn fs_main(in : VsOut) -> @location(0) vec4<f32> {
|
|
|
456
456
|
);
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
return
|
|
459
|
+
return vec4<f32>(color, alpha);
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
struct TemporalVsOut {
|
|
@@ -469,8 +469,8 @@ struct TemporalVsOut {
|
|
|
469
469
|
@location(5) uv5 : vec2<f32>,
|
|
470
470
|
@location(6) uv6 : vec2<f32>,
|
|
471
471
|
@location(7) uv7 : vec2<f32>,
|
|
472
|
-
@location(8) @interpolate(
|
|
473
|
-
@location(9) @interpolate(
|
|
472
|
+
@location(8) @interpolate(perspective) currentClip : vec4<f32>,
|
|
473
|
+
@location(9) @interpolate(perspective) previousClip : vec4<f32>,
|
|
474
474
|
#ifdef VERTEX_COLOR_AVAILABLE
|
|
475
475
|
@location(14) color : vec4<f32>,
|
|
476
476
|
#endif
|
|
@@ -531,6 +531,7 @@ fn fs_temporal(in : TemporalVsOut) -> @location(0) vec4<f32> {
|
|
|
531
531
|
material.baseColorTextureCoordinatesMetadata,
|
|
532
532
|
in.currentClip,
|
|
533
533
|
in.previousClip,
|
|
534
|
+
view.temporalProjection,
|
|
534
535
|
reactive,
|
|
535
536
|
in.uv, in.uv1, in.uv2, in.uv3,
|
|
536
537
|
in.uv4, in.uv5, in.uv6, in.uv7,
|