OpenGL not drawing nearest fragment to the camera
up vote
1
down vote
favorite
I have a scene with a teapot mesh in it.
I'm using a framgment shader to light it using a source of light whose value is equal to 10.
When the scene is rendered to the default framebuffer, everything seems to be fine.
But, if it's rendered in a custom framebuffer, the result looks like this :
OpenGL seems to prefer triangles defined "at the end of" the mesh.
I want the framebuffer to contain 16bits floats
so I can store values larger than 1.0
.
Sorry for my English.
opengl mesh fragment-shader framebuffer
add a comment |
up vote
1
down vote
favorite
I have a scene with a teapot mesh in it.
I'm using a framgment shader to light it using a source of light whose value is equal to 10.
When the scene is rendered to the default framebuffer, everything seems to be fine.
But, if it's rendered in a custom framebuffer, the result looks like this :
OpenGL seems to prefer triangles defined "at the end of" the mesh.
I want the framebuffer to contain 16bits floats
so I can store values larger than 1.0
.
Sorry for my English.
opengl mesh fragment-shader framebuffer
1
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall usingglClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
1
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a scene with a teapot mesh in it.
I'm using a framgment shader to light it using a source of light whose value is equal to 10.
When the scene is rendered to the default framebuffer, everything seems to be fine.
But, if it's rendered in a custom framebuffer, the result looks like this :
OpenGL seems to prefer triangles defined "at the end of" the mesh.
I want the framebuffer to contain 16bits floats
so I can store values larger than 1.0
.
Sorry for my English.
opengl mesh fragment-shader framebuffer
I have a scene with a teapot mesh in it.
I'm using a framgment shader to light it using a source of light whose value is equal to 10.
When the scene is rendered to the default framebuffer, everything seems to be fine.
But, if it's rendered in a custom framebuffer, the result looks like this :
OpenGL seems to prefer triangles defined "at the end of" the mesh.
I want the framebuffer to contain 16bits floats
so I can store values larger than 1.0
.
Sorry for my English.
opengl mesh fragment-shader framebuffer
opengl mesh fragment-shader framebuffer
asked Nov 10 at 19:50
Elirovi
1048
1048
1
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall usingglClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
1
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24
add a comment |
1
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall usingglClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
1
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24
1
1
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall using
glClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall using
glClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
1
1
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I forgot to add a depth renderBuffer and clear it using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
To do so, add :
GLuint rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width(), height());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
to your framebuffer implementation while it's bound.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I forgot to add a depth renderBuffer and clear it using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
To do so, add :
GLuint rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width(), height());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
to your framebuffer implementation while it's bound.
add a comment |
up vote
1
down vote
accepted
I forgot to add a depth renderBuffer and clear it using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
To do so, add :
GLuint rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width(), height());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
to your framebuffer implementation while it's bound.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I forgot to add a depth renderBuffer and clear it using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
To do so, add :
GLuint rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width(), height());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
to your framebuffer implementation while it's bound.
I forgot to add a depth renderBuffer and clear it using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
To do so, add :
GLuint rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width(), height());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
to your framebuffer implementation while it's bound.
answered Nov 10 at 20:29
Elirovi
1048
1048
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242809%2fopengl-not-drawing-nearest-fragment-to-the-camera%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Probably you don't attach a depth buffer to the framebuffer.
– Rabbid76
Nov 10 at 20:06
Oh. You're probably right. I didn't think of that. I'll do it right now.
– Elirovi
Nov 10 at 20:11
@Rabbid76, I just added and attached a depth renderBuffer to my framebuffer and now I'm not getting any result
– Elirovi
Nov 10 at 20:19
Ok I just found out what I did wrong : I forgot to clear the depth buffer in the drawcall using
glClear(GL_COLOR_BUFFER_BIT | **GL_DEPTH_BUFFER_BIT**);
– Elirovi
Nov 10 at 20:21
1
Possibly someone would've pointed that out, if you would've added any code to the question. Please read How to create a Minimal, Complete, and Verifiable example.
– Rabbid76
Nov 10 at 20:24