TOON SHADER AFTER UPGRADING TO GLSL 4.0
- Shaveen Kumar
- Aug 6, 2013
- 1 min read
Most of my previous projects were implemented using older standards of GLSL. Older standards provided a lot more ease in GLSL programming as they had several built in functions and variables which allowed easy access to some key properties within the shader. Some of these are gl_Vertex, ftransform() and access to the matrix stack via gl_ProjectionMatrix and gl_ModelViewMatrix. Since version 1.2, these have been deprecated and we are required to build our own matrix stack from the OpenGL program and pass them to the shader as a uniform. The same holds true for attributes such as the vertex color or position. These need to be passed via attribute arrays and the appropriate binding needs to be done. Although this is a lot of extra work on the OpenGL application side, it does provide a lot of flexibility.
By tagging my shader as #version 400, I am letting the compiler know that I will be using GLSL version 4.00 and all functions and attributes that conform to the standard. Here’s an output screenshot of my toon shader after re-implementing the vertex and fragment shaders conforming to the the 4.0 standards:

Kommentare