Friday, March 1, 2013

Graphics Assignment 7

I loved every bit of this assignment. It was really amazing to see how different blending modes worked for transparency.

I approached this assignment by setting the ALPHABLENDENABLE to True. Then I just changed few alpha values for the Meshes and I ran the program to see how it looks. So it did show some transparent surfaces. For doing so, I had to research a little bit the Render States. Sagar was little ahead of me in this part. So I took his help also in understanding the render states.

After doing this, I targeted each effect on its own. I created each of those effects one by one and tested them. I started with Additive because it was the easiest of the other transparency effects.

According to my understanding, ADDITIVE effect just adds up all the colors that have already been drawn on the screen at that particular pixel position.

SRCBLEND and DESTBLEND is ONE for ADDITIVE effect.

Then I moved to Partial Transparent Effect. For partial transparent effect, I took the alpha value from the material file. I set this Alpha value as a uniform so that the shaders can use it. Using this alpha value, I set the alpha value for the fragment and then GPU did the rest of the work using Render States.

SRCBLEND is SRCALPHA and DESTBLEND is DESTALPHA for PARTIAL TRANSPARENT effect.

Lastly, I worked on the Binary alpha. I created an Alpha map using an image of my favorite football (soccer ;P ) club. I got this image from google and then I deleted the background. I used this image for taking the alpha values for the shader. Then I used the clip function to clip of the unnecessary fragments.

 We set the ALPHABLENDENABLE to false in the case of BINARY EFFECT since we take care of it manually in the shader.

It was very important to sort the Entities from back to front because for creating transparent meshes, the Meshes in the back have to be drawn first.

But I divided the Entities into two different list. One for Opaque Entities (the color of the pixel depends only upon the current value of the fragment) and Translucent Entities (the color depends upon the pixels already drawn).

For optimization purposes, the Opaque Entities are sorted in the way mentioned in the last assignment.
For accuracy purposes, the Translucent Entities are sorted based upon the distance of the Entity from the Camera (descending order).

Here is the screenshot of my scene.





Below are the screenshots from Pix with Events.



Here is the link to my code: Download Code


No comments:

Post a Comment