POV-Ray : Newsgroups : povray.binaries.images : Pigment Functions : Re: Pigment Functions Server Time
8 Aug 2024 22:13:25 EDT (-0400)
  Re: Pigment Functions  
From: Christoph Hormann
Date: 30 Apr 2005 05:35:01
Message: <d4vjag$5d8$1@chho.imagico.de>
PM 2Ring wrote:
> Here's an example or two of using full-colour pigment functions.

Nice demo.  Note the mechsim include file coming with MegaPOV contains a 
generic Vector_Function() macro that can simplify this kind of thing. 
The version in MegaPOV 1.1 only supports positive function values - here 
is the improved, more universal version:


#ifndef (MSim_Fn_Range)
	#declare MSim_Fn_Range=1e6;
#end

#macro Vector_Function_Range(Fn_X, Fn_Y, Fn_Z, Range)

	#local PigX=
	pigment {
		function { 0.5+Fn_X(x, y, z)*(0.5/Range) }
		color_map {
			[0.0 color rgb -3*Range*x ]
			[0.5 color rgb 0 ]
			[1.0 color rgb  3*Range*x ]
		}
	}

	#local PigY=
	pigment {
		function { 0.5+Fn_Y(x, y, z)*(0.5/Range) }
		color_map {
			[0.0 color rgb -3*Range*y ]
			[0.5 color rgb 0 ]
			[1.0 color rgb  3*Range*y ]
		}
	}

	#local PigZ=
	pigment {
		function { 0.5+Fn_Z(x, y, z)*(0.5/Range) }
		color_map {
			[0.0 color rgb -3*Range*z ]
			[0.5 color rgb 0 ]
			[1.0 color rgb  3*Range*z ]
		}
	}

	function {
		pigment {
			average
			pigment_map {
				[1 PigX]
				[1 PigY]
				[1 PigZ]
			}
		}
	}

#end

#macro Vector_Function(Fn_X, Fn_Y, Fn_Z)

Vector_Function_Range(
	function { Fn_X(x, y, z) },
	function { Fn_Y(x, y, z) },
	function { Fn_Z(x, y, z) },
	MSim_Fn_Range
)

#end

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 27 Feb. 2005 _____./\/^>_*_<^\/\.______


Post a reply to this message

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