Added Parallax mapping tutorial

here is a new tutorial for parallax mapping in GLSL which is a very useful graphical effect for potentially reducing the complexity of geometric objects by storing additional detail information in a texture which is commonly known as a height map(or bump map).

here is a great example in STALKER Shadow of Chernobyl

PARALLAX_OCCLUSION.jpg

tinyShaders now with pre-compiled shaders support

my most recent addition to tinyShaders is the ability to save and load shader program binaries which is a great technique for greatly reducing loading times by allowing an application to completely bypass the shader compilation stage of initialization.

please note that pre-compiled shader binaries would be best used for caching purposes not distribution as every GPU vendor as well as driver version for that GPU would have a different implementation for saving shader binaries.

example 1. (a shader binary compiled on an AMD HD5800 GPU)
example 2. (a shader binary compiled on a Nvidia GTX550M GPU)

as you can see there is a very clear difference in shader binaries so your best bet would be to ship your product with the shader source code, compile the shader code to a binary and save it to the user’s filesystem.

the process of saving the binary is actually very straightforward and can be done whilst the shader source code is being loaded

//after specifying input and output shader attributes

GLchar errorLog[ TINYSHADERS_ERROR_LOG_SIZE ];
GLint successful = GL_FALSE;
//tell OpenGL to hang onto the shader binary
glProgramParameteri( programHandle, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE );

//if the shader program links correctly
glLinkProgram( programHandle );
glGetProgramiv( programHandle, GL_LINK_STATUS, &successful );
glGetProgramInfoLog( programHandle, sizeof( errorLog ), 0, errorLog );

GLint binarySize = 0;

//retrieve the size and format of the binary from OpenGL
glGetProgramiv( programHandle, GL_PROGRAM_BINARY_LENGTH, &binarySize );

void* buffer = nullptr;
buffer = ( void* )malloc( binarySize );
GLenum binaryFormat = GL_NONE; //the next function will set binary format as a reference parameter
glGetProgramBinary( programHandle, binarySize, NULL, &binaryFormat, buffer );

//now you have a buffer object that you can save to a file at a later time