@@ -9,17 +9,7 @@ import {
99 useLoader , 
1010 createPortal , 
1111}  from  "@react-three/fiber" ; 
12- import  { 
13-  useDoubleFBO , 
14-  useSingleFBO , 
15-  useFluid , 
16-  useCoverTexture , 
17-  useMotionBlur , 
18-  useSimpleBlur , 
19-  usePointer , 
20-  useNoise , 
21-  useCreateWobble3D , 
22- }  from  "@/packages/use-shader-fx/src" ; 
12+ import  {  useRawBlank  }  from  "@/packages/use-shader-fx/src" ; 
2313import  {  FxMaterial  }  from  "./FxMaterial" ; 
2414import  {  OrbitControls ,  useVideoTexture  }  from  "@react-three/drei" ; 
2515
@@ -28,57 +18,61 @@ extend({ FxMaterial });
2818export  const  Playground  =  ( )  =>  { 
2919 const  {  size,  viewport,  camera }  =  useThree ( ) ; 
3020
31-  // /FT_Ch02-comp.mp4 
32-  // http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 
33-  const  funkun_mov  =  useVideoTexture ( "/FT_Ch02-comp.mp4" ,  { 
34-  width : 1280 , 
35-  height : 720 , 
36-  } ) ; 
3721 const  [ funkun ]  =  useLoader ( THREE . TextureLoader ,  [ "/funkun.jpg" ] ) ; 
3822
39-  const  [ updateNoise , setNoise ,  {  output :  noise } ]  =  useNoise ( { 
23+  const  [ update , set ,  {  output} ]  =  useRawBlank ( { 
4024 size, 
41-  dpr : 0.2 , 
42-  } ) ; 
43-  setNoise ( { 
44-  noiseOctaves : 1 , 
45-  fbmOctaves : 1 , 
46-  warpOctaves : 1 , 
47-  timeStrength : 1 , 
48-  scale : 2000 , 
49-  } ) ; 
50- 51-  const  [ updateWobble ,  wobble ]  =  useCreateWobble3D ( { 
52-  materialParameters : { 
53-  color : "hotpink" , 
54-  // displacementMap: noise, 
55-  // displacementScale: 2, 
25+  dpr : 2 , 
26+  onBeforeInit : ( param )  =>  { 
27+  Object . assign ( param . uniforms ,  { 
28+  uTexture : {  value : funkun  } , 
29+  uTime : {  value : 0  } , 
30+  } ) ; 
31+  param . fragmentShader  =  param . fragmentShader . replace ( 
32+  "#usf <uniforms>" , 
33+  ` 
34+ 					uniform sampler2D uTexture; 
35+ 					uniform float uTime; 
36+ 				` 
37+  ) ; 
38+  param . fragmentShader  =  param . fragmentShader . replace ( 
39+  "#usf <main>" , 
40+  ` 
41+ 					vec2 uv = vUv; 
42+ 					vec2 perDivSize = vec2(20.) / uResolution; 
43+ 					vec4 outColor = vec4( 
44+ 						texture2D(uTexture, uv + perDivSize * vec2(-1.0, -1.0)) + 
45+ 						texture2D(uTexture, uv + perDivSize * vec2(0.0, -1.0)) +  
46+ 						texture2D(uTexture, uv + perDivSize * vec2(1.0, -1.0)) +  
47+ 						texture2D(uTexture, uv + perDivSize * vec2(-1.0, 0.0)) +  
48+ 						texture2D(uTexture, uv + perDivSize * vec2(0.0, 0.0)) +  
49+ 						texture2D(uTexture, uv + perDivSize * vec2(1.0, 0.0)) +  
50+ 						texture2D(uTexture, uv + perDivSize * vec2(-1.0, 1.0)) +  
51+ 						texture2D(uTexture, uv + perDivSize * vec2(0.0, 1.0)) +  
52+ 						texture2D(uTexture, uv + perDivSize * vec2(1.0, 1.0)) 
53+ 						) / 9.0; 
54+ 					usf_FragColor = outColor; 
55+ 					usf_FragColor.r += sin(uTime); 
56+ 				` 
57+  ) ; 
5658 } , 
5759 } ) ; 
5860
59-  updateWobble ( null ,  { 
60-  // wobbleStrength: 0.0, 
61-  // colorMix: 0, 
62-  } ) ; 
63- 6461 useFrame ( ( state )  =>  { 
65-  updateWobble ( state ) ; 
66-  // updateNoise(state); 
62+  update ( 
63+  state , 
64+  {  hofsehfgose : 2  } , 
65+  { 
66+  uTime : state . clock . getElapsedTime ( ) , 
67+  } 
68+  ) ; 
6769 } ) ; 
6870
6971 return  ( 
7072 < > 
7173 < mesh > 
72-  < directionalLight 
73-  color = { "white" } 
74-  position = { [ 0.25 ,  2 ,  3 ] } 
75-  intensity = { 2 } 
76-  /> 
77-  < ambientLight  intensity = { 1 }  /> 
78-  < primitive  object = { wobble . mesh }  /> 
79-  { /* <icosahedronGeometry args={[2, 20]} /> 
80-  <meshPhysicalMaterial color={"hotpink"} displacementMap={noise} /> */ } 
81-  < OrbitControls  /> 
74+  < planeGeometry  args = { [ 2 ,  2 ] }  /> 
75+  < fxMaterial  u_fx = { output }  key = { FxMaterial . key }  /> 
8276 </ mesh > 
8377 </ > 
8478 ) ; 
0 commit comments