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 3ad81df commit 96a8bef
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,31 +161,35 @@ unsigned int ERS_CLASS_DepthMaps::AllocateDepthMapIndex(unsigned int Framebuffer

}

ERS_STRUCT_DepthMap ERS_CLASS_DepthMaps::GenerateDepthMap(bool LogEnable) {
ERS_STRUCT_DepthMap ERS_CLASS_DepthMaps::GenerateDepthMap(int Number, bool LogEnable) {


SystemUtils_->Logger_->Log(std::string("Creating Depth Map With Resolution Of ") + std::to_string(DepthTextureArrayWidth_) + std::string("x") + std::to_string(DepthTextureArrayHeight_), 5, LogEnable);
SystemUtils_->Logger_->Log(std::string("Creating ") + std::to_string(Number) + std::string(" Depth Map(s) With Resolution Of ") + std::to_string(DepthTextureArrayWidth_) + std::string("x") + std::to_string(DepthTextureArrayHeight_), 5, LogEnable);

// Setup Struct
ERS_STRUCT_DepthMap Output;

// Generate FBO
SystemUtils_->Logger_->Log("Generating Framebuffer Object", 4, LogEnable);
glGenFramebuffers(1, &Output.FrameBufferObjectID);
SystemUtils_->Logger_->Log("Generated Framebuffer Object", 3, LogEnable);
// Iterate Over Total Quantity To Be Generated
for (unsigned int i = 0; i < Number; i++) {

// Allocate Depth Map Texture ID
Output.DepthMapTextureIndexes[0] = AllocateDepthMapIndex(Output.FrameBufferObjectID);
// Generate FBO
SystemUtils_->Logger_->Log("Generating Framebuffer Object", 4, LogEnable);
glGenFramebuffers(1, &Output.FrameBufferObjectID);
SystemUtils_->Logger_->Log("Generated Framebuffer Object", 3, LogEnable);

// Attach Depth Map Texture To Framebuffer
SystemUtils_->Logger_->Log(std::string("Attaching Depth Map Texture To Framebuffer Texture '") + std::to_string(Output.DepthMapTextureIndex) + std::string("'"), 4, LogEnable);
glBindFramebuffer(GL_FRAMEBUFFER, Output.FrameBufferObjectID);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, DepthTextureArrayID_, 0, Output.DepthMapTextureIndex);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
SystemUtils_->Logger_->Log("Finished Attaching Texture To Framebuffer", 3, LogEnable);
// Allocate Depth Map Texture ID
Output.DepthMapTextureIndexes[0] = AllocateDepthMapIndex(Output.FrameBufferObjectID);

// Attach Depth Map Texture To Framebuffer
SystemUtils_->Logger_->Log(std::string("Attaching Depth Map Texture To Framebuffer Texture '") + std::to_string(Output.DepthMapTextureIndex) + std::string("'"), 4, LogEnable);
glBindFramebuffer(GL_FRAMEBUFFER, Output.FrameBufferObjectID);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, DepthTextureArrayID_, 0, Output.DepthMapTextureIndex);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
SystemUtils_->Logger_->Log("Finished Attaching Texture To Framebuffer", 3, LogEnable);

}

Output.Initialized = true;

Expand Down

0 comments on commit 96a8bef

Please sign in to comment.