Я включил MultiSample: < /li>
< /ol>
Код: Выделить всё
glfwWindowHint(GLFW_SAMPLES, 4);
glEnable(GL_MULTISAMPLE);
< /code>
Настройка кадры и текстуры глубины: < /li>
< /ol>
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
unsigned int depthMapFBO;
glGenFramebuffers(1, &depthMapFBO);
// create depth texture
unsigned int depthMapTexture;
glGenTextures(1, &depthMapTexture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, depthMapTexture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, GL_TRUE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, depthMapTexture, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
< /code>
3.configuredessessessessed Debin Framebuffer and Texture: < /p>
GLuint resolveFramebuffer;
glGenFramebuffers(1, &resolveFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, resolveFramebuffer);
// resolve texture
GLuint resolvedDepthTexture;
glGenTextures(1, &resolvedDepthTexture);
glBindTexture(GL_TEXTURE_2D, resolvedDepthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, resolvedDepthTexture, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Код: Выделить всё
glBindFramebuffer(GL_READ_FRAMEBUFFER, depthMapFBO);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolveFramebuffer);
glBlitFramebuffer(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT, 0, 0, SHADOW_WIDTH, SHADOW_HEIGHT, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Что я сделал не так?
Подробнее здесь: https://stackoverflow.com/questions/794 ... tisampling