Shader is not running if I bind framebuffer to mipmap texture

大憨熊 提交于 2019-12-13 21:03:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!