Skip to content

Commit d849f33

Browse files
committed
added hashBlur
1 parent 4efe2d0 commit d849f33

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/jsm/tsl/display/hashBlur.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { float, Fn, vec2, sin, rand, degrees, cos, Loop, vec4 } from 'three/tsl';
2+
3+
// https://www.shadertoy.com/view/4lXXWn
4+
5+
export const hashBlur = /*#__PURE__*/ Fn( ( [ textureNode, bluramount = float( 0.1 ), repeats = float( 45 ) ] ) => {
6+
7+
const draw = ( uv ) => textureNode.uv( uv );
8+
9+
const targetUV = textureNode.uvNode;
10+
const blurred_image = vec4( 0. ).toVar();
11+
12+
//const map = textureNode.value;
13+
14+
Loop( { start: 0., end: repeats, type: 'float' }, ( { i } ) => {
15+
16+
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 ) ) );
17+
const uv2 = vec2( targetUV.add( q.mul( bluramount ) ) );
18+
blurred_image.addAssign( draw( uv2 ) );
19+
20+
} );
21+
22+
blurred_image.divAssign( repeats );
23+
24+
return blurred_image;
25+
26+
} );

0 commit comments

Comments
 (0)