November 28, 2011

basic deferred shading system in GLSL

Today I made a basic deferred renderer as an exercise in a single shader using only depth buffer and inverse modelview matrix as input.
Normals and position are calculated from depth buffer. Unfortunately normals are flat shaded using this method and the shader itself is quite slow, but maybe someone finds the parts of this shader useful.



blend:
HERE
fragment shader (code is quite messy) :
HERE

November 22, 2011

GLSL depth of field with bokeh v2.1

This is an update from the previous post on DoF bokeh shader.
The main addition is an option of pentagonal shape bokeh. The technique is hackish, but it works. Still I am looking for a more simpler way to make procedural n-gonal shapes of sampling.

The shader is made on 2006 iMac with Mobility Radeon card so it should work on any hardware supporting OpenGL

Screenshots are captured with high sample count, but the point is to show the features and capabilities of the shader.

some of the main features explained with images:

threshold & gain:
brings out highlights by "threshold" value and enhances them with "gain"
as you can see this is the main part that makes the distinct look of the bokeh blur. Without bringing out highlights, the blur looks like just a regular circular blur.








fringe:
adds chromatic aberration for the blur (small overlay image shows r,g,b color offset of the sample)



bias:
shifts the weights of the samples on the bokeh edges





pentagon:
pentagon shape of the bokeh (still needs some work)
edit: i have removed the "scale" factor, it is now automatic.




GLSL frag shader: HERE