Просмотр исходного кода

Optimize Vogel disk sampling sqrt. (#32407)

mrdoob 3 месяцев назад
Родитель
Сommit
712d2cacb4

+ 1 - 1
src/nodes/utils/PostProcessingUtils.js

@@ -139,7 +139,7 @@ export const interleavedGradientNoise = Fn( ( [ position ] ) => {
 export const vogelDiskSample = Fn( ( [ sampleIndex, samplesCount, phi ] ) => {
 
 	const goldenAngle = float( 2.399963229728653 ); // 2π * (2 - φ) where φ is golden ratio
-	const r = sqrt( float( sampleIndex ).add( 0.5 ) ).div( sqrt( float( samplesCount ) ) );
+	const r = sqrt( float( sampleIndex ).add( 0.5 ).div( float( samplesCount ) ) );
 	const theta = float( sampleIndex ).mul( goldenAngle ).add( phi );
 	return vec2( cos( theta ), sin( theta ) ).mul( r );
 

+ 1 - 1
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js

@@ -104,7 +104,7 @@ export default /* glsl */`
 		vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
 
 			const float goldenAngle = 2.399963229728653;
-			float r = sqrt( float( sampleIndex ) + 0.5 ) / sqrt( float( samplesCount ) );
+			float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
 			float theta = float( sampleIndex ) * goldenAngle + phi;
 			return vec2( cos( theta ), sin( theta ) ) * r;
 

粤ICP备19079148号