Dear forum,
I am trying to implement Shadowmapping into my program. I just tried to implement and rendering to FBO’s at all but it does not work. I’ve read some tutorials and i copied their code
for generating FBOs. The Texture will eventually be rendered on to a Quad. Below is the Code i am currently working with.
(JavaCode)
buffer = GL30.glGenFramebuffers();
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, buffer);
int tex = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 1024,768, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
int depthBuffer = GL30.glGenRenderbuffers();
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBuffer);
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, 1024,768);
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthBuffer);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, tex, 0);
GL20.glDrawBuffers(GL30.GL_COLOR_ATTACHMENT0);
GuiTexture text = new GuiTexture(tex, new Vector2f(), new Vector2f(1,1));
GuiSystem.addGuiElement(text);
System.out.println((GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE));
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
These 2 lines are for displaying the texture.
GuiTexture text = new GuiTexture(tex, new Vector2f(), new Vector2f(1,1));
GuiSystem.addGuiElement(text);
I do not want to implement Shadowmapping directly. At first i want to be able to render my scene to a texture but this is not working.
My render call looks like this:
L11.glViewport(0,0,1024,768);
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, buffer);
TerrainSystem.render(lights,c);
EntitySystem.render(lights, c);
EntityNormalSystem.render(lights,c);
InstancedEntitySystem.render(lights, c);
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
GL11.glViewport(0,0,1920,1080);
GuiSystem.render();
If i remove the
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, buffer);
and
GuiSystem.render();
it renders my scene the way it should be. But with it i only see black.
I would be very happy if someone could help me solve my problem
Greetings, Finn