Mark Sachs (ksleet) wrote,
Mark Sachs

  • Mood:
  • Music:

Captain, it's a planet of wheat!

Rings are pretty easy, of course.

To detect if our camera ray hits some rings, we just need to a) determine where the ray intersects the ring plane, and then b) check to see if the distance of the intersection point from the center of the rings is within the size of the rings themselves. The distance of the intersection point can be used to paint a texture on the rings as well.

The most time-consuming part of this wasn't the rings per se, but was instead that I rearranged the render pipeline to be a bit more flexible. When a ray is shot out from the camera, it collects a list of everything it may hit. These items are then sorted by distance and rendered back-to-front, so we can stack up any number of transparent objects (such as the halos and the rings.) Though that being said I can't think of too many other shapes I want to render right this second. Some sort of gas clouds, maybe.

I also made some efficiency improvements. Some very obvious changes to how I was projecting the vectors cut that CPU time down to almost nothing, and the frame rate has improved; the code is a lot better organized now as well, as a bonus. It's not smooth, not nearly, but it's certainly better.

Probably the most complex thing I did today was implement some code that smooths the surface normals of the planet's surface, as I referred to in the previous entry. I was actually able to do it by, for every point in the tessellated sphere, computing the average of the surface normals of all triangles that use it to create a surface normal for the point. Then, when you're rendering a point on a triangle, you can interpolate the surface normals from the corners of the triangles, smoothing the surface. However, the problem with this very standard method of smoothing the normals is that the surface ends up looking all mushy and melted, like so:

Yeah, the obvious triangular artifacts are gone, but the surface still looks odd in the same sort of pattern, and the apparent fine detail the triangles lent has vanished. So I'm disabling the smoothing code for right now while I think about what, if anything, I want to do with it.
Tags: raytracer
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.