I've managed to produce a bug using glsl which will function for the Object3d it is applied to but cause errors elsewhere in the program.
For context i was using a lighting shader i found elsewhere
http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-lights-per-pixel/ I modified it to work with glsl in jpct.
While using the version i created i made a call at the start of the fragment shader to
uniform [b]vec4[/b] specularColors[8];
Obviously i was going outside the Jpct spec you have here:
http://www.jpct.net/jpct-ae/doc/com/threed/jpct/GLSLShader.htmlWhich says it should be a vec3.
If you use it the shader still works seemingly perfectly, and the object3d looks how i want it to.
However i've found it breaks another part the program.
I was using Andre Silva's particle system
https://www.youtube.com/watch?v=cn-iS4YnqnE which worked perfectly until i tried using the new seemingly unrelated shader.
It would successfully generate the first particle sprite but then crash as it attempts to generate a second particle from the same texture.
Producing this vague error "
: - ERROR: before: glError 1282"
Somehow using a vec4 instead of a vec3 causes this.
If it helps here are the shaders
The vertex shader
precision mediump float;
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
attribute vec4 position;
attribute vec3 normal;
varying float fogthickness;
varying vec3 norm;
varying vec4 eye;
void main() {
vec3 n = normalize(modelViewMatrix * vec4(normal, 0.0)).xyz;
norm = n;
eye= -modelViewMatrix[3];
fogthickness = 1.0- dot(normalize(eye.xyz),n );
gl_Position = modelViewProjectionMatrix *position; //* vec4(position,1.0);
}
The fragment shader which causes the bug.
precision mediump float;
uniform vec3 atmosphereColour;
uniform vec4 specularColors[8];
uniform vec3 lightPositions[8];
varying vec3 norm;
varying vec4 eye;
varying float fogthickness;
void main() {
vec4 spec = vec4(0.0);
// normalize both input vectors
vec3 n = normalize(norm);
vec3 e = normalize(vec3(eye));
vec3 ligthDirection = normalize(lightPositions[0]);
float intensity = max(dot( n,ligthDirection), 0.0);
float shininess= 1.0;
// if the vertex is lit compute the specular color
if (intensity > 0.0) {
// compute the half vector
vec3 h = normalize(ligthDirection + e);
// compute the specular term into spec
float intSpec = max(dot(h,n), 0.0);
spec = specularColors[0] * pow(intSpec,shininess);
}
vec4 colorout = max(intensity * vec4(atmosphereColour,1) + spec, vec4(0.0));
gl_FragColor = vec4( colorout.xyz , fogthickness);
}
I have a hypothesis that it's because the shader will compile perfectly but when it's run only receives vec3 specularColor from Jpct itself when it expects a vec4.