POV-Ray : Newsgroups : povray.general : Trace macro workings with isosurfaces - Pov 3.5 Server Time
6 Nov 2024 14:26:16 EST (-0500)
  Trace macro workings with isosurfaces - Pov 3.5 (Message 1 to 5 of 5)  
From: Stefan Viljoen
Subject: Trace macro workings with isosurfaces - Pov 3.5
Date: 22 May 2004 08:59:05
Message: <40af4e92@news.povray.org>
Hi all

I have a problem using the trace macro - in the /advanced PovRay
installation directory, there is a scene called isocacti that uses the
built-in trace() macro to determine the "height" of ridges on a isosurface. 

I am attempting to use the same technique in one of my scenes to place
objects on the same isosurface (copied out of isocacti.pov), but trace()
seems to detect the isosurface at least 3 units too "high" - i.e . all my
objects "float" above the isosurface they are supposed to rest on. 

Exchanging the isosurface in my scene with a plane object in the xy plan
makes the trace macro in my scene work correctly - so the apparent problem
is with trying to trace() an isosurface (although - how can it work
correctly in isocacti.pov?)

My camera:

#declare center_loc = <3,4,1>;
#declare center_look = <0,0,1>;

#declare cam_loc = center_loc;
#declare cam_look = center_look;

camera
{
        sky <0,0,1>
        location cam_loc
        up <0,0,1>
        look_at cam_look
}

The "ground":

#declare Ground =
isosurface {
        function {y - f_snoise3d(x/7, 0, z/2)*0.5}
        threshold 0
        max_gradient 1.1
        contained_by {box {<-100,-3,-100>, < 100, 1, 100>}}

        texture {
                pigment {color rgb < 1, 0.9, 0.65>}
                normal {granite 0.2 scale 0.02}
                finish {
                        brilliance 0.5
                        specular 0.1
                        //diffuse 0.3
                        //ambient 0.3
                }
        }
}

object 
{
        Ground

        rotate <90,0,45>
        translate <50,-20,0>
}

#declare loc = trace(Ground,<0,0,5>,-z);

sphere
{
        <0,0,0>,0.25
        texture{pigment{color Red}}

        translate loc
}

The loc coordinate is consistently wrong - it never returns the actual
isosurface intersection with the correct Z, always a few units more - if I
do

#declare loc = trace(Ground,<0,0,15>,-z);

the error INCREASES - the sphere I want to place "on" the ground floating
"higher" and higher (i . e. +z direction).

However, exchanging the isosurface with a plane, instantly fixes the problem
and the sphere drops precisely to the surface of the plane.

But why does it work with the same isosurface in isocacti.pov? Can it be
that I use a different camera? Or because my isosurface is slightly
inclined? (Isocacti seems to use a "flat" isosurface in the xz plane) But
logically that should not matter?

This has really got me baffled - any help appreciated!

Regards,

Stefan Viljoen
Software Support Technician
Polar Design Solutions


Post a reply to this message

From: Christoph Hormann
Subject: Re: Trace macro workings with isosurfaces - Pov 3.5
Date: 22 May 2004 09:10:02
Message: <c8nj8u$59l$1@chho.imagico.de>
Stefan Viljoen
> 
> object 
> {
>         Ground 
>         rotate <90,0,45>
>         translate <50,-20,0>
> }
> 
> #declare loc = trace(Ground,<0,0,5>,-z);
> 
> sphere
> {
>         <0,0,0>,0.25 
>         translate loc
> }

What did you expect this to result in?  If you think the sphere will be 
placed on the surface of the object you obviously have misunderstood 
something about how transforms work.  You will either have to remove the 
"rotate <90,0,45> translate <50,-20,0>" from the object or add it to the 
sphere as well.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 01 May. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Stefan Viljoen
Subject: Re: Trace macro workings with isosurfaces - Pov 3.5
Date: 22 May 2004 09:29:00
Message: <40af5572@news.povray.org>
Christoph Hormann wrote:

> Stefan Viljoen
>> 
>> object
>> {
>>         Ground
>>         rotate <90,0,45>
>>         translate <50,-20,0>
>> }
>> 
>> #declare loc = trace(Ground,<0,0,5>,-z);
>> 
>> sphere
>> {
>>         <0,0,0>,0.25
>>         translate loc
>> }
> 
> What did you expect this to result in?  If you think the sphere will be
> placed on the surface of the object you obviously have misunderstood
> something about how transforms work.  You will either have to remove the
> "rotate <90,0,45> translate <50,-20,0>" from the object or add it to the
> sphere as well.

Hi Christoph!

I expected it to result in the sphere placed correctly on the surface.
Obivously I made a mistake. I guess I misunderstood the docs... from
reading them it said that the trace() macro will return the place where a
the ray, shot from the coordinate given, intersects the given object's
surface - I thought of this in terms of a "viewing ray" (?) i. e. that will
return a surface it intersects, no matter how far away or in what
orientation that surface is.

Obviously I was wrong. Thanks for the correction!
 
Regards,
-- 
Stefan Viljoen
Software Support Technician
Polar Design Solutions


Post a reply to this message

From: Christoph Hormann
Subject: Re: Trace macro workings with isosurfaces - Pov 3.5
Date: 22 May 2004 09:40:02
Message: <c8nl1c$66c$1@chho.imagico.de>
Stefan Viljoen
> 
> from
> reading them it said that the trace() macro will return the place where a
> the ray, shot from the coordinate given, intersects the given object's
> surface

That's exactly what it does but you trace 'Ground' while you display 
'object { Ground rotate <90,0,45> translate <50,-20,0> }'.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 01 May. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Mike Williams
Subject: Re: Trace macro workings with isosurfaces - Pov 3.5
Date: 22 May 2004 10:05:43
Message: <Ljx+GCAV31rAFwQ+@econym.demon.co.uk>
Wasn't it Stefan Viljoen who wrote:
>Hi all
>
>I have a problem using the trace macro - in the /advanced PovRay
>installation directory, there is a scene called isocacti that uses the
>built-in trace() macro to determine the "height" of ridges on a isosurface. 
>
>I am attempting to use the same technique in one of my scenes to place
>objects on the same isosurface (copied out of isocacti.pov), but trace()
>seems to detect the isosurface at least 3 units too "high" - i.e . all my
>objects "float" above the isosurface they are supposed to rest on. 
>
>Exchanging the isosurface in my scene with a plane object in the xy plan
>makes the trace macro in my scene work correctly - so the apparent problem
>is with trying to trace() an isosurface (although - how can it work
>correctly in isocacti.pov?)

The trace() function traces Ground at the position you #declared it.

You rotated and translated the Ground object after declaring it, but
trace() has no knowledge of that. 

Try applying the
         rotate <90,0,45>
         translate <50,-20,0>
commands inside the #declare Ground isosurface instead of the 
        object 
        {
                Ground
        }
section.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.