GL_LINEAR for depth texture

Hi! I’m trying to implement ESM technique on powervr. I’m creating a depth framebuffer for shadows using this:



glGenFramebuffers(1, &fbo);

glBindFramebuffer(GL_FRAMEBUFFER, fbo);



glGenRenderbuffers(1, &rbo);

glBindRenderbuffer(GL_RENDERBUFFER, rbo);



glGenTextures(1, &depth);

glBindTexture(GL_TEXTURE_2D, depth);



glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);



glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0);


However, when sampling, the filter is not enabled for this texture, despite myself specifying GL_LINEAR.
Does filter only work for RGB textures?

UPDATE: OK, Been reading more about the subject.


ESM is really simple, produces soft shadows and, if the hardware supports it, is faster than PCF  because you can use smaller shadow maps and only one texture read is enough for it to look great. The idea is to render a shadowmap normally and then blur it, to later read using the hardware filtering through an exp() function.

So, how would I go with blurring a depth renderbuffer? To blur I have to use 2 texures and use separatable convolution, but:

1) I can’t write back depth using gl_FragDepth in OpenGL ES, so I can’t blur a depth buffer
2) I can’t create a single-float render buffer in color attachment 0 to write to.

So, even if i solve the first issue, there is also the second issue, reading:

1) I can’t read an interpolated depth buffer, because in PowerVR, depth textures don’t seem to care about  GL_LINEAR
2) I could write the blurred depth to a packed GL_RGBA, but then the interpolation of that won’t be useful.

So, basically, there isn’t any renderbuffer format i can write a full float to, that i can later read filtered / interpolated??

I know i can read 4 floats and do bilinear myself, but that’s a big performance hit.



Hi goruka,

EXT_color_buffer_half_float allows you to render to half float surfaces and OES_texture_half_float_linear enables the filtering when reading back from them.
Apart from that the core spec does not include any renderable float formats.

If these extensions are not available on your platform the only way to emulate this behaviour is to pack the float into RGBA and do the filtering yourself, like you described.

The extension (OES_depth_texture) and the spec are not defining whether the filtering for your GL_UNSIGNED_INT texture should work (at least I couldn't find it). So I can't tell whether this is correct or not. Did you check your framebuffer completeness?

Regards,
Marco