POV-Ray : Newsgroups : povray.advanced-users : Alpha-transparent scattering media overlay problem. : Alpha-transparent scattering media overlay problem. Server Time
5 Jul 2024 14:23:43 EDT (-0400)
  Alpha-transparent scattering media overlay problem.  
From: Ghost2
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

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