POV-Ray : Newsgroups : povray.unofficial.patches : Some ideas about SDL enhancements : Re: Some ideas about SDL enhancements Server Time
8 Jul 2024 18:11:08 EDT (-0400)
  Re: Some ideas about SDL enhancements  
From: Christopher James Huff
Date: 3 Apr 2003 10:08:23
Message: <cjameshuff-56E41F.10084803042003@netplex.aussie.org>
In article <a5jn8vs8n8u2929ajl86cmjtbhsamdm4fh@4ax.com>,
 ABX <abx### [at] abxartpl> wrote:

> (Are you sure you used correct math for this effect? I used weighting.)

I didn't, but I wasn't really concerned with that, since the syntax 
itself is so rough.

define BasicCamera = camera {...usual camera stuff...}
function lerp(mn, mx, t) {return mn*t + mx*(1-t);}

special_camera {
    function trace_pixel(x, y) {
        //get the raw color of the pixel
        def pixelColor = BasicCamera.trace_pixel(x, y);
        
        //The result is a linear interpolation between the raw color
        //and the background, controlled by the alpha channel.
        def result = lerp(pixelColor, bkgndPigment(x/image_width, 
y/image_height, 0), pixelColor.alpha);
        
        //That calculation modified alpha, so set it back to normal
        result.alpha = pixelColor.alpha;
        
        //do I need to explain?
        return result;
    }
}


> That's possible and already tested with my post_process 
> implementation (if you wish I can send sample image to p.b.i but its 
> content seems obvious). It is possible with following script.

You seem to miss the point completely. I'm not talking about a post 
process feature, isn't that obvious? This is a way to specify the camera 
behavior at a very low level. That trace_pixel() function is called by 
POV to trace every pixel.


>   #declare f_avg=function(v1,v2,w){(1-w)*v1+w*v2}; // average/weight

Eh...this is linear interpolation, not any kind of average. A common 
name seems to be "lerp", though I don't know why, I usually use 
something like linInterp. Anyway, there should be a function already 
defined which does this...and it is unrelated to the subject of this 
thread.


>   global_settings{
>     post_process{
>       // functions for four channels of output
>       function{f_avg(f_output_red(x,y)  
>       ,back_Pig(x,y,0).x,f_output_alpha(x,y))}
>       function{f_avg(f_output_green(x,y),back_Pig(x,y,0).y,f_output_alpha(x,y)
>       )}
>       function{f_avg(f_output_blue(x,y) 
>       ,back_Pig(x,y,0).z,f_output_alpha(x,y))}
>       function{0}
>       save_file "with_background.png"
>     }
>   }

Sorry, but yuck. This is something that really needs vector functions, 
and IMO should wait until they are available because it will need to be 
redesigned and rewritten when they are here.


> Please note that you have more control in this implementation than in your
> script becouse you can define differend behaviour for each channel.

Wrong. My script only handled all channels at once because that was all 
that was needed. It could easily handle channels separately.


> I hope you like this new post_processing.

Sorry, I don't. Great improvement in functionality, but extreme loss in 
useability and efficiency. As I said, this really, really needs vector 
functions. Using n-tuples of functions makes things far more complex 
than necessary, and requires recomputing things that could be done once. 
your "one-pass" version calls camb_Pig() 6 times and back_Pig() 3 times 
per pixel, when once each would do. It also takes three functions whcih 
have only 2 characters that change, when one function of about the same 
length would do.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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