Using GLSL shaders to rendered scratched shield
This project was inspired by movie, Captain America: Civil War (2016). In this fight scene, Black Panther made a huge scratch on Captain America’s shield known as its indestructible. It was the first time I saw that the shield was scratched. I decided to reproduce that effect with shaders in OpenGL to commemorate that moment.
The whole project contains three parts: Build Shield, Made Scratches, and Add Lighting.
Build Shield
The raw shield object was imported from external obj file without any color on it. The first thing I did was to paint color on the shield in fragment shader. I used radius of the shield as parameters to paint the red color and math equations to draw the center star.
Made Scratches
The scratches on the shield was generated with noise functions and trigonometric functions. The core idea was modifying surface normal vectors to bump mapped the shadow on the shield without change the overall topology.
Add Lighting
After computing the normal, I added a light source into the scene and use BRDF equation to compute color for each fragment based on generated surface normal. There are four more parameters used here: Ambient Coefficient, Diffuse Coefficient, Secular Coefficient, and Shininess. The lighting source’s position can be adjusted, either.
This project can only work with Windows
. To demo this project, you firest need to run glman/glman.exe
and load the main GILB file src/Shield.glib
. glman is a teaching-ware developed by Professor Mike Bailey and Steve Cunningham in 2006, and it is totally no-harm. After loading src/Shield.glib
, glman will create a main display window and an user interface with several sidebars that control parameters in this program. You can play with them to see different effects. Note that src/Shield.vert
and src/Shield.frag
are vertex shader and fragment shader used in this program, be free to make some changes.