Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - oli3012

Pages: [1]
1
General Discussion / Accessing the depth buffer in GLSL
« on: December 16, 2009, 07:43:00 AM »
Hi! I am currently trying to implement DOF in GeeXLab 0.1.14, but I am unable to access the Depth Buffer. I started from a shader of the shader library, and that's what my code looks like:

       <render_texture name="sceneBuffer" type="FRAMEBUFFER" >
      <attach_texture_depth pixel_format="DEPTH"/>
      <attach_render_buffer type="DEPTH" />
   </render_texture>


   <post_processing name="MainPostProcessing">
      <effect name="Dream_Effect">
         <phase name="Dream_Effect_Phase">
            <step name="_1" target="FRAMEBUFFER" gpu_shader="DreamShader" >
               <texture render_texture="sceneBuffer" render_texture_type="DEPTH" render_texture_index="0" />
            </step>
         </phase>
      </effect>
   </post_processing>


   <shader_program name="DreamShader" >
      <constant_1i name="sceneTex" value="0" />
      <raw_data><![CDATA[   
[Vertex_Shader]
void main(void)
{
  gl_Position = ftransform();
  gl_TexCoord[0] = gl_MultiTexCoord0;
}
[Pixel_Shader]
uniform sampler2D sceneTex; // 0
void main()
{
  vec2 uv = gl_TexCoord[0].xy;
  float c = texture2D(sceneTex, uv);
 
  gl_FragColor = c == 0.0 ? vec4(1.0) : vec4(0.0);
}
      ]]></raw_data>
   </shader_program>


My screen is completely white, which means that the depth of every pixel is equal to 0... Could someone see if I made an error here, or send me a piece of code that can access the depth buffer ? Thank you for your help!

Pages: [1]