Skip to content

Commit

Permalink
Implement Point Light Shadows (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
datacrystals committed Jun 14, 2022
1 parent 223d4e5 commit 7fa2121
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,26 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC
ShadowTransforms.push_back(ObjectProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0, 1.0), glm::vec3(0.0,-1.0, 0.0)));
ShadowTransforms.push_back(ObjectProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0,-1.0), glm::vec3(0.0,-1.0, 0.0)));

// Render All Sides
for (unsigned int i = 0; i < ShadowTransforms.size(); i++) {

// Render With Depth Shader
DepthShader->MakeActive();
DepthShader->SetMat4("LightSpaceMatrix", ObjectSpace);
// Render With Depth Shader
DepthShader->MakeActive();
DepthShader->SetMat4("LightSpaceMatrix", ShadowTransforms[i]);

if (LightSpaceMatrix != nullptr) {
*LightSpaceMatrix = ObjectSpace;
}
if (LightSpaceMatrix != nullptr) {
*LightSpaceMatrix = ObjectSpace;
}

glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_);
glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectIDs[0]); // fix this later
glClear(GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
Renderer_->RenderSceneNoTextures(TargetScene, DepthShader);
glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_);
glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectIDs[0]); // fix this later
glClear(GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
Renderer_->RenderSceneNoTextures(TargetScene, DepthShader);

glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);

}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
struct ERS_STRUCT_DepthMap {

std::vector<unsigned int> FrameBufferObjectIDs; /**<OpenGL Depth Map FBO ID, Multiple to support point lights*/

std::vector<int> DepthMapTextureIndexes; /**<OpenGL Depth Map Texture Index In 2D Array, Multiple To Support CubeMaps For Point Lights*/
std::vector<glm::mat4> TransformationMatricies; /**<Used to store the transformation matrix for every index used in the matrix*/

bool Initialized = false; /**<Indiciates If The Target Is Initialized Or Not*/

};

0 comments on commit 7fa2121

Please sign in to comment.