Jump to content

  • Log In with Google      Sign In   
  • Create Account


Ray Tracing - Weird edges of triangle.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 MrOMGWTF   Members   -  Reputation: 433

Like
0Likes
Like

Posted 15 August 2012 - 03:08 AM

Hey, I just finished doing my ray-triangle intersection test. I made simple scene to test it. Just one triangle facing to the camera. I rendered it, and it works fine. I see the triangle. But at the bottom edge of the triangle, there are some weird artifacts. I'll post the code for intersection as well as the image of rendered image.

Image:
Spoiler


Code for intersection:
Spoiler


Code for generating eye rays:
Spoiler


I think the problem is in generating eye rays, but I don't see anything wrong here.

Sponsor:

#2 jefferytitan   Crossbones+   -  Reputation: 2003

Like
0Likes
Like

Posted 15 August 2012 - 05:00 AM

I don't really have an answer for you. It appears to me that all three edges are equally bad, but it's easier to tell on an axis aligned edge. Try it with a right angled triangle and that may show up more clearly.

Also try it with a simple plane test instead of a triangle, it may be easier to debug.

#3 Bacterius   Crossbones+   -  Reputation: 8580

Like
0Likes
Like

Posted 15 August 2012 - 05:09 AM

You want to add epsilon comparisons when comparing DdQ, DdE, QdN, etc... as well, as they seem to relate to your intersection point's barycentric coordinates with respect to the triangle, so they will produce weird nondeterministic edges because of floating-point inaccuracies. At least that's all I can think of, and the image clearly reminds me of the same thing I had in my own raytracer (due to forgetting epsilons).

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#4 Tudor Nita   Members   -  Reputation: 121

Like
0Likes
Like

Posted 15 August 2012 - 05:15 AM

Not exactly an answers, more like a guess but:

From a (very) quick look at the code, I assume you are taking a single sample per pixel. That will always generate edge artefacts. Try subdividing the pixel. You could start with a 2 by 2 and just average the results.

This is an assumption based on no data though ( can't see your raycast loop ) so take it as is.

P.S:
Bacterius makes a valid point too. I hit that block early as well. Wald's paper might help
This was also an eye opener when I was building my raytracer. Probably the most performance oriented intersection technique ( still using barycentric coords.)

Edited by Tudor Nita, 15 August 2012 - 05:21 AM.


#5 0BZEN   Crossbones+   -  Reputation: 2013

Like
0Likes
Like

Posted 17 August 2012 - 07:50 AM

yeah. 'edge' cases. Check your dividers multipliers. These usually produce artifacts when they get very small or very big, due to floating point innacuracies.

Or you can go 'double'. It' still not solving the problem.

Everything is better with Metal.


#6 Krypt0n   Crossbones+   -  Reputation: 2507

Like
1Likes
Like

Posted 17 August 2012 - 10:34 AM

I think the problem is not inside that code snippet.
Is it maybe the case that you're normalizing your direction vector? in case you do, try it without normalization (shouldn't be important for this test, I guess).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS