I have a shader 1 depth map texture attached to it.
glGenFramebuffers(1, &depthMapFrameBuffer);
glGenTextures(1, &depthMapTexture);
glBindTexture(GL_TEXTURE_2D, depthMapTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,depthMapTextureSize, depthMapTextureSize, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFrameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMapTexture, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
App::checkFrameBufferError(__FILE__,__LINE__);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
std::cerr << "Framebuffer not complete!" << std::endl;
}
Scene::debugTextures[5] = depthMapTexture;
#version 400 core
layout (location = 0) in vec3 ModelSpaceVertexPosition;
uniform mat4 LightSpaceMatrix;
uniform mat4 ModelMatrix;
uniform mat4 CameraSpaceTransformMatrix;
//uniform mat4 CameraSpaceScaleMatrix;
void main(){
//todo bug here.. translate to sorun yok ama scale yara rotasyon olmussa camera space matrixi kayiyor. kameraya gore translate oluyorlar
gl_Position = LightSpaceMatrix * CameraSpaceTransformMatrix * ModelMatrix * vec4(ModelSpaceVertexPosition, 1.0);
}
Is it possible to have more than 1 depth texture attached to different LightSpaceMatrix
es in one shader?
Or should I do it in different frame buffers?