Wednesday, November 23, 2011

Snapshot from my latest GLSL Path tracer

Here is a snapshot from my latest GLSL Path tracer which was inspired by the excellently done path tracer in WebGL by Evan Wallace( I have modified his code considerably to make it run even faster on PC.

GLSL Pathtracer

It runs at ~70fps with 128 samples per pixel for an output res. of 1024x1024. Check this video captured live from a session.
Another video showing a live editing session.
Another video showing the famous Cornell Box scene.
This demo renders the famous Cornell Box scene in realtime. You can edit all the parameters live and it renders at ~240 fps on my NVIDIA Quadro FX 5800 on an output resolution of 1024x1024. I have not added importance sampling or any other optimization. Adding those will certainly make it even faster.
Yet another video of Cornell Box
This time it is even better with more photons. Takes a bit longer to converge but the output is worth it. GLSL Pathtracer Demo Enjoy!!!

Sunday, November 20, 2011

Friday, November 18, 2011

Twirl filter in GLSL

I had worked on image processing project back in my high school days and so the last memories returned recently when I wanted to implement the twirl filter in GLSL. Mathematically, it is easily given as the following function in polar coordinates,
In normal world though, we are working in Cartesian coordiates so we need to add that conversion in. Other than that, it is the same function. Here is the output from my shader.
Twirl Filter in GLSL
The Lena image filtered with the twirl filter in GLSL.
And here is the GLSL fragment shader for doing this.

uniform sampler2D textureMap; //image
uniform float amount; //amount of twirl
void main() {
   vec2 uv = gl_TexCoord[0].st-0.5;
   float angle = atan2(uv.y,uv.x);
   float radius = length(uv);
   angle+= radius*amount;
   vec2 shifted = radius*vec2(cos(angle), sin(angle));
   gl_FragColor = texture(textureMap, (shifted+0.5));

I hope it is useful for others too.


Popular Posts

Copyright (C) 2011 - Movania Muhammad Mobeen. Awesome Inc. theme. Powered by Blogger.