Jump to content
Sign in to follow this  
konstantin magnus

One-parameter shader

Recommended Posts

A minimalist one-parameter shader that smoothly runs from emissive (0.0), over translucent (0.75), to diffuse (1.0) and opaque (1.25) all the way to metallic (2.0).


float shading = chf('shading');
vector color = chv('color');

vector pos_light = {2.6, 1.2, 0.6};
vector dir = normalize(pos_light - v@P);

float lumen = max(1.0 - shading, 0.0);
float angle = max(dot(dir, v@N), lumen);
shading = fit(shading, 1, 2, 1, 20);
float shade = pow(angle, max(shading, 1.0));

v@Cd = color * shade;



  • Like 1

Share this post

Link to post
Share on other sites

Very nice :)!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this