POV-Ray : Newsgroups : povray.newusers : Difference fom height field. Server Time
28 Jul 2024 22:26:45 EDT (-0400)
  Difference fom height field. (Message 1 to 7 of 7)  
From: Verm
Subject: Difference fom height field.
Date: 27 Apr 2007 10:20:51
Message: <463206c3$1@news.povray.org>
Hi,

I'm trying to make a pediment (I think that's the architectural term for 
the triangle on top of columns on classical buildings) out of a 
height-field differenced with two sloping boxes.

Using difference I'm not successfully cutting out the triangle. (it 
works if I replace the height-field with a box) Am I missing something 
obvious in the manual... is there a good reason for this not to work?

I can get it to work if I take the intersection of the height_field with 
a suitably differenced box but this seems silly.

Also is there a way to invert the height field (I ended up inverting the 
image in an image editor).

Here's a minimal scene showing the problem (it's meant to render a 
triangle). The commented out code shows that it works with intersection.

thanks

-----------------------------------
#default {
   pigment {rgb 1}
}

camera {
   location  <0.0, 3.5, -9.0>
   //direction 1.5*z
   //right     x*image_width/image_height
   look_at   <0.0, 1,  0.0>
}

light_source {
   <-30, 30, -30>
   color rgb 1
}

#local fh = 3;
#local fl = 5;
#local fw = 4;
#local fa = degrees(asin(fh/fl))  ;

difference {
   height_field {
     png "plasma3.png"
     rotate x*-90
     translate <-0.5,0,0>
     scale <fw*2,fh,0.2>
   }
   union {
     box{<0,-0.1,-2> <fl,4,2> rotate z*-fa translate <0,fh,0>}
     box{<0,-0.1,-2> <fl,4,2> rotate z*-fa translate <0,fh,0> scale x*-1}
   }
}


/*intersection {
   height_field {
     png "plasma3.png"
     rotate x*-90
     translate <-0.5,0,0>
     scale <fw*2,fh,0.2>
   }
   difference {
     box { <-fw,0,-1> <fw,fh,1> }

     union {
       box{<0,-0.1,-2> <fl,4,2> rotate z*-fa translate <0,fh,0>}
       box{<0,-0.1,-2> <fl,4,2> rotate z*-fa translate <0,fh,0> scale x*-1}
     }
   }
} */


Post a reply to this message

From: Tim Attwood
Subject: Re: Difference fom height field.
Date: 28 Apr 2007 06:29:54
Message: <46332222@news.povray.org>
Height_fields have depth, but only the "field" surface
is rendered... so you need to difference off a
slightly smaller box to give it edges...

difference {
   height_field {
     png "plasma3.png"
     rotate x*-90
     translate <-0.5,0,0>
     scale <fw*2,fh,0.2>
   }
   box{<-0.49,0.01,0>,<0.49,0.99,-1> inverse scale <fw*2,fh,0.2>}
   box{<0,-0.1,-2> <fl,4,2> rotate -fa*z translate <0,fh,0>}
   box{<0,-0.1,-2> <fl,4,2> rotate -fa*z translate <0,fh,0> scale -x}
}

or alternately, treat it as just a surface of triangles,
and use clipped_by ...

height_field {
   png "plasma3.png"
   rotate x*-90
   translate <-0.5,0,0>
   scale <fw*2,fh,0.2>
   clipped_by {
      box{<0,-0.1,-2> <fl,4,2> inverse rotate -fa*z translate <0,fh,0>}
      box{<0,-0.1,-2> <fl,4,2> inverse rotate -fa*z translate <0,fh,0> 
scale -x}
   }
}


Post a reply to this message

From: Verm
Subject: Re: Difference fom height field.
Date: 29 Apr 2007 03:38:02
Message: <46344b5a$1@news.povray.org>
Tim Attwood wrote:
> Height_fields have depth, but only the "field" surface
> is rendered...  so you need to difference off a
> slightly smaller box to give it edges...

Thanks ok I see this works fine. It still seems a little odd.

To me it seems counterintuitive that taking a height-field and 
differencing a larger box from it leaves anything. It's even stranger 
that whats left is outside the original bounding box of the height_field

difference {
   // height_field from <0 0 0> to <1 1 1>
   height_field {
     png  "plasma3.png"
   }
   box { -1, 2 }
}

It seems height_fields could be considered of infinite depth but that 
apart from the top face their faces don't show until something is 
differenced.

   In this case I'm not interested one way or the other in any edges as 
they won't be visible so clipping works fine too, and I *think* I now 
understand how hf's behave.

Now to try to complete the rest of my Before-After 3D-rtc entry :- )

thanks


Post a reply to this message

From: Kenneth
Subject: Re: Difference fom height field.
Date: 29 Apr 2007 07:00:01
Message: <web.463479816244d7c29d1710750@news.povray.org>
Verm <pov### [at] thirteeendynucom> wrote:

> Also is there a way to invert the height field (I ended up inverting the
> image in an image editor).

Yep, it's very easy: When you scale your height_field, make the
y-component negative.  For example, scale <10,-2,10>

Ken W.


Post a reply to this message

From: Verm
Subject: Re: Difference fom height field.
Date: 29 Apr 2007 09:02:58
Message: <46349782$1@news.povray.org>
Kenneth wrote:
> Verm <pov### [at] thirteeendynucom> wrote:
> 
>> Also is there a way to invert the height field (I ended up inverting the
>> image in an image editor).
> 
> Yep, it's very easy: When you scale your height_field, make the
> y-component negative.  For example, scale <10,-2,10>
> 
> Ken W.

I'd tried that but as soon as you do CSG that doesn't achieve the same 
thing as inverting the image.

You end up with the flat side of the height field facing you instead of 
the bumpy side :-)
(for an example change
scale <fw*2,fh,0.2>
to
scale <fw*2,fh,-0.2>
in the height_field in Tim's first code suggestion)

If I use clipped by instead of difference then it works fine though.


Post a reply to this message

From: Warp
Subject: Re: Difference fom height field.
Date: 29 Apr 2007 09:17:32
Message: <46349aec@news.povray.org>
Verm <pov### [at] thirteeendynucom> wrote:
> > Yep, it's very easy: When you scale your height_field, make the
> > y-component negative.  For example, scale <10,-2,10>
> > 
> > Ken W.

> I'd tried that but as soon as you do CSG that doesn't achieve the same 
> thing as inverting the image.

  Then apply 'inverse' to the heighfield besides the scale.

-- 
                                                          - Warp


Post a reply to this message

From: Verm
Subject: Re: Difference fom height field.
Date: 29 Apr 2007 15:52:12
Message: <4634f76c$1@news.povray.org>
Warp wrote:
> Verm <pov### [at] thirteeendynucom> wrote:
>>> Yep, it's very easy: When you scale your height_field, make the
>>> y-component negative.  For example, scale <10,-2,10>
>>>
>>> Ken W.
> 
>> I'd tried that but as soon as you do CSG that doesn't achieve the same 
>> thing as inverting the image.
> 
>   Then apply 'inverse' to the heighfield besides the scale.
> 
Grrr too obvious - Yup that would do it.

thanks


Post a reply to this message

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