2013년 1월 16일 수요일

read only depth stencil view in deferred shading.

In deferred shading, We have to both reading and writing with depth buffer. And We can't set depth buffer as rendertarget and set shader resource simultaneously.
So we have to create additinal read only depth stencil view and set it as rendertarget when lighting pass. If not, reading depth buffer will fail.



D3D11_DEPTH_STENCIL_VIEW_DESC desc;
desc.Flags = D3D11_DSV_READ_ONLY_DEPTH;


I wandered for 3 hours about this.

2013년 1월 14일 월요일

Calculating global time for animation clip.

The "Game engine architecture book" says that using global time instead of local time has several benefits. So I applied this algorithm to my current animation implementation.

Here is source code for calculating local time from global time.


float CurrentGlobalTime = GEngine->_TimeSeconds;
float NT;
if(_NumPlay == 0)
{
    NT = FLOAT_MAX;
}
else
{
    NT = _Clip->_Duration*(float)_NumPlay;
}

_LocalTime = fmod(Math::Clamp<float>((CurrentGlobalTime - _StartTime)*_TimeScale, -NT, NT), _Clip->_Duration);

if(_LocalTime < 0)
{
    _LocalTime = _Clip->_Duration + _LocalTime;
}

It works for loop and plus and minus time scale, but I think handling minus time scale is a little dirty.

looping


3x faster

repeat 3 times and stop



reverse (minus time scale)



2013년 1월 9일 수요일

Visual Memory Detector.

Quite useful!

http://www.codeproject.com/Articles/9815/Visual-Leak-Detector-Enhanced-Memory-Leak-Detectio#bandr


2013년 1월 8일 화요일

Skinning



First image shows unskinned mesh and current pose(red).
Next image shows skinned mesh and bind pose. Ugly stretched line is missing bind pose matrices(these are not skinned to mesh).

FBX was quite confusing and I think I need some refactoring of some codes.

2013년 1월 4일 금요일

Skeleton/Pose

Today, I imported skeleton data from FBX. I referenced the "Game Engine Architecture" book about data structure for the skeleton and poses. After that, calculated bone matrices. Next small objective is to render skinned mesh using GPU skinning. I think I would use uniform buffer approach for bone matrices.

I have done programming some kind of animation engine many years ago already. I've know this concept and know exactly how to do it. But doing this with dx11 and for completely hobby project is great. I don't even play games recently.

I've realized that my favorite hobby is engine/graphics programming. Unfortunately, Componies who is developing their own engine is rapidly disappearing. Anyway, It may be fun because it is just hobby~

2013년 1월 2일 수요일

xmamath crash problem.

I am using xnamath for the first time in this hobby project. yesterday I got a weird access violation at the assigning one XMMATRIX variable to another XMMATRIX variable.

GEngine->_ViewMat = ViewMat

After googling, I've found that I should not use XMVECTOR and XMMATRIX int the member variable which is allocated dynamically. That is because compiler doesn't align my class or struct with 16byte boundary. Instead of overlading new/delete operator I've decided that not using XMVECTOR for class member variables.

2012년 12월 30일 일요일

Started DirectX11 Project(Fbx Sdk today)

I stopped native directx programming a few years ago. I thought that I don't have to use it directly anymore. I thought that It is OK to understand it. But the day before yesterday, I opened directx11 tutorial project. I am planning to write an engine with directx11 features only. hmmm I just succeeded about importing FBX static mesh file. FBX is much easier that 3dsmax sdk. Why am I doing this now? In the age full of free or cheap excellent engines like udk/unity3d? Yes, just reading the code is not enough, After writing down the code from scratch, I really understand the things.

Now I am familiar with the concept of resource view and some other d3d objects. The next small objective would be animation. I would reference game engine architecture book  for animation data structure.

And after some considering, I've decided that not using seprated vertex buffers for position/normal/tex things. It could be convenient a little. but for performance reason, most engines does not seem to use that feature. but gothic3 game seems to use similar technique(buffer streaming feature in d3d9).