Right now, I'm trying really hard to update this really old vertex program to GLSL, and so far, it's been a complete nightmare. In fact, I've tried to convert this many times for a few years and never could get it to work! I even tried converting to an ARB vertex program and to a Direct3D vertex shader, but that didn't work either.

To be more specific, I have a really old OpenGL project that uses GL_NV_vertex_program for procedural animation of a jellyfish. This shouldn't be a challenge, really, because having a good understanding of both GL_NV_vertex_program and GLSL makes it less troublesome. Hopefully my problem is just something simple, but I can't pinpoint it to save my life. I had a friend on this forum that managed to do this successfully, but I've asked him twice, and he told me that not only did he forget how he did it, but he doesn't have the source code anymore! Aside from that, he's rarely on Skype.

Now, I really hate just "dumping" some code on you all and saying "plz help meee1!!!111!11", but I'm getting desperate, and my next course of action would be to bang my head against the wall. I'll only share the most relevant code because I converted much of the code to work on MacOSX, and chances are, you're a Windows user.

I'll start with the original GL_NV_vertex_program and the GLSL vertex program I wrote:

/* Vertex attributes */ attribute vec4 v_pos; attribute vec4 v_normal; varying float v_tex; /* Texture sampler */ uniform sampler1D texture; /* General purpose vectors */ vec4 R0, R1, R2, R3, R4, R5, R6; /* Constants */ uniform vec4 c8; uniform vec4 c9; uniform vec4 c10; uniform vec4 c11; uniform vec4 c12; uniform vec4 c13; uniform vec4 c14; uniform vec4 c15; uniform vec4 c16; uniform vec4 c17; /* Matrices */ mat4 mvp = gl_ModelViewProjectionMatrix; mat3 itmm = gl_NormalMatrix; //transpose(gl_ModelViewInverseMatrix); void main() { R0.x = ( v_pos.y * c16.x ) + c16.z; R0.x *= c11.w; R0.y = exp( R0.x ); R2.x = ( R0.y < c11.y ) ? 1.0f : 0.0f; R2.y = R2.z = ( R0.y > c11.y ) ? 1.0f : 0.0f; R2.y = dot( R2, c14.zwzw ); R5/*.xyz*/ = -R0.y + c10; R5 = R5 * R5; R0 = ( c12.xyxy * R5 ) + c12.zwzw; R0 = ( R0 * R5 ) + c13.xyxy; R0 = ( R0 * R5 ) + c13.zwzw; R0 = ( R0 * R5 ) + c14.xyxy; R0 = ( R0 * R5 ) + c14.zwzw; R1.x = dot( R0, -R2 ); R2.x = ( R1.x * c10.w ) + c10.z; R2.yw = c16.yw; R3 = v_pos * R2.xyxw; R4 = v_normal * R2.yxyw; gl_Position = R3 * mvp; R5.xyz = R4.xyz * itmm; R5.w = dot( R5, R5 ); R5.w = inversesqrt( R5.w ); R5 = R5 * R5.w; R6 = c8 + v_pos; R6.w = dot( R6, R6 ); R6.w = inversesqrt( R6.w ); R6 = R6 * R6.w; R6 = R6 * c10.y; v_tex = dot( R5, R6 ); gl_FrontColor = gl_Color; } /* Original vertex program: # R0 = (y coordinate of vertex * k) + (w * t) MAD R0.x, v[OPOS].y, c[16].x, c[16].z; # R1 = cos(R0), R0 = any floating point number MUL R0.x, c[11].w, R0.x; EXP R0.y, R0.x; SLT R2.x, R0.y, c[11]; SGE R2.yz, R0.y, c[11]; DP3 R2.y, R2, c[14].zwzw; ADD R5.xyz, -R0.y, c[10]; MUL R5, R5, R5; MAD R0, c[12].xyxy, R5, c[12].zwzw; MAD R0, R0, R5, c[13].xyxy; MAD R0, R0, R5, c[13].zwzw; MAD R0, R0, R5, c[14].xyxy; MAD R0, R0, R5, c[14].zwzw; DP3 R1.x, R0, -R2; # R2 = R1 * c[10] + 1.0 MAD R2.x, R1.x, c[10].w, c[10].z; # R3 = perturbed vertex # R4 = perturbed normal MOV R2.yw, c[16]; MUL R3, v[OPOS], R2.xyxw; MUL R4, v[NRML], R2.yxyw; # Transform vertices into clip space via modelview-projection matrix DP4 o[HPOS].x, R3, c[0]; DP4 o[HPOS].y, R3, c[1]; DP4 o[HPOS].z, R3, c[2]; DP4 o[HPOS].w, R3, c[3]; # Transform normals via inverse transpose modelview matrix & normalize # R5 = transformed normal DP3 R5.x, R4, c[4]; DP3 R5.y, R4, c[5]; DP3 R5.z, R4, c[6]; DP3 R5.w, R5, R5; RSQ R5.w, R5.w; MUL R5, R5, R5.w; # Get unit length eye vector to vertex....this is how we texture map # R6 = vector ADD R6, c[8], v[OPOS]; DP3 R6.w, R6, R6; RSQ R6.w, R6.w; MUL R6, R6, R6.w; # Multiply by 0.5 for texture wrapping MUL R6, R6, c[10].y; # Texture coord is dot product of normal and vector from eye to vertex DP3 o[TEX0].x, R5, R6; # Pass color through MOV o[COL0], v[COL0]; */

The fragment program I wrote:

varying float v_tex; uniform sampler1D texture; void main() { vec4 texel_colour = texture1D( texture, v_tex ); vec4 fragment_colour = gl_Color; gl_FragColor = texel_colour * fragment_colour; }

My modified jellyfish code (I commented out the shader code that needed to be changed; also, I couldn't get the ARB stuff working either):

#include "Jellyfish.h" //#include <glh_genext.h> #include "constants.h" #ifndef _WIN32 #include <sys/time.h> #endif extern GLuint vertexProgramsNV[1]; extern GLuint uniform_constants[18]; // Laziness... extern GLuint uniform_texture; extern GLuint attrib_v_pos; extern GLuint attrib_v_normal; /*extern PFNGLPROGRAMPARAMETER4FNVPROC glProgramParameter4fNV; extern PFNGLPROGRAMLOCALPARAMETER4FARBPROC glProgramLocalParameter4fARB; extern PFNGLBINDPROGRAMNVPROC glBindProgramNV;*/ float queryElapsedTime(); inline float myRandom( ) { static unsigned int n = 0; n += 7; n = (n<<13) ^ n; return 0.5f * ( 2.0f - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) * 9.313225746e-10f); } Jellyfish::Jellyfish( ) { Vector3 a,b,c; nVertices = 0; generateLightingTexture( ); create( ); } Jellyfish::~Jellyfish( ) { delete [] strip; delete [] normals; delete [] segments; delete [] points; glDeleteTextures(1, &texture); } void Jellyfish::create( ) { // jellyfish body float crossSection[118] = { 0.0f,9.44361f,0.38913f,9.44208f,1.0702f,9.38564f,1.77009f,9.26147f, 2.25174f, 9.11471f,2.92905f,8.79864f,3.42198f,8.45245f,4.0278f,7.89932f, 4.35141f,7.52679f,4.65243f,7.07149f,4.9798f,6.48072f,5.2849f,5.67923f, 5.46437f,5.16185f,5.66547f,4.77636f,5.93869f,4.45945f,6.28112f,4.16573f, 6.74834f, 3.90317f,7.27513f,3.53442f,7.54982f,3.28982f,7.8358f,2.95494f, 8.0277f,2.60876f,8.1293f,2.24376f,8.18051f,1.76588f,8.12177f,1.20145f, 7.98255f,0.719805f,7.82451f,0.471455f,7.6025f,0.264505f,7.30147f,0.0801254f, 7.0f,0.0f,6.54744f,0.0245184f,6.0959f,0.202837f,5.85738f,0.454947f, 5.68345f,0.817635f,5.54046f,1.53635f,5.41629f,2.01047f,5.1231f,2.5636f, 4.63738f,3.14684f,4.26862f,3.44818f,3.80579f,3.71534f,3.17363f,3.94456f, 2.56405f,4.14023f,2.13133f,4.3961f,1.92061f,4.66327f,1.84911f,4.96429f, 1.93942f,5.22769f,2.15767f,5.42712f,2.55653f,5.56635f,2.94034f,5.62655f, 3.23384f,5.72439f,3.39188f,5.87491f,3.44456f,6.10443f,3.38435f,6.35654f, 3.28276f,6.52588f,3.07204f,6.72155f,2.60168f,6.95484f,2.14261f,7.13546f, 1.40102f,7.32328f,0.58073f,7.41766f,0.0f,7.43333f }; nVertices = 118; float rotAngle = 2.0f * M_PI / 24.0f; float cosAngle = cosf(rotAngle); float sinAngle = sinf(rotAngle); float dy, dx, slope; strip = new Vector3[nVertices]; normals = new Vector3[nVertices]; tex = new Vector3[nVertices]; unsigned int i; for ( i = 0; i < nVertices / 2; i++ ) { strip[2*i].set(crossSection[2*i], crossSection[2*i+1]-10.0f, 0.0f ); tex[2*i].set(0.0f, strip[2*i](1) / 10.0f, 0.0f); strip[2*i+1].set(cosAngle * crossSection[2*i], crossSection[2*i+1]-10.0f, sinAngle * crossSection[2*i] ); tex[2*i+1].set(rotAngle / (2.0f * M_PI), strip[2*i+1](1) / 10.0f, 0.0f); if ( i == 0 || i == nVertices / 2 - 1) { normals[2*i].set(0.0f, 1.0f, 0.0f); normals[2*i+1].set(0.0f, 1.0f, 0.0f); } else { dx = crossSection[2*(i+1)] - crossSection[2*(i-1)]; dy = crossSection[2*(i+1)+1] - crossSection[2*(i-1)+1]; slope = dy / dx; normals[2*i].set( 1.0f, -1.0f / slope, 0.0f ); normals[2*i+1].set( cosAngle, -1.0f / slope, sinAngle ); } normals[2*i].normalize(); normals[2*i+1].normalize(); } // tentacles nSegments = 20; segments = new Vector3[nSegments]; for ( i = 0; i < nSegments; i++ ) { segments[i].set(7.0f, -10.0f - float(i), 0.0f); } // water debris nPoints = 1000; points = new Vector3[nPoints]; for ( i = 0; i < nPoints; i++ ) { points[i](0) = 700.0f * (myRandom( ) - 0.5f); points[i](1) = 700.0f * (myRandom( ) - 0.5f); points[i](2) = 700.0f * (myRandom( ) - 0.5f); } // Create jellyfish display list const unsigned int nSlices = 24; const float nRadPerSlice = 2.0f * M_PI / 24.0f; float angle, temp, texOffset; Vector3 v,n; jellyfishList = glGenLists(1); glNewList(jellyfishList, GL_COMPILE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_1D); glBindTexture(GL_TEXTURE_1D, texture); glUniform1i( uniform_texture, 0 ); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /*#if USE_ARB_VERTEXPROGRAM glEnable(GL_VERTEX_PROGRAM_ARB); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexProgramsNV[0]); #else glEnable(GL_VERTEX_PROGRAM_NV); glBindProgramNV(GL_VERTEX_PROGRAM_NV, vertexProgramsNV[0]); #endif*/ glUseProgram(vertexProgramsNV[0]); // draw the body glColor4f(1.0f, 0.0f, 1.0f, 0.4f); for ( i = 0; i < nSlices; i++) { angle = float(i) * nRadPerSlice; texOffset = 1.0f - angle / (2.0f * M_PI); cosAngle = cosf(angle); sinAngle = sinf(angle); unsigned int j; glBegin(GL_TRIANGLE_STRIP); for ( j = 0; j < nVertices; j++) { v = strip[j]; temp = cosAngle * v(0) + sinAngle * v(2); v(2) = -sinAngle * v(0) + cosAngle * v(2); v(0) = temp; n = normals[j]; temp = cosAngle * n(0) + sinAngle * n(2); n(2) = -sinAngle * n(0) + cosAngle * n(2); n(0) = temp; glVertexAttrib3fv( attrib_v_normal, n.get() ); glVertexAttrib3fv( attrib_v_pos, v.get() ); //glNormal3fv( n.get() ); //glVertex3fv( v.get() ); } glEnd( ); // draw the tentacles glBegin(GL_TRIANGLE_STRIP); Vector3 w(0.0f, 0.0f, 1.0f); glVertexAttrib3f( attrib_v_normal, cosAngle, 0.0f, -sinAngle ); //glNormal3f( cosAngle, 0.0f, -sinAngle); for ( j = 0; j < nSegments; j++) { w *= 0.9f; v = segments[j] + w; temp = cosAngle * v(0) + sinAngle * v(2); v(2) = -sinAngle * v(0) + cosAngle * v(2); v(0) = temp; glVertexAttrib3fv( attrib_v_pos, v.get() ); //glVertex3fv( v.get() ); v = segments[j] - w; temp = cosAngle * v(0) + sinAngle * v(2); v(2) = -sinAngle * v(0) + cosAngle * v(2); v(0) = temp; glVertexAttrib3fv( attrib_v_pos, v.get() ); // glVertex3fv( v.get() ); } glEnd( ); } /*#if USE_ARB_VERTEXPROGRAM glDisable(GL_VERTEX_PROGRAM_ARB); #else glDisable(GL_VERTEX_PROGRAM_NV); #endif*/ glUseProgram(0); glDisable(GL_TEXTURE_1D); glDepthMask(GL_TRUE); glEndList( ); } void Jellyfish::render( ) { static float lastTime = 0.0f; float dt; float time = 0.0f; static float ourTime = 0.0f; float k = 0.25f; // inverse wavelength of ripple float w = 3.0f; // inverse period of ripple // What follows is the CPU's only per-frame computations // for animating the jellyfish /* #ifdef _WIN32 time = queryElapsedTime( ); #else timeval tmptime; gettimeofday (&tmptime,NULL); time = tmptime.tv_sec+tmptime.tv_usec*.000001; #endif */ time = queryElapsedTime( ); dt = time - lastTime; lastTime = time; float hfactor = .805f - 0.195f * sinf(w * ourTime); if ( cosf(w * ourTime) < 0.0f ) { dt *= 2.0f; } ourTime += dt; // Begin drawing, water debris first /* glDisable(GL_BLEND); glBegin(GL_POINTS); glColor3f( 1.0f, 1.0f, 1.0f ); for ( unsigned int i = 0; i < nPoints; i++ ) { points[i](1) -= w * dt; if ( points[i](1) < -50.0f ) { points[i](1) += 1000.0f; } glVertex3fv( points[i].get() ); } glEnd( );*/ // Now send some parameters and draw the jellyfish /*#if USE_ARB_VERTEXPROGRAM float itmtx[16], imtx[16], mtx[16]; glGetFloatv( GL_MODELVIEW, mtx ); //gluInvertMatrix( mtx, imtx ); gluTransposeMatrix( mtx, itmtx ); glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 4, &itmtx[0]); glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 5, &itmtx[4]); glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 6, &itmtx[8]); glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 16, k, hfactor, w * ourTime, 1.0f); #else glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 16, k, hfactor, w * ourTime, 1.0f); #endif*/ glUniform4f(uniform_constants[16], k, hfactor, w * ourTime, 1.0f); glCallList(jellyfishList); } void Jellyfish::generateLightingTexture( ) { const unsigned int size = 256; unsigned int index; float *data; data = new float[4 * size]; for ( unsigned int i = 0; i < size; i++ ) { index = 4 * i; data[index] = 1.0f - float(i) / float(size); data[index] *= data[index]; data[++index] = 0.0f; data[++index] = 1.0f; data[++index] = 0.7f - float(i) / float(size); } glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_1D, texture); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, size, 0, GL_RGBA, GL_FLOAT, data); delete [] data; }

And this is how I setup the GLSL program, attributes, constants, etc. This time, I only included the relevant stuff. The unchanged code works fine without any problems or issues on Windows.

//----------------------------------------------------------------------------- // Name: loadVertexProgramsNV // Desc: Loads any vertex programs used in this demo. Instead of using NVParse, // the shader is loaded from a text file on disk. //----------------------------------------------------------------------------- #if 0 void loadVertexProgramsNV() { // Load the vertex programs if( !( vertexProgramsNV[0] = LoadProgramNV( GL_VERTEX_PROGRAM_NV, "..\\programs\\jellyfish_nv.vp" ) ) ) return; // Track the Projection matrix in c[0] to c[3]. glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); // Track the inverse of the Modelview matrix in c[4] to c[7] glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); // Load the view position into c[8] glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 8, 0.0f, 0.0f, 100.0f, 1.0f); // Load cosine series constants into c[9] glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 9, 1.0f, -1.0f/2.0f, 1.0f/24.0f, -1.0f/720.0f); // Constants for cosine glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 10, 0.0f, 0.5f, 1.0f, 0.2f); glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 11, 0.25f, -9.0f, 0.75f, 1.0f / (2.0f * M_PI) ); glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 12, 24.9808039603f, -24.9808039603f, -60.1458091736f, 60.1458091736f ); glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 13, 85.4537887573f, -85.4537887573f, -64.9393539429f, 64.9393539429f ); glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 14, 19.7392082214f, -19.7392082214f, - 1.0f, 1.0f ); // Light position glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 15, 0.0f, 0.7f, 0.7f, 1.0f ); glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 17, 0.3f, 0.3f, 0.3f, 1.0f ); } #endif void loadVertexProgramsGLSL() { GLuint vs, fs; /* Post-processing */ if ((vs = create_shader("programs/jellyfish_glsl_vp.txt", GL_VERTEX_SHADER)) == 0) return; if ((fs = create_shader("programs/jellyfish_glsl_fp.txt", GL_FRAGMENT_SHADER)) == 0) return; int link_ok, validate_ok; vertexProgramsNV[0] = glCreateProgram(); glAttachShader(vertexProgramsNV[0], vs); glAttachShader(vertexProgramsNV[0], fs); glLinkProgram(vertexProgramsNV[0]); glGetProgramiv(vertexProgramsNV[0], GL_LINK_STATUS, &link_ok); if (!link_ok) { fprintf(stderr, "glLinkProgram:"); //print_log(program_postproc); return; } glValidateProgram(vertexProgramsNV[0]); glGetProgramiv(vertexProgramsNV[0], GL_VALIDATE_STATUS, &validate_ok); if (!validate_ok) { fprintf(stderr, "glValidateProgram:"); //print_log(program_postproc); } attrib_v_pos = glGetAttribLocation(vertexProgramsNV[0], "v_pos"); if (attrib_v_pos == -1) { fprintf(stderr, "Could not bind attribute v_pos\n"); return; } attrib_v_normal = glGetAttribLocation(vertexProgramsNV[0], "v_normal"); if (attrib_v_normal == -1) { fprintf(stderr, "Could not bind attribute v_normal\n"); return; } uniform_texture = glGetUniformLocation(vertexProgramsNV[0], "texture"); if (uniform_texture == -1) { fprintf(stderr, "Could not bind uniform texture\n"); return; } /* Constants */ uniform_constants[8] = glGetUniformLocation(vertexProgramsNV[0], "c8"); if (uniform_constants[8] == -1) { fprintf(stderr, "Could not bind uniform c8\n"); return; } uniform_constants[9] = glGetUniformLocation(vertexProgramsNV[0], "c9"); if (uniform_constants[9] == -1) { fprintf(stderr, "Could not bind uniform c9\n"); //return; } uniform_constants[10] = glGetUniformLocation(vertexProgramsNV[0], "c10"); if (uniform_constants[10] == -1) { fprintf(stderr, "Could not bind uniform c10\n"); return; } uniform_constants[11] = glGetUniformLocation(vertexProgramsNV[0], "c11"); if (uniform_constants[11] == -1) { fprintf(stderr, "Could not bind uniform c11\n"); return; } uniform_constants[12] = glGetUniformLocation(vertexProgramsNV[0], "c12"); if (uniform_constants[12] == -1) { fprintf(stderr, "Could not bind uniform c12\n"); return; } uniform_constants[13] = glGetUniformLocation(vertexProgramsNV[0], "c13"); if (uniform_constants[13] == -1) { fprintf(stderr, "Could not bind uniform c13\n"); return; } uniform_constants[14] = glGetUniformLocation(vertexProgramsNV[0], "c14"); if (uniform_constants[14] == -1) { fprintf(stderr, "Could not bind uniform c14\n"); return; } uniform_constants[15] = glGetUniformLocation(vertexProgramsNV[0], "c15"); if (uniform_constants[15] == -1) { fprintf(stderr, "Could not bind uniform c15\n"); //return; } uniform_constants[16] = glGetUniformLocation(vertexProgramsNV[0], "c16"); if (uniform_constants[16] == -1) { fprintf(stderr, "Could not bind uniform c16\n"); return; } uniform_constants[17] = glGetUniformLocation(vertexProgramsNV[0], "c17"); if (uniform_constants[17] == -1) { fprintf(stderr, "Could not bind uniform c17\n"); //return; } // Load the view position into c[8] glUniform4f( uniform_constants[8], 0.0f, 0.0f, 100.0f, 1.0f); // Load cosine series constants into c[9] glUniform4f( uniform_constants[9], 1.0f, -1.0f/2.0f, 1.0f/24.0f, -1.0f/720.0f); // Constants for cosine glUniform4f( uniform_constants[10], 0.0f, 0.5f, 1.0f, 0.2f); glUniform4f( uniform_constants[11], 0.25f, -9.0f, 0.75f, 1.0f / (2.0f * M_PI) ); glUniform4f( uniform_constants[12], 24.9808039603f, -24.9808039603f, -60.1458091736f, 60.1458091736f ); glUniform4f( uniform_constants[13], 85.4537887573f, -85.4537887573f, -64.9393539429f, 64.9393539429f ); glUniform4f( uniform_constants[14], 19.7392082214f, -19.7392082214f, - 1.0f, 1.0f ); // Light position glUniform4f( uniform_constants[15], 0.0f, 0.7f, 0.7f, 1.0f ); glUniform4f( uniform_constants[17], 0.3f, 0.3f, 0.3f, 1.0f ); glDeleteShader(vs); glDeleteShader(fs); }

Now, one of your first thoughts might be "why on earth are you using glVertex3fv and friends?" FYI I didn't write the original code, this came from a [very] old version of the NVSDK and this code was invaluable to me and my future endeavours, so I wanted to expand on it.

Also, I wanted to state that instead of inverting and transposing the modelview matrix every frame, I thought that using gl_NormalMatrix would suffice (since it's essentially the same thing in a 3x3 matrix). Not sure if that matters, but I thought I'd add that in there anyway.

Lastly, I'm using GLSL 1.2 for the time being because I want to port this to OpenGL ES 2.x+ later on. Of course, my main goal is just getting it to work, so I can move on to more important things. After this works, I'll be moving on to GLSL 4.3, of course.

Hopefully this is enough information, and sorry if I started going off on tangents. I'm almost to the point where I'm ready to hire someone to help me with this! This really sucks. Any ideas? Thanks, I really appreciate it.

Shogun.