POV-Ray : Newsgroups : povray.newusers : Generating cross-section of a complicated model : Re: Generating cross-section of a complicated model Server Time
28 Jul 2024 12:29:58 EDT (-0400)
  Re: Generating cross-section of a complicated model  
From: Mike Williams
Date: 21 May 2009 02:53:18
Message: <KWQUDgDShPFKFwqf@econym.demon.co.uk>
Wasn't it Kenneth who wrote:
>"Chris B" <nom### [at] nomailcom> wrote:
>
>> I don't think there's a perfect answer to this. There is a
>> 'cutaway_textures' keyword that works with 'difference' and 'intersection'
>> CSG operations, but it's a long way from perfect and seems to be broken in
>> the 3.7 Beta 32. On the other hand it does work largely as documented on
>> POV-Ray 3.6, so it may help. Here's a very trivial test scene:
>
>[snip]
>
>> If you render this in 3.6 you'll notice that it works, but of course it
>> can't know which of the two colors to use for the overlapping part, so it
>> seems to average the two colors. Whether this is of any help to you will
>> depend on which version of POV-Ray you're on and upon the specifics of your
>> CSG operations. If you've been diligent enough to avoid overlapping parts of
>> different colors then you may be ok.
>>
>
>I wasn't aware of this limitation until now.  Bummer. Just running a
>simple test of randomly-placed (though overlapping) cubes, all with
>different colors, it does indeed show some kind of 'averaging' of the
>many pigments on the cut-away surfaces.

To avoid the texture averaging, you'd need to design your object so that
all the objects with different textures are cut away separately.

So instead of writing

camera {location  <0, 1,-3> look_at <0,0,0>}
light_source {< 70, 200, -80> color rgb 0.8}
difference {
 union {
   sphere {0,1 pigment {rgb <2,0,0>}}
   box {-0.9,0.9 pigment {rgb <0,0,2>}}
 }
 plane {z,0}
 cutaway_textures
}

You'd write it like this:

camera {location  <0, 1,-3> look_at <0,0,0>}
light_source {< 70, 200, -80> color rgb 0.8}

union {
  difference{
    sphere {0,1 pigment {rgb <2,0,0>}}
    plane {z,0} cutaway_textures
  }
  difference {
    box {-0.9,0.9 pigment {rgb <0,0,2>}}
    plane {z,0} cutaway_textures
  }
}

In this test scene I didn't get coincident surface problems, but I guess
that they might arise, so you might need to change the position of the
plane slightly for each cut. Changing the position of the plane also
gives you control over which of the textures is used for the overlapping
parts.

That removes the convenience of being able to create the whole engine
and then add the cut away effect afterwards. You can get some of the
convenience back by creating a macro to control the cut, like this:

camera {location  <0, 1,-3> look_at <0,0,0>}
light_source {< 70, 200, -80> color rgb 0.8}

#declare CutAway = true;

#macro Object(ZIndex, A)
  #if (CutAway)
    difference {
      object {A}
      plane{z,ZIndex * -0.000001} cutaway_textures
    }
  #else
    object {A}
  #end
#end

union {
  Object(0, sphere {0,1 pigment {rgb <2,0,0>}})
  Object(1, box {-0.9,0.9 pigment {rgb <0,0,2>}})
}

Changing the "#declare CutAway" switches between the normal view and the
cutaway view. I've used "ZIndex*-0.000001" so that you can use nice
positive integers in the Object() calls instead of negative millionths.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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