Lesson 8 of 10 · Forces in a shader
Ripple
Rings from center. The stone in the lake.
sin(length(p) - T), concentric waves expanding from center. Like throwing a stone into a lake. Distance creates the rings, T pushes them outward.
We add the ripple to the warp, waves deform the material instead of painting on top. The camo undulates as if someone hit the surface.
The stone you threw in the lake.
sin(length(p) - T)length(p) = distance to center (rings). Subtract T = rings move outward. Multiply by amplitude = how much they deform.
Change
d*12. to d*4., wide waves. To d*30., tight nervous waves. Change T*2.5 to T*0.5, lazy waves. To T*6., hard hit.The code
void main(){
vec2 p = (2.*gl_FragCoord.xy - R) / min(R.x, R.y);
float d = length(p);
float ripple = sin(d*12.-T*2.5)*.5+.5;
float ring = smoothstep(.04,.0,abs(fract(d*3.-T*.5)-.5)-.2);
ripple *= smoothstep(1.5, 0., d);
float center = smoothstep(.12,.1, d);
float shadow = smoothstep(0.,.2, length(p+vec2(.03,-.05))-.12);
vec3 col = vec3(.015,.02,.08) * shadow;
col += vec3(.2,.35,.9) * ripple;
col += vec3(.65,.85,1.) * ring * .3;
col += vec3(.4,.6,.95) * center;
col += vec3(.8,.9,1.) * exp(-d*3.) * .4;
col = hueShift(col, 0.0);
gl_FragColor = vec4(col, 1.);
}