rayzee 5.11.0 → 6.0.1

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.
Files changed (44) hide show
  1. package/README.md +81 -24
  2. package/dist/assets/AIUpscalerWorker-AXN-lKWN.js +2 -0
  3. package/dist/assets/AIUpscalerWorker-AXN-lKWN.js.map +1 -0
  4. package/dist/rayzee.es.js +1238 -1825
  5. package/dist/rayzee.es.js.map +1 -1
  6. package/dist/rayzee.umd.js +50 -74
  7. package/dist/rayzee.umd.js.map +1 -1
  8. package/package.json +1 -4
  9. package/src/AssetConfig.js +56 -0
  10. package/src/EngineDefaults.js +5 -3
  11. package/src/EngineEvents.js +1 -0
  12. package/src/Passes/AIUpscaler.js +44 -22
  13. package/src/Passes/OIDNDenoiser.js +4 -104
  14. package/src/PathTracerApp.js +54 -65
  15. package/src/Processor/AssetLoader.js +5 -2
  16. package/src/Processor/Workers/AIUpscalerWorker.js +21 -6
  17. package/src/Stages/ASVGF.js +6 -27
  18. package/src/Stages/AdaptiveSampling.js +10 -26
  19. package/src/Stages/PathTracer.js +4 -5
  20. package/src/TSL/BVHTraversal.js +3 -30
  21. package/src/TSL/Clearcoat.js +1 -6
  22. package/src/TSL/Common.js +1 -14
  23. package/src/TSL/Debugger.js +0 -12
  24. package/src/TSL/EmissiveSampling.js +0 -16
  25. package/src/TSL/Environment.js +0 -7
  26. package/src/TSL/LightsDirect.js +3 -379
  27. package/src/TSL/LightsIndirect.js +2 -1
  28. package/src/TSL/LightsSampling.js +0 -171
  29. package/src/TSL/MaterialEvaluation.js +3 -103
  30. package/src/TSL/MaterialProperties.js +1 -56
  31. package/src/TSL/MaterialSampling.js +2 -284
  32. package/src/TSL/MaterialTransmission.js +80 -276
  33. package/src/TSL/PathTracerCore.js +8 -1
  34. package/src/TSL/Random.js +0 -23
  35. package/src/TSL/Struct.js +0 -21
  36. package/src/TSL/TextureSampling.js +0 -69
  37. package/src/index.js +5 -2
  38. package/src/managers/DenoisingManager.js +13 -5
  39. package/src/managers/VideoRenderManager.js +4 -4
  40. package/dist/assets/AIUpscalerWorker-D58dcMrY.js +0 -2
  41. package/dist/assets/AIUpscalerWorker-D58dcMrY.js.map +0 -1
  42. package/src/Processor/createRenderTargetHelper.js +0 -521
  43. package/src/TSL/RayIntersection.js +0 -162
  44. package/src/managers/helpers/StatsHelper.js +0 -45
@@ -1,162 +0,0 @@
1
- import { Fn, float, vec2, vec3, int, If, dot, cross, abs, normalize, sqrt, min, max, select } from 'three/tsl';
2
-
3
- import {
4
- HitInfo,
5
- } from './Struct.js';
6
-
7
- // Optimized Intersection with Geometry only (no attributes)
8
- // Returns { hit, t, u, v }
9
- export const RayTriangleGeometry = Fn( ( [ ray, posA, posB, posC ] ) => {
10
-
11
- const edge1 = posB.sub( posA );
12
- const edge2 = posC.sub( posA );
13
- const h = cross( ray.direction, edge2 );
14
- const a = dot( edge1, h ).toVar();
15
-
16
- const t = float( 0.0 ).toVar();
17
- const u = float( 0.0 ).toVar();
18
- const v = float( 0.0 ).toVar();
19
- const hit = int( 0 ).toVar();
20
-
21
- If( abs( a ).greaterThan( 1e-8 ), () => {
22
-
23
- const f = float( 1.0 ).div( a );
24
- const s = ray.origin.sub( posA );
25
- u.assign( f.mul( dot( s, h ) ) );
26
-
27
- If( u.greaterThanEqual( 0.0 ).and( u.lessThanEqual( 1.0 ) ), () => {
28
-
29
- const q = cross( s, edge1 );
30
- v.assign( f.mul( dot( ray.direction, q ) ) );
31
-
32
- If( v.greaterThanEqual( 0.0 ).and( u.add( v ).lessThanEqual( 1.0 ) ), () => {
33
-
34
- t.assign( f.mul( dot( edge2, q ) ) );
35
-
36
- If( t.greaterThan( 1e-8 ), () => {
37
-
38
- hit.assign( 1 );
39
-
40
- } );
41
-
42
- } );
43
-
44
- } );
45
-
46
- } );
47
-
48
- return hit;
49
-
50
- } );
51
-
52
- // Calculate the intersection of a ray with a triangle using Möller-Trumbore algorithm
53
- export const RayTriangle = Fn( ( [ ray, tri ] ) => {
54
-
55
- const didHit = int( 0 ).toVar();
56
- const dst = float( 1.0e20 ).toVar();
57
- const hitPoint = vec3( 0.0 ).toVar();
58
- const normal = vec3( 0.0, 0.0, 1.0 ).toVar();
59
- const uv = vec2( 0.0 ).toVar();
60
- const material = int( - 1 ).toVar();
61
-
62
- const edge1 = tri.posB.sub( tri.posA );
63
- const edge2 = tri.posC.sub( tri.posA );
64
- const h = cross( ray.direction, edge2 );
65
- const a = dot( edge1, h ).toVar();
66
-
67
- If( abs( a ).greaterThan( 1e-8 ), () => {
68
-
69
- const f = float( 1.0 ).div( a );
70
- const s = ray.origin.sub( tri.posA );
71
- const u = f.mul( dot( s, h ) ).toVar();
72
-
73
- If( u.greaterThanEqual( 0.0 ).and( u.lessThanEqual( 1.0 ) ), () => {
74
-
75
- const q = cross( s, edge1 );
76
- const v = f.mul( dot( ray.direction, q ) ).toVar();
77
-
78
- If( v.greaterThanEqual( 0.0 ).and( u.add( v ).lessThanEqual( 1.0 ) ), () => {
79
-
80
- const t = f.mul( dot( edge2, q ) ).toVar();
81
-
82
- If( t.greaterThan( 1e-8 ).and( t.lessThan( dst ) ), () => {
83
-
84
- didHit.assign( 1 );
85
- dst.assign( t );
86
- hitPoint.assign( ray.origin.add( ray.direction.mul( t ) ) );
87
-
88
- // Interpolate normal using barycentric coordinates
89
- const w = float( 1.0 ).sub( u ).sub( v );
90
- normal.assign( normalize(
91
- tri.normalA.mul( w ).add( tri.normalB.mul( u ) ).add( tri.normalC.mul( v ) )
92
- ) );
93
-
94
- // Interpolate UV coordinates
95
- uv.assign( tri.uvA.mul( w ).add( tri.uvB.mul( u ) ).add( tri.uvC.mul( v ) ) );
96
-
97
- // Set material index
98
- material.assign( tri.material );
99
-
100
- } );
101
-
102
- } );
103
-
104
- } );
105
-
106
- } );
107
-
108
- return HitInfo( { didHit, dst, hitPoint, normal, uv, materialIndex: material, meshIndex: int( - 1 ), boxTests: int( 0 ), triTests: int( 0 ) } );
109
-
110
- } );
111
-
112
- // Ray-sphere intersection
113
- export const RaySphere = Fn( ( [ ray, sphere ] ) => {
114
-
115
- const didHit = int( 0 ).toVar();
116
- const dst = float( 1.0e20 ).toVar();
117
- const hitPoint = vec3( 0.0 ).toVar();
118
- const normal = vec3( 0.0, 0.0, 1.0 ).toVar();
119
- const material = int( - 1 ).toVar();
120
-
121
- const oc = ray.origin.sub( sphere.position );
122
- const a = dot( ray.direction, ray.direction );
123
- const b = float( 2.0 ).mul( dot( oc, ray.direction ) );
124
- const c = dot( oc, oc ).sub( sphere.radius.mul( sphere.radius ) );
125
- const discriminant = b.mul( b ).sub( float( 4.0 ).mul( a ).mul( c ) ).toVar();
126
-
127
- If( discriminant.greaterThan( 0.0 ), () => {
128
-
129
- const t = b.negate().sub( sqrt( discriminant ) ).div( float( 2.0 ).mul( a ) ).toVar();
130
-
131
- If( t.greaterThan( 0.0 ), () => {
132
-
133
- didHit.assign( 1 );
134
- dst.assign( t );
135
- hitPoint.assign( ray.origin.add( ray.direction.mul( t ) ) );
136
- normal.assign( normalize( hitPoint.sub( sphere.position ) ) );
137
- material.assign( sphere.material );
138
-
139
- } );
140
-
141
- } );
142
-
143
- return HitInfo( { didHit, dst, hitPoint, normal, uv: vec2( 0.0 ), materialIndex: material, meshIndex: int( - 1 ), boxTests: int( 0 ), triTests: int( 0 ) } );
144
-
145
- } );
146
-
147
- // Fast ray-AABB distance calculation with early exit optimization
148
- export const fastRayAABBDst = Fn( ( [ ray, invDir, boxMin, boxMax ] ) => {
149
-
150
- const t1 = boxMin.sub( ray.origin ).mul( invDir );
151
- const t2 = boxMax.sub( ray.origin ).mul( invDir );
152
-
153
- const tMin = min( t1, t2 );
154
- const tMax = max( t1, t2 );
155
-
156
- const dstNear = max( max( tMin.x, tMin.y ), tMin.z );
157
- const dstFar = min( min( tMax.x, tMax.y ), tMax.z ).mul( 1.00000024 ); // Robust traversal: 2 ULP padding (Ize 2013)
158
-
159
- // Optimized early rejection
160
- return select( dstFar.greaterThanEqual( max( dstNear, 0.0 ) ), max( dstNear, 0.0 ), float( 1e20 ) );
161
-
162
- } );
@@ -1,45 +0,0 @@
1
- import Stats from 'stats-gl';
2
-
3
- /**
4
- * Creates and configures a stats-gl performance panel.
5
- *
6
- * @param {import('three/webgpu').WebGPURenderer} renderer
7
- * @param {HTMLElement} [container=document.body] - DOM element to mount the stats panel
8
- * @returns {Stats}
9
- */
10
- export function createStats( renderer, container ) {
11
-
12
- const stats = new Stats( { horizontal: true, trackGPU: true } );
13
- stats.dom.style.position = 'absolute';
14
- stats.dom.style.top = 'unset';
15
- stats.dom.style.bottom = '48px';
16
-
17
- stats.init( renderer );
18
- ( container || document.body ).appendChild( stats.dom );
19
-
20
- const foregroundColor = '#ffffff';
21
- const backgroundColor = '#1e293b';
22
-
23
- const gradient = stats.fpsPanel.context.createLinearGradient(
24
- 0, stats.fpsPanel.GRAPH_Y,
25
- 0, stats.fpsPanel.GRAPH_Y + stats.fpsPanel.GRAPH_HEIGHT
26
- );
27
- gradient.addColorStop( 0, foregroundColor );
28
-
29
- stats.fpsPanel.fg = stats.msPanel.fg = foregroundColor;
30
- stats.fpsPanel.bg = stats.msPanel.bg = backgroundColor;
31
- stats.fpsPanel.gradient = stats.msPanel.gradient = gradient;
32
-
33
- if ( stats.gpuPanel ) {
34
-
35
- stats.gpuPanel.fg = foregroundColor;
36
- stats.gpuPanel.bg = backgroundColor;
37
- stats.gpuPanel.gradient = gradient;
38
-
39
- }
40
-
41
- stats.dom.style.display = '';
42
-
43
- return stats;
44
-
45
- }