first-hit ray casting problem?

Started by
5 comments, last by null Alaska 18 years, 8 months ago
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.
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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

This topic is closed to new replies.

Advertisement