POV-Ray : Newsgroups : povray.general : location dependant refractive index : Re: location dependant refractive index Server Time
30 Jul 2024 22:27:55 EDT (-0400)
  Re: location dependant refractive index  
From: Florian Siegmund
Date: 9 Nov 2008 09:15:01
Message: <web.4916eea1a1a15775aacab8cf0@news.povray.org>
"feestje" <fee### [at] gmailcom> wrote:
> hi all
>
> thanks a lot Florian! I'm starting to understand the code (remember I'm a
> newbie) and I like the rendering. It looks great. It isn't exactly what I'm
> looking for.
>
> Let me explain myself better. I'm trying to mimic the result of Cooper in 1984.
> http://img513.imageshack.us/my.php?image=mirageeffectrg9.jpg
>
> He submerges a bal in what I presume is water above a heater. As more water get
> heated it rises up through convection. The boundary between hot and cold rises
> up. When lit from behind as is often the case in bubble research he witnesses
> the mirage effect. An effect I would like to make an animation of. The first
> step is to see the effect in 1 frame. making an animation should be easy after
> that.
>
> I tried to use the radiosity setting but I to didn't generate the effect.
> somewhere I am making a mistake. I'll keep trying to solve it.
>
> Any help from you would be greatly appreciated!
>
> regards, Ruud

Hello Ruud,
here's something new for you to work with. and i think now i'm very close to
what you have in mind.
i wrote a new, carefully commented code so to make it easy for you to understand
what i did to create the desired effect. and to make it easy for you to change
things which are not exactly the way you want them to be.
and, of course, i will also post a rendered image again. (rendering time at
1024x768: about 40m)

the code starts here:

// select as many samples as you need for getting an acceptable image,
// but think of increasing rendering time!
#declare heat_samples = 50;

#declare mirage_effect = on;

// simply change this value over time to create an animation (ideally use
// values between 0 and 0.5)
#declare hot_layer_level = 0.45;

#declare camera_location = <0, 0.2, -30>;

global_settings {
    // radiosity for a more realistic image and a 'devilly glowing' heater...
    // if you'd like to use this feature, you have to do at least
    // two render passes for the image to render correctly.
    // this is beacause radiosity is also affected by the 'mirage effect', but
    // in an undesired way.
    // turn off the mirage_effect (above) and render.
    // then turn the mirage_effect on again and replace 'save_file'
    // with 'load_file' in the radiosity settings and render a second time.
    // for every other rendering with only the hot_layer_level changing, you
    // can leave it this way.
    // for a faster rendering without radiosity, comment the following line...
    radiosity {brightness 1.7  normal on  save_file "mirage effect.rad"}
    max_trace_level heat_samples*2+2
}

camera {
    location camera_location
    up y
    right 4/3*x
    look_at 2.2*y
    angle 17.5
}

// the heater
union {
    cylinder {-y, 0, 23}
    torus {23, 5  scale 0.5*y+x+z  translate -2.5*y}
    pigment {
        bozo
        color_map {
            [0     color rgb <1, 0.8, 0.15>]
            [0.5   color rgb <1, 0.06, 0.05>]
            [1     color rgb <1, 0.8, 0.15>]
        }
        scale 4
        turbulence 1.5
        omega 0.1
        lambda 3.6
    }
    finish {ambient 7  diffuse 0.1}
}

// a small ball
sphere {
    2.4*y, 2
    pigment {color rgb <0.3, 0.3, 0.7>}
    finish {
        ambient 0
        diffuse 0.08
        specular 0.975*1.75
        roughness 0.0018
        phong 0.3*1.75
        phong_size 35
        brilliance 7
        metallic
        reflection {0.75  fresnel  metallic}
    }
    interior {ior 2.6}
}

light_source {<-20, 40, -30>  color rgb 1}

// background and foreground planes
union {
    plane {-z, -10}
    plane {z, -31}
    pigment {
        granite
        scale 2
        pigment_map {
            [0  color rgb 0.5]
            [1  color rgb 0.75]
        }
        turbulence 1
    }
    normal {
        granite 0.3
    }
}



// hot air
#declare heat_ripples = normal {
    #if (hot_layer_level > 0)  // this is only for saving your pc from trying
        // to divide through zero

        // this function doesn't describe a physically correct heat layer,
        // but it's a good visual approximation
        function {
            select (y, 1, atan (y/hot_layer_level)/pi*2)*
            select (hot_layer_level-0.05,  // if hot_layer_level < 0.05
                    // then the air is still getting hotter
                    hot_layer_level/0.05,
                    1  // else the air is hot enough
            )
        }
    #else
        function {0}  // a function for pure nothing
    #end
    // smooth turbulence, hardly noticeable
    turbulence 0.01
    omega 0.125
}

// a heat-pattern-test-plane
// (turn off the mirage_effect up above and uncomment the following lines to
// see the pattern)
/* plane {
    -z, 0
    pigment {
        #if (hot_layer_level > 0)
            function {
                select (y, 1, atan (y/hot_layer_level)/pi*2)*
                select (hot_layer_level-0.05,
                        hot_layer_level/0.05,
                        1
                )
            }
        #else
            function {0}
        #end
        color_map {
            [0  color rgb 1]
            [1  color rgb 0]
        }
    }
    finish {ambient 1  diffuse 0}
} */

#if (mirage_effect)  // if mirage effect is turned on
    // refractive spheres centered at the camera location
    #declare I = 0;
    union {
        #while (I < heat_samples)
            sphere {
                camera_location, 5+50*I/heat_samples
                // it's funny, but the viewing ray does NOT refract when it's
                // coming from
                // the inside of an object and is hitting the object's surface
                // from 'inside to outside'.
                // i don't know why, but one has to inverse the object in
                // this case, although it is already declared as 'hollow' :)
                inverse
            }
            #declare I = I+1;
        #end
        pigment {color rgbt 1}
        normal {heat_ripples 1}
        interior {ior 1+0.75/heat_samples}
        no_reflection
        no_shadow
        hollow
    }

    // non-refractive spheres, slightly larger than the refractive ones
    #declare I = 0;
    union {
        #while (I < heat_samples)
            sphere {camera_location, 5.0001+50*I/heat_samples  inverse}
            #declare I = I+1;
        #end
        pigment {color rgbt 1}
        no_reflection
        no_shadow
        hollow
    }
#end


Post a reply to this message

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