Logo by chaos_crystal - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit us on facebook
 
*
Welcome, Guest. Please login or register. February 23, 2018, 05:51:45 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: simple non-standard approaches  (Read 7222 times)
Description: a non-standard terrain generator built from wave modulation and diffraction
0 Members and 1 Guest are viewing this topic.
eiffie
Guest
« on: February 14, 2012, 11:59:53 PM »

I'm always looking for shortcuts so when I wanted some terrain with waves in it rather than adding waves to the standard diamond square method I built one out of sine waves.
<a href="http://www.youtube.com/v/GTp71zHLfvM&rel=1&fs=1&hd=1" target="_blank">http://www.youtube.com/v/GTp71zHLfvM&rel=1&fs=1&hd=1</a>

Code:
uniform vec3 eye;   //the camera position
uniform float time; //animation time in seconds
const float maxDepth=500.0;
#define ang 0.6
const mat2 rmx=mat2(cos(ang),sin(ang),-sin(ang),cos(ang));

float wvTrn(vec2 z, float amp, float freq, float phase){//simple sine generated terrain
float h=0.0;
vec2 offset=vec2(2.5+phase*0.1,1.0+phase*0.07); //phase animates the waves
for(int i=0;i<9;i++){
z=z*rmx*freq+offset; //rotate, scale and translate
h+=sin(z.x+phase)*sin(z.y+phase*1.33)*sin(length(z)*2.33+phase)*amp; //add modulated waves
amp=pow(amp,1.25); //a fiesta of magic numbers, enjoy!
}
return h;
}

float DE(vec3 z)
{// returns the distance to water, land or sky
float dMax=maxDepth*0.25-25.0-length((z-eye)*vec3(0.25,1.0,0.25)); //sky radius squished
float dCld=dMax-min(wvTrn(z.xz*0.005,0.25,2.0,time*0.0625)*25.0,0.0); //clouds
float dMnt=wvTrn(z.xz*0.01,0.25,2.0,0.0)*25.0+wvTrn(z.xz,0.37,1.75,0.0)*0.05+z.y+1.0; //land (bad detail)
float dWtr=wvTrn(z.xz,0.2,1.75,time*3.0)*0.25+z.y+1.0; //water
float d=min(dMnt,min(dWtr,dCld)); //find the closest

//this coloring section sets global vars for glow, specularity, specular exponent and diffuse color
//the diffuse color has an alpha value that i use to determine reflection (-) and refraction (+)
if(bColoring){ //for fragmentarium this is a seperate function: color()
cGlow=vec3(0.3);spec=0.25;specExp=32.0;
diffuse=vec4(0.5+wvTrn(z.xz*0.25,0.25,2.0,0.0),0.7,0.4,0.0)*(0.2+dMnt*4.0);
if(d==dWtr){ //if we hit water mix with land color if shallow and then reflect
spec=1.0;cGlow=mix(cGlow,vec3(0.8),min((dMnt-dWtr),1.0));
diffuse=mix(diffuse,vec4(0.007,0.01,0.015,-0.5),min((dMnt-dWtr)*2.0,1.0));
}
if(d==dCld){ //we hit a cloud (not very good coloring yet)
spec=0.5;cGlow=vec3(0.6,0.7,8.0);specExp=8.0;
diffuse=mix(vec4(0.5,0.6,1.0,0.0),vec4(1.0,1.0,1.0,0.0),(dCld-dMax)*0.5-0.5);
}else{ //we didn't hit a cloud so add fog
float f=distance(z,eye);
diffuse=mix(diffuse,vec4(0.45,0.55,0.95,0.0),min(f/maxDepth,1.0));
cGlow=mix(cGlow,vec3(0.45,0.55,0.95),min(f/maxDepth,1.0));
}
}
return d;
}

Does anyone have any similar terrain tricks?
Logged
AndyAlias
Forums Newbie
*
Posts: 9


acaudwell
« Reply #1 on: December 17, 2012, 10:48:24 PM »

This is really nice. Better than Elevated, even smiley (if not as fast)

Interesting that it doesn't seem to suffer from over stepping. It's quite a bit faster if you get rid of the length() in the inner loop.

I got some interesting terrain results by mixing (ie mix(d1,d2,0.5)) KIFS fractals with spheres:

http://www.thealphablenders.com/2012/11/more-alien-vistas/
Logged

eiffie
Guest
« Reply #2 on: December 18, 2012, 06:16:42 PM »

Nice blog - glad to see more people writing about DE!
Logged
eiffie
Guest
« Reply #3 on: January 11, 2013, 06:43:51 PM »

Here are some simple GLSL terrain generators. I love it when you can build a world from a few lines of code.
The first was a naive attempt by me simply using smoothstep. It has smooth square patterns in the first few iterations then looks OK.
Code:
float rand( vec3 co ){//2d version from lumina extended
return fract(sin(dot(vec3(co)*0.123,vec3(12.9898,78.233,112.166))) * 43758.5453);
}
float noyz(vec3 co){
vec3 d=smoothstep(0.0,1.0,fract(co));
co=floor(co);const vec2 v=vec2(1.0,0.0);
return mix(mix(mix(rand(co),rand(co+v.xyy),d.x),
mix(rand(co+v.yxy),rand(co+v.xxy),d.x),
d.y),mix(mix(rand(co+v.yyx),rand(co+v.xyx),d.x),
mix(rand(co+v.yxx),rand(co+v.xxx),d.x),d.y),d.z);
}
float HeightMap(vec3 z){
float w=0.5,f=0.0;
for(int i=0;i<12;i++){
f+=w*noyz(z);
w*=0.5;
z*=2.0;
}
return f;
}

The second is a vectorized version of Inigo Quilezles' FBM which you can read about here:
http://iquilezles.org/www/articles/morenoise/morenoise.htm

Code:
vec4 dnoise3d(vec3 z){
vec3 iv=floor(z),uv=fract(z);
vec2 iV=vec2(0.0,1.0);
vec3 du=30.0*uv*uv*(uv*(uv-2.0)+1.0);
uv=uv*uv*uv*(uv*(uv*6.0-15.0)+10.0);
float a = rand( iv );
vec3 b=vec3(rand( iv+iV.yxx ),rand( iv+iV.xyx ),rand( iv+iV.xxy ));
vec3 d=vec3(rand( iv+iV.yyx ),rand( iv+iV.xyy ),rand( iv+iV.yxy ));
vec3 k1=b-vec3(a),k2=vec3(a)-b-b.yzx+d;
float k3 = - a + b.x + b.y +b.z - d.x - d.y - d.z + rand( iv+iV.yyy );
return vec4(du*(k1+k2*uv.yzx+k2.zxy*uv.zxy+k3*uv.yzx*uv.zxy),
a+dot(k1,uv)+dot(k2,uv*uv.yzx)+k3*uv.x*uv.y*uv.z);
}

float iqFBM(vec3 z){
float w=0.5,f=0.0;
vec3 dv=vec3(0.0);
for(int i=0;i<12;i++){
vec4 n=dnoise3d(z);
dv+=n.xyz;
f+=w*n.w/(1.0+dot(dv,dv));
w*=0.5;
z*=2.0;
}
return f;
}

I think a combination of the wave generator for a few iterations then an FBM looks nice since at large scales the earth's crust acts like a fluid compressing and relaxing creating waves (mountain ranges and valleys).
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #4 on: January 12, 2013, 11:29:34 AM »

Tip; have you tried to replace

Code:
amp=pow(amp,1.25);

with

Code:
amp=amp*sqrt(sqrt(amp));

Should be faster, I'm not sure A Beer Cup
Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: January 12, 2013, 06:35:44 PM »

I have implemented it in Mandelbulb, it's very hard to get a realistic terrain "with mountains" with a good detail level. cry I tried hard, but the most decent result was this.

It looks somewhat like a "rose" - i think because you strongly rely on radius for the noise (length(z)*2.33 ... 2.33 is a lot).

The worst defect is that amplitude varies without a lower limit so if it's like 0.1 after some its it goes to 0. sad this means, too low amplitude for higher its... So after 5-6 iters you don't get more details even if you use more iters


* tukti.JPG (52.04 KB, 728x364 - viewed 512 times.)
« Last Edit: January 12, 2013, 06:42:06 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #6 on: January 12, 2013, 06:56:48 PM »

So ok, I made those modifications;


   int mit=9; // more for more detail
   float h=0.0;
        //float sh=2.5;
        float sh=1.2; // looks better than yours imho
   vec2 offset=vec2(sh+phase*0.1,1.0+phase*0.07); //phase animates the waves
   for(int i=0;i<mit;i++){
      z=z*rmx*freq+offset; //rotate, scale and translate
      h+=sin(z.x+phase)*sin(z.y+phase)*sin(length(z)*sh+phase)*amp; //I recycled 2.5 to save constants but other vals may be better - and I dunno why you putted phase x 1.33 smiley
                if amp > 0.001 {
           amp=pow(amp,1.25); }
   }
   return 0.125 * pow2(h,0.5); // while pow2(a,b) = sgn(a)*pow(abs(a),abs(b)) but try other stuff for those floats cheesy


* tukti.JPG (43.72 KB, 475x360 - viewed 884 times.)
« Last Edit: January 12, 2013, 07:05:07 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
eiffie
Guest
« Reply #7 on: January 15, 2013, 04:56:21 PM »

Much better terrain DarkBeam but now it no longer looks like waves smiley I guess you can't have both. Will you be able to mix this with other formulas?? That would be interesting.
Logged
Woz
Forums Newbie
*
Posts: 1


« Reply #8 on: January 24, 2013, 01:21:40 AM »

I have implemented it in Mandelbulb, it's very hard to get a realistic terrain "with mountains" with a good detail level. cry I tried hard, but the most decent result was this.

It looks somewhat like a "rose" - i think because you strongly rely on radius for the noise (length(z)*2.33 ... 2.33 is a lot).

The worst defect is that amplitude varies without a lower limit so if it's like 0.1 after some its it goes to 0. sad this means, too low amplitude for higher its... So after 5-6 iters you don't get more details even if you use more iters
I use Mojoworld Pro its a terrain generator using fractal design elements. Your result looks similar to my Voronoi Volumetrics landscape.

The nearest to any reasonable looking terrain Ive managed with MB3D is this....


Mandelbulb3Dv18{
b.....k1...Q6...D....2A....g95c9PceozGJwAvqK4.2EKg7d3UGUc.QTNtD22oJ6.jX/hGQYF0uD
................................CQTdB/C4a.2.......U9.p6........E.......EE/2...wD
...Uz.....U52.../w.1/......8....J0...2k4.....2l9/hTXUdkD/w.uYOAEDeee2xckpn1.OaNa
z.....cD16../2.iSIsuFVfXz.........yjnAnAnAnA1z9..........c.u1....y1...sD...../..
.wXaNadDCWGuioIuXvvvSw1ozY88z03So3sqRJijNGb0.a88Iwf/q/UxjIuuyYDNwD1p1Omj1IW0oqzW
awHe6wZQqPhoy0QpWMY45Flj.....72j4...v5........sD.2....sD1.E.....................
.............oAnAt1...sD....z.rbE7.2U0Z.k08I0.JcE7.wV0Z.E88I0.ncE7.8yV8EE....2..
.....AQxcz1.....9.kz/wzzznlj.Y8.R....61...EH....h/.06M8..UUszzzzH....MJ7..kii.5g
..UU0yzzC16E...U.1Ak.0.U.9M61k/..0sz..EbG7eFT5wj4Ak5eP./czH..........20/8.kU/t0.
.....................6..........X6V0.wzzza...0.......g0U......../.M3ZaYq1zP05c..
YZaO............S/..........2aUODFhwzIk7tozf5q1..grio9XW8.I091WZUJsxz.UIhlTrxLyj
ZQG1zvOPy...KZajjzXyz0kYEkti4xwD.EO89.34Lz9..wPXG/EiahX7zzlNVs1.APtGoszDzhLB.QSe
dZHzTZtW1/Ugyho6QsLYJO0.T...a.bT4K16.sxaTN0lyp2IZ..dUJW7Mw5cbU3.1i1/akqTm/bJ.o/.
.M0kzxsL./k3..U7...crIGJzzFoTuIdyzngi8qdxzZX.4rU.wKRiFLMdt46KZKNrtWOkR4.5tWOkR4.
E....A....E.....I....U....EEh3aSdtqNUAJRmN4...........................k/.MU/4.U.
..........ED8QxckpXzz.........yD........E.2........7./..................2.2.....
..............zD................................................................
.....................2.....3....1....wZIjFLMoJ4.................................
4MU/.........................EyD..........2.....................................
................................................................................
................................/....E/..../....T7pPo34RZFaFjl4NdtqN............
..........U/4M..........................E.2........../.......U/Eg53iSIsu/z1.....
................................................................................
............................................}
« Last Edit: January 24, 2013, 01:27:44 AM by Woz » Logged
alexl
Safarist
******
Posts: 91


WWW
« Reply #9 on: March 25, 2013, 09:26:24 PM »

OK, I it's my 5 cents:

Screenshot:


one more:


Video:
<a href="http://www.youtube.com/v/ChzIJ1RfvmQ&rel=1&fs=1&hd=1" target="_blank">http://www.youtube.com/v/ChzIJ1RfvmQ&rel=1&fs=1&hd=1</a>
Logged

weavers
Fractal Phenom
******
Posts: 434


« Reply #10 on: March 26, 2013, 01:23:23 AM »






Thank you Master



 
the Fractal Forums the possibilities are infinite






.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Contest Voting deadline approaches! 1st Annual Fractal Art Competition 2008 (Completed) cKleinhuis 0 1302 Last post May 29, 2008, 06:25:25 PM
by cKleinhuis
Trying different approaches with das Mandelbulb Discuss Fractal Forums Brummbaer 0 1498 Last post August 24, 2011, 01:05:06 AM
by Brummbaer
Spinal regions on standard bulbs Tutorials DarkBeam 9 1799 Last post July 29, 2012, 09:20:03 PM
by Madman
a standard name for buddhabrot-like fractal ? General Discussion « 1 2 » ker2x 25 1436 Last post June 02, 2015, 10:28:03 AM
by ker2x
Bifurcation fractal of Standard Map (new) Theories & Research bkercso 5 282 Last post July 15, 2015, 12:45:03 AM
by bkercso

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.907 seconds with 28 queries. (Pretty URLs adds 0.016s, 2q)