Raytracing

Started by
15 comments, last by thebigMuh 21 years, 6 months ago
Cheers!

That''s nice, since it allows for an early out for me:

if (t >= maximumAlreadyRecordedHitDistance)
return false;

Which will spare me a few more cross and dot products.

Thanksalot, can''t wait to implement it!

Ciao, ¡muh!
They're watching us...
Advertisement

    bool intersect_triangle(ray ray,v3 a,v3 b,v3 c,f32 old_t,f32& new_t,f32& new_u,f32& new_v) {	v3 e1 = c - a;	v3 p = ray.dir.cross(e1);	v3 t = ray.orig - a;	f32 det = e0.dp3(p);	if(det<=0.f) return false;	t /= det;	if(t<=0.f || t>=old_t) return false;	f32 u = t.dp3(p);	if(u<=0.f || u>=det) return false;	v3 e0 = b - a;	v3 q = t.cross(e0);	f32 v = ray.dir.dp3(q);	if(v<=0.f || u+v>=det) return false;	u /= det;	v /= det;	new_t = t;	new_u = u;	new_v = v;	return true;}    


so thats what you like, right?

"take a look around" - limp bizkit
www.google.com

[edit] i forgot return true:D

[edited by - davepermen on October 2, 2002 9:12:20 AM]
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Yup ;-)

However, I can completely ommit the new u and v values, since I don''t need them.

Ciao, ¡muh!
They're watching us...
why ever.. don''t you need them for uhm.. texturing and lighting? well i do:D

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

That''s only a dirtmap I''m building. It doesn''t do texturing and lighting, it only tells the renderer the amount of dirt for a certain pixel. It does that by sending out rays in a hemisphere and averaging the distance each ray needed to score the closest hit. However, since QMC sampling needs a quite high raycount to achieve more or less noise free images, and I cannot do subsampling, the raytracer has to be as fast as possible.

Thanks again for the routines!

Ciao, ¡muh!
They're watching us...
BTW: I just noticed that your t magically changes from a vector to a float and back again...

Ciao, ¡muh!
They're watching us...
Just wanted to add to the "SWEET PIC!!!!!!" thing

My raytracer''s nothing on yours; for anyone following this thread and thinking "I have GOT to write one of those" though, it might be useful - small, OO, commented source.

Keep up the good work, the dirt particularly is excellant.

www.coldcity.com
code, pics, life
[size="2"]www.coldcity.com code, art, life

This topic is closed to new replies.

Advertisement