Jump to content

WebGL rotating F: Difference between revisions

m
m (→‎{{header|J}}: add a bit of documentation on the approach)
Line 123:
In other words, we construct the letter F using three rectangular blocks near the origin of our coordinate system. And we construct a rectangle covering the screen using triangle strip. Finally, for each pixel on the screen we project a vector representing a potential pixel from our camera position towards the blocks.
 
In ray marching we find the minimum distance from an origin point to any point in the geometric structure, move in the ray direction that distance and repeat (in this case we repeat this operation 100 time for each pixel). After these iterations we have either shot past the geometry or we're within some small epsilon distance from the surface of the object. We can inspect the distance the array has progressed to determine whether we should use background color or surface color. And we can check distances with a some minor variations on this ray to determine the orientation of the surface at that point.
 
Finally, to achieve the "rotating" effect, we rotatespin our camera (and light source) so that it rotates around the blocks which form our letter "F", with the camera always facing towards the origin.
 
Tested in J9.03 and a J9.04 beta.
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.