POV-Ray : Newsgroups : povray.advanced-users : Alpha-transparent scattering media overlay problem. Server Time
24 Nov 2024 07:50:23 EST (-0500)
  Alpha-transparent scattering media overlay problem. (Message 1 to 8 of 8)  
From: Ghost2
Subject: Alpha-transparent scattering media overlay problem.
Date: 24 Oct 2007 14:35:00
Message: <web.471f8f98fa9e7a548433e9240@news.povray.org>
I've been working on a simple image in which a prism is used to split a beam
of light into a rainbow pattern.  The floor is white, and the only main
source of light comes from a box with a narrow slit, so that a beam of
light shines on the prism. The system works pretty well.  Because it's use
is intended as a forum signature, I also have an area light that
projects_through a text object, casting a 'light shadow' onto the floor.
That works pretty good as well.  I have a (slightly old) copy of the image
here:

http://img527.imageshack.us/img527/4008/prismwb3.jpg


In order to enhance this image, I have a hollow/invisible block that sits on
top of where the name is projected, and is filled with a scattering media to
give a certain light effect (hard to describe).  The media has a gradient
density such that it is dense at the bottom, and no density at the top.
The problem is that the colored light coming from the prism hits this box,
and gets screwed up.  I want it to appear as if the media box has no effect
on the light.  As a work around, I tried rendering the image without the
box, then rendering a second image with only the media/light_source as an
alpha transparent png, so that I could overlay it in post-processing.  The
problem is that when the media is rendered on a transparent background, the
parts that should be lit/visible are fine, but the parts that should be
clear end up with a black-ish color.  I've tried messing with all kinds of
settings, colors, and media types, but to no avail.  I've come up with a
few ideas that might work, but I either don't know how to implement them,
or doubt their possibility:

*Can I tell the box to allow all light from the main source/beam through,
while still interacting with the name light? Or is it possible to tell the
box to only interact with the name light, excluding all other sources?
*For the overlay method, can I tell it to only show 'particles' that have a
direct LOS to the source through the text?


Cheers.

Here's the name code.  For what it should look like, run it with -ua, and
leave the plane at the bottom visible.  For the overlay version, comment
out the plane and set +ua:

//+q11 -a0.3 +am2 +r4 +hts +w405 +h135 -ua +fn32
//Image is best viewed at 3x*y
#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "functions.inc"
#include "rand.inc"

#version unofficial megapov 1.2; //Set as necessary

#declare Photons=off;     //Toggles photons
#declare PhoCount=100000; //200000
#declare AreaL=off;       //Toggle area light or point source (testing)
#declare LGrid=5;         //arealight grid size e.g. 5x5
#declare Rad=off;         //Toggle radiosity
#declare traceLev=5;
#declare ortho=off;
#declare ShowAx=off;      //Toggles rendering of axis markers

#declare Haze=on;         //Toggle media box
#declare HazeTest=on;    //Disables media, shows box with its densities

global_settings {
  assumed_gamma 1.0
  max_trace_level traceLev
  exposure 1.6
  exposure_gain 1.2
  #if (Photons)           // global photon block
    photons {
      count PhoCount      // alternatively use a total number of photons
      media on
    }

  #end

  #if (Rad)
    radiosity{
      media on
      pretrace_start 0.08
      pretrace_end   0.01
    }
  #end
}

#declare Camtrans=<-0.3,0,0.9>;
camera {
  #if (ortho) //////////ortho
    orthographic
    location <0,10,0>
    look_at 0
    right x*405/135
  #else ////////////////regular
    right x*405/135
    location <2,1.35,-1.0>+Camtrans
    look_at <0,0.1,0.0>+Camtrans
  #end

}

#if (ShowAx)
  cylinder {<0,0,0>, <5,0,0>, 0.05 pigment{rgb <1,0,0>}}
  cylinder {<0,0,0>, <0,5,0>, 0.05 pigment{rgb <0,1,0>}}
  cylinder {<0,0,0>, <0,0,5>, 0.05 pigment{rgb <0,0,1>}}
#end


//////The main part ////////////
//ghost
#declare ghost=
  text {
    ttf "arial.ttf" "Ghost2"
    0.2, 0

    pigment { rgb 1 }
    finish {ambient 1}

    scale 1
    rotate <90,-90,0>
    translate <0.25,0.5,0.6>
    rotate <0,-10,0>
    translate <0,4,0.2>
  }

light_source {
  <0,40,1>
  rgb <167,204,162>/127

  #if (AreaL)
    area_light <-1, 0, -0.2>/2, <1, 0, 0.2>/3, LGrid, LGrid
  #end

  jitter
  projected_through {ghost}

  photons {
    refraction off
    reflection off
  }

}


//Haze
#if (Haze)
  box { <-0.8,0.0,0.65>,<0.8,2,7>
    #if (HazeTest)
      pigment {
        gradient y
        color_map {
          [0.0 rgb 1]
          [0.25 rgb 0.3]
          [0.40 rgb 0.0]
          [1.0 rgb 0.0]
        }
        scale 2
      }

      finish {
        ambient 0.5
      }

    #else
      pigment { rgbt 1 } hollow
      interior {
        media {
          scattering { 3,
            rgb<0.235,0.596,1>
            extinction 0.3
          }

          //ratio 0.5

          density {
            gradient y
            color_map {
              [0.0 rgb 1]
              [0.25 rgb 0.3]
              [0.40 rgb 0.0]
              [1.0 rgb 0.0]
            }

            scale 2
          }
        }
      }
    photons {
      target 1.0          // photon block for a light source
      refraction off
      reflection off
    }
    #end

    rotate y*-12

  }
#end

plane { y, 0
  pigment {
    rgb 1
  }

  normal {
    crackle 0.1
    scale 0.5
  }

  finish {
    ambient 0
  }

}


Post a reply to this message

From: Leef me
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 24 Oct 2007 16:35:00
Message: <web.471fabe9cfe67d58892adb1d0@news.povray.org>
"Ghost2" <nomail@nomail> wrote:
> I've been working on a simple image in which a prism is used to split a beam
> of light into a rainbow pattern.  The floor is white, and the only main
> source of light comes from a box with a narrow slit, so that a beam of
> light shines on the prism. The system works pretty well.  Because it's use
> is intended as a forum signature, I also have an area light that
> projects_through a text object, casting a 'light shadow' onto the floor.
> That works pretty good as well.  I have a (slightly old) copy of the image
> here:
>
> http://img527.imageshack.us/img527/4008/prismwb3.jpg
>
>
> In order to enhance this image, I have a hollow/invisible block that sits on
> top of where the name is projected, and is filled with a scattering media to
> give a certain light effect (hard to describe).  The media has a gradient
> density such that it is dense at the bottom, and no density at the top.
> The problem is that the colored light coming from the prism hits this box,
> and gets screwed up.  I want it to appear as if the media box has no effect
> on the light.  As a work around, I tried rendering the image without the
> box, then rendering a second image with only the media/light_source as an
> alpha transparent png, so that I could overlay it in post-processing.  The
> problem is that when the media is rendered on a transparent background, the
> parts that should be lit/visible are fine, but the parts that should be
> clear end up with a black-ish color.  I've tried messing with all kinds of
> settings, colors, and media types, but to no avail.  I've come up with a
> few ideas that might work, but I either don't know how to implement them,
> or doubt their possibility:
>
> *Can I tell the box to allow all light from the main source/beam through,
> while still interacting with the name light? Or is it possible to tell the
> box to only interact with the name light, excluding all other sources?
> *For the overlay method, can I tell it to only show 'particles' that have a
> direct LOS to the source through the text?
>

Hi Ghost2,

I am not certain if this will help, but you might check out the keyword
light_group    someone asked for ultaviolet light that only effects part of
the scene. Here is the post

image   http://news.povray.org/438c41a2%40news.povray.org
scene   http://news.povray.org/438c4240%241%40news.povray.org

Leef_me


Post a reply to this message

From: Alain
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 25 Oct 2007 11:53:17
Message: <4720bbed$1@news.povray.org>
Ghost2 nous apporta ses lumieres en ce 2007/10/24 14:31:
> I've been working on a simple image in which a prism is used to split a beam
> of light into a rainbow pattern.  The floor is white, and the only main
> source of light comes from a box with a narrow slit, so that a beam of
> light shines on the prism. The system works pretty well.  Because it's use
> is intended as a forum signature, I also have an area light that
> projects_through a text object, casting a 'light shadow' onto the floor.
> That works pretty good as well.  I have a (slightly old) copy of the image
> here:
> 
> http://img527.imageshack.us/img527/4008/prismwb3.jpg
> 
> 
> In order to enhance this image, I have a hollow/invisible block that sits on
> top of where the name is projected, and is filled with a scattering media to
> give a certain light effect (hard to describe).  The media has a gradient
> density such that it is dense at the bottom, and no density at the top.
> The problem is that the colored light coming from the prism hits this box,
> and gets screwed up.  I want it to appear as if the media box has no effect
> on the light.  As a work around, I tried rendering the image without the
> box, then rendering a second image with only the media/light_source as an
> alpha transparent png, so that I could overlay it in post-processing.  The
> problem is that when the media is rendered on a transparent background, the
> parts that should be lit/visible are fine, but the parts that should be
> clear end up with a black-ish color.  I've tried messing with all kinds of
> settings, colors, and media types, but to no avail.  I've come up with a
> few ideas that might work, but I either don't know how to implement them,
> or doubt their possibility:
> 
> *Can I tell the box to allow all light from the main source/beam through,
> while still interacting with the name light? Or is it possible to tell the
> box to only interact with the name light, excluding all other sources?
> *For the overlay method, can I tell it to only show 'particles' that have a
> direct LOS to the source through the text?
> 
> 
> Cheers.
> 
I'd use 2 light_group.
The first for the prism and ground plane.
The second for the ghost-like name.

When you use a light_group the included light_source only affect the elements in 
it's own group, and the objects of the group only receive light from their light.

-- 
Alain
-------------------------------------------------
After any salary raise, you will have less money at the end of the month than 
you did before.


Post a reply to this message

From: Ghost2
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 25 Oct 2007 23:35:00
Message: <web.47215ff7cfe67d588433e9240@news.povray.org>
No dice.  I tried the light_group trick, and either the media box blocks the
light coming from the prism; or when I put the prism/light emitter/plane in
a group, it disables photon mapping, which gets rid of the rainbow effect.


Post a reply to this message

From: Tim Attwood
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 26 Oct 2007 05:22:54
Message: <4721b1ee$1@news.povray.org>
> No dice.  I tried the light_group trick, and either the media box blocks 
> the
> light coming from the prism; or when I put the prism/light emitter/plane 
> in
> a group, it disables photon mapping, which gets rid of the rainbow effect.

For alpha transparency to have any effect you need to be looking at
the background and not a solid plane.  Comment that out and then
you can layer your glow image over the other image with the text and
prism.


Post a reply to this message

From: Ghost2
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 26 Oct 2007 13:45:01
Message: <web.47222681cfe67d58f8cd2ee70@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> > No dice.  I tried the light_group trick, and either the media box blocks
> > the
> > light coming from the prism; or when I put the prism/light emitter/plane
> > in
> > a group, it disables photon mapping, which gets rid of the rainbow effect.
>
> For alpha transparency to have any effect you need to be looking at
> the background and not a solid plane.  Comment that out and then
> you can layer your glow image over the other image with the text and
> prism.

I know.  The problem is that when it renders, the whole image is transparent
(checker) except for the region where the media box is.  It is mostly
transparent (e.g. the lit areas look normal), but the parts that arent lit
are a dark grey color, instead of being completely transparent.   So you
end up with a box-shaped grey artifact instead of just the lit areas (e.g.
name 'halo').

If you run the example code I posted without the plane, and alpha on, you'll
see what I mean.


Post a reply to this message

From: Tim Attwood
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 26 Oct 2007 17:45:19
Message: <47225fef@news.povray.org>
> I know.  The problem is that when it renders, the whole image is 
> transparent
> (checker) except for the region where the media box is.  It is mostly
> transparent (e.g. the lit areas look normal), but the parts that arent lit
> are a dark grey color, instead of being completely transparent.   So you
> end up with a box-shaped grey artifact instead of just the lit areas (e.g.
> name 'halo').
>
> If you run the example code I posted without the plane, and alpha on, 
> you'll
> see what I mean.

Yes, that's the way it's supposed to be, the media interacts with the
camera rays, scattering some of them. I can see what you want though.
You want an emission media in a text container...

// Haze material
#declare haze2_Mat = material {
   texture {
      pigment {rgbt <1,1,1,1>}
   }
   interior {
      media {
         emission rgb <0.235,0.596,1>
         density {
            gradient y
            color_map {
               [0.0 rgb 1]
               [0.25 rgb 0.3]
               [0.40 rgb 0.0]
               [1.0 rgb 0.0]
            }
            scale 2
         }
      }
   }
};

// Haze container
#declare ghost2 = text {
   ttf "arial.ttf" "Ghost2" 2.5, 0
   scale 1.14 // fudge to size of text on ground
   rotate <90,-90,0>
   translate <0.25,0.5,0.6>
   rotate <0,-10,0>
   translate <0,2,0.2>
};

// Haze
object {
   ghost2
   hollow
   material {haze2_Mat}
}


Post a reply to this message

From: Ghost2
Subject: Re: Alpha-transparent scattering media overlay problem.
Date: 26 Oct 2007 22:30:01
Message: <web.4722a1e6cfe67d588433e9240@news.povray.org>
Yay! I finally got the overlay working! Thanks!

I had to set max tracelevels to around 30 to kill all of the artefacts, but
it works! Yay! Now I just need to wait 5 hours to render the main image...


Post a reply to this message

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