简体   繁体   English

OpenGL ES 2.0:在顶点着色器中是否存在缺少纹理访问的解决方法?

[英]OpenGL ES 2.0: Is there a workaround for missing texture access in vertex shader?

I'm currently trying out some OpenGL ES 2.0 with Android for a game. 我目前正在尝试使用Android的OpenGL ES 2.0进行游戏。 My map is a 2d grid map with a heights value for every position. 我的地图是一个二维网格地图,每个位置都有一个高度值。 Now I wanted to store the heights of each coordinate in a texture to do the height lookup in the vertex shader. 现在我想在纹理中存储每个坐标的高度,以在顶点着色器中进行高度查找。

The benefit of this idea would be that I can generate a generic triangle net and place it (with an offset) on the position of the map the user is currently looking at. 这个想法的好处是我可以生成一个通用三角网并将其(带偏移)放在用户当前正在查看的地图位置上。 Due to the offset I can omit the need to create a new triangle net every time the user moves its view position and the height profile I would read from the texture. 由于偏移,我可以省略每次用户移动其视图位置和我将从纹理读取的高度轮廓时创建新三角网的需要。

Now there is the problem that many current Android devices (even the Galaxy S3) do not support texture lookups in the vertex shader. 现在存在的问题是许多当前的Android设备(甚至是Galaxy S3)不支持顶点着色器中的纹理查找。 Sadly this totally destroys my current approach. 可悲的是,这完全破坏了我目前的做法。

My question: Is there any other possibility to fetch data from the graphic card's memory in the vertex shader? 我的问题:还有其他可能从顶点着色器中的图形卡内存中获取数据吗? Without specifying the data for each vertex directly, what would force me (as far as I know) to recreate the heights map each time the user changes the view position. 如果不直接指定每个顶点的数据,每次用户更改视图位置时,会强制我(据我所知)重新创建高度贴图。 (Creating the heights map every time the user changes the view position is to slow...) (每次用户更改视图位置时创建高度图都会变慢...)

Thank you for your help + best regards, 感谢您的帮助+最好的问候,

Andreas 安德烈亚斯

texture2DLod() function is meant to be used to do texture lookups in vertex shaders. texture2DLod()函数用于在顶点着色器中进行纹理查找。

Please refer to section 8.7 Texture Lookup Functions of GLSL ES specs . 请参阅GLSL ES规范的8.7纹理查找功能

According to andy 's comment, don't forget to check GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS before using texture2DLod() . 根据andy的评论,在使用texture2DLod()之前不要忘记检查GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS If vertex texture lookup is not supported, you should fall back to another shader without this feature. 如果不支持顶点纹理查找,则应该回退到没有此功能的另一个着色器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM