POV-Ray : Newsgroups : povray.general : eval_pigment? : Re: eval_pigment? Server Time
23 Apr 2024 17:46:28 EDT (-0400)
  Re: eval_pigment?  
From: Tor Olav Kristensen
Date: 22 Nov 2022 17:55:00
Message: <web.637d52cd287863e9d3631ec089db30a9@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

>...

>  Now that's taken care of, While I was waiting for replies, I wrote my own
> 'Eval_pigment' & 'Eval_Cmap' &'Eval_ObjPig' macros.

>...

> #macro Eval_Obj_Pig(Obj,Pig,N)
>   #local Mx=max_extent(Obj);
>   #local Mn=min_extent(Obj);
>   #local Mc=(Mx+Mn)/2;
>  #local Norm = <0, 0, 0>;
>  #local Start =vlength(Mx-Mn)*N+Mc;
>  #local V = trace (Obj,Start,-N,Norm );
>  #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)
>   #local Fna=function{pigment{Pig}}
>   #local R=Fna(V.x,V.y,V.z);
>  #else
>   #local R=<0,0,0>;// default color
>  #end
>
>  R
>
> #end

Hi Leroy

If you want a faster macro then you'll probably find that this statement:

    #if (vlength(Norm) > 0)

executes faster (and is easier to read) than this:

    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)


--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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