POV-Ray : Newsgroups : povray.newusers : Adding transparency to several objects after they've been defined : Re: Adding transparency to several objects after they've been defined Server Time
28 Jul 2024 18:17:26 EDT (-0400)
  Re: Adding transparency to several objects after they've been defined  
From: Chris B
Date: 16 Jan 2008 04:56:46
Message: <478dd4de$1@news.povray.org>
"Josh VW" <the### [at] yahoocom> wrote in message 
news:web.478d98ed277aa08f49e5cfeb0@news.povray.org...
> Hi all,
>  If I have a large, complex object and want to render a series of images 
> with
> different sub-objects faded out (made semi-transparent), is there a best 
> way to
> do that?  In my case, I am trying to highlight different parts of a laser 
> table
> with lots of lenses and mirrors, but you could imagine having an engine
> or clock and then fading out everything but one particular gear assembly 
> at a
> time.
>
> I basically have a scene file that looks like this:
>
> ---------------------------------------------------------------
> #include "colors.inc"
>
> #declare Std_Texture = texture { pigment { color Blue} };
>
> #macro big_optic (xpos, ypos, height)
>  //this will actually be a mirror/lens/etc
>  box { <0,0,0> <1,1,height>
>        texture {Std_Texture}
>        translate <xpos,ypos,0>
>  }
> #end
>
> //part 1 of laser table
> big_optic (2,3,4)
> big_optic (5,6,3)
>
> //part 2
> big_optic(-1,4,3)
> big_optic(-3,0,2)
>
>
> camera{
>  location <0, -10, 5>
>  look_at <0, 0, 0 >
> }
> background { color White }
> light_source { <5,-10,5>, color White}
>
> ------------------------------------------------------
>
> and I would like to add transparency to the optics in part 1 or part 2.  I 
> could
> just redefine Std_Texture between sections, but in reality I have 
> big_optic_1,
> big_optic_2, etc, and each may use several texures.  I would like to be 
> able to
> do something like add "transmit 0.9" to everything within a block.
>
> Sorry for such a long question, and thanks for any help you can give.
>
> -Josh
>

Hi Josh,

There are quite a few approaches you could take. IMO the easiest would be to 
replace your //part 1 comments with #declare Optic_Part= 1; etc. Then 
replace Std_Texture with Std_Texture() and write a macro that returns the 
texture based upon the value of an array that you can set at the top of the 
file. If you are able to use the same technique with all of your textures 
(hopefully there aren't too many to do that) then you can just switch on or 
off the parts you want to see on a particular render.

#declare Optic_Part_Switch = array[3];
#declare Optic_Part_Switch[0] = 0;
#declare Optic_Part_Switch[1] = 1;
#declare Optic_Part_Switch[2] = 0;

#macro Std_Texture ()
  #if(Optic_Part_Switch[Optic_Part])
    texture {... opaque texture ...}
  #else
    texture {... texture with transmit 0.9...}
  #end
#end

// WARNING. Untested, so look out for potential syntactical errors.

Hope this is some help
Regards,
Chris B.


Post a reply to this message

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