Jump to content
  • Advertisement
Sign in to follow this  
null Alaska

first-hit ray casting problem?

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to cast ray in each pixel of screen, then get the intersect point of each ray.when i use first-hit ray casting. i set the object triangle color as it's index,set shading as flat, disable lighting. then render them to a texture surface. i use the pixel color of the texture surface as the index of the intersct triangle. cast a ray to test the intersect point with the triangle. but sometimes it failed (means no collide with the triangle). what's the problem of this? it's the sampling problem (means the resolution of the screen for rendering to the texture surface, maybe the ray collide with the neighbors of the triangle that be draw)? if yes, how did i solve the problem? (just increase the resolution? but i think there still some pixel(ray) will fail) sorry for my poor english. and thanks for any help. Alaska.

Share this post


Link to post
Share on other sites
Advertisement
If you're casting a ray for each pixel of the screen, you shouldn't run into the sampling problem - because you're casting rays at the same rate as you're sampling. You're guaranteed a sample for each ray.

Presumably, you're certain that your geometry covers the whole surface, and that when these tests are being reported as failing they are actually incorrect? If you're not covering the whole surface, and some rays are saying "I didn't hit anything", they may be quite correct...

Is it that the rays are hitting pixels with the background colour, or that they're hitting colours that don't seem to belong to any triangles? If the latter, it could be down to antialiasing and blending.

Share this post


Link to post
Share on other sites
i guess that is the aliasing problem.

http://homelf.kimo.com.tw/cclf_a_tw/TriangleIndex.bmp

i save the texture surface to a file ( i multiply the triangle index with 50000, because i want to see the difference from two triangle that index is close) , to see the picture, use the paint(or you can use any painter software), don't use the default picture browser (that's will blend the color).
that's pic is 64x64. bellow is 256x256 (i just resize the 64x64 pic, you can see the pixel of the pic easily).

http://homelf.kimo.com.tw/cclf_a_tw/TriangleIndex256.bmp

my guess is, when i cast a ray from the "blue" pixel that the neighbor's color is "black"(on the top right of the picture), the ray actually collide triangle is the "black", not the "blue"'s one. but i only test collide with the "blue"'s triangle. so the ray says "there are no collision with the "blue" triangle". the ray fail and the ray's intersect point is none. i have try to use ray casting to test with all tirangle (per ray test with all triangles). the result is correct, but the performace is an issue.

i try to increase the resolution, but there are some ray failed. how can i solve the aliasing problem? or it's the other problem?

sorry for my poor english and thanks for any help.

Alaska.

Share this post


Link to post
Share on other sites
I cant see your pictures. I would guess this is not an aliasing problem. ray traced images like you're doing should be similiar in all respects to opengl, scanline based rendering. can you post the pics to another site, it's not allowing us to see.

Tim

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It's possible that you have precision problems with a bad triangle intersector.
Google around for ray triangle intersection and you'll find some nice fast accurate routines.

Share this post


Link to post
Share on other sites
http://home.pchome.com.tw/web/null_alaska/TriangleIndex.bmp
http://home.pchome.com.tw/web/null_alaska/TriangleIndex256.bmp

can these work?

thanks for any help.

Alaska.

Share this post


Link to post
Share on other sites
thank for all the help.

now, the problem has solved with two ways.

one:
supersampling?
if the ray says "there are no collision, but the pixel of the texture is coloring by the triangle index", i use the same ray to test the triangle that is the neighbors (8-connect) of the pixel of the texture.

two:
improve the precision problem of triangle intersector.

with the two ways. now, there are no problem when the resolution is 32x32,64x64, 128x128, 256x256, 512x512, 1024x1024.

thank for all the help again.

Alaska.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!