So far, a great deal of the posts I've made to this board really haven't helped me. With my last few problems, I've ended up finding out the answers myself, sometimes not long after I make the post. Strange business, eh?
Anyway, I got bump-mapping to work with GL_ATI_vertex_array_object. I'm not quite comfortable with the method since I've ended up using glUpdateObjectBufferATI to change elements of my array. IMHO, this kinda defeats the whole purpose of them since I'm basically updating each and every element when I render a polygon. To increase efficiency, I've decided to try my hand at vertex shaders.
So far, I'm not having much luck. The result that appears on screen is just blank. In case it helps, here's how I defined my shader:
I believe that I set up the variant data correctly using glVariantArrayObjectATI and glEnableVariantClientStateEXT, as is explained in the GL_ATI_vertex_array_object specs. The normal, binormal, and tangent values for each vertex is defined in my data file and I'm quite sure I have them calculated correctly given that the same data works for when I'm not using the vertex shader.
A question I have is: Does it matter that my data uses 3 dimensional vectors, while vertex shaders use 4 dimensional vectors?
Anyway, I got bump-mapping to work with GL_ATI_vertex_array_object. I'm not quite comfortable with the method since I've ended up using glUpdateObjectBufferATI to change elements of my array. IMHO, this kinda defeats the whole purpose of them since I'm basically updating each and every element when I render a polygon. To increase efficiency, I've decided to try my hand at vertex shaders.
So far, I'm not having much luck. The result that appears on screen is just blank. In case it helps, here's how I defined my shader:
void OpenGLRenderer::CreateVertexShaders()
{
GLuint vertex;
vertex = glBindParameterEXT (GL_CURRENT_VERTEX_EXT);
tangentVariantID = glGenSymbolsEXT (GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);
binormalVariantID = glGenSymbolsEXT (GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);
normalVariantID = glGenSymbolsEXT (GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);
lightpos = glGenSymbolsEXT (GL_VECTOR_EXT, GL_INVARIANT_EXT, GL_FULL_RANGE_EXT, 1);
gluiVertexShader = glGenVertexShadersEXT (1);
glBindVertexShaderEXT (gluiVertexShader);
glBeginVertexShaderEXT ();
{
float scale = 0.5f;
float bias = 0.5f;
float identitymatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
GLuint lightscale; // the light scaling
GLuint lightbias; // the light bias
GLuint lightvec; // the light vector
GLuint lightvect; // the light vector in tangent space
GLuint colourtemp; // the temporary colour of the vertex
GLuint identmat; // the identity matrix
GLuint tanmat; // the tangent matrix
// generate temporary local variables
lightvec = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_NORMALIZED_RANGE_EXT, 1);
lightvect = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_NORMALIZED_RANGE_EXT, 1);
colourtemp = glGenSymbolsEXT (GL_VECTOR_EXT, GL_LOCAL_EXT, GL_NORMALIZED_RANGE_EXT, 1);
tanmat = glGenSymbolsEXT (GL_MATRIX_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);
// generate local constants
lightscale = glGenSymbolsEXT (GL_SCALAR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
lightbias = glGenSymbolsEXT (GL_SCALAR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
identmat = glGenSymbolsEXT (GL_MATRIX_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
// set the local constants
glSetLocalConstantEXT (lightscale, GL_FLOAT, &scale);
glSetLocalConstantEXT (lightbias, GL_FLOAT, &bias);
glSetLocalConstantEXT (identmat, GL_FLOAT, identitymatrix);
// generate the tangent matrix
glShaderOp1EXT (GL_OP_MOV_EXT, tanmat, identmat);
glInsertComponentEXT (tanmat, tangentVariantID, 0);
glInsertComponentEXT (tanmat, binormalVariantID, 1);
glInsertComponentEXT (tanmat, normalVariantID, 2);
// calculate the light vector
glShaderOp2EXT (GL_OP_SUB_EXT, lightvec, lightpos, vertex);
// calculate the light vector in tangent space
glShaderOp2EXT (GL_OP_MULTIPLY_MATRIX_EXT, lightvect, tanmat, lightvec);
// calculate the vertex colour
glShaderOp2EXT (GL_OP_MUL_EXT, colourtemp, lightvect, lightscale);
glShaderOp2EXT (GL_OP_ADD_EXT, GL_OUTPUT_COLOR0_EXT, colourtemp, lightbias);
glShaderOp1EXT (GL_OP_MOV_EXT, GL_OUTPUT_VERTEX_EXT, vertex);
}
glEndVertexShaderEXT ();
}
I believe that I set up the variant data correctly using glVariantArrayObjectATI and glEnableVariantClientStateEXT, as is explained in the GL_ATI_vertex_array_object specs. The normal, binormal, and tangent values for each vertex is defined in my data file and I'm quite sure I have them calculated correctly given that the same data works for when I'm not using the vertex shader.
A question I have is: Does it matter that my data uses 3 dimensional vectors, while vertex shaders use 4 dimensional vectors?