• entries
    743
  • comments
    1924
  • views
    580068

Shadow Mapping part 2

Sign in to follow this  
Aardvajk

1237 views

Untitled.jpg

Painfully slow progress as is normal for me, but the shadow mapping experiment continues well. I'm trying very hard to make sure I understand everything properly rather than just copy-paste code, hence the snail-like pace.

I've combined the shadow map with standard normal-based lighting now. I pass the diffuse value from the vertex shader into the pixel shader then reduce the diffuse value down to the ambient minimum if the pixel is in shadow, ensuring that the shadow colours are the same as a face recieving no direct light.

I'm using the method of rendering back-faces only into the shadow buffer as it produces less artifacts and have to say that when combined with normal diffuse lighting, it produces excellent results. The next step is to figure out why the pixels for the shadow are so large and implement something like PCF to smooth them out, although I suspect there is something more fundamental wrong at the moment that just the lack of a smoothing function and need to investigate that first.

But good progress nonetheless, considering that I do feel I've actually implemented every step of this rather than just copied code from a tutorial. All good fun.

[EDIT] So found out why the pixels were so large. :)

[source]

int size = 256;

depthTexture.acquire(graphics, 256, 256, D3DFMT_R32F, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT);
[/source]

Turns out when you write code like that, it doesn't actually make much difference when you change the value of size. Doh!

With a 1024x1024 depth texture, I now get the kind of size of shadow pixels I'd expect, so now on to PCF I guess.
Sign in to follow this  


3 Comments


Recommended Comments

Well, this is DX9 so not even sure what an FBO is - an OpenGL thing?

It seems the pixelly thing is unaffected by either increasing the size of the shadow map or tightening the near/far planes of the projection, which seem to be the solutions I've read about so I think maybe something else is at fault somewhere in my shader pipeline.

Share this comment


Link to comment
Yeah sorry, FBO = Frame Buffer Object (OpenGL) Didn't even think what your using :-) Woops...

yeah maybe your shadowmap lookup is wrong in the shader?

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now