PDA

View Full Version : OpenGL ES 2.0, instructions limit exceeded, how to use multiple shaders / one object



chrisendymion
08-09-2012, 08:14 AM
Hello ;) I'm facing a problem with terrain rendering with OpenGL ES 2.0 (on Android). First, the naive algo :

CPU
- Prepare a 2D grid thru the screen (Projection space)

GPU
- Unproject the grid to eye space
- With trigo math, project each point of the grid onto a surface (spherical)
- Calculate a Simplex noise (with parameters) 3D height and apply to the vertex (vector from sphere radius)

I have a problem with the last point (applying the noise) because of :

Shader log : (0) : error C6002: Instruction limit of 256 exceeded; 402 instructions needed to compile program

Ok, my shader is too big. And I cannot reduce it enough...
So I think about two passes rendering.

First pass (shader A) : projecting vertex on the surface.
Second pass (shader B) : applying the noise height.

I'm a beginner and I don't know how to get "modified" vertices from the first pass to apply them to the second shader ?
Or an another method to do it ?

If it's not required, I don't want to produce an heightmap before (with CPU). Because of LOD, not as good as recalculating noise every time in GPU, based on distance.

Thank you very much and sorry for my poor english.