POV-Ray : Newsgroups : povray.binaries.images : Using functions to distort images : Re: Using functions to distort images Server Time
3 May 2024 22:23:41 EDT (-0400)
  Re: Using functions to distort images  
From: Tor Olav Kristensen
Date: 21 May 2006 18:25:45
Message: <4470e8e9@news.povray.org>
Dave Matthews wrote:
> Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:
>> Here's the results of a little experiment I did today.
>>
>> Functions are used to distort heavily photos (shot with my mobile).
>> (The resulting pigments can can be used in textures.)
>>
> 
> Very cool (and useful, I think!)  I'm pretty sure I know how this is done,
> but could you post up a snippet of code, showing it, please?

Sure Dave - see source code below.

Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Use of functions to distort image
// Tor Olav Kristensen, 21. May 2006
// http://subcube.com
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.6;

#include "functions.inc"

global_settings {
   ambient_light color rgb <1, 1, 1>
//  assumed_gamma 1.0
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare ImageFn =
   function { pigment { image_map { "YourImage.png" } } }

#declare Ampl = 1.5;
#declare Freq = 1.0;

#declare NoiseFnX =
   function { Ampl*(f_agate( 0 + Freq*x, Freq*y, z) - 0.5) }
#declare NoiseFnY =
   function { Ampl*(f_agate(10 + Freq*x, Freq*y, z) - 0.5) }

#declare PigmentR =
   pigment {
     function {
       ImageFn(x + NoiseFnX(x, y, z), y + NoiseFnY(x, y, z), z).red
     }
     color_map {
       [ 0 color red 0 ]
       [ 1 color red 3 ]
     }
   }

#declare PigmentG =
   pigment {
     function {
       ImageFn(x + NoiseFnX(x, y, z), y + NoiseFnY(x, y, z), z).green
     }
     color_map {
       [ 0 color green 0 ]
       [ 1 color green 3 ]
     }
   }

#declare PigmentB =
   pigment {
     function {
       ImageFn(x + NoiseFnX(x, y, z), y + NoiseFnY(x, y, z), z).blue
     }
     color_map {
       [ 0 color blue 0 ]
       [ 1 color blue 3 ]
     }
   }

box {
   -<1, 1, 1>/2, <1, 1, 1>/2
   texture {
     pigment {
       average
       pigment_map {
         [ PigmentR ]
         [ PigmentG ]
         [ PigmentB ]
       }
     }
     finish { ambient color rgb <1, 1, 1> } // Adjust brightness here
     translate -<1, 1, 0>/2
   }
   scale <4, 3, 1>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

camera {
   orthographic
   location -3.1*z
   look_at 0*y
}

background { color rgb <1, 1, 1> }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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