GLSL shader example

Brushed Metal with Directional Highlights

Fine grain and the stretched highlight share one rotated coordinate system, so rotating the brush direction rotates both.

Live example

Edit the code and the preview updates as you type.

What to observe

Brushed Metal with Directional Highlights.

Mechanism

Fine grain and the stretched highlight share one rotated coordinate system, so rotating the brush direction rotates both.

The controlling code

vec2 q=rot(u_parameter*3.14159)*p;float grain=noise(vec2(q.x*5.,q.y*350.));float h=pow(max(0.,1.-abs(q.y+.15*sin(u_time*.3))),18.);c=vec3(.3,.34,.38)*(.65+.25*grain)+vec3(1.,.85,.65)*h;

Experiment

Set u_parameter to 0 and then 0.5 so rot(u_parameter*3.14159) changes the brush orientation from zero to about 90 degrees. The fine grain and elongated bright band rotate together because both use q.

Debugging and cost

The material uses one noise call for grain rather than texture-based anisotropic lighting. Lower q.y*350. to q.y*100. to widen the fine bands and reduce their tendency to shimmer at small preview sizes.

Built-in functions used

Learn it step by step