The other evening I decided to set out to create shadows for a 3D scene using shadow mapping as it's something I hadn't done before and is very common in games, animation and basically anything rendered in 3D. For anyone who doesn't know how shadow mapping works, I'll quickly explain. Rather than just rendering a frame from the camera's perspective and performing all your pixel operations and send that frame to the screen, you create a "shadow map" from the perspective of the light (or lights but let keep this very simple for now) in the scene then from the cameras perspective. Now when you are doing your pixel operations you also compare the depth from the shadow map and the current depth buffer, if the pixel from the camera to further away than from the light it's in shadow. Now you know if the pixel is in shadow or not.
If the pixel is in shadow then you can apply a factor to make the output colour result darker, this can be done easily with a scalar; such as a float that equals 0.5. Depending on the approach taken there are different ways to calculate this scalar.
I'm going to write another post in the next few weeks that will go into more detail how you can implement this in C++ and OpenGL.
© 2016 Lewis Ward. All rights reserved.
Software Engineer at Improbable, credited on Mavericks: Proving Grounds (PC - Alpha) and Deceit (PC). Formerly working at Automaton Games and Graduate from Bournemouth University