Using this:
gl.glGetProgramivARB(GL.GL_FRAGMENT_PROGRAM_ARB, GL.GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, value, 0);
Returns 31, one less than INSTRUCTIONS and here are what I have tested so far:
GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 128
GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 31
GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 32
I thought I would do some more testing to see if it really was because of the texture2D() calls, so I commented out the calls and in their place put in the same calculations that were done inside the texture2d() call. So When I used this noise function:
float noise(vec2 P)
{
vec2 Pi = ONE*floor(P)+ONEHALF; // Integer part, scaled and offset for texture lookup
vec2 Pf = fract(P); // Fractional part for interpolation P-floor(P) (0 - 1)
// Noise contribution from lower left corner
vec2 grad00 = vec2(0.5)/*texture2D(permTexture, Pi).rg*/ * 4.0 - 1.0; //(-1, 255, 511)
float n00 = dot(grad00, Pf);//()
// Noise contribution from lower right corner
vec2 grad10 = (Pi + vec2(ONE, 0.0))/*texture2D(permTexture, Pi + vec2(ONE, 0.0)).rg*/ * 4.0 - 1.0; // Compute the dot-product between the vectors and the gradients
//DotProduct = (x1*x2 + y1*y2)
float n10 = dot(grad10, Pf - vec2(1.0, 0.0));
// Noise contribution from upper left corner
vec2 grad01 = (Pi + vec2(0.0, ONE))/*texture2D(permTexture, Pi + vec2(0.0, ONE)).rg*/ * 4.0 - 1.0;
float n01 = dot(grad01, Pf - vec2(0.0, 1.0));
// Noise contribution from upper right corner
vec2 grad11 = (Pi + vec2(ONE, ONE))/*texture2D(permTexture, Pi + vec2(ONE, ONE)).rg*/ * 4.0 - 1.0;
float n11 = dot(grad11, Pf - vec2(1.0, 1.0));
// Blend contributions along x
vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade(Pf.x));
// Blend contributions along y
float n_xy = mix(n_x.x, n_x.y, fade(Pf.y));
// We're done, return the final noise value.
return n_xy ;
}
It confirmed to me that the error message had nothing to do with the texture2D() calls, despite having none it gave out the same error message:
Link successful. The GLSL vertex shader will run in software due to the GLSL fragment shader running in software. The GLSL fragment shader will run in software - available number of texture instructions exceeded. Validation successful.
Although if I simply commented out the texture2D() call without replacing it with the same amount of calculations that are done in the first place I am able to do 3 noise calls without a problem but fails on 4.
I thought I would also paste in my fade() method as that too is rather mathematically expensive.
/*
* The interpolation function. This could be a 1D texture lookup
* to get some more speed, but it's not the main part of the algorithm.
*/
float fade(float t) {
// return t*t*(3.0-2.0*t); // Old fade, yields discontinuous second derivative
return t*t*t*(t*(t*6.0-15.0)+10.0); // Improved fade, yields C2-continuous noise
}
Would this be a driver problem then or I am I simply doing too many calculations that the card can handle?
Thanks again