POV-Ray : Newsgroups : povray.general : media tester scene : media tester scene Server Time
27 Apr 2024 13:33:49 EDT (-0400)
  media tester scene  
From: Kenneth
Date: 9 Sep 2017 17:25:00
Message: <web.59b45aa0c2559bcd883fb31c0@news.povray.org>
The recent discussion about emission media here...

http://news.povray.org/povray.newusers/thread/%3Cweb.59ad8cfca4b127e95cafe28e0%40news.povray.org%3E/

....gave me an idea to put together a basic, easy-to-use media tester scene (for
all three media types), for experimentation, and for the *combining* of
different medias (of the same or complementary color.) The scene is basically a
media 'cloud', with extra objects of specific colors to show how the media
affects them.  Although POV-Ray already includes some example scenes that
demonstrate the use of media, this tester allows easier changes and
combinations, using simple on-off switches, as well as changes to the media
parameters (color, density, etc.)  My original reason for making this was to
test PURE-color media, but it can be used for any color. It uses the recommended
media settings of
                 method 3
                 intervals 1
                 samples xx (a single value)

I made this in version 3.7 (actually 3.7.1 beta 9). I haven't tested it in v3.6,
but I think it should work there as well.

It's initially set up to render a pure green cloud, with lighting effects.
(Scattering media + complementary-color absorption media.) But the various media
combinations show some interesting effects, as well as the 'filtering' of
background colors. Experiment with it! I hope it proves useful. Feel free to
comment or to suggest changes.

----------------
// NOTE 1: All medias use the same density PATTERN.
// NOTE 2: When using v3.7xx, you will get warning messages about
// "high ambient value" for the objects. Ignore those.

#version 3.71; // or 3.7, etc.

global_settings{assumed_gamma 1.0  max_trace_level 5}
#default {finish{ambient 1 diffuse 0}}

#declare LIGHT_ON = on; // (only affects scattering media,
// and the long box embedded in it)

#declare BACKGROUND_COLOR = 2; // switch-- for the color/pattern of
// the background box.
// 1 for WHITE
// 2 for medium GRAY (rgb .214)
// 3 for BLACK
// 4 for HEXAGON pigment pattern (with its default colors of red,
// green and blue)

// These three medias have the SAME color and density amount;
// change those below.
#declare EMISSION_MEDIA = off;
#declare ABSORPTION_MEDIA = off;
#declare SCATTERING_MEDIA = on;
     #declare EXT = 1.0; // EXTINCTION amount, only for SCATTERING media

#declare MEDIA_COLOR = <0,1,0>; // color of the main media (but not
// the density multiplier)
#declare MEDIA_DENSITY = 4.0; // density multiplier for the main media
// (but not the color)
#declare SAM = 20; // media samples

#declare ADD_COMPLEMENTARY_COLOR_EMISSION = off; // add EMISSION media but
// with the COMPLEMENTARY color of the main media.
    #declare C_C_E_DENSITY = 2.0; // density multiplier for this

#declare ADD_SAME_COLOR_ABSORPTION = off; // add ABSORPTION media but
// with the SAME color as the main media.
    #declare S_C_A_DENSITY = 2.5; // density multiplier for this

#declare ADD_COMPLEMENTARY_COLOR_ABSORPTION = on; // add ABSORPTION media but
// with the COMPLEMENTARY color of the main media.
    #declare C_C_A_DENSITY = 4.0; // density multiplier for this

#declare ADD_COLORLESS_ABSORPTION = off; // adds ABSORPTION media with
// NO color, to absorb ALL colors equally.
    #declare N_C_DENSITY = 2.5; // density multiplier for this

background {rgb .5}

camera {
  perspective
  location  <0, .3, -9>
  look_at   <0, 0,  0>
  right     x*image_width/image_height
  angle 16
}

#if(LIGHT_ON)
light_source {
  0*x
  color rgb <1,1,1>
  translate <-20, 100, -20>
}
#else
#end

plane{y,-1.05
    no_shadow
    pigment{hexagon scale .3*<1,1,6>}
    }

// background box
box{<-.35,-.5,0>,<.35,.5,0>
    no_shadow
    scale 10
        pigment{
                #switch(BACKGROUND_COLOR)
                #case(1)
                rgb 1
                #break
                #case(2)
                rgb .218
                #break
                #case(3)
                rgb 0
                #break
                #case(4)
                hexagon scale .35 rotate 90*x
                #break
                #else
                #end
            }
        translate 20*z
        }

#declare DENSITY_PATTERN =
density{
        spherical
        color_map{
             [.20 rgb 0]
             [.23 rgb 1]
                 }
             scale 3.5
             warp{turbulence .7 omega .5}
             scale 1/3.5
        }

sphere{0,1
   // no_shadow // DON'T add this-- it eliminates scattering media's
   // self-shadowing
    hollow on
        pigment{rgbt 1}
        interior{
                #if(EMISSION_MEDIA)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    emission MEDIA_DENSITY*MEDIA_COLOR
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(ABSORPTION_MEDIA)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    absorption MEDIA_DENSITY*MEDIA_COLOR
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(SCATTERING_MEDIA)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    scattering{1, MEDIA_DENSITY*MEDIA_COLOR extinction EXT}
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(ADD_COMPLEMENTARY_COLOR_EMISSION)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    emission C_C_E_DENSITY*(1 - MEDIA_COLOR)
                    // (1 - MEDIA_COLOR) will change <1,1,0> into
                    // <0,0,1>, for example
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(ADD_SAME_COLOR_ABSORPTION)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    absorption S_C_A_DENSITY*MEDIA_COLOR
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(ADD_COMPLEMENTARY_COLOR_ABSORPTION)
                    media{
                    method 3
                    intervals 1
                    samples SAM
                    absorption C_C_A_DENSITY*(1 - MEDIA_COLOR)
                    density{DENSITY_PATTERN}
                         }
                #else
                #end

                #if(ADD_COLORLESS_ABSORPTION)
                media{
                method 3
                intervals 1
                samples SAM
                absorption N_C_DENSITY
                density{DENSITY_PATTERN}
                     }
                #else
                #end
                } // end of interior
       }

// long box embedded in media
box{-.37,.55 scale <3.5,.15,.15>
        pigment{
            gradient x
            scale .7
            color_map{
                [0.0 rgb <1,0,0>]
                [.333 rgb <1,0,0>]
                [.333 rgb <0,1,0>]
                [.666 rgb <0,1,0>]
                [.666 rgb <0,0,1>]
                     }
                }
        // OR...
        // pigment{rgb .5}

    rotate -60*y
    rotate -15*x
    translate .1*y
    }
// END


Post a reply to this message

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