Deferred shading issues?

Started by
17 comments, last by GameDevGoro 13 years, 10 months ago
Thanks, wiegje85! :)

But yes, I'm well aware of how this all works, and I've read *many* PDFs and that sort of thing.
The problems I am having is with the application itself. Not the theory behind it all. The shader's I've written are not working as I'd expected, OpenGL doing some things differently from DirectX (mostly the world matrix and gl's Modelview) and things of that nature that are confusing the heck out of me.

But I WILL read it again though. Can't hurt. ;)
Advertisement
As Wiegje said, you need to make sure all your data is in the same coordinate space. Store everything either in eyespace or worldspace.
Alright, I actually got to a laptop right now where I could actually *see* your screenshots (was on a mobile phone before).

I look at the second screenshot and I can say with 99% certainty that: the lights are all in each object's relative space. Make sure that everything is in world space (or eye/view space as BertS said (which is the more common space when using deferred lighting)).

Multiply your IN.position with the world matrix of the object. Multiply your IN.normal, IN.tangent, IN.binormal with the world transform (i.e. the float3x3 part of the float4x4) and then do the lighting calculations on it. Then(!) make sure the lights are also in this same space.
Thank you. :)

Yeah I'm trying the best I can to make sure everything is in the same space.

So in my OpenGL code I'm just moving stuff by multiplying it with a custom matrix I'm building based on two vectors, one for rotations and one for positions. And that's it. I'm not keeping track of any world matrix or anything so I'm left with that matrix I'm moving the objects with.

But that is what you mean by referring to the "world matrix of the object" right?

If so, here's a problem with that. When I tried that the other day I had some very unpleasant stuff happen to the depth buffer output.
When I multiplied the In.position with the whole matrix, like I'm supposed to, it turned the output completely white. As soon as I removed the rotation part from the matrix and left those as identity the output went back to how it was before that multiplication, but even then the two objects with different positions and rotations displayed no change at all.
Any idea of what would cause the "white-out"?

And which one of these approaches (depth VS position) is easiest to implement?
I'm likely to try to implement the easiest first.
Because I'm pretty tired of fighting with this now I just want it to work, even if it does so poorly.
I'm sorry but to me it sounds like you need to get your scene graph working first :) I think you're a bit too eager to get working on pretty things when your base is not properly setup yet.

To me it sounds like - and I can be completely wrong - that you don't have a proper hierarchy in your scene. Get your head around the concept of relative and absolute space first. I know this can be quite a big thing to get your head around; it took me the greater part of the last two years to get it. Then again, I'm no math genious, I just happen to know where to apply what.

So concern yourself with the basics first, then you shall see that suddenly your shaders will work properly :)
Thanks, wiegje85. :)

There's some truth in your words. But I'm not completely new to relative and absolute spaces as they are.
I'm just a little new to dealing with these spaces inside shaders, and since I don't know what these spaces should look like in the output. >.<
And simply because deferred rendering has a few ways to do some of the things, it makes it harder to know if you've done something right or wrong. :S

But yeah OK, I'll take it easy for a while and work on some other stuff in the engine. I'll admit defeat this time, next time, though, I will be victorious! xD

Oh yeah, before I go. I'm not going to get by without any lighting at all so I'm going to assume forward rendering is the next best thing to deferred rendering.
So correct me if I am wrong- There IS a way to blend a lot of lights with forward rendering too, right? Say, like... Uh... Let's say 32 lights.
You could do that with forward rendering?
I know the performance wouldn't be to much speak of but I am not constrained to the old 8-lights-active-at-once-thing right?
just get this to work! you're but a multiplication or two away from working deferred shading, why give up now? forward rendering is SO 1995... ;)
I'm not talking about giving up exactly but it is apparent I don't know as much about matrices as I thought, especially in conjunction with shaders.
So I'm going to have to study OpenGL's matrices a fair bit, and how those tie in compared to DirectX's.
I'm also going to have to cram my head with the CG shader language details so I get a better idea of how these actually work compared to HLSL and GLSL. Though the difference hasn't been unbelievable yet, there just might be something I'm missing.

I'm sure I'll get this to work some day, but I'm no genius so it could take a while. ;P
Hello again.

I thought I'd just pop back in and say I got it to work. :D
And the answer was what you all said it was... *clears throat* Right...

I have this looming feeling that it's going to break down, it's just a matter of time, BUT at least I can put this behind me (for now) and continue working on some other stuff.

So thank you all! :D

This topic is closed to new replies.

Advertisement