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:19:23 EDT (-0400)
  Re: Adding transparency to several objects after they've been defined  
From: Josh VW
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

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