Tag Archives: OpenGL

wavelength-based thinfilm interference

I managed to successfully port some cg shaders over to glsl, gave them a spring-cleaning and integrated them into an OpenGL 3.2 core renderer (yeah, OS X 10.8 if you have to ask – bummer). It is kinda “the real deal”: thinfilm interference evaluated per lambda with interactive refraction indices, light + material spectral power distributions and thickness. I might have more results soon, so far these images below have to do:

Alien, smooth surface, film: 400nmAlien, semi-rough surface, film: 340nmAlien, rough surface, film: 430nm

Besides I still have other work todo, writing down my ph.d thesis…

libSOIL

As I was working with libSOIL (https://github.com/smibarber/libSOIL for a mac makefile) an exception occured and I couldn’t load anything. Turns out, libSOIL is not OpenGL 3.2 core compatible. Main reason for this is the beautiful safety-net which I encountered in the function

int query_NPOT_capability( void ){
  ...
  if((NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), 
      "GL_ARB_texture_non_power_of_two")){
  ...

This mechanism can be found elsewhere too. As this specific feature is definitely part of OpenGL 3.2 core the problem was easy to resolve (remove the check) and it works now as expected. Yay!

Integrating FXAA

Revently I’ve integrated Timothy Lottes extreme powerful Anti-Alising filter Fast Approximate Anti-Aliasing into my ph.d.-project (might be introduced later on…).¬† It didn’t really take a long time as the filter source is documented quite well.

As I already have a class CPostProcessor that takes a base image and filters it using a generic vertex- and a custom fragment-shader I’ve created a class CPPFXAA that applies the FXAA filter.

1. Setup

Before integrating the FXAA shader you have to set it up, meaning going through the first part of the downloadable header-file and choose the defines to what you need/want.

2. Texture to RGBL

This step is not really necessary, but I somehow ended up integrating it anyway. Instead of an alpha value the alpha channel stores the luminace: (for me: color.a = dot(color.rgb, vec3(0.299, 0.587, 0.114));).

3. FXAA filter

Disable blending (if it was enabled) and apply the filter: render a screen-aligned quad with a fxaa as a fragment-shader. Set the input image as your “BaseImage” and set the correct viewport dimensions (“screenwidth” and “screenheight”).

4. done.

That’s it.

 

I hope it works as good for you as it does for me:)