Sunday, September 22, 2013

Post-processing added

After some big refactoring made in Gine, I started to play with shaders.

It's not my first time of course, but I'm trying to standarize fx file loading and usage. Another time - make it user friendly.

My first goal was to make a very simple greyscale post-processing effect. Now it looks like that:


Supersimple pixel shader goes like:
Notice the usage of a gTransition float. Yeah! I made smoot transitions as well and I must say it looks exactly as it should ;)

The next step was to blur the background at a pause stage:


The thing was tricky - Gaussian blur needs two passes to work in an optimal way. So after adding a backbuffer render target view, I had to add another and swap them in meantime. Geez, it's so unnecessarily complicated at that level.

I'm happy that main rendering loop looks like that:
And when you want to enable or disable the effect:

Monday, August 19, 2013

Font, Text and Substate

It's been a while... Well, I made a personal portfolio at that time. You can find it here:

Grzegorz Michalak Gamefolio | michalak.net.pl

To the business.
I've sat a little and write some better classes for text rendering. Right now I have a Font and Text class. Many texts can have the same font if you take it that way. It's much better right now and code is also cleaner.

The thing I've done today is a level start state. Here you have a level number and countdown timer - 3 seconds till you can start solving current level. After 3 seconds, these texts are tweening out of the screen with a smooth animation - it's also a nice thing to implement :)

The next step will be level ending screen. It's quite more complex, you need to count some points, draw some clickable menus etc.

Monday, May 27, 2013

Game Interface

It's very simple, but required some Sprite and Font classes. I've made them with last projects, but now, they've got some crucial improvements.


In next steps, I'll add some gameplay states UIs, like beginning of a level, finishing it and pausing.

Tuesday, April 30, 2013

Like a boss

Today I spent some time making animations for my game character. As for now, we have an idle, walk and push animations. I upgraded Gine to handle multiple animations by simply calling them like:
mPlayer.GetModel()->AnimationStart("Walk");


One of the most important thing I haven't done is a transition between animations. It shouldn't be a problem, but right now I need to get some rest and code some simpler, but more necessary things like gameplay ;)

Download:

Monday, April 29, 2013

Exporting animations from Blender to DirectX

It's been a while since my last post... Owh Gooood! The most time and energy consuming thing is behind me. Skeletal animations has been written and I'm really happy about it. In fact, I was swearing at them all the week, the more technologies you use - the more potential bugs you get. What a discovery!

Let me share a few critical problems I got on my way. Maybe it'll save someone's time in the future ;)
It's not a tutorial or step by step instruction, only hints.
  1. Exporting skeletal animation from Blender (v2.65) to a .x file
    • Only active ArmatureAction strip is exported, I was trying with NlaTrack but failed
    • Remember to triangulate the mesh
    • Keyframes on frames <=0 aren't exported
    • Bones have to be in rest pose before running the exporter (but not in Rest Position from Skeleton tab in Object Data panel, I prefer to make a special "rest keyframe" in frame 0)
    • You need to select armature and object first, then launch the .x exporter
    • My exporter options checked:
      • System: Right-Handed (my Assimp loader is configured to automatically change coordinated to Left-Handed)
      • Apply Modifiers
      • Export Textures
      • Export Armatures
      • Animations: Keyframes Only (I guess you know why)
      • Export: Selected Objects

  2. Importing a .x file with Assimp library
    Assimp interface is very neat, so there probably won't be any problems with it. The main I had, was with this function:
    Despite of a fabulous name - it just converts Assimp matrix to XNA matrix. They're both structures with 16 floats in them, and XMFLOAT4X4 has a constructor that enables to build it from a float pointer.
    Tracking this error was a really funny thing, you know where was the problem? The returned XMFLOAT4X4 matrix was transposed... Here's the fix:

  3. Some code issues:
    • Watch out when you want to have a structure like a list of keyframes containing offsets of every bone in current pose. When you're importing, you have a list of channels (corresponding to bones) containing offsets for every frame. It's easy to write some dirty code here.
    • Take a special care for quaternions. Sometimes they're stored as (x, y, z, w) and sometimes as (w, x, y, z)
    • IMHO pointers are much better than lists when managing a bone and animation structure
    • When stuck and don't know what to do, start small. Make a super simple animation with a 3 bones and 6 vertices. Debug all transformations and properties, you'll figure out what happens for sure :)

Friday, April 19, 2013

Suckoban prototype

Finally it's here :)
The best part is that this is fully playable :D Of course you can't save/load, select a specific level from map's pack, etc., but the main idea is on.

Probably I'll spend most of my time trying to implement animations, we'll see if I can do that till the end of April :)


Download:

Wednesday, April 17, 2013

Meet Gine

Gine Is Not an Engine

Finally I've come to name my renderer. I really don't want to say it's an engine or something, just wanted to make a happy little framework that I can make 3D games with.

So today was a hard day of refactoring and of course I haven't finished it yet. With every game I made lastly I've been upgrading this framework by adding little pieces. Not it's the time to get them strictly together and make something like Gine v0.1 :)

Tuesday, April 16, 2013

Introducing Suckoban

Ok, so why do I post a new project introduction in a half of the month? I've been doing a secret project that I can't share but it was still in DirectX, so I'm on fire all the time ;)

Suckoban is a 3D remake of a classic Sokoban game, nothing more. It's a project I've been working on 3 years ago with my friend. Here's the site with our WIP:
 http://gngc.ghassan.pl/suckoban/

And a little trailer here:

Thursday, March 21, 2013

Say hello to my little friend

Only for people with good eyesight:


This looks better in game, believe me! :D

Shadow figures made with billboard technique, geometry shader used for expanding points into quads and texture array for different images on them. In next step I'll try to put some texture masks for bloodstains etc. :P

Monday, March 18, 2013

Dark, Darker, The Darkness

So I implemented my first dynamic SSAO. Results are following:


I still need to tweak light intensivity etc. but this SSAO method looks weird to me. Model's edges around the camera frustum aren't shaded, but the rest seems to be alright. Also it's quite expensive for rendering time, I know it's post-process but a geometry is rendered twice. Of course it's possible to do it in one pass, but I need to learn about MRT technique first ;)

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 ;)

Tuesday, March 12, 2013

Maze MVP

I'm so wasted because of coding that I barely know how to write anything (in English all the more).

OK, a couple things has been done; multiple point lights, bump and specular mapping, particles, maze generation, 3D sound effects and more. I really regret now that I haven't wrote a post every work day. It's as hard for me as getting up at 7 a.m.
But for now, here's the screen:


And download link:
Omg, such a big file for download... I need to do something about that...

Thursday, March 7, 2013

Labyrinth of Restlessness prototype

That one was kind of quick. My "engine" is getting more and more programmer-friendly. Today I've added diffuse texture support (after 2 months, believe?!) and did some fixes and little additions.
Prototype was really easy to make, now I can go to more serious things like advanced texture mapping techniques (normal, specular and shadow) and some other graphical effects.

Prepare to be scared ;)

Download:

Monday, March 4, 2013

Introducing Labyrinth of Restlessness

You wake up in a Labyrinth of Restlessness. You don't know why you are here. The only thing you know is that you have to escape in no time.

Saturday, March 2, 2013

Drumstep Defenders v1.0

February was a very short month for me. But in fact I managed to finish my game aaaaaaand....


Download:

Tuesday, February 26, 2013

Glow me baby

You know what sucks when participating in OGAM? Having room redecoration in the same time. But now it's over and I finally have some time to finish my game. Unfortunately I'll had to close the project in beta stage just to fit in February.

I had some hard time with post-processing, after hours of wondering if I'm that stupid or something I found a solution for my problem and it was in adding that line:
SetGeometryShader(NULL);
DirectX is a state machine, one rendering technique turns geo shader on and it's on until you disable it. Jesus, I know that but it's really hard to debug that kind of stuff on my knowledge level...

Anyway, finally I've added some music-dependent glow:


Of course it looks better in game (it's a music-like game at last). FMOD is really fantastic sound engine, you write something like
float* spectrum = new float[64];
channel->getSpectrum(spectrum, 64, 0, FMOD_DSP_FFT_WINDOW_RECT);
and in spectrum array you have 64 0.0f to 1.0f values describing sound intensity by pitch. Right now I only take bass spectrum to describe wireframe width and glow size but it's really easy to make some fancy effects with it.

Now I have only 3 days left and the next big thing to do is instancing and frustum culling (yes, I still haven't done it).

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.

Tuesday, February 19, 2013

MVP ready!



MVP of Drumstep Defenders is on! Download it here:
And here's a little screen:


Fast track to beta version now! I need to replace laser with lightning machine gun, add few more enemies, some bosses maybe, and of course 2 more scripted tracks to play. Meanwhile, have you seen this video yet? It's hilarious :D