Ver código fonte

TSL: Fix angle bug in `hashBlur()`. (#34077)

Michael Herzog 1 dia atrás
pai
commit
cfbf866243
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      examples/jsm/tsl/display/hashBlur.js

+ 3 - 2
examples/jsm/tsl/display/hashBlur.js

@@ -1,4 +1,4 @@
-import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4, premultiplyAlpha, unpremultiplyAlpha, convertToTexture, nodeObject } from 'three/tsl';
+import { float, Fn, vec2, uv, sin, rand, TWO_PI, cos, Loop, vec4, premultiplyAlpha, unpremultiplyAlpha, convertToTexture, nodeObject } from 'three/tsl';
 
 /**
  * Applies a hash blur effect to the given texture node.
@@ -41,7 +41,8 @@ export const hashBlur = /*#__PURE__*/ Fn( ( [ textureNode, bluramount = float( 0
 
 	Loop( { start: 0., end: repeats, type: 'float' }, ( { i } ) => {
 
-		const q = vec2( vec2( cos( degrees( i.div( repeats ).mul( 360. ) ) ), sin( degrees( i.div( repeats ).mul( 360. ) ) ) ).mul( rand( vec2( i, targetUV.x.add( targetUV.y ) ) ).add( bluramount ) ) );
+		const angle = i.div( repeats ).mul( TWO_PI ).toConst();
+		const q = vec2( cos( angle ), sin( angle ) ).mul( rand( vec2( i, targetUV.x.add( targetUV.y ) ) ).add( bluramount ) );
 		const uv2 = vec2( targetUV.add( q.mul( bluramount ) ) );
 		blurred_image.addAssign( tap( uv2 ) );
 

粤ICP备19079148号