Website powered by

Basic Lighting Models in HLSL

Over the semester break, I took the chance to learn more about the lighting models throughout the history of computer graphics, and here is what I've come up with. The detailed project documentation can be found in the GitHub repository, where I talk about how I implemented these in Unity's HLSL. I hope you enjoy this as much as I did making it.
______________
Link to technical write-up:
https://bentobaux.github.io/posts/basic-lighting-models-in-hlsl
______________

Demo Video

The classic Lambertian diffuse lighting

The classic Lambertian diffuse lighting

Gouraud-Phong is adds a specular term on top of Lambertian lighting but calculated in the vertex shader.

Gouraud-Phong is adds a specular term on top of Lambertian lighting but calculated in the vertex shader.

Phong does the specular lighting in the fragment shader instead.

Phong does the specular lighting in the fragment shader instead.

Blinn-Phong is a variant of Phong shading that offers more natural specular highlights.

Blinn-Phong is a variant of Phong shading that offers more natural specular highlights.

Toon Shading creates a cartoonish look by clamping the lighting to only two levels: pure light and pure dark.

Toon Shading creates a cartoonish look by clamping the lighting to only two levels: pure light and pure dark.

Flat Shading uses a single normal per face, giving each polygon a solid, faceted look.

Flat Shading uses a single normal per face, giving each polygon a solid, faceted look.

Oren-Nayar Diffuse models rough, matte surfaces as a field of tiny microfacets that scatter light in many directions, giving soft, realistic shading.

Oren-Nayar Diffuse models rough, matte surfaces as a field of tiny microfacets that scatter light in many directions, giving soft, realistic shading.

Cook-Torrance Specular treats shiny materials as countless microscopic mirrors and combines their reflections for lifelike highlights and fresnel effects.

Cook-Torrance Specular treats shiny materials as countless microscopic mirrors and combines their reflections for lifelike highlights and fresnel effects.