Jump to content
  • Advertisement
Sign in to follow this  
AnujKalia

ARB_vertex_program on ATI graphics card

This topic is 2392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I'm using the following ARB vertex program. I have an ATI 5000 series graphics card. However, I'm not seeing any texture on my models. Could someone point out how to correct this? The author of the code says that his texturing works fine (but on an Nvidia graphics card)


"!!ARBvp1.0\n"\
"PARAM constant = { 1, 3, 0, 0 };\n"\
"TEMP R0, R1, R2, R3, R4, R5;\n"\
"ADDRESS A0;\n"\
"ATTRIB texCoord = vertex.attrib[8];\n"\
"ATTRIB normal = vertex.attrib[2];\n"\
"ATTRIB index = vertex.attrib[3];\n"\
"ATTRIB weight = vertex.attrib[1];\n"\
"ATTRIB position = vertex.attrib[0];\n"\
"PARAM worldViewProjMatrix[4] = { state.matrix.mvp };\n"\
"PARAM diffuse = state.material.diffuse;\n"\
"PARAM ambient = state.material.ambient;\n"\
"PARAM lightDir = state.light[0].position;\n"\
"PARAM matrix[87] = { program.local[0..86] };\n"\
"\n"\
"MOV result.texcoord[0].xy, texCoord.xyxx; \n"\
"\n"\
"MUL R4, index, constant.y; \n"\
"\n"\
"ARL A0.x, R4.y;\n"\
"DP3 R0.x, matrix[A0.x].xyzx, normal.xyzx;\n"\
"DP3 R0.y, matrix[A0.x + 1].xyzx, normal.xyzx;\n"\
"DP3 R0.z, matrix[A0.x + 2].xyzx, normal.xyzx;\n"\
"MUL R1.yzw, R0.xxyz, weight.y;\n"\
"\n"\
"ARL A0.x, R4.x;\n"\
"DP3 R0.x, matrix[A0.x].xyzx, normal.xyzx;\n"\
"DP3 R0.y, matrix[A0.x + 1].xyzx, normal.xyzx;\n"\
"DP3 R0.z, matrix[A0.x + 2].xyzx, normal.xyzx;\n"\
"MAD R1.yzw, R0.xxyz, weight.x, R1.yyzw;\n"\
"\n"\
"DP3 R0.x, R1.yzwy, R1.yzwy;\n"\
"RSQ R0.x, R0.x;\n"\
"MUL R0.xyz, R0.x, R1.yzwy;\n"\
"DP3 R1.x, lightDir.xyzx, lightDir.xyzx;\n"\
"RSQ R1.x, R1.x;\n"\
"MUL R2.xyz, R1.x, lightDir.xyzx;\n"\
"DP3 R0.x, R0.xyzx, R2.xyzx;\n"\
"MAX R0.x, R0.x, constant.z;\n"\
"ADD R0, R0.x, ambient;\n"\
"MUL result.color.front.primary, R0, diffuse;\n"\
"\n"\
"ARL A0.x, R4.w;\n"\
"DPH R0.x, position.xyzx, matrix[A0.x];\n"\
"DPH R0.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R0.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"ARL A0.x, R4.z;\n"\
"DPH R3.x, position.xyzx, matrix[A0.x];\n"\
"DPH R3.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R3.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"ARL A0.x, R4.y;\n"\
"DPH R1.y, position.xyzx, matrix[A0.x];\n"\
"DPH R1.z, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R1.w, position.xyzx, matrix[A0.x + 2];\n"\
"MUL R2.xyz, R1.yzwy, weight.y;\n"\
"\n"\
"ARL A0.x, R4.x;\n"\
"DPH R1.x, position.xyzx, matrix[A0.x];\n"\
"DPH R1.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R1.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"MAD R1.xyz, R1.xyzx, weight.x, R2.xyzx;\n"\
"MAD R1.xyz, R3.xyzx, weight.z, R1.xyzx;\n"\
"MAD R0.xyz, R0.xyzx, weight.w, R1.xyzx;\n"\
"\n"\
"DPH result.position.x, R0.xyzx, worldViewProjMatrix[0];\n"\
"DPH result.position.y, R0.xyzx, worldViewProjMatrix[1];\n"\
"DPH result.position.z, R0.xyzx, worldViewProjMatrix[2];\n"\
"DPH result.position.w, R0.xyzx, worldViewProjMatrix[3];\n"\
"END\n";

Share this post


Link to post
Share on other sites
Advertisement

Hi! I'm using the following ARB vertex program. I have an ATI 5000 series graphics card. However, I'm not seeing any texture on my models. Could someone point out how to correct this? The author of the code says that his texturing works fine (but on an Nvidia graphics card)


"!!ARBvp1.0\n"\
"PARAM constant = { 1, 3, 0, 0 };\n"\
"TEMP R0, R1, R2, R3, R4, R5;\n"\
"ADDRESS A0;\n"\
"ATTRIB texCoord = vertex.attrib[8];\n"\
"ATTRIB normal = vertex.attrib[2];\n"\
"ATTRIB index = vertex.attrib[3];\n"\
"ATTRIB weight = vertex.attrib[1];\n"\
"ATTRIB position = vertex.attrib[0];\n"\
"PARAM worldViewProjMatrix[4] = { state.matrix.mvp };\n"\
"PARAM diffuse = state.material.diffuse;\n"\
"PARAM ambient = state.material.ambient;\n"\
"PARAM lightDir = state.light[0].position;\n"\
"PARAM matrix[87] = { program.local[0..86] };\n"\
"\n"\
"MOV result.texcoord[0].xy, texCoord.xyxx; \n"\
"\n"\
"MUL R4, index, constant.y; \n"\
"\n"\
"ARL A0.x, R4.y;\n"\
"DP3 R0.x, matrix[A0.x].xyzx, normal.xyzx;\n"\
"DP3 R0.y, matrix[A0.x + 1].xyzx, normal.xyzx;\n"\
"DP3 R0.z, matrix[A0.x + 2].xyzx, normal.xyzx;\n"\
"MUL R1.yzw, R0.xxyz, weight.y;\n"\
"\n"\
"ARL A0.x, R4.x;\n"\
"DP3 R0.x, matrix[A0.x].xyzx, normal.xyzx;\n"\
"DP3 R0.y, matrix[A0.x + 1].xyzx, normal.xyzx;\n"\
"DP3 R0.z, matrix[A0.x + 2].xyzx, normal.xyzx;\n"\
"MAD R1.yzw, R0.xxyz, weight.x, R1.yyzw;\n"\
"\n"\
"DP3 R0.x, R1.yzwy, R1.yzwy;\n"\
"RSQ R0.x, R0.x;\n"\
"MUL R0.xyz, R0.x, R1.yzwy;\n"\
"DP3 R1.x, lightDir.xyzx, lightDir.xyzx;\n"\
"RSQ R1.x, R1.x;\n"\
"MUL R2.xyz, R1.x, lightDir.xyzx;\n"\
"DP3 R0.x, R0.xyzx, R2.xyzx;\n"\
"MAX R0.x, R0.x, constant.z;\n"\
"ADD R0, R0.x, ambient;\n"\
"MUL result.color.front.primary, R0, diffuse;\n"\
"\n"\
"ARL A0.x, R4.w;\n"\
"DPH R0.x, position.xyzx, matrix[A0.x];\n"\
"DPH R0.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R0.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"ARL A0.x, R4.z;\n"\
"DPH R3.x, position.xyzx, matrix[A0.x];\n"\
"DPH R3.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R3.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"ARL A0.x, R4.y;\n"\
"DPH R1.y, position.xyzx, matrix[A0.x];\n"\
"DPH R1.z, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R1.w, position.xyzx, matrix[A0.x + 2];\n"\
"MUL R2.xyz, R1.yzwy, weight.y;\n"\
"\n"\
"ARL A0.x, R4.x;\n"\
"DPH R1.x, position.xyzx, matrix[A0.x];\n"\
"DPH R1.y, position.xyzx, matrix[A0.x + 1];\n"\
"DPH R1.z, position.xyzx, matrix[A0.x + 2];\n"\
"\n"\
"MAD R1.xyz, R1.xyzx, weight.x, R2.xyzx;\n"\
"MAD R1.xyz, R3.xyzx, weight.z, R1.xyzx;\n"\
"MAD R0.xyz, R0.xyzx, weight.w, R1.xyzx;\n"\
"\n"\
"DPH result.position.x, R0.xyzx, worldViewProjMatrix[0];\n"\
"DPH result.position.y, R0.xyzx, worldViewProjMatrix[1];\n"\
"DPH result.position.z, R0.xyzx, worldViewProjMatrix[2];\n"\
"DPH result.position.w, R0.xyzx, worldViewProjMatrix[3];\n"\
"END\n";



I've only really glanced over it so I can't be sure, but it looks like this is simply doing a matrix transform alongside some weighted bone transforms?
There's no sampling here, infact there's no sampler/texture registers declared either.The texture coordinates are simply passed through to the next stage.
It looks like the issue is probably in your pixel shader. Or the vertex data is incorrect - or your vertex attribute declaration is incorrect and the attributes are getting mapped to the wrong registers...

Share this post


Link to post
Share on other sites
Hi!
Thanks for replying.

You are right. Its a shader for hardware skinning that Cal3D provides as an example. But, I'm not using any fragment shader (is that a pixel shader?) and I'm expecting the default fragment shader to do its job.

Also, I guess that the attributes are getting mapped correctly because the animation is working fine. Only the textures are not appearing!

Here's some more code

Creating the buffers:

glGenBuffersARB(6, m_bufferObject);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[0]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalVertexCount()*3*sizeof(float),(const void*)pVertexBuffer, GL_STATIC_DRAW_ARB);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[1]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalVertexCount()*4*sizeof(float),(const void*)pWeightBuffer, GL_STATIC_DRAW_ARB);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[2]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalVertexCount()*3*sizeof(float),(const void*)pNormalBuffer, GL_STATIC_DRAW_ARB);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[3]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalVertexCount()*4*sizeof(float),(const void*)pMatrixIndexBuffer, GL_STATIC_DRAW_ARB);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[4]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalVertexCount()*2*sizeof(float),(const void*)pTexCoordBuffer, GL_STATIC_DRAW_ARB);

glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferObject[5]);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_calHardwareModel->getTotalFaceCount()*3*sizeof(CalIndex),(const void*)pIndexBuffer, GL_STATIC_DRAW_ARB);


and here's the mapping:



glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[0]);
glVertexAttribPointerARB(0, 3 , GL_FLOAT, false, 0, NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[1]);
glVertexAttribPointerARB(1, 4 , GL_FLOAT, false, 0, NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[2]);
glVertexAttribPointerARB(2, 3 , GL_FLOAT, false, 0, NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[3]);
glVertexAttribPointerARB(3, 4 , GL_FLOAT, false, 0, NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferObject[4]);
glVertexAttribPointerARB(8, 2 , GL_FLOAT, false, 0, NULL);

glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferObject[5]);

Share this post


Link to post
Share on other sites
I ran the exe on 3 separate laptops, and found different results:

ATI (1GB): no texture at all!
ATI (512MB): bad texturing...can't describe how bad..

Intel Graphics (128MB): the texture appears perfectly!

Could someone explain?

Share this post


Link to post
Share on other sites
anything i can try to get it running on an ATI card? i'm going to try it on an nVidia card tonight but sadly i have to work on this ATI one!!!:(

Share this post


Link to post
Share on other sites

anything i can try to get it running on an ATI card? i'm going to try it on an nVidia card tonight but sadly i have to work on this ATI one!!!:(

ATI is known for strict syntax requirements, nvidia for once has a less strict interpretation of GLSL. That often result in shaders running flawless on nvidia cards, but not running at all on ATI. Always check for errors when compiling you shaders and log them, the error messages contain detailed information about the type and occurrence of syntax errors.

Share this post


Link to post
Share on other sites

[quote name='anujkaliaiitd' timestamp='1320672087' post='4881386']
anything i can try to get it running on an ATI card? i'm going to try it on an nVidia card tonight but sadly i have to work on this ATI one!!!:(

ATI is known for strict syntax requirements, nvidia for once has a less strict interpretation of GLSL. That often result in shaders running flawless on nvidia cards, but not running at all on ATI. Always check for errors when compiling you shaders and log them, the error messages contain detailed information about the type and occurrence of syntax errors.
[/quote]

He isn't using GLSL. He is using the 8 year old ASM extension.

Share this post


Link to post
Share on other sites
It works like a charm with an nVidia card! Thanks Anshaman73! Still, any suggestions are welcome. I don't want to try and convert it to GLSL just now because I'm a little out of time!

If someone wants to try it themselves, they can download the cal3D library from http://download.gna.org/cal3d/sources/?M=D.
(cal3d-complete-0.10.0.tar.bz2)I'm running miniviewer_gl_vp from the examples folder.
I guess you will need to build the cal3D libraries first.

Share this post


Link to post
Share on other sites

It works like a charm with an nVidia card! Thanks Anshaman73! Still, any suggestions are welcome. I don't want to try and convert it to GLSL just now because I'm a little out of time!

If someone wants to try it themselves, they can download the cal3D library from http://download.gna....d/sources/?M=D.
(cal3d-complete-0.10.0.tar.bz2)I'm running miniviewer_gl_vp from the examples folder.
I guess you will need to build the cal3D libraries first.


Hi, just read your email,
the project where i translated the code to glsl. I don't have the time right now but i remember beeing "weight" to refer the weights related to 4 of the bones, which was the limit of influences for a vertex. Also matrix[86] contains the current state of the bones, hence limiting the amount of bones to 87/3 = 29. This was pretty easy once i knew what the opcode stands for ;)

Sorry i can't supply the glsl shader anymore.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!