One of the things I see in there is CameraPosition, which would definitely be a useful thing rather than passing in the camera position for some things. However, when I use it, it seems like it’s never filled and I’m always getting (0, 0, 0). I’ve added it to the parameters in my MatDef, and it’s set in GLSL as a uniform vec3. I’ve tried prefixing it with both g_ and m_ and both have the same results. Does this uniform not work anymore, am I missing something stupidly obvious, or is this some kinda bug?
I’ve been messing with parallax and trying to implement it with my deferred rendering (which will already prove quite difficult due to the nature of deferred rendering). This is really my only hang-up, instead of having to pass in the camera position for every object in the scene manually.
All global uniforms are prefixed with g_… so this:
uniform vec3 m_CameraPosition;
Should be:
uniform vec3 g_CameraPosition;
…which will be available in DLighting.vert and DLighting.frag but not the other shaders (because they don’t have CameraPosition in their WorldParameters).
stick a breakpoint in the UniformBindingManager in the ‘Case CameraPosition’ statement, to make sure it is actually being called, and is what you expect.
If for some reason it doesn’t work (I never tried tbh), you can also just get the translation component of g_ViewMatrixInverse.
@vinexgames said:
@wezrule That might prove a bit easier, I'll probably give that a shot.
If you can’t get CameraPosition working then you will likely run into the exact same problem.
@vinexgames said:
@pspeed Hmm. Maybe I broke something? Or maybe it's working flawlessly and I'm just crazy. I'll figure something out.
Well, I told you what was wrong with the code you posted. If you fix that and it still doesn’t work then post that code too.
Is your camera actually moving or are you moving the world instead? In that case, camera position and the translation of view matrix inverse will be 0,0,0 anyway.