rayzee 6.5.0 → 7.0.0
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 +24 -5
- package/dist/rayzee.es.js +7554 -7014
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +157 -236
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/EngineDefaults.js +12 -9
- package/src/PathTracerApp.js +118 -26
- package/src/Pipeline/PipelineContext.js +1 -2
- package/src/Pipeline/RenderPipeline.js +1 -1
- package/src/Pipeline/RenderStage.js +1 -1
- package/src/Processor/CameraOptimizer.js +0 -5
- package/src/Processor/GeometryExtractor.js +6 -0
- package/src/Processor/KernelManager.js +277 -0
- package/src/Processor/PackedRayBuffer.js +265 -0
- package/src/Processor/QueueManager.js +173 -0
- package/src/Processor/SceneProcessor.js +1 -0
- package/src/Processor/ShaderBuilder.js +11 -317
- package/src/Processor/StorageTexturePool.js +29 -15
- package/src/Processor/VRAMTracker.js +169 -0
- package/src/Processor/utils.js +11 -110
- package/src/RenderSettings.js +0 -3
- package/src/Stages/ASVGF.js +76 -20
- package/src/Stages/BilateralFilter.js +34 -10
- package/src/Stages/EdgeFilter.js +2 -3
- package/src/Stages/MotionVector.js +16 -9
- package/src/Stages/NormalDepth.js +17 -5
- package/src/Stages/PathTracer.js +671 -1456
- package/src/Stages/PathTracerStage.js +1451 -0
- package/src/Stages/SSRC.js +32 -15
- package/src/Stages/Variance.js +35 -12
- package/src/TSL/CompactKernel.js +110 -0
- package/src/TSL/DebugKernel.js +98 -0
- package/src/TSL/Environment.js +13 -11
- package/src/TSL/ExtendKernel.js +75 -0
- package/src/TSL/FinalWriteKernel.js +121 -0
- package/src/TSL/GenerateKernel.js +109 -0
- package/src/TSL/LightsSampling.js +2 -2
- package/src/TSL/PathTracerCore.js +43 -1039
- package/src/TSL/ShadeKernel.js +873 -0
- package/src/TSL/patches.js +81 -4
- package/src/index.js +3 -0
- package/src/managers/CameraManager.js +1 -1
- package/src/managers/DenoisingManager.js +40 -75
- package/src/managers/EnvironmentManager.js +30 -39
- package/src/managers/OverlayManager.js +7 -22
- package/src/managers/UniformManager.js +0 -3
- package/src/managers/helpers/TileHelper.js +2 -2
- package/src/Stages/AdaptiveSampling.js +0 -483
- package/src/TSL/PathTracer.js +0 -384
- package/src/managers/TileManager.js +0 -298
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenerateKernel.js — wavefront primary ray generation (16×16, 2D screen-space dispatch).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Fn, float, vec2, vec3, vec4, int, uint,
|
|
7
|
+
If, select,
|
|
8
|
+
localId, workgroupId,
|
|
9
|
+
} from 'three/tsl';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
getDecorrelatedSeed,
|
|
13
|
+
pcgHash,
|
|
14
|
+
getStratifiedSample,
|
|
15
|
+
} from './Random.js';
|
|
16
|
+
|
|
17
|
+
import { generateRayFromCamera } from './BVHTraversal.js';
|
|
18
|
+
import { Ray } from './Struct.js';
|
|
19
|
+
import { RAY_FLAG } from '../Processor/QueueManager.js';
|
|
20
|
+
import {
|
|
21
|
+
writeRayOriginMeta, writeRayDirFlags, writeRayThroughputPdf,
|
|
22
|
+
writeRayRadiance, writeGBuffer,
|
|
23
|
+
writeMediumStack,
|
|
24
|
+
} from '../Processor/PackedRayBuffer.js';
|
|
25
|
+
|
|
26
|
+
const WG_SIZE = 16;
|
|
27
|
+
|
|
28
|
+
export function buildGenerateKernel( params ) {
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
rayBufferRW, rngBufferRW, gBufferRW,
|
|
32
|
+
resolution, frame,
|
|
33
|
+
cameraWorldMatrix, cameraProjectionMatrixInverse,
|
|
34
|
+
enableDOF, focalLength, aperture, focusDistance, sceneScale, apertureScale, anamorphicRatio,
|
|
35
|
+
renderWidth, renderHeight,
|
|
36
|
+
// Multi-sample: S primary rays/pixel/frame; S>1 dispatch covers h*S rows, ray lands in slot subSample*(w*h) + pixelIndex.
|
|
37
|
+
samplesPerPass = 1,
|
|
38
|
+
transmissiveBounces, // per-ray refraction budget (megakernel parity: PathTracerCore.js:606)
|
|
39
|
+
transparentBackground, // alpha inits to 1 here (megakernel parity: PathTracerCore.js:554) — env-escape-without-opaque zeroes it in Shade
|
|
40
|
+
} = params;
|
|
41
|
+
|
|
42
|
+
const S = samplesPerPass | 0;
|
|
43
|
+
|
|
44
|
+
const computeFn = Fn( () => {
|
|
45
|
+
|
|
46
|
+
const gx = int( workgroupId.x ).mul( WG_SIZE ).add( int( localId.x ) );
|
|
47
|
+
const gyRaw = int( workgroupId.y ).mul( WG_SIZE ).add( int( localId.y ) );
|
|
48
|
+
|
|
49
|
+
const subSample = S > 1 ? gyRaw.div( renderHeight ).toVar() : int( 0 );
|
|
50
|
+
const gy = S > 1 ? gyRaw.sub( subSample.mul( renderHeight ) ).toVar() : gyRaw;
|
|
51
|
+
const yBound = S > 1 ? renderHeight.mul( int( S ) ) : renderHeight;
|
|
52
|
+
|
|
53
|
+
If( gx.lessThan( renderWidth ).and( gyRaw.lessThan( yBound ) ), () => {
|
|
54
|
+
|
|
55
|
+
const pixelCoord = vec2( float( gx ).add( 0.5 ), float( gy ).add( 0.5 ) );
|
|
56
|
+
const pixelIndex = gy.mul( int( resolution.x ) ).add( gx );
|
|
57
|
+
// maxRaysPerSample = w*h, derived from the resolution uniform (NOT baked) so resize never changes the WGSL.
|
|
58
|
+
const rayID = S > 1
|
|
59
|
+
? uint( pixelIndex ).add( uint( subSample ).mul( uint( resolution.x ).mul( uint( resolution.y ) ) ) )
|
|
60
|
+
: uint( pixelIndex );
|
|
61
|
+
|
|
62
|
+
const screenPosition = pixelCoord.div( resolution ).mul( 2.0 ).sub( 1.0 ).toVar();
|
|
63
|
+
screenPosition.y.assign( screenPosition.y.negate() );
|
|
64
|
+
|
|
65
|
+
const baseSeed = getDecorrelatedSeed( { pixelCoord, rayIndex: subSample, frame } ).toVar();
|
|
66
|
+
const seed = pcgHash( { state: baseSeed } ).toVar();
|
|
67
|
+
|
|
68
|
+
const stratifiedJitter = getStratifiedSample( pixelCoord, subSample, int( S ), seed, resolution, frame ).toVar();
|
|
69
|
+
|
|
70
|
+
const jitterScale = vec2( 2.0 ).div( resolution );
|
|
71
|
+
const jitter = stratifiedJitter.sub( 0.5 ).mul( jitterScale );
|
|
72
|
+
const jitteredScreenPosition = screenPosition.add( jitter );
|
|
73
|
+
|
|
74
|
+
const ray = Ray.wrap( generateRayFromCamera(
|
|
75
|
+
jitteredScreenPosition, seed,
|
|
76
|
+
cameraWorldMatrix, cameraProjectionMatrixInverse,
|
|
77
|
+
enableDOF, focalLength, aperture, focusDistance, sceneScale, apertureScale, anamorphicRatio,
|
|
78
|
+
) );
|
|
79
|
+
|
|
80
|
+
writeRayOriginMeta( rayBufferRW, rayID, ray.origin, int( 0 ), int( 0 ) );
|
|
81
|
+
writeRayDirFlags( rayBufferRW, rayID, ray.direction, uint( RAY_FLAG.ACTIVE ) );
|
|
82
|
+
// pdf inits to 0 = prevBouncePdf (megakernel parity PathTracerCore.js:556). The bounce>0 env/emissive
|
|
83
|
+
// MIS gate skips until an opaque scatter writes a real combinedPdf; free bounces preserve it.
|
|
84
|
+
writeRayThroughputPdf( rayBufferRW, rayID, vec4( 1.0, 1.0, 1.0, 0.0 ).xyz, float( 0.0 ) );
|
|
85
|
+
// Alpha inits to 1 in transparent-bg mode (megakernel parity: PathTracerCore.js:554). Shade zeroes
|
|
86
|
+
// it only on env-escape-without-opaque; a ray that dies inside geometry (e.g. SSS walk termination)
|
|
87
|
+
// keeps alpha 1 → solid. Non-transparent mode is inert (FinalWrite forces alpha 1).
|
|
88
|
+
writeRayRadiance( rayBufferRW, rayID, vec4( vec3( 0.0 ), select( transparentBackground, float( 1.0 ), float( 0.0 ) ) ) );
|
|
89
|
+
|
|
90
|
+
If( subSample.equal( int( 0 ) ), () => {
|
|
91
|
+
|
|
92
|
+
// default: normal +Z, depth 1 (far), black albedo (background/miss)
|
|
93
|
+
writeGBuffer( gBufferRW, uint( pixelIndex ), vec3( 0.0, 0.0, 1.0 ), float( 1.0 ), vec3( 0.0 ) );
|
|
94
|
+
|
|
95
|
+
} );
|
|
96
|
+
|
|
97
|
+
writeMediumStack( rayBufferRW, rayID, uint( 0 ), uint( transmissiveBounces ), float( 1.0 ), float( 1.0 ), float( 1.0 ) );
|
|
98
|
+
|
|
99
|
+
rngBufferRW.element( rayID ).assign( seed );
|
|
100
|
+
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
return computeFn;
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { WG_SIZE as GENERATE_WG_SIZE };
|
|
@@ -704,7 +704,7 @@ export const calculateDirectLightingUnified = Fn( ( [
|
|
|
704
704
|
materialBuffer,
|
|
705
705
|
// Environment resources
|
|
706
706
|
envTexture, environmentIntensity, envMatrix,
|
|
707
|
-
|
|
707
|
+
envCDFTexture,
|
|
708
708
|
envTotalSum, envCompensationDelta, envResolution,
|
|
709
709
|
enableEnvironmentLight,
|
|
710
710
|
] ) => {
|
|
@@ -969,7 +969,7 @@ export const calculateDirectLightingUnified = Fn( ( [
|
|
|
969
969
|
|
|
970
970
|
// Sample direction + PDF + color from importance-sampled environment
|
|
971
971
|
const envSampleResult = sampleEquirectProbability(
|
|
972
|
-
envTexture,
|
|
972
|
+
envTexture, envCDFTexture,
|
|
973
973
|
envMatrix, environmentIntensity, envTotalSum, envCompensationDelta, envResolution, envRandom, envColor
|
|
974
974
|
).toVar();
|
|
975
975
|
|