This would look something like this:įor(unsigned int i = 0 i shadowTransforms One (quite obvious) way to do this, is render the scene 6 times with 6 different view matrices, each time attaching a different cubemap face to the framebuffer object. To create a cubemap of a light's surrounding depth values we have to render the scene 6 times: once for each face.
What makes this technique a bit more difficult is the depth cubemap generation. Most of the complicated stuff we've already discussed in the shadow mapping chapter.
The generated depth cubemap is then passed to the lighting fragment shader that samples the cubemap with a direction vector to obtain the closest depth (from the light's perspective) at that fragment.
NO MANS SKY DOES SUPPORT OPENGL 4.1 FULL
The depth map we need requires rendering a scene from all surrounding directions of a point light and as such a normal 2D depth map won't work what if we were to use a cubemap instead? Because a cubemap can store full environment data with only 6 faces, it is possible to render the entire scene to each of the faces of a cubemap and sample these as the point light's surrounding depth values. The main difference between directional shadow mapping and omnidirectional shadow mapping is the depth map we use. The technique is mostly similar to directional shadow mapping: we generate a depth map from the light's perspective(s), sample the depth map based on the current fragment position, and compare each fragment with the stored depth value to see whether it is in shadow. This chapter builds upon the previous shadow mapping chapter so unless you're familiar with traditional shadow mapping it is advised to read the shadow mapping chapter first. This technique is known as point (light) shadows or more formerly as omnidirectional shadow maps. The technique we're using is perfect for point lights as a real point light would cast shadows in all directions. What this chapter will focus on is the generation of dynamic shadows in all surrounding directions. It is therefore also known as directional shadow mapping as the depth (or shadow) map is generated from only the direction the light is looking at. It works great, but it's mostly suited for directional (or spot) lights as the shadows are generated only in the direction of the light source. In the last chapter we learned to create dynamic shadows with shadow mapping. Point Shadows Advanced-Lighting/Shadows/Point-Shadows