Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. 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

like image 644
andy Avatar asked Jan 22 '13 16:01

andy


1 Answers

texture2DLod() function is meant to be used to do texture lookups in vertex shaders.

Please refer to section 8.7 Texture Lookup Functions of GLSL ES specs.

According to andy's comment, don't forget to check GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS before using texture2DLod(). If vertex texture lookup is not supported, you should fall back to another shader without this feature.

like image 135
keaukraine Avatar answered Sep 22 '22 21:09

keaukraine