2013년 2월 3일 일요일

Deferred Shadow.

I added shadow into my test engine.
It is called "deferred shadow". It is same with standard shadow technique, except that the shadow term is calculated in the deferred pass. Like deferred shading, we can reconstruct shadow space depth and compared this value to shadow map pixel value. Like deferred shading, this technique simplify engine architecture very much.



2013년 1월 21일 월요일

Deferred shading works.


There is 1 blue point light and 1 green point light in the scene. For every point light, Full-screen quad is being drawn. But final objective is tile-based deferred shading using compute shader. this is test for building blocks(g-buffers, view space positions, normals) for that.

2013년 1월 19일 토요일

This is my drawing. I wanted to draw cat at first. But it became a dog.


2013년 1월 18일 금요일

Weird thing in converting device depth to linear depth.

Below is the functions I used to convert device depth to linear depth. I derived this code from the projection matrix.


// Projection._34 = zn*zf/(zn-zf)
// Projection._33 = zf/(zn-zf)
//float A = Projection._34;
//float B = Projection._33;
float A = ProjectionParams.z/zf;
float B = ProjectionParams.w;

float LInearZ = A/(DeviceZ + B);

It did not work. when ZNear value is not small, resulting linear depth was smaller than the real linear depth.

But when I change the code like below, It worked.

// Projection._34 = zn*zf/(zn-zf)
// Projection._33 = zf/(zn-zf)
//float A = Projection._34/zf;
//float B = Projection._33;
float A = ProjectionParams.z;
float B = ProjectionParams.w;

float LInearZ = A/(DeviceZ + B);

The difference is deviding by 'zf' is done in CPU code. It is exactly same as the crytek's GetLinearDepth function. I still don't know what is the cause. 

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.