本文介绍了如何正确使用GL_HALF_FLOAT_OES作为纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad 2/3上使用OpenGL ES 2.0.我想在创建纹理时使用GL_FLOAT:

I'm using OpenGL ES 2.0 on an iPad 2 / 3. I'd like to use GL_FLOAT when creating textures:

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,texWidth,texHeight,0,GL_RGBA,GL_FLOAT,rawData);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, rawData);

,但是问题是,如果在支持的扩展名列表中未显示GL_OES_texture_float_linear,则在使用GL_FLOAT时不支持GL_LINEAR作为GL_TEXTURE_MAG_FILTER. (没有一个iPad.)

but the problem is that GL_LINEAR is not supported as a GL_TEXTURE_MAG_FILTER when GL_FLOAT is used if you don't have GL_OES_texture_float_linear showing up in your list of supported extensions. (None of the iPads do.)

但是我的扩展列表中确实有GL_OES_texture_half_float_linear.因此,使用半浮点纹理应该可以进行线性插值.

But I do have GL_OES_texture_half_float_linear in my list of extensions. So using a half-float texture ought to work with linear interpolation.

问题是,将我的纹理创建切换为:

Problem is, switching my texture creation to:

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,texWidth,texHeight,0,GL_RGBA,GL_HALF_FLOAT_OES,rawData);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_HALF_FLOAT_OES, rawData);

当我运行应用程序时,会导致EXC_BAD_ACCESS. (libGPUSupportMercury.dlylib'gpus_ReturnGuiltyForHardwareRestart)

causes EXC_BAD_ACCESS when I run the app. (libGPUSupportMercury.dlylib'gpus_ReturnGuiltyForHardwareRestart)

自从用GL_FLOAT调用数据以来,我没有更改过数据的格式.输入数据是否需要以某种方式更改为HALF_FLOAT?如果是这样,怎么办?我不知道如何将输入浮点数分成两半.当前每个组件都是GLfloat.

I haven't changed the format of the data since calling it with GL_FLOAT. Does the input data need to change for HALF_FLOAT somehow? If so, how? I don't know how I would split my input floats in half. Each component is GLfloat currently.

推荐答案

我目前的解决方案"是将我自己的双线性插值添加到片段着色器中,因为使用GL_FLOAT时OpenGL不会为我这样做.

My "solution" for right now has been to add my own bilinear interpolation to the fragment shader, since OpenGL won't do it for me when GL_FLOAT is used.

这篇关于如何正确使用GL_HALF_FLOAT_OES作为纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 16:42