|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Here's an example or two of using full-colour pigment functions. This
example shows how to do a fake MC Escher "Circle Limit" effect, using
stereographic projection. True "Circle Limit" pictures use hyperbolic
(angle-preserving), FWIW.
// Persistence of Vision Ray Tracer Scene Description File
// File: PigFunc.pov
// Vers: 3.6
// Desc: Pigment function demo
// Date: 2005.02.19
// Auth: PM 2Ring
//
// -D +A0.1 +AM2 +R4
// -F -A0.4 +AM2 +R1
//
#version 3.6;
global_settings {
assumed_gamma 1
}
camera {
location <0, 5, -1> * 2.4
look_at 0
direction z
angle 40
}
light_source {
<0, 2, -1> * 50
rgb 1.75 // 2.25
}
//---Color Maps--------------------------------------------
//Make a color_map from a0 to a1
#macro CMRange(a0, a1)color_map{[0 a0][1 a1]}#end
//Make a color_map from Black to a
#macro CMFull(a)CMRange(rgb 0, a)#end
//---Stereographically projected
pigment!-----------------------------------------
#declare R2 = 8.8;
#declare f_proj = function(x,z){R2/sqrt(R2 - min(R2-1E-12, x*x+z*z))}
#declare TestPig = pigment{hexagon rgb<1 .9 .5>, rgb <.85 .5 .6>, rgb <0 0
...8>}
#declare f_Pig = function{pigment{TestPig}}
#declare f_Pig1 = f_Pig;
//Turn a pigment function into a real-live pigment!
#declare PigRGB0 =
pigment{
average
pigment_map {
[1 function{f_Pig(x,y,z).red} CMFull(red 3)]
[1 function{f_Pig(x,y,z).green} CMFull(green 3)]
[1 function{f_Pig(x,y,z).blue} CMFull(blue 3)]
}
}
//And now, with projection!
#declare f_X = function{x*f_proj(x,z)}
#declare f_Y = function{y}
#declare f_Z = function{z*f_proj(x,z)}
#declare PigRGB1 =
pigment{
average
pigment_map {
#if(0)
[1 function{f_Pig(f_X(x,y,z), f_Y(x,y,z), f_Z(x,y,z)).red} CMFull(red
3)]
[1 function{f_Pig(f_X(x,y,z), f_Y(x,y,z), f_Z(x,y,z)).green}
CMFull(green 3)]
[1 function{f_Pig(f_X(x,y,z), f_Y(x,y,z), f_Z(x,y,z)).blue} CMFull(blue
3)]
#else
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).red} CMFull(red 3)]
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).green} CMFull(green
3)]
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).blue} CMFull(blue 3)]
#end
}
}
//---Scene--------------------------------
cylinder{
-.1*y, .1*y, 3
//open
pigment{
PigRGB1
//PigRGB0
//TestPig
}
}
background{
//rgb<0.035, 0.27, 0.67>
rgb 0
}
//-------------------------------------------------------
Post a reply to this message
Attachments:
Download 'pigfuncda0.jpg' (106 KB)
Preview of image 'pigfuncda0.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Christoph Hormann <chr### [at] gmxde> wrote:
> PM 2Ring wrote:
Sorry about the delay replying, I've been unwell.
> > Here's an example or two of using full-colour pigment functions.
>
> Nice demo.
Thanks! It would be even better if I hadn't screwed up the algebra. :)
Fortunately, the error only gives an incorrect scale to the projection. See
the next message for a corrected version.
And BTW, thanks for all the helpful tutorials you've created over the years.
> 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) }
If only POV would allow the passing of function names... I guess it can be
done in a roundabout way using Parse_String().
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Here's the mathematically correct version:
// Persistence of Vision Ray Tracer Scene Description File
// File: PigFunc.pov
// Vers: 3.5+
// Desc: Pigment function demo
// Date: 2005.02.19
// Auth: PM 2Ring
//
// -D +A0.01 +AM2 +R4 +W640 +H640
// -F -A0.4 +AM2 +R1
//
global_settings {assumed_gamma 1}
//---Color Maps--------------------------------------------
//Make a color_map from a0 to a1
#macro CMRange(a0, a1)color_map{[0 a0][1 a1]}#end
//Make a color_map from Black to a
#macro CMFull(a)CMRange(rgb 0, a)#end
//---Stereographically projected
pigment!-----------------------------------------
#declare R = 3; //Radius of projection
#declare R2 = R*R;
#declare f_proj = function(x,z){1/sqrt(1 - (x*x+z*z)/R2)}
#declare TestPig = pigment{hexagon rgb<1 .9 .5>, rgb <.85 .5 .6>, rgb <0 0
...8> scale .5}
#declare f_Pig = function{pigment{TestPig}}
#declare Brite = 3;
#declare PigRGB =
pigment{
average
pigment_map {
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).red} CMFull(red
Brite)]
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).green} CMFull(green
Brite)]
[1 function{f_Pig(x*f_proj(x,z), y, z*f_proj(x,z)).blue} CMFull(blue
Brite)]
}
}
//---Scene--------------------------------
cylinder{
-.1*y, .1*y, R
pigment{
PigRGB
//TestPig
}
finish{ambient 1 diffuse 0}
}
camera {
orthographic
location y * R * 4
look_at 0
right x*image_width/image_height up y
direction z
angle 30
}
background{rgb .5}
//-------------------------------------------------------
Post a reply to this message
Attachments:
Download 'pigfuncha2.png' (139 KB)
Preview of image 'pigfuncha2.png'
|
|
| |
| |
|
|
|
|
| |
|
|