Shaders: Reflection 1

What are Shaders and its Application

At the scope of computer architecture, shaders are a set of parallel programmable instructions that run on GPUs, that utilize GPU’s multi-pipeline feature to customize or accelerate the rendering process in graphic applications. For the case of 2D graphics, I think using shaders will significantly increase the rendering efficiency if a good graphics card is running on a given computer. For example, if we want to traverse through each pixel using p5.js or processing, we have to write it like this: 

for (let i = 0; i < width; i++) {
  for (let j =0; j < height; j++) {
    // do some operations
  }
}
That makes the time complexity O(n²). If the program inside this nested loop gets too complicated, we would experience a drop in framerate. This is mostly because programs like processing and p5 do not use GPU efficiently as shaders do. Hence, in the case of 2D graphics, (pixel) shaders work pretty well in writing faster rendering programs. 

For cases considering 3D graphics, it would consider more of the vertex shader. Computing how vertexes move on a 3D model / 3D space involves a lot of vector/matrix computation. These computations naturally suit the usage of GPUs. While shaders could manipulate these vertexes manually, the potentials of creating stunning creative coding art are huge.

One application of shaders could be producing styled lighting/texture schemes in 3d graphics, especially with creating complicated ray tracing algorithms. It will enhance the 3D scene and make it more natural, and fluent.

Computer Graphics and Me

The first time I encountered computer games is this program that was embedded on Windows XP: 3D Pinball. I was at the age of 6 and was pretty amazed by how it simulates real-world physical phenomenons like gravity, springs, and bouncing force. The interaction is rather very simple, controlling the two bumpers to prevent the ball from falling out of the court and score higher by hitting the obstacles. Starting from here, I grew up witnessing a boom in the 3D gaming industry.

Enlarge

maxresdefault
3d pinball

About 8 years after, another game caught my eyes, similarly also by its excellent physical simulation engine, geometrical aesthetics, and futuristic electronic music tracks: Smash Hit. It is a 3D scroller game that the player survives by hitting crystals to gain points and break the obstacles in front of you using pinballs. This game mostly fascinates me because of the nice graphic process when showing how a piece of glass/crystal breaks into pieces, with stunning foley sounds that play along. At the time, my interest in physical simulations and graphics grew. 

As I went to university, I begin able to learn the mechanics behind these nice graphic representations. I took the Nature of Code with Prof. Moon before and was able to produce smooth animations using spring simulations, or creating basic flow field behaviors that are seen in a lot of media artworks. However, I still lack knowledge about lighting, modeling, and 3d shadings that would give more potentials to computer graphics creation, and that is what drew my interest of taking this class. 

Shader Examples

1. Example from Shadertoys

This piece, titled Cable Nest, shows an astonishingly fluent looped animation. Constructed with a set of recursively generated cable shapes, it is wiring forever forward with a warm and spread-out light beam in the center. Metaphorically, it can be interpreted as a representation of the Internet, communication infrastructures consisting of optical fiber. As this animation loops endlessly so does the spread of information that is made up of various sources and contains a reasonable amount of noise. 

In terms of lighting, it chose a rather flat shading texture on the cables and applied a kind of smoothing lighting in the center part, that made a fair contrast between these two parts. It also includes a gradual change of camera angle, that shows a more spatial variety in this 3d model

2.  Example from vertexshaderart

This is a shape that is generated from attaching noises onto a blob. This irregular shape is rich in color and contrast, as well as its noisy texture.

In terms of color, this work chooses to stay on a singular hue axis, but with dynamic shades that create an obvious contrast between light and dark. 

In terms of vertex, the noisy pattern that is applied to the surface creates a groovy dynamic that is suitable to dance with.