Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Ray Tracing - Weird edges of triangle.

4: Adsense

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   

444
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.

#2 jefferytitan   Members   

2523
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   Members   

13164
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).

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”


#4 Tudor Nita   Members   

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   Members   

2195
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   Members   

4692
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.