Showing posts with label instancing. Show all posts
Showing posts with label instancing. 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...

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.

Thursday, January 17, 2013

The work is on!

Oh gosh... I got a terrible flu last Sunday. I wasn't capable of thinking not only coding...
So, from the OGAM POV I'm 5 days late.

Fortunately, I managed to sit on my ass today and do some work. Custom OBJ loader went to a trash, in case, it was junk :P I've used the Assimp (Open Asset Import Library) for importing my OBJ and MTL files and it looks alright. Quite simple to pin it to the project and extract all the useful-for-me data from its objects. But in fact, documentation for Assimp is terrible.

I've manage to load two models with different materials on mesh subsets. The funny thing is that I made "materials library" global, so I can take vehicle body material, change its color and all models on scene using this material will change its color as well.


Of course some simple instancing was made. You know, just for not loading and holding two identical meshes. 13 FPS on the screenshot below but we have here ~400 objects, no frustum culling and it's in debug mode, quite OK I think.



I've made my try to cel-shading. The only acceptable method will be the one with post-processing. Normals map need to be rendered for the full scene, then some edge detection algorithm implemented for this. I probably wait with that kind of stuff and right now focus on main gameplay :)