• Create Account

### #Actuald0nuts

Posted 21 January 2013 - 09:37 PM

Thanks for the response!

I don’t know what you mean by this being the only thing you are “getting”. This is the only region over which you are not drawing blue. See image.

I am rendering a single quad that should cover up the whole screen exactly. If I use a fragment shader that just outputs a single color, it fills the screen completely. But when I multiply the vertex coordinates by model view projection matrix, store them, and then check in the fragment shader if they are exactly the screen (0 < x < 720 and 0 < y < 480) only the top right half projects into this. I am misunderstanding something about the projection?

(0.5f, 0.5f) and (1.0f, 1.0f) also return 0. Maybe I am setting something up wrong:

// Creation

glGenTextures(1, &depthTexture);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT , 0);
glBindTexture(GL_TEXTURE_2D, 0);

...

// Attach to fbo

glGenFramebuffersEXT(1, &depthFramebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);

checkStatus() <-- returns complete okay!

// Bind to fbo, render scene once, then switch back to default

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

renderHWLoop();

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

...

//switch to visualizing programs

//eventually these get called

fragmentDepthText = cgGetNamedParameter(fragmentProgram, "depthTex");

cgGLSetTextureParameter(fragmentDepthText, depthTexture);

### #1d0nuts

Posted 21 January 2013 - 09:36 PM

Thanks for the response!

I don’t know what you mean by this being the only thing you are “getting”. This is the only region over which you are not drawing blue. See image.

I am rendering a single quad that should cover up the whole screen exactly. If I use a fragment shader that just outputs a single color, it fills the screen completely. But when I multiply the vertex coordinates by model view projection matrix, store them, and then check in the fragment shader if they are exactly the screen (0 < x < 720 and 0 < y < 480) only the top right half projects into this. I am misunderstanding something about the projection?

(0.5f, 0.5f) and (1.0f, 1.0f) also return 0. Maybe I am setting something up wrong:

// Creation

glGenTextures(1, &depthTexture);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT , 0);
glBindTexture(GL_TEXTURE_2D, 0);

...

// Attach to fbo

glGenFramebuffersEXT(1, &depthFramebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0); checkStatus() <-- returns complete okay! // Bind to fbo, render scene once, then switch back to default glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderHWLoop(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); ... //switch to visualizing programs //eventually these get called fragmentDepthText = cgGetNamedParameter(fragmentProgram, "depthTex"); cgGLSetTextureParameter(fragmentDepthText, depthTexture);

PARTNERS