|
|
//##############################################################################
// INFO
//##############################################################################
/*
See http://tinyurl.com/5n7g7 for the full thread.
This scene demonstrates how to create a wake effect (e.g. of a plane
flying low
over water) using a place and an isosurface.
The effect is in the y-plane (y=0), facing -z.
Do with this whatever you like :)
*/
//##############################################################################
// OVERALL SCENE SETTINGS
//##############################################################################
#version 3.6;
#default { finish { ambient 0 } }
global_settings {
assumed_gamma 1
}
camera {
location <1,1,-1>*3
look_at 0
}
light_source { <1,1,-1>*100 rgb 1 }
#include "colors.inc"
//##############################################################################
// WAKE CONFIGURATION
//##############################################################################
/*
The following values are not necessarily measured in POV-units or real
numbers,
so you'll propably have to do some tests.
*/
//the length of the effect on the -z side
#local Length_Negative_Z = 0.5;
//the length of the effect on the +z side
#local Length_Positive_Z = 2;
//the width of the effect (in x and -x direction)
#local Width = 10;
//the height of the effect
#local Height = 0.2;
//values < Delta will be considered 0 for cosmetical reasons
//this cuts off the spikes at the end of the effect on the
//z-axis
#local Delta = 0.01;
//Maximum amount of waves
#local Wave_Count = 25;
//##############################################################################
// HELPFUL FUNCTIONS
//##############################################################################
//simplified Bell curve
#local f_Bell = function(x) { exp(-x*x/2) }
//creates a wake in one dimension
#local f_Wake_1D = function(x,wave_width_fade_out,overall_fade_out) {
-
cos(x*sqrt(abs(x/wave_width_fade_out))) //waves with changing width
* f_Bell(x/overall_fade_out) //fade out with bell curve
}
//cuts off a value below a given delta and returns delta_value instead
#local f_Cutoff = function(value,delta,delta_value) {
select(value-delta,delta_value,value)
}
//a bell curve which is stretched differently for -x and x
#local f_Two_Sided_Bell = function(x,fade_out_negative,fade_out_positive) {
select (
x,
f_Bell(x/fade_out_negative),
f_Bell(x/fade_out_positive)
)
}
//##############################################################################
// THE WAKE
//##############################################################################
#local Wake = isosurface {
function {
y
- f_Wake_1D(
x*10,
f_Cutoff(f_Two_Sided_Bell(z,Length_Negative_Z,Length_Positive_Z),Delta,0.00001)*Wave_Count,
f_Cutoff(f_Two_Sided_Bell(z,Length_Negative_Z,Length_Positive_Z),Delta,0.00001)*Width
)*Height
}
max_gradient 3 //POV will report much more, but I can't see any errors
with 3
contained_by { box { <-3,-0.5,-1.5>, <3,1.1*Height,6.5> } }
}
//##############################################################################
// GRID
//##############################################################################
/*
Original by Carl (see link at the top). Changed slightly to adjust scale
and textures.
*/
#local f_Grid = function {
min(abs(x)-int(abs(x)),abs(z)-int(abs(z)),
1-(abs(x)-int(abs(x))),1-(abs(z)-int(abs(z))))
}
#local Grid_Texture = texture {
pigment {
function { f_Grid(x, y, z) }
color_map {
[0 White]
[0.01 White]
[0.02 rgb <0, 0.05, 0>]
[0.98 rgb <0,0.05, 0>]
[0.99 White]
[1 White]
}
//scale 500
scale 0.5
}
normal { bumps 0.01 scale 30 }
finish {
ambient .1
diffuse .5
//reflection .55
specular 1
phong 1
}
}
//Uncomment for plain color render
//#local Grid_Texture = texture { pigment { rgb x } }
#local Grid = plane { y, 0 }
/*
The whole object is not one huge isosurface (would take ages to render),
but
a plane in with a part is replaced by our wake-iso.
*/
#local Grid_With_Wake = union {
difference {
object { Grid }
box { min_extent(Wake),max_extent(Wake) }
}
object { Wake }
texture { Grid_Texture }
}
//show it!
object { Grid_With_Wake }
Post a reply to this message
|
|