- Add lightmaps to the main shader (currently only OpenGL)

- Create a version of CreateIndexedSectorVertices that works with lightmap sectors
This commit is contained in:
nashmuhandes 2021-09-24 16:56:15 +08:00
commit 2f8cff90b6
12 changed files with 166 additions and 11 deletions

View file

@ -364,6 +364,29 @@ void OpenGLFrameBuffer::BlurScene(float amount)
GLRenderer->BlurScene(amount);
}
void OpenGLFrameBuffer::InitLightmap(FLevelLocals *Level)
{
if (Level->LMTextureData.Size() > 0)
{
GLint activeTex = 0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
glActiveTexture(GL_TEXTURE0 + 17);
if (GLRenderer->mLightMapID == 0)
glGenTextures(1, (GLuint*)&GLRenderer->mLightMapID);
glBindTexture(GL_TEXTURE_2D_ARRAY, GLRenderer->mLightMapID);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB16F, Level->LMTextureSize, Level->LMTextureSize, Level->LMTextureCount, 0, GL_RGB, GL_HALF_FLOAT, &Level->LMTextureData[0]);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
glActiveTexture(activeTex);
Level->LMTextureData.Reset(); // We no longer need this, release the memory
}
}
void OpenGLFrameBuffer::SetViewportRects(IntRect *bounds)
{
Super::SetViewportRects(bounds);