Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void setupShadowFrameBuffer()
- {
- if (usedShadowDepthBuffers == 0)
- {
- return;
- }
- if (sfb != 0)
- {
- glDeleteFramebuffersEXT(sfb);
- GlStateManager.deleteTextures(sfbDepthTextures);
- GlStateManager.deleteTextures(sfbColorTextures);
- }
- sfb = glGenFramebuffersEXT();
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, sfb);
- glDrawBuffer(GL_NONE);
- glReadBuffer(GL_NONE);
- glGenTextures((IntBuffer) sfbDepthTextures.clear().limit(usedShadowDepthBuffers));
- glGenTextures((IntBuffer) sfbColorTextures.clear().limit(usedShadowColorBuffers));
- //printIntBuffer(sfbDepthTextures);
- //printIntBuffer(sfbColorTextures);
- sfbDepthTextures.position(0);
- sfbColorTextures.position(0);
- // depth
- for (int i = 0; i < usedShadowDepthBuffers; ++i)
- {
- GlStateManager.bindTexture(sfbDepthTextures.get(i));
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- int filter = shadowFilterNearest[i] ? GL_NEAREST : GL_LINEAR;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
- if (shadowHardwareFilteringEnabled[i])
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadowMapWidth, shadowMapHeight, 0, GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (FloatBuffer) null);
- }
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, sfbDepthTextures.get(0), 0);
- checkGLError("FT sd");
- // color shadow
- for (int i = 0; i < usedShadowColorBuffers; ++i)
- {
- GlStateManager.bindTexture(sfbColorTextures.get(i));
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- int filter = shadowColorFilterNearest[i] ? GL_NEAREST : GL_LINEAR;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shadowMapWidth, shadowMapHeight, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (ByteBuffer) null);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, sfbColorTextures.get(i), 0);
- checkGLError("FT sc");
- }
- GlStateManager.bindTexture(0);
- if (usedShadowColorBuffers > 0)
- {
- //glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glDrawBuffers(Shaders.sfbDrawBuffers);
- }
- int status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
- {
- printChatAndLogError("[Shaders] Error: Failed creating shadow framebuffer! (Status " + status + ")");
- }
- else
- {
- SMCLog.info("Shadow framebuffer created.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement