@plasius/gpu-renderer 0.2.49 → 0.2.51
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/CHANGELOG.md +34 -0
- package/README.md +12 -3
- package/dist/index.cjs +24 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/wavefront-compute.js +2 -1
- package/src/wavefront-config.js +8 -0
- package/src/wavefront-shader-kernels.js +5 -63
- package/src/wavefront-shader-lighting.js +12 -2
package/dist/index.js
CHANGED
|
@@ -5950,7 +5950,7 @@ fn scatter_direction(ray: RayRecord, hit: HitRecord) -> ScatterResult {
|
|
|
5950
5950
|
if (cannotRefract || transmissionSelector < transmissionReflectChance) {
|
|
5951
5951
|
return ScatterResult(
|
|
5952
5952
|
vec4<f32>(reflect(ray.direction.xyz, normal), 0.0),
|
|
5953
|
-
1.0,
|
|
5953
|
+
select(transmissionReflectChance, 1.0, cannotRefract),
|
|
5954
5954
|
ray.mediumRefId,
|
|
5955
5955
|
RAY_FLAG_DELTA_SAMPLE,
|
|
5956
5956
|
SCATTER_LOBE_DELTA_REFLECTION,
|
|
@@ -5958,7 +5958,7 @@ fn scatter_direction(ray: RayRecord, hit: HitRecord) -> ScatterResult {
|
|
|
5958
5958
|
}
|
|
5959
5959
|
return ScatterResult(
|
|
5960
5960
|
vec4<f32>(refract_direction(ray.direction.xyz, normal, etaRatio), 0.0),
|
|
5961
|
-
1.0,
|
|
5961
|
+
1.0 - transmissionReflectChance,
|
|
5962
5962
|
transmitted_medium_ref_id(ray, hit),
|
|
5963
5963
|
RAY_FLAG_DELTA_SAMPLE,
|
|
5964
5964
|
SCATTER_LOBE_DELTA_TRANSMISSION,
|
|
@@ -6350,7 +6350,6 @@ fn resolveSurfaceRecords(@builtin(global_invocation_id) globalId: vec3<u32>) {
|
|
|
6350
6350
|
}
|
|
6351
6351
|
record_deferred_path_throughput(ray, continuationThroughput);
|
|
6352
6352
|
let throughput = ray.throughput.xyz * continuationThroughput;
|
|
6353
|
-
let transmissionBranch = scatter.lobeKind == SCATTER_LOBE_DELTA_TRANSMISSION;
|
|
6354
6353
|
let nextMediumStack = select(
|
|
6355
6354
|
transitioned_medium_stack(ray, hit),
|
|
6356
6355
|
ray.mediumStack,
|
|
@@ -6389,66 +6388,9 @@ fn resolveSurfaceRecords(@builtin(global_invocation_id) globalId: vec3<u32>) {
|
|
|
6389
6388
|
nextMediumStack
|
|
6390
6389
|
);
|
|
6391
6390
|
|
|
6392
|
-
//
|
|
6393
|
-
//
|
|
6394
|
-
//
|
|
6395
|
-
if (
|
|
6396
|
-
scatter.lobeKind == SCATTER_LOBE_DELTA_REFLECTION ||
|
|
6397
|
-
scatter.lobeKind == SCATTER_LOBE_DELTA_TRANSMISSION
|
|
6398
|
-
) {
|
|
6399
|
-
let secondaryIndex = atomicAdd(&counters.nextCount, 1u);
|
|
6400
|
-
if (secondaryIndex < config.tilePixelCount) {
|
|
6401
|
-
let secondaryIsReflection = transmissionBranch;
|
|
6402
|
-
let secondaryDirection = select(
|
|
6403
|
-
refract_direction(ray.direction.xyz, surface_shading_normal(hit),
|
|
6404
|
-
select(1.0 / max(hit.material.w, 1.01), max(hit.material.w, 1.01), hit.frontFace == 1u)),
|
|
6405
|
-
reflect(ray.direction.xyz, surface_shading_normal(hit)),
|
|
6406
|
-
secondaryIsReflection
|
|
6407
|
-
);
|
|
6408
|
-
let secondaryThroughput = select(
|
|
6409
|
-
surface_delta_transmission_throughput(hit, continuationViewDirection),
|
|
6410
|
-
surface_delta_reflection_throughput(hit, continuationViewDirection),
|
|
6411
|
-
secondaryIsReflection
|
|
6412
|
-
) * segmentTransmittance;
|
|
6413
|
-
let secondaryStack = select(
|
|
6414
|
-
transitioned_medium_stack(ray, hit),
|
|
6415
|
-
ray.mediumStack,
|
|
6416
|
-
secondaryIsReflection
|
|
6417
|
-
);
|
|
6418
|
-
let secondaryDepth = select(
|
|
6419
|
-
transitioned_medium_stack_depth(ray, hit),
|
|
6420
|
-
ray.mediumStackDepth,
|
|
6421
|
-
secondaryIsReflection
|
|
6422
|
-
);
|
|
6423
|
-
let secondaryMedium = select(
|
|
6424
|
-
transmitted_medium_ref_id(ray, hit),
|
|
6425
|
-
ray.mediumRefId,
|
|
6426
|
-
secondaryIsReflection
|
|
6427
|
-
);
|
|
6428
|
-
nextQueue[secondaryIndex] = RayRecord(
|
|
6429
|
-
ray.rayId,
|
|
6430
|
-
ray.rayId,
|
|
6431
|
-
ray.sourcePixelId,
|
|
6432
|
-
ray.sampleId,
|
|
6433
|
-
ray.bounce + 1u,
|
|
6434
|
-
secondaryMedium,
|
|
6435
|
-
scatter.flags,
|
|
6436
|
-
secondaryDepth,
|
|
6437
|
-
vec4<f32>(
|
|
6438
|
-
offset_origin(
|
|
6439
|
-
hit.position.xyz,
|
|
6440
|
-
hit.geometricNormal.xyz,
|
|
6441
|
-
hit.shadingNormal.xyz,
|
|
6442
|
-
secondaryDirection
|
|
6443
|
-
),
|
|
6444
|
-
1.0
|
|
6445
|
-
),
|
|
6446
|
-
vec4<f32>(secondaryDirection, 0.0),
|
|
6447
|
-
vec4<f32>(ray.throughput.xyz * secondaryThroughput, scatter.pdf),
|
|
6448
|
-
secondaryStack
|
|
6449
|
-
);
|
|
6450
|
-
}
|
|
6451
|
-
}
|
|
6391
|
+
// One continuation per incoming path keeps the tile queue bounded and gives
|
|
6392
|
+
// each accumulation/deferred record a single writer. The selected dielectric
|
|
6393
|
+
// lobe is probability-weighted; a sibling must never be silently dropped.
|
|
6452
6394
|
}
|
|
6453
6395
|
|
|
6454
6396
|
@compute @workgroup_size(1)
|
|
@@ -7751,10 +7693,20 @@ fn surface_continuation_throughput(
|
|
|
7751
7693
|
scatter: ScatterResult
|
|
7752
7694
|
) -> vec3<f32> {
|
|
7753
7695
|
if ((scatter.flags & RAY_FLAG_DELTA_SAMPLE) != 0u) {
|
|
7696
|
+
let refractive = hit.materialKind == 2u || hit.materialKind == 3u || hit.materialExtension.z > 0.001;
|
|
7697
|
+
if (refractive) {
|
|
7698
|
+
let normal = surface_shading_normal(hit);
|
|
7699
|
+
let eta = select(max(hit.material.w, 1.01), 1.0 / max(hit.material.w, 1.01), hit.frontFace == 1u);
|
|
7700
|
+
let cosine = min(dot(viewDirection, normal), 1.0);
|
|
7701
|
+
let cannotRefract = eta * sqrt(max(0.0, 1.0 - cosine * cosine)) > 1.0;
|
|
7702
|
+
if (cannotRefract) {
|
|
7703
|
+
return vec3<f32>(1.0);
|
|
7704
|
+
}
|
|
7705
|
+
}
|
|
7754
7706
|
if (scatter.lobeKind == SCATTER_LOBE_DELTA_TRANSMISSION) {
|
|
7755
|
-
return surface_delta_transmission_throughput(hit, viewDirection);
|
|
7707
|
+
return surface_delta_transmission_throughput(hit, viewDirection) / scatter.pdf;
|
|
7756
7708
|
}
|
|
7757
|
-
return surface_delta_reflection_throughput(hit, viewDirection);
|
|
7709
|
+
return surface_delta_reflection_throughput(hit, viewDirection) / scatter.pdf;
|
|
7758
7710
|
}
|
|
7759
7711
|
if (scatter.pdf <= 0.000001) {
|
|
7760
7712
|
return vec3<f32>(0.0);
|
|
@@ -10602,6 +10554,12 @@ function resolveCamera(input, width, height) {
|
|
|
10602
10554
|
tanHalfFovY
|
|
10603
10555
|
});
|
|
10604
10556
|
}
|
|
10557
|
+
function updateWavefrontCameraConfig(config, camera) {
|
|
10558
|
+
return Object.freeze({
|
|
10559
|
+
...config,
|
|
10560
|
+
camera: resolveCamera(camera, config.width, config.height)
|
|
10561
|
+
});
|
|
10562
|
+
}
|
|
10605
10563
|
function estimateWavefrontPathTracingMemory(options = {}) {
|
|
10606
10564
|
const width = readPositiveInteger2("width", options.width, DEFAULT_WIDTH);
|
|
10607
10565
|
const height = readPositiveInteger2("height", options.height, DEFAULT_HEIGHT);
|
|
@@ -13522,7 +13480,7 @@ async function createWavefrontPathTracingComputeRenderer(options = {}) {
|
|
|
13522
13480
|
function updateCamera(cameraOptions = {}) {
|
|
13523
13481
|
progressive?.reset();
|
|
13524
13482
|
activeCameraOptions = cameraOptions;
|
|
13525
|
-
config =
|
|
13483
|
+
config = updateWavefrontCameraConfig(config, cameraOptions);
|
|
13526
13484
|
return config;
|
|
13527
13485
|
}
|
|
13528
13486
|
function getSnapshot() {
|