My game still uses shadow volumes (think doom 3), it was easy to implement, to get something working but they are prone to various rendering faults and issues, use the obsolete stencil buffer, and generally look bad.
I want to transition to shadow mapping, i got the shaders infrastructure in engine and got as far to render a scene depth buffer to a frame buffer object into texture - so the framebuffer part. I can also render a color buffer in order to test things.
What i want right now is basic global illumination, so i've looked up some tutorials and what i need is a orthographic view projection of a rendering from light point of view.
So.. i assume that this has to be rendered by taking center of my world where camera is currently, then creating 2 imaginary points (sun origin and sun lookat points ), this will result in 2 matrixes - modelview matrix (looking from sun towards world) and projection matrix (ortho matrix).
But how does the vector for sun get calculated? do the relation between position even matter? does "orientation" during lookat for the light matter?
This is the tutorial i use as a base: http://www.opengl-tutorial.org/inter...asic-shadowmap
For the modelview they just use this, is this esentially going from 0.5, 2, 2 towards 0,0,0 ?
glm::vec3 lightInvDir = glm::vec3(0.5f,2,2);
glm::mat4 depthViewMatrix = glm::lookAt(lightInvDir, glm::vec3(0,0,0), glm::vec3(0,1,0));
So.. the final depthMVP is then used in shader in both steps: light output render and shadow apply - nothing else needs to be done? s this complex only in my head?
Bookmarks