Hi,
I have this problem:
At the moment I using RenderMonkey to do some GLSL shader programs. In RenderMonkey the Tangent and Binormal for every vertex is given by:
attribute vec3 rm_Tangent;
attribute vec3 rm_Binormal;
I’m implementing this in Opengl.
At the moment I can calculate the Tangent and Binormal for every vertex, but How Do I Pass This Values To The Shader Program in OPENGL???
I know passing Uniforms and samplers in OpenGL can be done like this:
// Send Uniforms and samplers
glUseProgramObject(shaderProgram);
int myColor3f_Location = glGetUniformLocation(shaderProgram, “myColor3f”);
glUniform3f(myColor3f_Location, 1.0f, 0.5f, 0.2f);
int mySampler2D_Location = glGetUniformLocation(shaderProgram, “mySampler2D”);
glActiveTexture(GL_TEXTURE0); // MultiTexture activate Texture0
glBindTexture(GL_TEXTURE_2D, texture[0]);
glUniform1i(mySampler2D_Location, 0);
But how do I send Attributes??
Thanks.
Corrail
October 27, 2004, 3:18am
#2
You can either pass them by using texture coordinates (glMultiTexCoord) or by using glVertexAttrib{1234}{bsifd ubusui}. See http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_shader.txt chapter 2.7 for more details.
Write something like this:
float *m_pT; // Array of Tangents
glEnableVertexAttribArrayARB(6); // use 7 for binormals
glVertexAttribPointerARB(6, 3, GL_FLOAT, GL_FALSE, 0, m_pT);
glBindAttribLocationARB(ProgramObject, 6, “rm_Tangent”);
glLinkProgramARB(ProgramObject);
Don’t forget to Link the program AFTER doing the glBindAttribLocationARB.
There was also this extension:
GL_EXT_coordinate_frame (published back to 1998 !)
With two new functions:
glBinormalPointerEXT
glTangentPointerEXT
But actually no video card supports it (due to patents issues)
system
closed
October 19, 2021, 7:49pm
#6
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.