Skip to content

Commit 712d2ca

Browse files
authored
Optimize Vogel disk sampling sqrt. (#32407)
1 parent 5d233d9 commit 712d2ca

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/nodes/utils/PostProcessingUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const interleavedGradientNoise = Fn( ( [ position ] ) => {
139139
export const vogelDiskSample = Fn( ( [ sampleIndex, samplesCount, phi ] ) => {
140140

141141
const goldenAngle = float( 2.399963229728653 ); // 2π * (2 - φ) where φ is golden ratio
142-
const r = sqrt( float( sampleIndex ).add( 0.5 ) ).div( sqrt( float( samplesCount ) ) );
142+
const r = sqrt( float( sampleIndex ).add( 0.5 ).div( float( samplesCount ) ) );
143143
const theta = float( sampleIndex ).mul( goldenAngle ).add( phi );
144144
return vec2( cos( theta ), sin( theta ) ).mul( r );
145145

src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default /* glsl */`
104104
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
105105
106106
const float goldenAngle = 2.399963229728653;
107-
float r = sqrt( float( sampleIndex ) + 0.5 ) / sqrt( float( samplesCount ) );
107+
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
108108
float theta = float( sampleIndex ) * goldenAngle + phi;
109109
return vec2( cos( theta ), sin( theta ) ) * r;
110110

0 commit comments

Comments
 (0)