Jump to content
  • Advertisement
Sign in to follow this  
Andrew Lucas

Vertex Texture Fetch

This topic is 3084 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

I'd need some help, as I'm trying to implement vertex texture fetching in my engine for faster rendering, but no matter what I do, it doesn't want to work. I have a Geforce 6 series graphics card, wich in theory should properly support it. I'm using Cg as my shader language, and I've used the compiler to check if I get any errors during compile, but everything worked out fine. I'm basically uploading my bone matrix data to a vertex texture I bind on initialization, and update it for each model I have to draw.
However, ingame, even the simplest models lag the scene horribly and they aren't drawn, like as if the vertex texture was full of zeroes. I'm pretty sure the maths in my vertex shader are working, and unless I actually bind the vertex texture in my code, it won't lag.

This is the code I use in the vertex shader:
bonemat[0] = tex2D(boneTexture, float2((vin.boneid*3)/512.0f, 0));
bonemat[1] = tex2D(boneTexture, float2(((vin.boneid*3)+1)/512.0f, 0));
bonemat[2] = tex2D(boneTexture, float2(((vin.boneid*3)+2)/512.0f, 0));

vertex[0] = vin.pos[0] * bonemat[0][0] + vin.pos[1] * bonemat[0][1] + vin.pos[2] * bonemat[0][2] + bonemat[0][3];
vertex[1] = vin.pos[0] * bonemat[1][0] + vin.pos[1] * bonemat[1][1] + vin.pos[2] * bonemat[1][2] + bonemat[1][3];
vertex[2] = vin.pos[0] * bonemat[2][0] + vin.pos[1] * bonemat[2][1] + vin.pos[2] * bonemat[2][2] + bonemat[2][3];
vertex[3] = 1;

normal[0] = vin.norm[0] * bonemat[0][0] + vin.norm[1] * bonemat[0][1] + vin.norm[2] * bonemat[0][2];
normal[1] = vin.norm[0] * bonemat[1][0] + vin.norm[1] * bonemat[1][1] + vin.norm[2] * bonemat[1][2];
normal[2] = vin.norm[0] * bonemat[2][0] + vin.norm[1] * bonemat[2][1] + vin.norm[2] * bonemat[2][2];

The bone ID is sent through the second multitexture unit as a float.

This is how I request the texture:
glBindTexture(GL_TEXTURE_2D, m_iBoneTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA_FLOAT32_ATI, 512, 2, 0, GL_RGBA, GL_FLOAT, 0);

And how I update this:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 2, GL_RGBA, GL_FLOAT, (*m_pbonetransform));

m_pbonetransform is a 128x3x4 float matrix. I tried getting over this for a long time, but I have no idea what I'm doing wrong here. I'd be really thankful for any help that there is.

Share this post


Link to post
Share on other sites
Advertisement
Firstly

GL_RGBA_FLOAT32_ATI

on an Nvidia card?

Secondly have you tried just a simple texture and single sample to see if you have it working?

Thirdly, a 6600 is ancient now. I specifically remember that it had problems with vertex texture fetches. Usually cripplingly bad performance or not working at all.

Edit:

Also try using standard textures and not floats. Your hardware probably doesn't support floating point textures.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!