Here are my first results from my self programmed 2D Raytracer:
Here’s a update including Source & .exe .
http://www.blendpolis.de/viewtopic.php?f=17&t=38332&start=0
Attachments
wow - that’s cool
I’m no programmer but I’ve always wondered in raytracers, how do you do the intersections? (with the ray and the object)
m1 = tan(alpha*pi/180);
m2 = (getEdgesY1(i) - getEdgesY2(i))/(getEdgesX1(i) - getEdgesX2(i)); v = (getEdgesY1(i)-y+x*m2-getEdgesX1(i)*m2)/(m1-m2);
// printf("V: %f
“,v);
// printf(”%f x; %f y
",x + v,x + v);
xs = x + v;
ys = y + v * m1;
like this
and then this:
if(inBounds(xs,ys,x-0.0001,y-0.0001,x+0.0001,y+0.0001))
{
interSec ->x = noInters;
interSec ->y = noInters;
return 1;
}
else
{
if ( inBounds(xs,ys,getEdgesX1(i),getEdgesY1(i),getEdgesX2(i),getEdgesY2(i)) )
{
if (inDirection(alpha,xs,ys,x,y))
{
interSec->x = xs;
interSec->y = ys;
//printf(" xs: %f , ys: %f
",xs,ys);
return 0;
}
else
{
interSec ->x = noInters;
interSec ->y = noInters;
return 0;
}
}
else
{
interSec ->x = noInters;
interSec ->y = noInters;
return 0;
}
}
Wow - that makes so much sense… I always though it would be more complicated than that
That is just not true.
I really like what I’m seeing here. Is the concept something that’s implemented for practical use in any software field? Do you have any specific goal for it yourself?
nice.
i could imagine making custom .ior files with that
First two pictures are very, very cool! How do you define camera position and the 2d slice you render? Are rays parallel?
Awesome idea, too!