No idea what that error should be. Something isn't quite right with the gl state for some reason. I would ignore it for now.
Okay, thank you
And yes, 4 is a hard coded limit. I looked into expanding it once, but decided against it for reasons that I can't remember anymore. Must have been a technical limitation of some kind. There's no way to hack around it, I'm afraid.
I found this post (Reply #1) for a possible reason why:
http://www.jpct.net/forum2/index.php?topic=3371.0Another possible reason I could think of: the minimum amount of vertex attributes is used up.
But I still think it should be possible to increase the limit to at least 8; especially modern devices (I think actually old ones too) should support this.
It is true that vertex shaders have very limited textures to access (minimum of 0).
Though, usually I believe textures are only accessed in the fragment shader (so there should be no problem at all considering the limit for the amount of vertex shader textures).
The amount of textures that can be accessed in the fragment shader is at least 8.
To fix the vertex attributes being used up: merge variables into one bigger variable.
Currently there's 4 texture attributes for the texture coordinates (as seen in:
http://www.jpct.net/jpct-ae/doc/com/threed/jpct/GLSLShader.html)
However, these are all vec2's, while they could be vec4's.
4 vec4's could potentially hold texture coordinates for 8 texture stages.
Example:
//VERTEX SHADER
...
attribute vec4 texture01;
...
void main(){
...
vec2 texture0 = texture01.xy;
vec2 texture1 = texture01.zw;
...
}
According to the OpenGLES2 spec:
https://www.khronos.org/registry/OpenGL/specs/es/2.0/es_cm_spec_2.0.pdf (page 66 of documentation; page 71 of PDF)
State | Minimum value |
MAX VERTEX TEXTURE IMAGE UNITS | 0 |
MAX TEXTURE IMAGE UNITS | 8 |
MAX VERTEX ATTRIBS | 8 |
I suppose it'd be a quite a challenge to be rewriting this so I'm not sure if it's too much to ask for.
I'd have wanted to give it a shot if jPCT-AE was open-source but yeah...
Otherwise, would it be possible to add something more hacky so I'd still be able to bind these textures to the Object3D (and its GLSLShader) from stage 5 to 8?
A TextureBindingHook or something for additional texture stages, something like:
TextureInfo blah ... // first 4 textures go here
obj.setTexture(blah);
obj.setTextureBindingHook(new TextureBindingHook(){
@Override
public void beforeFinishedBinding(){
Texture tex = fifthTex;
int stage = 5;
String variableName = "textureUnit4";
methodToBind(tex, stage, variableName);
}
});
(Additional texture coordinates attributes I don't really need; but only being able to access the textures in the fragment shader)