Artifact black lines on raytraced mesh (with Embree)

336 views Asked by At

I am developing a Embree based ray tracer (currently very early in development). If you are not familiar with Embree you can read more at their webpage.

The issue: Currently if you start the renderer to use 1 ray per pixel and per iteration (referred to 1 ray mode from now on), it renderers just fine. If you set it trace 4 rays in a packet (raypacket4) it renders the mesh fine, util you move some distace away from it, then some black lines appear.

Issue Screenshots Screenshot camera parameters are (all in ray packet mode):

  1. position 0, 1, 0, rotation 20, 0, 0
  2. position 0, 38, 0 rotation 90, 0, 0
  3. position 9.5, 5, 0 rotation 90, 0, 0
  4. position 9.5, 38, 0 rotation 90, 0, 0

Investigation showed that the lines appear only in pakcet mode and when some distance away from mesh. I am posting screens of the issue (rendered images) in several different camera positions. Here is the source code of the project (on GitHub) Source Code

My bet is that the problem is in either the packet generation (found at camera.cpp/GetRayPacket4) or in the rendering (renderer.h/RenderBuffer4, Raytrace4). Switching between the modes is done in main.cpp by just replacing RenderToBuffer4 with RenderToBuffer and RTC_INTERSECT4 to RTC_INTERSECT1.

Any help or ideas are much appreciated.

Edit:

I apologize for the lack of config files, or scene files, it is currently in very early dev stage( 2 days spent) and everything is hardcoded for testing at the moment.

Edit 2:

I have discovered that removid the + i in the ray direction calculation in GetRayPacket4, removes the issue, but then the 4 packed rays are identical. Why would that fix it ?

1

There are 1 answers

0
Alexander Mladenov On BEST ANSWER

Solved.

The issue was that the __m128 keeps the data in reverse order, so some pixel swapping had to take place.