GLSL shader example
Layered Parallax Mountain Landscape
Move each mountain layer at a different speed and draw back-to-front, using lighter distant layers and darker foreground.
Live example
Edit the code and the preview updates as you type.
What to observe
Layered Parallax Mountain Landscape.
Mechanism
Move each mountain layer at a different speed and draw back-to-front, using lighter distant layers and darker foreground.
The controlling code
c=mix(vec3(.05,.1,.24),vec3(.7,.5,.5),uv.y);for(int i=0;i<4;i++){float f=float(i),speed=.04+f*.035;float h=.15+f*.12+.15*fbm(vec2(uv.x*3.+u_time*speed,f*7.));if(uv.y<h)c=mix(vec3(.25,.4,.55),vec3(.03,.08,.12),f/3.);}
Experiment
Replace the speed increment .035 in speed=.04+f*.035 with 0.. All four layers then move at the same rate, removing the relative motion that gives the landscape its parallax depth.
Debugging and cost
The loop evaluates one four-octave fbm height per layer, for four layers total. Change i<4 to i<2 to keep only the two distant layers and lower noise work; the original f/3. colors remain those of the background layers.