|
|
Am I doing something wrong, or just not going far enough?
<code>
#declare _aspect = image_height/image_width;
#declare _size = 175;
global_settings {
number_of_waves 35
assumed_gamma 1.0
}
camera {
orthographic
location <0,0,-90> // position & direction of view
look_at <0,0,0>
right _size*x // horizontal size of view
up _aspect*_size*y // vertical size of view
}
#declare ptLiq1 = function { pattern { waves turbulence 0.86 scale 134 } }
#declare ptLiq2 = function { pattern { ripples turbulence 0.41 scale 54 } }
#declare ptLiquid = function { pow(ptLiq1(x,y,z),.6)*13.0 -
pow(ptLiq2(x,y,z),1.4)*5.5 }
#macro gridLiquid(rd,sz)
function { (
#local to = 0;
#local xp = -rd;
#while (xp<=rd)
#local yp = -rd;
#while (yp<=rd)
ptLiquid(x+xp*sz,y+yp*sz,z)
#if (xp<rd | yp<rd) + #end
#local yp = yp + .25;
#end
#local to = to + 1;
#local xp = xp + .25;
#end
)/to }
#end
#declare texLiquid = texture {
pigment {
gridLiquid(3,_size)
triangle_wave
color_map {
[ 0.05 rgb <0.000,0.000,0.000> ]
[ 0.08 rgb <0.000,0.076,0.324> ]
[ 0.23 rgb <0.000,0.231,0.479> ]
[ 0.46 rgb <0.118,0.423,0.763> ]
[ 0.70 rgb <0.213,0.459,1.000> ]
[ 0.99 rgb <0.654,1.000,1.000> ]
}
phase clock
}
finish {
ambient 1
diffuse 0
}
}
box { -.5,.5 scale _size texture { texLiquid } }
</code>
The idea is to create an animated seamless liquid texture that I can import into
a game. I don't want to fool with post-processing, which would create less than
perfect results anyway: I am seeking an all-POV solution. The code above comes
pretty close, but I can still detect seams when I tile the image.
Any suggestions?
--------------
David Wallace
TenArbor Consulting
"Just In Time Cash"
www.tenarbor.com
1-866-572-CASH
Post a reply to this message
|
|
|
|
Apparently the secret is to apply a periodic input to a pattern function like this:
#declare _aspect = image_width/image_height;
#declare _size = 16;
global_settings {
number_of_waves 35
assumed_gamma 1.0
}
camera {
orthographic
location <0,0,-90> // position & direction of view
look_at <0,0,0>
right _aspect*_size*x // horizontal size of view
up _size*y // vertical size of view
}
#debug concat("aspect ratio: ",str(_aspect,1,6),"\n")
#declare wsd = seed(541);
#declare sca = 1/_size/32;
#declare wnm = 4;
#declare pgWave = array[wnm]
#declare ptLiq1 = function { pattern { waves turbulence 0.86 scale 14 } }
#declare ptLiq2 = function { pattern { ripples turbulence 0.41 scale 4 } }
#declare ptLiq3 = function { pattern { cells turbulence 1.41 omega 0.69 scale 25 } }
#declare ptLiq4 = function { pattern { granite scale 3 } }
#declare ptWave = function { cos(2*pi*(x+clock)) }
#declare ptLiquid = function { pow(ptLiq1(x,y,z),.6)*13.0 -
pow(ptLiq2(x,y,z),1.4)*5.5 }
#macro WaveSet(n,nm)
#local fq0 = int(rand(wsd)*58)+3; // Primary frequency, 3-60
#local rt0 = 90*int(rand(wsd)*4);
#local tphi = 2*int(rand(wsd)*(fq0+1))/fq0; // Rotation angle tangent
#local wvl = sqrt(1+tphi*tphi); // Main secondary wavelength
#local fq1 = (int(rand(wsd)*20)+1)/wvl; // Secondary frequency
#local am1 = rand(wsd)*.3/fq0; // Secondary amplitude
#local ofp = rand(wsd); // phase offset
#local ofx = rand(wsd)*_size; // x offset
#local ofy = rand(wsd)*_size; // y offset
#declare pgWave[n] = function {
pattern {
function { ptLiquid(cos(2/_size*pi*x)+1,cos(2/_size*pi*y)+1,cos(z))/nm }
phase ofp
translate <ofx,ofy,0>
}
}
#end
#macro gridWave(nm,sz,fn)
function { (
#local to = nm;
#while (to>0)
WaveSet(to-1,nm)
pgWave[to-1](x,y,z)
#local to = to - 1;
#if (to>0) + #end
#end
) }
#end
#declare mapLiq1 = color_map {
[ 0.00 rgb <0.000,0.000,0.000> ]
[ 0.03 rgb <0.000,0.076,0.324> ]
[ 0.13 rgb <0.000,0.231,0.479> ]
[ 0.66 rgb <0.118,0.423,0.763> ]
[ 0.80 rgb <0.213,0.459,1.000> ]
[ 1.00 rgb <0.654,1.000,1.000> ]
}
#declare mapLiq2 = color_map {
[ 0.05 rgb <0.000,0.000,0.000> ]
[ 0.08 rgb <0.000,0.076,0.324> ]
[ 0.23 rgb <0.000,0.231,0.479> ]
[ 0.46 rgb <0.118,0.423,0.763> ]
[ 0.70 rgb <0.213,0.459,1.000> ]
[ 0.99 rgb <0.654,1.000,1.000> ]
}
#declare mapLiq3 = color_map {
[ 0.00 rgb <0.000,0.000,0.500> ]
[ 0.90 rgb <0.000,1.000,1.000> ]
[ 1.00 rgb <0.750,1.000,1.000> ]
}
#declare texLiquid = texture {
pigment {
gridWave(wnm,_size,1)
triangle_wave
color_map { mapLiq3 }
phase clock
}
finish {
ambient 1
diffuse 0
}
}
box { -.5,.5 scale _size texture { texLiquid } }
--------------
David Wallace
TenArbor Consulting
"Just In Time Cash"
www.tenarbor.com
1-866-572-CASH
Post a reply to this message
|
|