Results 1 to 5 of 5

Thread: Compute shader and GL_TEXTURE_2D_ARRAY

  1. #1
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59

    Compute shader and GL_TEXTURE_2D_ARRAY

    Hi,

    I try to read some data in a FBO (GL_TEXTURE_2D_ARRAY) that contains fragment normals and position to do defered shading in a compute shader.
    All the data i read seems to be 0. My FBO is not empty and contains good datas when i display it and my fbo is correectly binded.

    I try to acess it like this :
    Code :
    layout (binding=0)  uniform sampler2D inColor;
    layout (binding=1)  uniform sampler2D inNormal;
     
    ....
     
    void main(void)	
    {
    	const uint i= gl_GlobalInvocationID.x;
    	const uint x = i%1024;
    	const uint y = (i-x)/1024;
    	const ivec2 storepos = ivec2(x,y);//gl_GlobalInvocationID.xy);
    	vec2 coord   =  vec2(storepos)/vec2(1024.0);
    	vec4 pos       =	texture2D(inColor,coord); 
    	vec4 norm    =  texture2D(inNormal,coord);
     
    	value[i] = queryHardShadow(pos,norm); //my wonderfull work xD
    //	value[i] = pos.x; always black if displayed 
    }

    Any on have an idea?

    Thanks!

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    Shouldn't the samplers be of type sampler2DArray if you want to use them with array textures (you'll need vec3 texcoords in that case as well).

  3. #3
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59
    Ho, it must be better....

    So i try :

    Code :
    layout (binding=0)  uniform sampler2DArray inColor;
    ....
     
    vec3 norm = texture(inColor,vec3(coord,1)).xyz;

    But it still return me dummy vec3(0)...

  4. #4
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896
    I assume it is intentional that you are reading from layer 1 (you are passing in vec3(coord, 1)) and that your array texture has at least two layers filled with real data? Other than that I don't know what's wrong, you could try running in a debug context and see if there are any messages or under an OpenGL debugger.

  5. #5
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59
    It works! I've forgotten to bind my fbo as texture color.

    Thanks!

    A screen shot of new kind of shadow volumes with an hudge model!

    myShadow.jpg

Similar Threads

  1. Replies: 3
    Last Post: 05-03-2018, 03:52 PM
  2. Some questions about compute shader
    By Van der Deken in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-14-2017, 10:36 AM
  3. Some questions about compute shader
    By Van der Deken in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-13-2017, 09:01 AM
  4. VBO and compute shader
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-09-2015, 09:00 AM
  5. Compute shader and barrier
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-21-2014, 07:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean