Jump to content

  • Log In with Google      Sign In   
  • Create Account


d0nuts

Member Since 21 Jan 2013
Offline Last Active Feb 20 2013 09:15 PM
-----

Posts I've Made

In Topic: Framebuffer - render to texture trouble

28 January 2013 - 11:21 AM

So the problem was using all of the EXT functions and variables instead of the normal ones (ex. glBindFramebufferEXT() instead of glBindFramebuffer() ).


In Topic: Sampling depth texture

22 January 2013 - 09:27 PM

Awesome! Thank you!


In Topic: Sampling depth texture

22 January 2013 - 10:05 AM

Found it! Apparently there is something called cgEnableTextureParameter(). I don't understand why you would set a texture parameter but not have it enabled :/

But my question about the projection still stands!

In Topic: Sampling depth texture

22 January 2013 - 09:46 AM

Sorry for the confusion. Let me try rewording it. With the simplest shader just outputing a color, it fills the screen. But when I project the points by multiplying by the modelviewproj and check if they are within the bounds of the screen, only the top corner projects into this range. Am I misunderstanding something about projection?

 

And I tried this fragment shader with just pass-through texture coordinates and am still getting all black.

 

ShadowVisualDataPixelOutput ret;

float depth = tex2D(depthTex, pdi.texture).x;
if (depth == 0.0f) {
	ret.color = float4(0,0,0,0);
	return ret;
} else {
	ret.color = float4(depth, depth, depth, 1);
	return ret;
}

In Topic: Sampling depth texture

21 January 2013 - 09:36 PM

Thanks for the response! smile.png

 

 

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