POV-Ray : Newsgroups : povray.newusers : Adding transparency to several objects after they've been defined Server Time
1 Nov 2024 16:24:25 EDT (-0400)
  Adding transparency to several objects after they've been defined (Message 1 to 4 of 4)  
From: Josh VW
Subject: Adding transparency to several objects after they've been defined
Date: 16 Jan 2008 00:45:00
Message: <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


Post a reply to this message

From: Chris B
Subject: Re: Adding transparency to several objects after they've been defined
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

From: Josh VW
Subject: Re: Adding transparency to several objects after they've been defined
Date: 17 Jan 2008 00:55:00
Message: <web.478eeccaec8d04e218a725020@news.povray.org>
Hi Chris,
  Thanks for the suggestion - it definitely pointed me in the right direction.
Here's what I ended up doing, in case anyone else has the same problem.  I put
my texture declarations inside a macro which I could call to switch on and off
transparency.  By being inside a macro, they are evaluated at runtime and not
compile time (in my way of thinking), so I can switch textures on the fly.
Here's the whole test file:

#include "colors.inc"

#macro define_textures(fade)
  #if (fade)
    #declare trans = 0.9;
  #else
    #declare trans = 0;
  #end

  #declare Std_Texture = texture { pigment { color Blue transmit trans} };
  #declare some_other_texture =  texture { pigment { color Red transmit trans}
};

#end

#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


define_textures(0) // not faded
big_optic (2,3,4)
big_optic (5,6,3)

define_textures(1) //turn on fade
big_optic(-1,4,3)

define_textures(0) //turn of fade
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}


Post a reply to this message

From: Jan Dvorak
Subject: Re: Adding transparency to several objects after they've been defined
Date: 17 Jan 2008 10:44:47
Message: <478f77ef$1@news.povray.org>
Josh VW napsal(a):
> Hi Chris,
>   Thanks for the suggestion - it definitely pointed me in the right direction.
> Here's what I ended up doing, in case anyone else has the same problem.  I put
> my texture declarations inside a macro which I could call to switch on and off
> transparency.  By being inside a macro, they are evaluated at runtime and not
> compile time (in my way of thinking), so I can switch textures on the fly.
> Here's the whole test file:

Actually it's just that macros are only parsed if and anytime it is 
used. Pigments are evaluated when the parser meets them (actually you 
can define a pigment inside a macro if you know what you are doing)


Post a reply to this message

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