Thursday, October 29, 2009

Half angle slicing






Half angle slicing


Half angle slicing


Half angle slicing


I was looking to implement Half angle slicing but
due to some problems I was unable to get the results.
see the image below. The problems included how to
update the OpenGL blending order front to back
and back to front for the light and eye buffers.
Once this was sorted, I was still not getting the same
output as was shown in the paper by Joe Kniss.
So just today I noticed I was not clearing the eye
and light buffers doing so removed the bugs. Finally,
I managed to get it working. Compare the above images
to this one.

Half angle slicing

Saturday, May 23, 2009

Half angle slicing



Half angle slicing is a really wonderful technique invented by Joe Kniss. The details are given in GPUGems1-Chapter 39. I implemented it and the results are amazing. I will post videos after the whole thing is finished. Till then, enjoy some snapshots.



Half angle slicing
Half angle slicing
Half angle slicing
Half angle slicing
Half angle slicing
Half angle slicing

Wednesday, April 8, 2009

Screen space water on GPU

I saw an interesting demo from NVIDIA in the OpenGL sdk using render to 3D texture functionality to run a realtime water simulation. I thought I would replicate the same thing in 2D atleast to get started. So here it is.







The reference for this was this wonderful article. The snapshot from the application is on the top. Here is how I implemented this on OpenGL. I created 3 textures and attached them to the three color attachments using the FBO. The first color attachement was for the 3D scene (the teapot and the plane). The second and third color attachments were for the water simulation. Basically I have simply converted the main code given in the article. See it for details in this regard. In the display function, first the scene is rendered and then the water simulation is rendered by ping pongging btw color attachment 1 and 2. The complete fragment shader for water is given below

 

fragment_out fragment_water( frag_vertex IN,
uniform sampler2D currentMap,
uniform sampler2D prevMap)
{
fragment_out OUT;
float4 smoothed;
float4 prev = tex2D(prevMap, IN.UV);

smoothed = tex2D(currentMap, IN.UV + float2(s.x, 0));
smoothed += tex2D(currentMap, IN.UV + float2(-s.x,0));
smoothed += tex2D(currentMap, IN.UV + float2(0, s.y));
smoothed += tex2D(currentMap, IN.UV + float2(0,-s.y));
smoothed /= 4.0;
OUT.Color = (smoothed*2.0 - prev)*damping;
return OUT;
}


After this, we have three rendered outputs the first one containing the rendering result, the second and third contain the water buffer. These textures are then used in another fragment shader to show the final output. The fragment shader is given below.


 

fragment_out fragment_main( frag_vertex IN,
uniform sampler2D buffer,
uniform sampler2D textureMap)
{
fragment_out OUT;
float Xoffset = tex2D(buffer, IN.UV+half2(-s.x, 0)) -
tex2D(buffer, IN.UV+half2(s.x, 0));
float Yoffset = tex2D(buffer, IN.UV+half2(0, -s.y)) -
tex2D(buffer, IN.UV+half2(0, s.y));
half4 t = tex2D(textureMap, IN.UV+half2(Xoffset,Yoffset));
OUT.Color = t+half4(Xoffset);
return OUT;
}


This gives the result shown in the image below.
Screen space water on GPU

Rest is just openGL bits and pieces.

Wednesday, March 11, 2009

A cool screen space magnifier

Hi,
After working on the raindrop shader, i was able to come up with this magnifier in less than half an hour. Enjoy!!!

Tuesday, March 10, 2009

Rain drops on the camera screen


I was playing around with some post processing effects. Here is a cool effect of water drops dropping on the camera screen. It looks amazing. Enjoy!!!

Popular Posts

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