POV-Ray : Newsgroups : povray.binaries.images : Proximity Pattern testing : Re: Proximity Pattern testing Server Time
14 May 2024 23:30:38 EDT (-0400)
  Re: Proximity Pattern testing  
From: Norbert Kern
Date: 23 Sep 2017 05:00:00
Message: <web.59c621c881230942f5eec2f90@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

>
> That's a beautiful image.
>
> I'm a big fan of Rune's illusion.inc code. If I understand your method
> correctly, it means generating an ambient occlusion render first (in whichever
> way you want to go about that--a grayscale image, with the entire scene and
> object using a temporary white pigment?) Then, using illusion.inc to
> 'camera-project' that AO render back onto the object's real texture, as an
> additional overlay.
>
> If I'm correct about the method, then the grayscale AO render first needs to be
> taken into, say, Photoshop, to create an alpha-channel mask (using the *same*
> image for that but inverted, to create transparency for the white parts of the
> image.) *Then* it's overlayed onto the object, so that the real texture can show
> through--except where the AO render has darker areas.
>
> Correct so far? (I hope I'm making sense.) Or does your method use an actual
> 'proximity pattern' as well, in some way?
>
> To Thomas: Nice work with your trials and experiments. I still haven't played
> around with the proximity pattern code yet; real-life chores keep getting in the
> way. Very irritating :-/


The AO render uses good radiosity settings, no background, a simple texture and
an emissive sphere like that:

sphere {
        0, 10000
        texture {
                pigment {color rgb 1}
                finish {emission 1.2 diffuse 0}
        }
}

#declare T2 =
material {
 texture {
  pigment {color rgb 1}
  finish {ambient 0 diffuse 0.8}
 }
 interior {ior 1}
}

No transparency is used.

Rune's Illusion code is used to create a pigment pattern with perfect fit for a
texture map:

//______________________________________________________________________________

// illusion

#declare illusion_image     = "AO render.png"          ///////////////////////
#declare illusion_scale     = 10;
#declare illusion_samples   = 50;
#declare illusion_location  = <50,0,-201.5>; // camera location
#declare illusion_angle     = 46;            // camera angle
#declare illusion_look_at   = <0,0,0>;       // camera look at

#ifndef (illusion_location)  #declare illusion_location  = <0,0,0>; #end
#ifndef (illusion_right)     #declare illusion_right     =
image_width/image_height*x;  #end
#ifndef (illusion_up)        #declare illusion_up        = y;       #end
#ifndef (illusion_direction) #declare illusion_direction = z;       #end
#ifndef (illusion_sky)       #declare illusion_sky       = y;       #end
#ifndef (illusion_angle)     #declare illusion_angle     = degrees (atan2
(vlength (illusion_right)/2/vlength (illusion_direction),1))*2; #end
#ifndef (illusion_look_at)   #declare illusion_look_at   =
illusion_location+illusion_direction; #end

#ifndef (illusion_image)     #debug "\n\n--> you must specify
'illusion_image'!\n\n"  #end

#declare illusion_format = strlwr (substr (illusion_image,strlen
(illusion_image)-3,4))
#if (strcmp (illusion_format,".png") != 0 & strcmp (illusion_format,".tga") !=
0)
        #debug concat (
                "\n\n--> extension of illusion_image: ",
                strlwr (substr (illusion_image, strlen (illusion_image)-3,4)),
                "\n--> illusion_image must be a .png or .tga file!\n\n"
        )
#end

// CREATE THE IMAGE MAP USED IN THE ILLUSION
// *****************************************
#ifdef (illusion_image_function)
        #undef illusion_image_function
#end
#declare illusion_image_function =
function {
        #if (strcmp (illusion_format,".png") = 0)
                pigment {image_map {png illusion_image gamma 2.2 once} translate
-0.5}
        #else
                pigment {image_map {tga illusion_image gamma 2.2 once} translate
-0.5}
        #end
}

// CREATE THE RAW ILLUSION ALIGNED ALONG Z AXIS
// ********************************************
#declare illusion_raw =
pigment {
        average
        pigment_map {
                [1      function {illusion_image_function (x/z,y/z,z).red}
color_map {[0  rgb 0][1  rgb <4,0,0>]}]
                [1      function {illusion_image_function (x/z,y/z,z).green}
color_map {[0  rgb 0][1  rgb <0,4,0>]}]
                [1      function {illusion_image_function (x/z,y/z,z).blue}
color_map {[0  rgb 0][1  rgb <0,0,4>]}]
                [1      function {illusion_image_function (x/z,y/z,z).transmit}
color_map {[0  rgb 0][1  transmit 4]}]
        }
}

// ALIGNMENT CALCULATIONS
// **********************
#declare illusion_t = illusion_location;
#declare illusion_z = vnormalize (illusion_look_at-illusion_location);
#declare illusion_x = vnormalize (vcross (illusion_sky, illusion_z))*tan
(radians (illusion_angle/2))*2;
#declare illusion_y = vnormalize (vcross (illusion_z, illusion_x))*tan (radians
(illusion_angle/2))*2*vlength (illusion_up)/vlength (illusion_right);

// CREATE AND ALIGN THE ILLUSION
// *****************************
#declare illusion =
pigment {
        illusion_raw
        matrix <
                illusion_x.x,illusion_x.y,illusion_x.z,
                illusion_y.x,illusion_y.y,illusion_y.z,
                illusion_z.x,illusion_z.y,illusion_z.z,
                illusion_t.x,illusion_t.y,illusion_t.z
        >
}

#declare f_illu = function {pigment {illusion}}

#declare T3 =
material {
 texture {
                pigment_pattern {
                        illusion_raw
                        matrix <
                                illusion_x.x,illusion_x.y,illusion_x.z,
                                illusion_y.x,illusion_y.y,illusion_y.z,
                                illusion_z.x,illusion_z.y,illusion_z.z,
                                illusion_t.x,illusion_t.y,illusion_t.z
                        >
                }
                texture_map {
                 [0.5   copper3]  // copper rust
                 [0.8   copper2]  // copper patina
                 [0.9   copper2]
                        [1     copper1]  // polished copper
                }
        }
 interior {ior 1.6}
 scale 1
}

//______________________________________________________________________________

Norbert


Post a reply to this message

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