An experiment to simulate water refraction. The code is compiled using java 1.1, to run it simpily double click
island.html.
My attempt to simulate water refraction is quite simple:
-
render the water surface just like a normal polygon.
-
I perform a “nearest polygon first” drawing routine, so each pixel is filled only once.
-
instead of drawing the polygon which represents the water surface, I store the postions of the pixels that the polygon covers.
-
after all the solid polygons are drawn, fill the pixels which were covered by water surface with the colors of neigbour pixels.
(the distance change is determined by a precalculated Sin table)
Here is a shot of it:
http://www.freewebs.com/phu004/island.jpg
You can grab the file here:
www.freewebs.com/phu004/island.zip
(you have to manually save the file due to hotlink protection)
