Final update to real time raytracer

Image

raytrace6.cpp

Update adds:

  • shading to the reflective surfaces.
  • jitter to the light source to cast poor mans 1bit “soft” shadows.
  • remove redundant square route from inner loop.
Advertisements

2 thoughts on “Final update to real time raytracer

  1. Based on your last source code post you can take advantage of SSE on intel when compiling with GCC.
    On linux (Ubuntu) install SDL with:
    sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev
    Then in the source change:
    – remove #include
    wherever you construct temporaries with your vec3’s, you need to give the constructor/function definitions const for those temp params or create actual temporaries for them. eg: sSphere(vec3 &center, float r ) needs to become sSphere( const vec3 &center, float r )
    or GCC will complain a lot. There are a few instancies of this.. I am sure you can find them.
    This is because gcc doesn’t like constructing sSphere like sSphere(vec3(stuff)blah..)
    – _InterlockedIncrement( &threads ); should be replaced with __sync_fetch_and_add(&threads, 1);
    – _InterlockedDecrement( &threads ); should be replaced with __sync_fetch_and_sub(&threads, 1);

    Then build it with:
    g++ -O3 -msse4 -I/usr/include/SDL/ main.cpp -o out -L/usr/lib -lSDL
    run with ./out

    Test it by chaging the vidSize to 1080 ish.
    Seem to get decient fps by turning on sse4 at that resolution, -O3 on the compiler helps a lot too becasue it removes all the redundant load calls between sse instructions I think.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s