Jump to content
  • Advertisement
Sign in to follow this  
Juliean

Shadow mapping issues

This topic is 2606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I've tried out a lot of tutorials about shadow mapping, and none of them seems to work. Currently I'm trying to use this one:
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Projective_texturing.php

Though it is made for XNA and I'm using c++/directx9, it's not hard to use because I have already got render-targets set up from previous tutorials. However, I'm getting some weird results:

kq6scq5l.png

Yeah. Not quite what I expected. Well first of all, here is the shader i'm using to output shadow depth values from the light:

struct VS_INPUT_SHADOW
{
float3 vPos : POSITION0;
};

struct VS_OUTPUT_SHADOW
{
float4 vPosition : POSITION;
float4 vDepth : TEXCOORD0;
};

struct PS_OUTPUT_SHADOW
{
float4 vDepth : COLOR0;
};


VS_OUTPUT_SHADOW vsShadow(VS_INPUT_SHADOW i)
{
VS_OUTPUT_SHADOW o;

o.vPosition = mul(i.vPos, mul(World , LightViewProj));
o.vDepth = o.vPosition;

return o;
};

// psBuild()
// put geometry data into render targets
PS_OUTPUT_SHADOW psShadow(VS_OUTPUT_SHADOW i) : COLOR0
{
PS_OUTPUT_SHADOW o;

o.vDepth = i.vDepth.z/i.vDepth.w;

return o;
};


To calculate the shadow map for depth comparison, I do like it is said in the tutorial too:

VS_OUTPUT_BUILD vsBuild(VS_INPUT_BUILD i)
{
VS_OUTPUT_BUILD o;

o.vTexCoord = mul(mul(i.vPos, World), LightViewProj);

return o;
};

// psBuild()
// put geometry data into render targets
PS_OUTPUT_BUILD psBuild(VS_OUTPUT_BUILD i)
{
PS_OUTPUT_BUILD o;

float4 ProjectedTexCoords;
ProjectedTexCoords.x = i.vTexCoord.x/i.vTexCoord.w/2.0f +0.5f;
ProjectedTexCoords.y = -i.vTexCoord.y/i.vTexCoord.w/2.0f +0.5f;

o.vShadow = tex2D(ShadowSampler, ProjectedTexCoords);
return o;
};


I'm using this render target:

m_lpDevice->CreateTexture(1024,1024,1,D3DUSAGE_RENDERTARGET,D3DFMT_R32F,D3DPOOL_DEFAULT,&m_ShadowBuffer,NULL);

The light is asigned that way:

D3DXMATRIX matView, matProj, matLightViewProj, matTexture;
D3DXVECTOR3 LightPos, LightAim, Up;

LightAim = D3DXVECTOR3(0.0, 0.0, 0.0);
LightPos = D3DXVECTOR3(10.0, 10.0, 10.0);
Up = D3DXVECTOR3(0.0, 1.0, 0.0);

D3DXMatrixLookAtLH( &matView, &LightPos, &LightAim, &Up );
D3DXMatrixPerspectiveFovLH(&matProj, D3DXToRadian(30.0f), 1.0f, 1.0f, 1024.0f );

matLightViewProj = matView * matProj;

m_Manager->GetEffect(L"Effect.fx")->SetMatrix("LightViewProj", &matLightViewProj);


Anyone knows whats going on? Deferred lighting rendering is working so it has nothing to do with that, matrices should be asigned correctly. I found a maybe bug, namely the input-coordinates set to float3 instead of 4. Changing the input-coordinates to float4 however causes the screen to stay completely black. I already tried out three tutorials (one in a book of mine), and I pretty much always endet with a black screen. Somebody seeing the mistake from looking at my code, or any suggestions/or other tutorials?

Share this post


Link to post
Share on other sites
Advertisement
Are you creating a new depth stencil buffer for use when you render to the shadow map? It should be the same dimensions as your shadow map texture.

Share this post


Link to post
Share on other sites
I'm running the window in the same size as the shadow buffer (1024*1024), so I thought that would be ok. Should I still create a new depth stencil? For testing porpuses I'll go with fixed size shadow maps.

Anyway, thats a good point, I remember having some issues with rendertargets and depth stencil before. I'll try creating a new depth stencil, but what settings should I use? Currently my shadow map pass is running at:

ZwriteEnable = false;
CullMode = ccw;
ZFunc = less;
StencilEnable = true;
AlphaBlendEnable = false;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;


Anything I have to set before and unset unset after creating the shadow map?

Share this post


Link to post
Share on other sites
Really nobody? This problem seems kinda strange, as I seem to simply not being able to render to any surface from my shadow-pass. No matter what I do, this technique just seems to refuse to write anything to any surface of any format. Now, after serveral days of trying and several stages I went from thinking eventually having it working, some results that gave me just black screens, and now I'm back at black screen. Code pretty much stayed the same. If I do the same kind of calculations in my normal shader, I get results, even if rendering to the excact same surface.

Any ideas what's going on? Is there any way to view the content of a rendertarget outside of the application? Maybe that would help..

Share this post


Link to post
Share on other sites

Any ideas what's going on? Is there any way to view the content of a rendertarget outside of the application? Maybe that would help..


Yes, use PIX. You can view the state of your render targets (and the state of the device) at each point in the frame.

Share this post


Link to post
Share on other sites
Yes, use PIX. You can view the state of your render targets (and the state of the device) at each point in the frame. [/quote]

Yeah, I do know PIX, but I can't use it. Somehow, it keeps crashing my application. If I try to capture a frame with F12, the app crashes with the following message:

release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <14><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <13><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <12><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <11><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <10><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <9><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <8><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <7><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <6><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <5><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <4><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 140, 108, 210, 54)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 140, 108, 210, 54)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........PRE: <this=0x05492b38>IDirect3DTexture9::Release()
Frame 000002 ........POST: <5><this=0x05492b38> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 248, 4, 372, 2)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 248, 4, 372, 2)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTexture(0, 0x0548DC78)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTexture(0, 0x0548DC78)
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <3><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <2><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 252, 8, 378, 4)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 252, 8, 378, 4)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........PRE: <this=0x05492b38>IDirect3DTexture9::Release()
Frame 000002 ........POST: <4><this=0x05492b38> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x05492b38>IDirect3DTexture9::Release()
Frame 000002 ........POST: <3><this=0x05492b38> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 260, 8, 390, 4)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 260, 8, 390, 4)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTexture(0, 0x0548DC78)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTexture(0, 0x0548DC78)
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........PRE: <this=0x0548dc78>IDirect3DTexture9::Release()
Frame 000002 ........POST: <1><this=0x0548dc78> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 268, 4, 402, 2)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 268, 4, 402, 2)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTexture(0, 0x05492B38)
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Lock(0, 0, 0x0012F9B8, D3DLOCK_NOOVERWRITE)
Frame 000002 ........PRE: <this=0x05492b38>IDirect3DTexture9::Release()
Frame 000002 ........POST: <2><this=0x05492b38> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x05492b38>IDirect3DTexture9::Release()
Frame 000002 ........POST: <1><this=0x05492b38> IDirect3DTexture9::Release()
Frame 000002 ........PRE: <this=0x0548b7c0>IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........POST: <S_OK><this=0x0548b7c0> IDirect3DVertexBuffer9::Unlock()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 272, 8, 408, 4)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 272, 8, 408, 4)
Frame 000002 ........PRE: DebugSetMute(TRUE)
Frame 000002 ........POST: <> DebugSetMute(TRUE)
Frame 000002 ........PRE: <this=0x05488ed8>IDirect3DStateBlock9::Apply()
Frame 000002 ........POST: <S_OK><this=0x05488ed8> IDirect3DStateBlock9::Apply()
Frame 000002 ........PRE: <this=0x054a5388>IDirect3DStateBlock9::Apply()
Frame 000002 ........POST: <S_OK><this=0x054a5388> IDirect3DStateBlock9::Apply()
Frame 000002 ........PRE: <this=0x054a87d0>IDirect3DStateBlock9::Apply()
Frame 000002 ........POST: <S_OK><this=0x054a87d0> IDirect3DStateBlock9::Apply()
Frame 000002 ........PRE: DebugSetMute(FALSE)
Frame 000002 ........POST: <> DebugSetMute(FALSE)
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::EndScene()
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::EndScene()
Frame 000002 ........PRE: <this=0x05445a48>IDirect3DDevice9::Present(NULL, NULL, NULL, NULL)
Frame 000002 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::Present(NULL, NULL, NULL, NULL)
Frame 000002 ....POST: <> Frame(2)
Frame 000003 ....PRE: Frame(3)
Trigger 'Key Combo "F12"' fired
Created PIXRun file at: C:\DOKUME~1\Neo\LOKALE~1\Temp\PIX259.tmp
Frame 000003 ........PRE: <this=0x05445a48>IDirect3DDevice9::SetTransform(D3DTS_VIEW, 0x0012FAB0)
An unhandled exception occurred.
Closing Run File
Created PIXRun file at: C:\DOKUME~1\Neo\LOKALE~1\Temp\PIX25A.tmp
Frame 000003 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::SetTransform(D3DTS_VIEW, 0x0012FAB0)
Frame 000003 ........PRE: CreateProcessW(NULL, 0x0781DE6C, <unknown type 193>, <unknown type 193>, TRUE, 0x04000020, NULL, 0x0781E3BC, <unknown type 195>, <unknown type 196>)
Frame 000003 ........POST: <TRUE> CreateProcessW(NULL, 0x0781DE6C, <unknown type 193>, <unknown type 193>, TRUE, 0x04000024, NULL, 0x0781E3BC, <unknown type 195>, <unknown type 196>)
Frame 000003 ........PRE: <this=0x05445a48>IDirect3DDevice9::GetTransform(D3DTS_PROJECTION, 0x0012F9EC)
Frame 000003 ........POST: <S_OK><this=0x05445a48> IDirect3DDevice9::GetTransform(D3DTS_PROJECTION, 0x0012F9EC)
An unhandled exception occurred.
Closing Run File
Frame 000003 ........PRE: CreateProcessW(NULL, 0x0012F2F4, <unknown type 193>, <unknown type 193>, TRUE, 0x00000000, NULL, NULL, <unknown type 195>, <unknown type 196>)
Created PIXRun file at: C:\DOKUME~1\Neo\LOKALE~1\Temp\PIX25B.tmp
Frame 000003 ........POST: <TRUE> CreateProcessW(NULL, 0x0012F2F4, <unknown type 193>, <unknown type 193>, TRUE, 0x00000004, NULL, NULL, <unknown type 195>, <unknown type 196>)


And if I start it with more settings, it straigthforward crashes and gives me that output:

exDeclaration(0x006E16F0, 0x064659F0)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDeviceCaps(0x0012F8D8)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDeviceCaps(0x0012F8D8)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetCreationParameters(0x0012F8BC)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetCreationParameters(0x0012F8BC)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetRenderTarget(0x00000000, 0x0012F86C)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetRenderTarget(0x00000000, 0x0012F86C)
Frame 000001 ........PRE: <this=0x05479f18>IDirect3DSurface9::GetDesc(0x0012F870)
Frame 000001 ........POST: <S_OK><this=0x05479f18> IDirect3DSurface9::GetDesc(0x0012F870)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDisplayMode(0, 0x0012F890)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDisplayMode(0, 0x0012F890)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8)
Frame 000001 ........POST: <S_OK><this=0x05479e08> IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8)
Frame 000001 ........PRE: <this=0x05479f18>IDirect3DSurface9::Release()
Frame 000001 ........POST: <1><this=0x05479f18> IDirect3DSurface9::Release()
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::AddRef()
Frame 000001 ........POST: <8><this=0x05445190> IDirect3DDevice9::AddRef()
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F8FC)
Frame 000001 ........POST: <E_NOINTERFACE><this=0x05445190> IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F8FC)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F750)
Frame 000001 ........POST: <E_NOINTERFACE><this=0x05445190> IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F750)
Frame 000001 ........PRE: DebugSetMute(TRUE)
Frame 000001 ........POST: <> DebugSetMute(TRUE)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDirect3D(0x0012F5E0)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDirect3D(0x0012F5E0)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDeviceCaps(0x0012F5E4)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDeviceCaps(0x0012F5E4)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDisplayMode(0, 0x0012F714)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDisplayMode(0, 0x0012F714)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R8G8B8)
Frame 000001 ........POST: <D3DERR_NOTAVAILABLE><this=0x05479e08> IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R8G8B8)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8)
Frame 000001 ........POST: <S_OK><this=0x05479e08> IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::Release()
Frame 000001 ........POST: <4><this=0x05479e08> IDirect3D9::Release()
Frame 000001 ........PRE: DebugSetMute(FALSE)
Frame 000001 ........POST: <> DebugSetMute(FALSE)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDeviceCaps(0x0012F770)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDeviceCaps(0x0012F770)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F750)
Frame 000001 ........POST: <E_NOINTERFACE><this=0x05445190> IDirect3DDevice9::QueryInterface({0xb18b10ce, 0x2649, 0x405a, 0x87, 0x0f, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a}, 0x0012F750)
Frame 000001 ........PRE: DebugSetMute(TRUE)
Frame 000001 ........POST: <> DebugSetMute(TRUE)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDirect3D(0x0012F5E0)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDirect3D(0x0012F5E0)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDeviceCaps(0x0012F5E4)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDeviceCaps(0x0012F5E4)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDisplayMode(0, 0x0012F714)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDisplayMode(0, 0x0012F714)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R8G8B8)
Frame 000001 ........POST: <D3DERR_NOTAVAILABLE><this=0x05479e08> IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R8G8B8)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8)
Frame 000001 ........POST: <S_OK><this=0x05479e08> IDirect3D9::CheckDeviceFormat(0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8)
Frame 000001 ........PRE: <this=0x05479e08>IDirect3D9::Release()
Frame 000001 ........POST: <4><this=0x05479e08> IDirect3D9::Release()
Frame 000001 ........PRE: DebugSetMute(FALSE)
Frame 000001 ........POST: <> DebugSetMute(FALSE)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::GetDeviceCaps(0x0012F770)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::GetDeviceCaps(0x0012F770)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, 0x00515288, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Texture, 0x054465E0, 0x064669A0)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Texture, 0x054465E0, 0x064669A0)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x05446688, 0x06466C00)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x05446688, 0x06466C00)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, 0x00515288, NULL)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, 0x0051528C, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Texture, 0x05446718, 0x06466D00)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Texture, 0x05446718, 0x06466D00)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x054467C0, 0x06466F40)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x054467C0, 0x06466F40)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, 0x0051528C, NULL)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, 0x00515290, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Texture, 0x05446850, 0x06467040)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Texture, 0x05446850, 0x06467040)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x054468F8, 0x06467280)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x054468F8, 0x06467280)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, 0x00515290, NULL)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateTexture(1024, 1024, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, 0x00515298, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Texture, 0x05446988, 0x06467380)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Texture, 0x05446988, 0x06467380)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x05446A30, 0x064675E0)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x05446A30, 0x064675E0)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateTexture(1024, 1024, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, 0x00515298, NULL)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, 0x00515294, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Texture, 0x05446AC0, 0x064676C0)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Texture, 0x05446AC0, 0x064676C0)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x05446B68, 0x06467920)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x05446B68, 0x06467920)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateTexture(1920, 1920, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, 0x00515294, NULL)
Frame 000001 ........PRE: <this=0x05445190>IDirect3DDevice9::CreateDepthStencilSurface(1024, 1024, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0x00000000, FALSE, 0x0051529C, NULL)
Frame 000001 ............PRE: AddObject(D3D9 Surface, 0x05446BF8, 0x064679E0)
Frame 000001 ............POST: <TRUE> AddObject(D3D9 Surface, 0x05446BF8, 0x064679E0)
Frame 000001 ........POST: <S_OK><this=0x05445190> IDirect3DDevice9::CreateDepthStencilSurface(1024, 1024, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0x00000000, FALSE, 0x0051529C, NULL)
An unhandled exception occurred.


so is PIX telling me thats it is crashing after creating a surface that actually was sucessfully created, as well as trying to set a world matrix?? My app runs without problems without using pix, no warnings, release & debug.. I have never been able to use pix since then.. any ideas? its a bit offtopic, but I think I'd need less help if I actually was able to debug my directx-device and stuff.

Oh yeah, I actually figured out the problem with the shading. It was this line:

o.vPosition = mul(float4(mul(i.vPos, World),1) , LightViewProj);

I forgot to add float4(world, 1).. why do I have to do this anyway? I mean I saw it once in a code and obviously used it in my normal vertex shader, and though I know somehow what the w-value does, I don't really know why I'd have to add it here?

Just some remaining questions here, though..

1) My shadows are very heavy aliased and sometimes arent even right. Consider this picture:

l6um4aon.jpg

Best example here is the shadow of the guy on the left. The shadow looks like something you'd expect from a 2d games from 20 years ago, and although he is standing with his feet IN the ground, the shadow is only depicted on the wall. All the other shadows have this too. For example when moving the box in the middle near the plane towards the plane, it doesn't smoothly gets smaller, but rather jumps in small steps, which is looking very akward. I know that shadow mapping doesn't grant soft edges. Is this what I'm experiencing here something "normal" and I need some algorythms to smooth the edges out or is this some other problem? Maybe because I'm using deferred lighting? I don't know how this could cause such disgusting effects, but who knows..

2) I'm having issues switching the stencil buffer. I created this buffer:

m_lpDevice->CreateDepthStencilSurface(1024, 1024, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, true, &m_DepthBuffer, NULL);

However, whenever I want to use it for rendering the shadow pass, I keep getting strange artifacts:

SetRenderTarget(0,m_ShadowBuffer);
m_Manager->SetEffectTechnique("shadowPass");
m_lpDevice->GetDepthStencilSurface(&m_OldStencil);
m_lpDevice->SetDepthStencilSurface(m_DepthBuffer);
m_Render->RenderObjects();
m_lpDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
m_lpDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
m_lpDevice->Clear(0, NULL, D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
m_lpDevice->SetDepthStencilSurface(m_OldStencil);
m_OldStencil->Release();
m_Manager->GetEffect(L"Effect.fx")->SetTexture("SceneShadowMap", m_ShadowBuffer);


I tried playing with the positions of clear and set, but all I get is more artifacts.

r6rbekxo.jpg

Does someone knows what I'm doing wrong? I use my auto stencil buffer the same way for my premultiplied-alpha-billboards (shader turns zwrite off and stencil on in both cases). I quess the stencil might be guilty for my glitched shadows..

Share this post


Link to post
Share on other sites


PS_OUTPUT_BUILD psBuild(VS_OUTPUT_BUILD i)
{
PS_OUTPUT_BUILD o;

float4 ProjectedTexCoords;
ProjectedTexCoords.x = i.vTexCoord.x/i.vTexCoord.w/2.0f +0.5f;
ProjectedTexCoords.y = -i.vTexCoord.y/i.vTexCoord.w/2.0f +0.5f;

o.vShadow = tex2D(ShadowSampler, ProjectedTexCoords);
return o;
};



That's the pixel shader you use to render the shadowed scene? If yes then it cannot be right, if I'm not missing something really badly :)

First problem is that you are not really making any color, textures, lighting, anything. But let's presume you know it and this was just a testing PS for shadows.
But even then there's something wrong. You're using tex2D to sample the shadow map, which is 32F format (32bit floating point) and you are directly outputing this value as a color. That doesn't give much sense and also it's not how shadow mapping works - you need to make depth comparison. For each pixel you calculate its distance from the light and compare this value with the value sampled from the shadow map texture. If the point distance is smaller, the point is not in shadow and vice versa.

Share this post


Link to post
Share on other sites
That's the pixel shader you use to render the shadowed scene? If yes then it cannot be right, if I'm not missing something really badly smile.gif[/quote]

Ah, not quite. With this pixel shader I store the shadow map for further treatment. Depth comparison, like you said, happens here:

float3 vWorldPos = tex2D(ScenePositionSampler, i.vTex0).rgb;
float4 vShadowPos = mul(float4(vWorldPos, 1), LightViewProj);
float2 vShadowTex;
vShadowTex.x = vShadowPos.x/vShadowPos.w/2.0f + 0.5f;
vShadowTex.y = -vShadowPos.y/vShadowPos.w/2.0f + 0.5f;

float depth = tex2D(ShadowSampler, vShadowTex).x;
float dist = vShadowPos.z / vShadowPos.w;
float fShadowTerm = (depth >= dist - 0.00005)? 1.0f : 0.0f;


As I said I'm using deferred lighting and so I have to do the actual shading for each and every light, though I still have to cache the shadow map for advanced techniques like blurring the shadow.

First problem is that you are not really making any color, textures, lighting, anything.[/quote]

Hm, here you are quite mistaken. I'm actually using all of it. Lighting works via spotlight, if you look close enough on the second screen you can see the cone of spotlight on the bottom of the screen. You may get the feeling that there is no texture, because this actually represents the peak of a mountain covered in snow. I'm even using some bumpmapping, which doesn't look good as I use the same bump map for all other textures^^

Well, so far nothing wrong with my graphics themselfs. Ah yeah and if you/someone wants to take a deep look into it, here is my whole shader:


float4x3 World;
float4x3 View;
float4x3 ViewInverse;
float4x4 Projection;
float4x4 ViewProjection;
float4x4 WorldViewProj;
float3 CameraPos;
float3 CameraDir;
float4x4 LightViewProj;
float4x4 matTexture;

// light parameters
float3 LightDir;
float4 LightPos;
float4 LightDiffuse;
float4 LightSpecular;
float4 LightAmbient;
float4 LightAttenuation;
float LightTheta;
float LightPhi;
float LightRange;
float LightFalloff;

// material parameters
float4 MaterialDiffuse;
float4 MaterialSpecular;
float SpecularPower;

// textures
texture2D DiffuseMap;
texture2D BumpMap;
texture2D SceneMaterialMap;
texture2D SceneNormalMap;
texture2D ScenePositionMap;
texture2D SceneShadowMap;
texture2D SceneBlurMap;


sampler DiffuseSampler = sampler_state
{
Texture = <DiffuseMap>;

AddressU = Wrap;
AddressV = Wrap;

MagFilter = Linear;
MinFilter = Point;
MipFilter = Linear;
};

sampler BumpSampler = sampler_state
{
Texture = <BumpMap>;

AddressU = Wrap;
AddressV = Wrap;

MagFilter = Linear;
MinFilter = Linear;
MipFilter = Linear;
};

// rendertargets
sampler SceneMaterialSampler = sampler_state
{
Texture = <SceneMaterialMap>;
MagFilter = Point;
MinFilter = Point;
};

sampler SceneNormalSampler = sampler_state
{
Texture = <SceneNormalMap>;
MagFilter = Point;
MinFilter = Point;
};

sampler ScenePositionSampler = sampler_state
{
Texture = <ScenePositionMap>;
MagFilter = Point;
MinFilter = Point;
};

sampler ShadowSampler = sampler_state
{
Texture = <SceneShadowMap>;
MagFilter = Point;
MinFilter = Point;
};

sampler BlurSampler = sampler_state
{
Texture = <SceneBlurMap>;
MagFilter = Point;
MinFilter = Point;
};



struct VS_INPUT_BUILD
{
float4 vPos : POSITION0;
float2 vTex0 : TEXCOORD0;
float3 vNrm : NORMAL0;
float3 vTan : TANGENT0;
float3 vBin : BINORMAL0;
};

struct VS_OUTPUT_BUILD
{
float4 vPos : POSITION0;
float2 vTex0 : TEXCOORD0;
float3 vWorldPos : TEXCOORD1;
float3x3 mTBN : TEXCOORD2;
float4 vTexCoord : TEXCOORD5;
};

struct PS_OUTPUT_BUILD
{
float4 vMaterial : COLOR0;
float4 vWorldNrm : COLOR1;
float4 vWorldPos : COLOR2;
float4 vShadow : COLOR3;
};

VS_OUTPUT_BUILD vsBuild(VS_INPUT_BUILD i)
{
VS_OUTPUT_BUILD o;

o.vWorldPos = mul(i.vPos, World);
o.vPos = mul(float4(o.vWorldPos, 1), ViewProjection);
o.vTex0 = i.vTex0;
float3 vWorldNrm = mul(i.vNrm, World);
o.vTexCoord = mul(mul(i.vPos, World), LightViewProj);

float3 N = normalize(vWorldNrm);
float3 T = normalize(mul(i.vTan, World));
float3 B = normalize(mul(i.vBin, World));

o.mTBN = float3x3(T, B, N);
return o;
};

// psBuild()
// put geometry data into render targets
PS_OUTPUT_BUILD psBuild(VS_OUTPUT_BUILD i)
{
PS_OUTPUT_BUILD o;

float4 vDiffuseMaterial = tex2D(DiffuseSampler, i.vTex0);

o.vMaterial.rgb = vDiffuseMaterial;
o.vMaterial.a = 1.0;

float3 bumpNormal = tex2D(BumpSampler, i.vTex0).rgb;
bumpNormal = 2.0* bumpNormal - 1.0;
bumpNormal = mul(bumpNormal, i.mTBN);
bumpNormal = normalize(bumpNormal);
bumpNormal = 0.5 * bumpNormal + 0.5;

o.vWorldNrm.xyz = bumpNormal;
o.vWorldNrm.w = 1.0;

// position
o.vWorldPos = float4(i.vWorldPos.xyz, 0);

o.vShadow = i.vTexCoord.z/i.vTexCoord.w;
return o;
};

float4 psSpot(PS_INPUT_LIGHT i) : COLOR0
{
float3 vDiffuseMaterial = tex2D(SceneMaterialSampler, i.vTex0).rgb;
float3 vSpecularMaterial = tex2D(SceneMaterialSampler, i.vTex0).a;

// normals are stored in texture space [0,1] -> convert them back to [-1,+1] range
float4 vWorldNrm = tex2D(SceneNormalSampler, i.vTex0);
vWorldNrm.rgb = 2.0 * vWorldNrm.rgb - 1.0;

float3 vWorldPos = tex2D(ScenePositionSampler, i.vTex0).rgb;
float4 vShadowPos = mul(float4(vWorldPos, 1), LightViewProj);
float2 vShadowTex;
vShadowTex.x = vShadowPos.x/vShadowPos.w/2.0f + 0.5f;
vShadowTex.y = -vShadowPos.y/vShadowPos.w/2.0f + 0.5f;

float depth = tex2D(ShadowSampler, vShadowTex).x;
float dist = vShadowPos.z / vShadowPos.w;
float fShadowTerm = (depth >= dist - 0.00005)? 1.0f : 0.0f;

float3 vCameraDir = CameraPos - vWorldPos;
float3 vLightDir = (LightPos - vWorldPos).xyz;
float fLightDist = length(vLightDir);

float spotEffect = 0.0f;
float cosAlpha = dot(normalize(vLightDir), normalize(LightDir));

if(cosAlpha <= LightPhi)
spotEffect = 0.0f;
else if(cosAlpha > LightTheta)
spotEffect = 1.0f;
else
spotEffect = pow(((cosAlpha - LightPhi)/(LightTheta - LightPhi)), LightFalloff);

float4 color;
float fAtten = 1.0/dot(LightAttenuation, float4(1, fLightDist, fLightDist*fLightDist,0));
fAtten *= spotEffect;
float3 vLightDist = normalize(vLightDir);

float3 vDiffuseIntensity = max(0, dot(vLightDist, vWorldNrm));
float3 Reflect = normalize(2 * -vDiffuseIntensity * vWorldNrm - vLightDist);
float shadow = saturate(4* vDiffuseIntensity);
float4 specular = pow(saturate(dot(Reflect, normalize(-vCameraDir))), 8); // R.V^n


color.rgb = (shadow * ( vDiffuseIntensity * LightDiffuse.xyz * vDiffuseMaterial +
vDiffuseMaterial * specular * LightSpecular.xyz) ) *spotEffect *fShadowTerm;

color.a = 1.0;

//color.rgb = lerp(color,float4(0.5, 0.5, 0.5, 0.5),saturate((length(vCameraDir)-10.0f)/(100.0f-10.0f))) * fAtten;

//color.rgb = f;

return color;
};



struct VS_INPUT_SHADOW
{
float4 vPos : POSITION0;
};

struct VS_OUTPUT_SHADOW
{
float4 vPosition : POSITION0;
float4 vDepth : TEXCOORD0;
};

struct PS_OUTPUT_SHADOW
{
float4 vDepth : COLOR0;
};


VS_OUTPUT_SHADOW vsShadow(VS_INPUT_SHADOW i)
{
VS_OUTPUT_SHADOW o;

o.vPosition = mul(float4(mul(i.vPos, World),1) , LightViewProj);
o.vDepth = o.vPosition;

return o;
};

// psBuild()
// put geometry data into render targets
PS_OUTPUT_SHADOW psShadow(VS_OUTPUT_SHADOW i)
{
PS_OUTPUT_SHADOW o;

o.vDepth = i.vDepth.z/i.vDepth.w;

return o;
};



technique buildPass
{
pass p0
{
VertexShader = compile vs_3_0 vsBuild();
PixelShader = compile ps_3_0 psBuild();

ZwriteEnable = true;
CullMode = ccw;
ZFunc = less;
StencilEnable = false;
AlphaBlendEnable = false;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;
}
};

technique shadowPass
{
pass p0
{
VertexShader = compile vs_3_0 vsShadow();
PixelShader = compile ps_3_0 psShadow();

ZwriteEnable = false;
CullMode = ccw;
ZFunc = less;
StencilEnable = true;
AlphaBlendEnable = false;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;
}
};

technique buildPass
{
pass p0
{
VertexShader = compile vs_3_0 vsBuild();
PixelShader = compile ps_3_0 psBuild();

ZwriteEnable = true;
CullMode = ccw;
ZFunc = less;
StencilEnable = false;
AlphaBlendEnable = false;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;
}
};

technique shadowPass
{
pass p0
{
VertexShader = compile vs_3_0 vsShadow();
PixelShader = compile ps_3_0 psShadow();

ZwriteEnable = false;
CullMode = ccw;
ZFunc = less;
StencilEnable = true;
AlphaBlendEnable = false;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;
}
};

technique lightSpot
{
pass p0
{
VertexShader = NULL;
PixelShader = compile ps_3_0 psSpot();

CullMode = none;
Zenable = false;
StencilEnable = false;
AlphaBlendEnable = true;
Srcblend = One;
Destblend = One;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;
}
};


shadowPass to render the shadow map from lights view, buildPass to render to the g-buffer, lightPass to render the deferred light effects.

Share this post


Link to post
Share on other sites

Hm, here you are quite mistaken.


Sorry I didn't notice you were doing deferred lighting ;) Thought it was a simple case.
The picture is just black and while so I thought it was just a badly rendered shadow map with a bad shader.

OK, no ideas then, sorry.

Share this post


Link to post
Share on other sites
The picture is just black and while so I thought it was just a badly rendered shadow map with a bad shader. [/quote]

Well its not quite if you look at the guy and the shrine in the first picture, but never mind, you could have easily overseen it. I would normally draw my skybox, but somehow it isn't working well together with my shading shader..

OK, no ideas then, sorry.
[/quote]

No problem at all ;) I still hope someone figures out or at least can point me some tips, if not, I've ordered a new book about directx which stated to have some shadow mapping in it, and I'm also trying to solve it myself.^^

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!