What is the minimum Texture size for OpenGL?

Is there minimum size restriction in texture size or is there any recommended minimum size to use for texture size.

There is no minimum, you can create a 1x1 texture if you wish.

Thank you for the reply.

Is there any restrictions on OpenGL ES 2.0 for minimum texture size.

Again, no. You can have a 1x1 texture.

This line of questioning suggests that you have something specific in mind. If so, it might help you more if you said what that something was.

I’m trying to implement shadow mapping and its working fine when the texture size is above 64.
When it is below 64 I’m expecting pixelated shadow but what I am getting is random round shape dark patch as the shadow. I am trying to understand reason for this behaviour.
I am using OpenGL ES 2.0.

Is there any possible reason for this kind of behavour.

That could be a number of things.

After rendering to your shadow map, you might try rendering it to the screen in orthographic so you can see the contents of it. That might give you some clues as to what is going on. Alternatively (or in addition), you could read back the shadow map texel values with glReadPixels() and inspect them on the CPU.

If you fail to get any leads, you might post a little code with the creation of your shadow map texture and FBO (including all your TexParameter settings), setup for your shadow map generation pass (incl. viewport/projection/viewing matrix setup), and setup for your scene render pass as pertains to your shadow map.

You might also post a picture of your scene using the smallest shadow map size that works properly, and then one with the next power-of-two-smaller shadow map size which doesn’t render properly.

(Here’s one blindfolded shot-over-the-shoulder for you to check: Do you have the GL_TEXTURE_MIN_FILTER on your shadow map set to GL_NEAREST or GL_LINEAR, and if you are using anisotropic texture filtering, do you have MAX_ANISOTROPY nailed to 1?)

Thank you for the reply.
I got problem when inspect the shadow map values in CPU. As I am using OpenGL ES glReadPixels() cannot read values from the GL_DEPTH_COMPONENT.

I tried the GL_TEXTURE_MIN_FILTER value. I tried with both GL_NEAREST or GL_LINEAR, but getting the same output I previously mentioned.
Also checked MAX_ANISOTROPY it set to 1.
Is there any other things I need to check?

Hi guys,

I’m sure everyone’s on top of this by now, but FYI I just moved my PBR engine from individual textures to array textures. I had a bunch of 1 x 1 pixel textures that I was using for “no-map textures” (eg for quick and nasty test rendering on just an albedo, or an albedo and metallic etc).

When I moved to array textures, the 1 x 1 maps all stopped working! Through quick trial and error, they started working again at 16 x 16.

This is on OpenGL 4.6 with the latest Nvidia driver, so it looks like we know array textures are subject to the minimum 64 pixel constraint.

Cheers,
MWS

We know no such thing. OpenGL 4.6 has no such constraint; if NVIDIA’s driver doesn’t work with a 1x1 array texture, then that’s a driver bug.

1 Like

Thanks AR,

That is very interesting then… I’ll throw together some isolated diagnostic code to see if I can replicate it - all I know so far is that sizing the textures in Photoshop with no code changes whatsoever worked above 64 pixels but stopped working below that. So there might be something in my code somewhere causing some condition…

Cheers,
MWS

Update - I worked it out… the code was trying to mipmap the 1 x 1 textures with the storage call failing without detection:

glTexStorage3D(GL_TEXTURE_2D_ARRAY, 5, GL_RGB8, width, height, textureCount);

This returns a 1282 if you ask for more than 1 level which makes sense.

Thanks again!