Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the size of an image unit (eg. image2D) in GLSL just like textureSize

textureSize is a handy function to get texture dimensions in a shader without having to pass them in by hand as uniforms.

Is there a similar API for image units?

like image 506
jozxyqk Avatar asked Jan 27 '26 07:01

jozxyqk


1 Answers

Yes, it's in OpenGL 4.3:

  • imageSize() docs
  • imageSize() wiki
  • ARB_shader_image_size specs

Example:

layout(rgba32f) uniform image2D myImage;
...
ivec2 size = imageSize(myImage);
like image 98
jozxyqk Avatar answered Jan 31 '26 01:01

jozxyqk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!