Created
July 9, 2024 20:56
-
-
Save seantai/4b84ef9778e4c627aadaaf972e0914cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uniforms = useRef(null) | |
useFrame(({ clock }) => { | |
if (!uniforms.current) return | |
uniforms.current.u_color.value.y = Math.sin(clock.elapsedTime * 2) | |
}) | |
return ( | |
<mesh geometry={Suz.nodes.geometry}> | |
<meshNormalMaterial | |
onBeforeCompile={(shader) => { | |
shader.uniforms.u_color = { value: new Vector3(0.2, 0, 0.02) } | |
shader.fragmentShader = 'uniform vec3 u_color;\n' + shader.fragmentShader | |
shader.fragmentShader = shader.fragmentShader.replace(' normal ', ' normal * u_color') | |
uniforms.current = shader.uniforms | |
}} | |
/> | |
</mesh> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment