
SVG logo to 3D
July 6, 2024
Shadow Particles
August 28, 2024Pixel Displacement Effect
This article teaches you how to create a cool pixel/grid displacement effect on an image in Three.js. It uses shaders and GPGPU techniques to achieve this effect. Here's the gist:
- Setup:
- You'll need two textures: the original image and a separate texture to store displacement data.
- The code creates a plane with a shader material to display the image.
- Displacement with GPGPU:
- A separate shader calculates the displacement based on mouse movement and stores it in a texture.
- This displacement texture is invisible but affects how the final image is rendered.
- Handling Mouse Movement:
- The code tracks mouse movement and updates the displacement data accordingly.
- When you move the mouse, it creates a trail effect that fades out slowly.
- Creating the RGB Shift Effect:
- This final step adds a subtle RGB shift effect to the displaced image.
- It achieves this by applying the displacement data slightly differently to the red, green, and blue channels of the image, creating a color shift.
By the end, you'll have an interactive image with a cool pixelated displacement effect that responds to your mouse movement!
I wrote a tutorial for @codrops on how to create this pixel displacement effect with RGB shift using Three.js shaders.
— Jean Mazouni (@Jean_mazouni) August 27, 2024
You can read it here : https://t.co/Kloki8tPI2 pic.twitter.com/IcKDuTJYXW



