Sylvain LC's Blog

A GitHub blog, usefull to me, hope the same for you.

Ambiant lighing

It’s just a color the material has assigned when there is no lighting at all. Very flat and boring, may be needed in some situations to avoid totally black zones.

Diffuse ligthing

This is the simpliest of all, there is an use of the dot product between the surface normal and the light direction to get an intensity.

Here the artistic work starts because we can paint the material with different colors coming from light sources.

Related references :

Occlusion

This effect creates a very subtile shadow. This helps to understand the concavities of the object we are looking at. Procedural occulsion calculations are very frequent on Shadertoy, and this add a lot of details.

Blackle knowledge : Fake IBL etc

I found with Blackle awesome work a lot of nice ideas and tricks she used for live coding.

Related references :

IQ magic specular ligthing

This sun_spe term below make the magic of the rendering.

Question : how does it works ?

I did my own interpretation of specularity !

Specularity is about reflexion of the light on a surface, as “specular” means mirror.

    vec3  sun_hal = normalize( sun_lig-rd );
    float sun_spe = ks*pow(clamp(dot(nor,sun_hal),0.0,1.0),8.0)*sun_dif*(0.04+0.96*pow(clamp(1.0+dot(sun_hal,rd),0.0,1.0),5.0));
    col += sun_spe*vec3(8.10,6.00,4.20)*sun_sha;

Just try to comment it in my Rocket Toy shader to see the difference.

I very lately realized that this is a variation of the Blinn-Phong reflection model, with a bit of fresnel, and “hal” means “halfway vector”.

Related references :

Other sources

Raymarch template GGX - darkeclipz Specular highlight models - darkeclipz Physically Based Shading at Disney