问题
I am using open gl to generate Gaussian Parimid, I create a 2D texture with mipmap, and bind to array of FBO, FBO[0] -> base level of texture, FBO[1] -> level 1 texture and so on ...
Platform: Android OpenGL ES 2.0
When run the code below:
gaussV.Use();
glUniform1f(gaussV("mip_level"), 0.0); //some param to shader
glUniform1f(gaussV("delta"), 1.0f / h); // some param to shader
glBindFramebuffer(GL_FRAMEBUFFER, filterFBO_IDs[m]);
draw(gaussV("vPosition")); // draw arrays.
gaussV.UnUse();
If m==0, the shader will be called, but if m>0, the shader program will not be called.
回答1:
From opengl es3.0 specification (http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.2.pdf) , we can see the list of news feature, one of them is:
ability to attach any mipmap level to a framebuffer object
So that means in opengl es2.0, it doesn't support rendering to specific level of texture.
So how to solve this if you need render to specific mipmap level?
1)Create more textures to render one, each texture corresponding to one level mipmap, this way will create many textures, not efficient.
2) Create a big texture to hold all levels of mipmap, it's like put the pyramid from vertical to horizontal.
来源:https://stackoverflow.com/questions/18593171/shader-is-not-running-if-i-bind-framebuffer-to-mipmap-texture