Tuesday, February 26, 2013

Game Graphics Assignment 7

Not too bad of an assignment. I had done a bit of alpha stuff in both Game Engineering and more in an XNA prototype for game projects 1.
I also didn't have to redesign much of my code. I redid how i was going the draw. Since now i needed to be able to draw objects in different orders, which meant two seperate locations for the draw call, I decided to make a function out of it. So now i have a DrawEntity function that will set all of the effect, material, uniforms that need to be changed and make the draw call.
Then for the Opaque entities i call that function in order of Effect->Material. For the transparent objects i draw them in order of distance away from the camera.

But for the files i only had to update the format for one of the file types, my effect. I added an enum (saved as an int) for whether it was transparent, additive, opaque...

The one part i didn't like is how i had to loop through every entity to check if it had a material that used an effect that was transparent, when drawing the transparent objects. It is a lot of finds that take place (2 * the number of entities you have). I couldn't think of an easy way to divide my entities into opaque and transparent. I can fairly easily do this for the effects, but i have no quick way to get all of the entities that use a specific effect.
So that section is a bit slow, but still fast enough.

Everything should work.
Link To Code

Pix screenshot of events collapsed

Pix screenshot of the Translucent events expanded


No comments:

Post a Comment