- July 14, 2012 at 4:26 pm #30919
Hi! I’m trying to implement ESM technique on powervr. I’m creating a depth framebuffer for shadows using this:
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?July 15, 2012 at 3:15 am #36000
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 buffer2) 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_LINEAR2) 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.August 31, 2012 at 12:54 pm #36001
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?