POV-Ray : Newsgroups : povray.newusers : Slicing a media object Server Time
23 Nov 2024 14:59:46 EST (-0500)
  Slicing a media object (Message 1 to 3 of 3)  
From: IanDean
Subject: Slicing a media object
Date: 22 Sep 2013 15:20:01
Message: <web.523f41c6f5157c2664ac7e00@news.povray.org>
Greetings everyone,

I'm trying to draw a 2D array of light beams (currently implemented as
cylindrical emitting media). I plan on creating several of them in different
directions, then I want to intersect this multi-array with a box, so that I
render only a small portion of it.

My issue is that when intersecting my current single array with a box, the
cylinder ends become black, they don't retain the color of the cylinders if the
box wasn't there. I've tried all combinations of intersection and difference

1) How do I slice the beams, but retain the color at their ends?
2) How can I do this rendering, but with a white background? I don't see
anything when I make it so.
3) Is there a better way  to implement the beams? I really like the "emitting"
look of the cylinders. I might be able to do that solid objects, but I'm not
sure how.

Code is below. Cylinders are in the y direction, 10 units long from 0 to 10. The
box is cutting the beams so they are from 1 to 9 in the y direction.

Appreciate anyone's help,

Ian


//--------------------------------------------------
#include "colors.inc"
#include "functions.inc"

camera {
   location <0,10,10>*3
   rotate y*-45
   rotate z*0
   rotate x*0
   look_at  <0,0,0>
}

light_source {
   <0,50,0>
    rgb <1,1,1>
}


//background{color rgb<1,1,1>}

#declare boxtexture = texture {
   pigment {
      rgbf 1
   }
}


  #declare r_violet1 = color rgbf<1.0, 0.5, 1.0, 1.0>;
  #declare r_violet2 = color rgbf<1.0, 0.5, 1.0, 0.8>;
  #declare r_indigo  = color rgbf<0.5, 0.5, 1.0, 0.8>;
  #declare r_blue    = color rgbf<0.2, 0.2, 1.0, 0.8>;
  #declare r_cyan    = color rgbf<0.2, 1.0, 1.0, 0.8>;
  #declare r_green   = color rgbf<0.2, 1.0, 0.2, 0.8>;
  #declare r_yellow  = color rgbf<1.0, 1.0, 0.2, 0.8>;
  #declare r_orange  = color rgbf<1.0, 0.5, 0.2, 0.8>;
  #declare r_red1    = color rgbf<1.0, 0.2, 0.2, 0.8>;
  #declare r_red2    = color rgbf<1.0, 0.2, 0.2, 1.0>;

#declare boxinterior = interior {
   media {
      intervals 10
      samples 1,20
      emission <1,1,1>
      absorption <0,0,0>
      scattering { 1,<0,0,0> }
      confidence 0.9999
      variance 1/1000
        density { cylindrical
      color_map {
      [0.000  color r_violet1 transmit 0.98]
      [0.100  color r_violet2 transmit 0.96]
      [0.214  color r_indigo  transmit 0.94]
      [0.328  color r_blue    transmit 0.92]
      [0.442  color r_cyan    transmit 0.90]
      [0.556  color r_green   transmit 0.92]
      [0.670  color r_yellow  transmit 0.94]
      [0.784  color r_orange  transmit 0.96]
      [0.900  color r_red1    transmit 0.98]

      }
    }
   }
}


declare length=15;
declare r=1;
declare a=r*4.5;


// CREATE LIGHT BEAM
#declare wg = union {

        cylinder {
        <0,0,0>, <0,10,0>    r
        texture { boxtexture }
        interior { boxinterior }
        hollow
        //rotate<0,0,30>
        }

}

#declare n   = 1;
#declare m   = 1;

// REPEAT BEAM IN THE X DIRECTION
#declare waveguide2D = union
{
        #local j = -n/2;
        #while (j <= n/2)
                object{wg translate<j*a,0,0>}
                #local j = j + 1;
        #end
}

// REPEAT IN THE Z DIRECTION
#declare waveguide3D = union
{
        #local j = -m/2;
        #while (j <= m/2)
                object{waveguide2D translate<0,0,j*a>}
                #local j = j + 1;
        #end
}




// SLICE THE BEAMS USING INTERSECTION WITH A BOX
intersection{
object{waveguide3D rotate<0,0,0>}
box{<-10,1,-10> <10,9,10>}
}

//--------------------------------------------------


Post a reply to this message

From: Warp
Subject: Re: Slicing a media object
Date: 22 Sep 2013 15:46:54
Message: <523f492e@news.povray.org>
IanDean <nomail@nomail> wrote:
> My issue is that when intersecting my current single array with a box, the
> cylinder ends become black, they don't retain the color of the cylinders if the
> box wasn't there. I've tried all combinations of intersection and difference

If you are applying an intersection between a pre-textured object and
another object, and you want for the cut parts to have the texture of
the first object, you have to use the 'cutaway_textures' keyword in
the intersection.

> 2) How can I do this rendering, but with a white background? I don't see
> anything when I make it so.

Emissive media can only add to the color behind it, never subtract
from it. Therefore any emissive media against a fully white background
will become white.

You'll have to add some absorbing component to the media if you want
it to be seen against a white background.

-- 
                                                          - Warp


Post a reply to this message

From: Alain
Subject: Re: Slicing a media object
Date: 23 Sep 2013 16:27:30
Message: <5240a432$1@news.povray.org>
Le 13-09-22 15:46, Warp a écrit :
> IanDean <nomail@nomail> wrote:
>> My issue is that when intersecting my current single array with a box, the
>> cylinder ends become black, they don't retain the color of the cylinders if the
>> box wasn't there. I've tried all combinations of intersection and difference
>
> If you are applying an intersection between a pre-textured object and
> another object, and you want for the cut parts to have the texture of
> the first object, you have to use the 'cutaway_textures' keyword in
> the intersection.
>
>> 2) How can I do this rendering, but with a white background? I don't see
>> anything when I make it so.
>
> Emissive media can only add to the color behind it, never subtract
> from it. Therefore any emissive media against a fully white background
> will become white.
>
> You'll have to add some absorbing component to the media if you want
> it to be seen against a white background.
>

I've done some test and got unexpected results.

If I apply "boxtexture" to the intersection as a whole, or apply it to 
the cuting box, or use cutaway_textures, the end of the rods become 
invisible with no media showing.

Adding hollow to the box or the intersection don't work.

The following Do work:

union{
	object{waveguide3D rotate<0,0,0>}
	box{<-10,2,-10> <10,-1,10>}
	box{<-10,8,-10> <10,11,10>}
	texture { boxtexture }
	rotate -7*y}

The media is suppressed inside the 2 non-hollow boxes and the media 
correctly show through the top of the cylinders.

Also, I think that it's preferable to change the beggining of the 
colour_map as follow:
       [0 rgb 0]
       [0.001  color r_violet1 transmit 0.98]


Next, to get MUCH faster results, in the media definition, remove 
intervals 10 and use the default value of 1.
Increase samples around 40 to 60. Note that the second value is silently 
ignored if present.
intervals 1 samples 100 is usualy faster than intervals 10 samples 1, 
10, with the "10" been ignored, for 10 times as many samples.
You can also remove confidence and variance.



Alain


Post a reply to this message

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