POV-Ray : Newsgroups : povray.binaries.images : Additive transparency Server Time
9 Aug 2024 11:22:39 EDT (-0400)
  Additive transparency (Message 1 to 1 of 1)  
From: Slime
Subject: Additive transparency
Date: 3 Feb 2005 19:46:48
Message: <4202c5f8@news.povray.org>
In POV-Ray, when you have a transparent surface, the color of the surface is
always (t * background + (1-t) * color). So as t goes from 0 to 1, you fade
to total transparency.

In OpenGL, you can set the way that transparency is calculated. This allows
for, among other equations, the equation (background + (1-t) * color). This
is similar to normal transparency when t is close to 1, but when t is near
zero, you get an "additive" effect: the background is added to the
foreground, creating an effect much like that of emission media. This
creates a pretty artistic effect and is occasionally useful for modeling
realistic objects.

Although POV-Ray has emission media to simulate this effect, sometimes you
want just a thin surface with additive color blending, and you'd rather not
take the time to give it a small amount of depth and fill it with emission
media. I realized in the shower the other day that this can be done with the
existing transparency model, by scaling the color way up and using a
transparency value close to (but not quite equal to) 1.

So today I put a macro together that generates such "additive" transparent
colors very easily. This image shows it in action; the particles in the
distance are all flat discs with simple pigments on them:

#declare Particle = disc {
 0,-z,1
 pigment {
  spherical
  color_map {
   #declare additiveness = 1;
   [0 Additive_Blend(<.8,.1,.1>, additiveness, 1)]
   [1 Additive_Blend(<.8,.1,.1>, additiveness, 0)]
  }
  cubic_wave
 }
 finish {ambient 1 diffuse 0}
}

The macro parameters are the color you want, how additive you want it to be
(a value of 1 creates the OpenGL effect that I mentioned), and how
transparent to make it afterwards (a value of 1 fades to invisible).

I'll post the macro in povray.binaries.scene-files in case anyone might
benefit from it.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message


Attachments:
Download 'additivetest.jpg' (95 KB)

Preview of image 'additivetest.jpg'
additivetest.jpg


 

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