|
![](/i/fill.gif) |
Slime <fak### [at] email address> wrote:
> By the way: I'd like to point out that this:
> #local T1 = (-DV+SQ)/D2;
> #local T2 = (-DV-SQ)/D2;
> #local Result = (T1<T2 ? T1 : T2);
> can be safely replaced with this:
> #local Result = (-DV-SQ)/D2;
You are right. I didn't think of that.
Actually the "#local SQ = sqrt(SQ);" line can be removed too, so it
becomes:
#if(SQ < 0)
#local Result = -1;
#else
#local Result = (-DV-sqrt(SQ))/D2;
#end
This probably speeds up the "raytracing" a bit.
The reason why this can be reduced so much is that the macro always
returns the smallest 'T', regardless of whether it is the correct one
or not (meaning that if the camera is inside a sphere, it will not
raytrace it).
For a correct raytracer, where you can have the camera inside the objects
or, moreover, you can have semi-transparent objects, this is not enough,
but I didn't want to go too far into raytracing for this simple tutorial.
(In this case you also must advance along the ray by a distance of epsilon
before you actually compute the ray-object intersection or else you'll be
sometimes hitting the object itself from which the reflected/refracted ray
was shot.)
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
![](/i/fill.gif) |