Turn an image into a normal map that refracts light in just the right way to create that image!
For a nice explanation of what's happening (and the inspiration for this), look at this video: https://m.youtube.com/watch?v=wk67eGXtbIw
Here's an example (if your device supports it, a higher quality mp4 is down below):
Note: I'm not 100% convinced, that I'm calculating everything correctly (especially the direction of the normals could be exactly opposite). If you know a program where I can double check my results, that would be nice! (I couldn't get proper caustics to work in Blender with my crappy laptop.)
Here's the normal map corresponding to the eye (not obvious, right?! :D)
- Make sure you got processing installed (this was written in it).
- Put your (grayscale) image that you want to convert into the
resources
folder ofImageCausticsGenerator
. - Open the
ImageCausticsGenerator.pde
file and edit theloadImage
line, so it loads your image instead of the example provided. - Press the play button in the top left and wait until the numbers in the console stop or the image animates back and forth between two states.
- Copy paste the
normals.png
into theresources
folder ofImageCausticsViewer
. - Open the
ImageCausticsViewer.pde
file and make sure theloadImage
line loads the correct normals. - Press the play button in the top left and you should be able to view the caustics and slightly rotate the virtual glass with your mouse.
- You can also move the glass closer and further from the screen with the up and down arrows.
Note: This is simplified
- Figure out which light has to move where
- Start with a uniform light distribution
- Optimize according to the image horizontally and vertically
- Iterate until the mean movement of light goes up again (not quite sure why that happens yet, but it's a good indicator that it's done)
- Calculate the normals from each movement
- Simulate a uniform light distribution refracting through a glass plate
- Holes can be difficult for the algorithm (see the circle/torus example image)
- If there are multiple elements that can't reach each other by a single horizontal or vertical move, the brightness will probably be off
- The images you get in the viewer are more fuzzy (see the dot example image for a big fail in that regard)
- I'm not taking fresnel into account, so the light intensities might be a bit off (especially when roatating the glass in the viewer)