opengl - Can I use three-dimensional compute shader to write to a three-dimensional image -
define three-dimensional texture , dispatch compute
gltexstorage3d(gl_texture_3d, 1, gl_rgba32f, screen_width, screen_height, texture_depth); glbindimagetexture(0, m_texture, 0, gl_false, 0, gl_read_write, gl_rgba32f); gldispatchcompute(16, 16, 2);
compute shader
#version 450 layout(local_size_x = 32,local_size_y = 32, local_size_z = 2) in; layout(binding = 0, rgba32f) uniform image3d image; void main() { ivec3 position = ivec3(gl_globalinvocationid.xyz); vec4 color = vec4(gl_workgroupid / vec3(gl_numworkgroups), 1.0); imagestore(image, position, color); }
but code doesn't work, want konw value of gl_globalinvocationid.z depth of space
i had solved probelm, parameters of gldispatchcompute() x,y,z, ifxyzlocal_size_xlocal_size_ylocal_size_z > screensize.xscreensize.y, cannot work, downsample texture resolution.
Comments
Post a Comment