Jump to content
  • Advertisement
DividedByZero

DX11 Depth shadow mapping question

Recommended Posts

That step is only necessary if it isn't sufficient to use the depth as-is, as written by the output merger into the depth-stencil target, or if you need to cut holes into your geometry (alpha-testing), for example. Either way, the colour output isn't important in our case.

Edited by pcmaster

Share this post


Link to post
Share on other sites
Advertisement

Hi, DividedByZero, I took a look at you project and was able to get the shadows working.

The main issue seems to be in vs_shadow.hlsl, lines 43-45:

output.lightViewPosition = mul(input.position, matWorld);
output.lightViewPosition = mul(output.position, matLightView);
output.lightViewPosition = mul(output.position, matLightProjection);

Instead of output.position it should really be output.lightViewPosition. Otherwise you're not getting a correct light-space position in the corresponding fragment shader; looks like a copy-paste error.

However, I also had to move the camera

float camX = 10.0f;
float camY = 5.0f;
float camZ = -3.0f;

and increase the width and height of the light's ortho projection to get this result.

shadow.PNG

EDIT: was looking back through the thread and saw that blicili already pointed this out a while ago:)

Edited by dietrich

Share this post


Link to post
Share on other sites

@dietrich good catch! I went through that shader several times and just didn't see the copy-pasta at midnight :)

Edited by pcmaster

Share this post


Link to post
Share on other sites

Oh man, you guys are absolute legends.

	output.lightViewPosition = mul(output.lightViewPosition, matLightView);
	output.lightViewPosition = mul(output.lightViewPosition, matLightProjection);

A two line change and it worked. 

Yeah, I knew the light camera would need some tweaking and anticipated a close up cut out, which happened with my default positioning. So that's cool.

I don't know how many times I looked at that shader trying various things. Even double and triple checking those calculations.

I rewrote the project from scratch four times being extremely meticulous as to what each step did. Yes, a bit of copy/paste of code that I was sure was working having scrutinised each line. LOL.

If nothing else, I understand each individual step a hell of a lot more than I would have if it worked first time. SO there is always a bright side. :)

Thanks once again, it is truly huge of you guys (and everyone who helped out).

Edited by DividedByZero

Share this post


Link to post
Share on other sites

Hey guys, just a quick update.

I borrowed the model from Unreal Engine and things are working awesomely.

0cDWF6d.png

Thanks again. Couldn't have done it without your help. 😎

Share this post


Link to post
Share on other sites

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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!