POV-Ray : Newsgroups : povray.general : Using a height_field for a CSG difference ... Server Time
2 Aug 2024 04:23:09 EDT (-0400)
  Using a height_field for a CSG difference ... (Message 1 to 7 of 7)  
From: Neil Kolban
Subject: Using a height_field for a CSG difference ...
Date: 1 Feb 2005 20:32:47
Message: <42002dbf$1@news.povray.org>
Folks,
I wanted to subtract from an object an "indentation" of a complex shape. 
Reading about CSGs and difference, it clearly stated that only solid objects 
that have clearly defined insides and outsides could be used.  Looking at 
the manual, it seems to say that height_fields are solid objects.

Can anyone confirm or deny that a height_field can be used as an object that 
I can remove from another using a CSG difference?

Neil


Post a reply to this message

From: Slime
Subject: Re: Using a height_field for a CSG difference ...
Date: 1 Feb 2005 20:49:07
Message: <42003193$1@news.povray.org>
> Can anyone confirm or deny that a height_field can be used as an object
that
> I can remove from another using a CSG difference?


Yes, a height field can be used in CSG. The "inside" part of a height field
is everything below it. Keep in mind that it doesn't have surfaces
surrounding this region on the sides, only on the top, so you may get
strange results if the object you're subtracting the height field from
touches parts other than the surface of the height field.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Jeremy M  Praay
Subject: Re: Using a height_field for a CSG difference ...
Date: 1 Feb 2005 22:58:33
Message: <42004fe9$1@news.povray.org>
"Neil Kolban" <kol### [at] kolbancom> wrote in message 
news:42002dbf$1@news.povray.org...
> Folks,
> I wanted to subtract from an object an "indentation" of a complex shape. 
> Reading about CSGs and difference, it clearly stated that only solid 
> objects that have clearly defined insides and outsides could be used. 
> Looking at the manual, it seems to say that height_fields are solid 
> objects.
>
> Can anyone confirm or deny that a height_field can be used as an object 
> that I can remove from another using a CSG difference?
>

I have had really bizarre things happen when I have tried to use 
heightfields to subtract from a CSG object.  I had a very simple 
heightfield, which was simply a white circle with a black background.  I 
tried differencing it from a CSG box.  One of the bizarre effects was that 
no matter what I did, the hole cut by the heightfield would extend all the 
way through to the other side of the object.  It didn't seem to matter how 
small I made the heightfield or how deep I made the box.

Using the following code, it's pretty easy to demonstrate the problem. 
Hole.png is simply a white circle on a black background.  The same thing 
appears to happen under 3.5, 3.6.1, and MegaPov 1.1.

//replace the "basic scene" sphere with this
difference {
  box { 0, 1 pigment {Red} }
  height_field {
    png "hole.png"
    rotate x*-90
    scale 0.5
  }
  rotate y*180
}

-- 
Jeremy
www.beantoad.com


Post a reply to this message

From: Slime
Subject: Re: Using a height_field for a CSG difference ...
Date: 1 Feb 2005 23:32:48
Message: <420057f0$1@news.povray.org>
> One of the bizarre effects was that
> no matter what I did, the hole cut by the heightfield would extend all the
> way through to the other side of the object.  It didn't seem to matter how
> small I made the heightfield or how deep I made the box.


The sample code you gave gives the expected results for me. Remember that
the "inside" of a height field is everything under the surface, all the way
down to negative infinity. When you difference the height field like you're
doing there, its surface coincides with one side of the box and the other
side is "underneath" the now-sideways height field. So both sides get cut
out. Also, since height fields have no surfaces on the sides, your box looks
hollow in the places where the sides of the height field cut into it.

Maybe replacing your height field with this will give you the results you
expected?

intersection {
    height_field {png "hole.png"}
    box {0.0001, 0.9999} // forces the height field to have a bottom and
sides
    ...
}

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Neil Kolban
Subject: Re: Using a height_field for a CSG difference ...
Date: 4 Feb 2005 22:43:36
Message: <420440e8$1@news.povray.org>
Jeremy,
I finally got around to testing your scene and ... exactly as you claimed, I 
had the same problems.  This is quite troubling and I can't seem to find an 
explanation.  Thanks for posting this puzzle ... I am going to look at it 
some more in case it isn't a bug but just something we don't yet understand.

Neil


Post a reply to this message

From: Slime
Subject: Re: Using a height_field for a CSG difference ...
Date: 4 Feb 2005 22:49:40
Message: <42044254$1@news.povray.org>
> One of the bizarre effects was that
> no matter what I did, the hole cut by the heightfield would extend all the
> way through to the other side of the object.  It didn't seem to matter how
> small I made the heightfield or how deep I made the box.


By the way, are you aware that your height field surface is completely
outside of the box's surface? This is why it cuts all the way through. Since
you're rotating it by -90 degrees in the x direction, it extends from Z = 0
backwards to Z = -0.5, whereas your box extends from Z = 0 to Z = 1. So
everything in the box {0, <0.5, 0.5, infinity>} is cut away by the height
field.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Jeremy M  Praay
Subject: Re: Using a height_field for a CSG difference ...
Date: 5 Feb 2005 19:28:04
Message: <42056494@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote in message 
news:42044254$1@news.povray.org...
>> One of the bizarre effects was that
>> no matter what I did, the hole cut by the heightfield would extend all 
>> the
>> way through to the other side of the object.  It didn't seem to matter 
>> how
>> small I made the heightfield or how deep I made the box.
>
>
> By the way, are you aware that your height field surface is completely
> outside of the box's surface? This is why it cuts all the way through. 
> Since
> you're rotating it by -90 degrees in the x direction, it extends from Z = 
> 0
> backwards to Z = -0.5, whereas your box extends from Z = 0 to Z = 1. So
> everything in the box {0, <0.5, 0.5, infinity>} is cut away by the height
> field.
>


I think I understand what's going on now.  Originally, I had used a 
heightfield with "waterlevel".  Even though the heightfield appeared just as 
I expected, the difference operation was quite a bit different from what I 
had expected.  I tried to make an example based on that faulty bit of code. 
Simply rotating and translating (in order so "slice" from the other 
direction) seems to have fixed the problem.

I was not aware of the "infinity" aspect of heightfields.  I believed that 
they were contained within a box, which then led to my confusion.  Thanks 
for the "paradigm shift".  ;-)

This code below produces what I expected to see (though it's not the 
cleanest bit of code).

difference {
  box { 0, 1}
  height_field {
    png "hole.png"
    rotate x*-90
    scale 0.5
    translate z*1.2
  }
  rotate y*160
  pigment {Red}
}

-- 
Jeremy
www.beantoad.com


Post a reply to this message

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