Color and Depth buffers to same fragment

Hi all!
I’ve seen lots of tutorials that show how to send multiple color texture from 1 FBO to a fragment shader but none about my problem.
I’m trying to send both a color buffer and the depth buffer of a FBO to a fragment shader, and Actually, I success to send either 1 or the other, but not together.
I’m initializing well (I believe, since I can modify the Texture i’m sending by changing

glBindTexture(GL_TEXTURE_2D, visibilityFBO.getColorTexture());

to

glBindTexture(GL_TEXTURE_2D, visibilityFBO.getDepthTexture());

).
In the fragment, I have

uniform sampler2D screenTexture;
uniform sampler2D depthTexture;

but the 2 are fill with the same texture (depth or color). Even with trying to use
glActiveTexture(GL_DEPTH) after glActiveTexture(GL_TEXTURE0), it doesn’t work. I’m lost, here :confused:
Can someone help me understand how I can make it?

Thanks a lot!! :slight_smile:
EDIT : Problem solved… after 3 days working on the subject, I found the subject 1 hour after having post the post… The way to do it is


                glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, visibilityFBO.getColorTexture()); 
		glUniform1i(glGetUniformLocation(visibilityPassShader.Program, "positionTexture"), 0);
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_2D, visibilityFBO.getDepthTexture());
		glUniform1i(glGetUniformLocation(visibilityPassShader.Program, "depthTexture"), 1);

you may find these sites interesting:
https://www.khronos.org/opengl/wiki/Sampler_(GLSL)#Shadow_samplers
https://www.khronos.org/opengl/wiki/Sampler_Object#Comparison_mode

you can set these texture binding points directly in the shader source without calling “glUniform1i(…)”, using “layout qualifier”:
https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)#Binding_points

example:

layout (binding = 0) uniform sampler2D positionTexture;
layout (binding = 1) uniform sampler2D depthTexture;

Thanks for your links, I’ll take a look at them!

I believe it requires OpenGL4 or more, since i’m using openGL3.3 (I want my program to work with a maximum number of station), I can’t use it. But it is good to know!
Thanks again :slight_smile: