Showing posts with label frustum culling. Show all posts
Showing posts with label frustum culling. Show all posts

Monday, March 18, 2013

Instancing and a bit of shader play

I sat down and started to refactor my code for serious. FPS rate was still silly low, but the code looked ok. I've implement instancing and saw that it accelerated draw function by 4-5 times, also frustum culling lowers the drawing time at average 4 times. It was really ok, but still...


Consider following shader code:

What will happen in 28 and 29th line?

I'm setting a value for gRenderedPointLights to 7, so it will be logical if this loop unrolls and just copy its code 7 times with different i values.

 

HLSL attributes are very sensitive. I don't know why, but in that case the loop unrolled circa 50 times, removing the [unroll] attribute solves the problem. Now rendering time jumped like +100FPS.

Victory...

Thursday, March 14, 2013

Frustrum culling - so what?

Yesterday I added bounding box and sphere calculation to my model class. With that data it was simply enough to finally implement frustum culling. I also refactored inside of the model class, should be functioning faster now :)

Everything is working etc, but... application in debug mode is still at 10-20 FPS level, I've checked lights, normal maps, particles and other things and I still can't figure out what slows it down so bad. Unfortunately I need to spend more time on refactoring and optimization at the expense of gameplay.

Just in case - next step will be SSAO, I don't know if I'll manage but it's worth trying for this project ;)

Wednesday, February 20, 2013

Plasma gun

No screen today, only a little note.
Yesterday I've replaced static laser canon with a plasma gun. Technically you can imagine it as standard spaceship weapon in Star Wars series. It requires quite more of CPU cycles, but I think the result is worth it. Collisions in 3D can really be pain in the ass, fortunately I'm using XNA math library for vectors, matrices, etc. Is has this set of functions in xnacollision.h like:
BOOL IntersectRayTriangle( FXMVECTOR Origin, FXMVECTOR Direction, FXMVECTOR V0, CXMVECTOR V1, CXMVECTOR V2, FLOAT* pDist );
So collision detection is quite simple with this. When I finally sit down and force myself to write instancing and frustum culling every model will have its own bounding volume which make collision detections even simpler and faster.