vertex texture fetching dramatically slows down rendering

Started by
2 comments, last by g3k0 16 years ago
Hello... I can't handle with this problem... when I use texture in my vertex shader my application dramatically slows down... This is how I create texture: ================================================================= glGenTextures( 1, &_materialTex ); glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, _materialTex ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, texW, texH, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0 ); glBindTexture( GL_TEXTURE_2D, 0 ); ================================================================= this is my vertex program: ================================================================= varying vec3 Position; varying vec4 Color; varying vec3 ViewDir; varying vec3 LightDir; varying vec2 TexCoord; uniform sampler2D MaterialTex; uniform vec3 MaterialPosition; uniform vec3 MaterialSize; const vec3 eyePosition = vec3( 0, 0, 100 ); const vec3 lightPosition = vec3( 0, 100, 100 ); void main( void ) { TexCoord = gl_Vertex.xy / MaterialSize.xy; float depth = texture2D( MaterialTex, TexCoord ).x * MaterialSize.z; vec4 p = gl_Vertex; p.xyz += MaterialPosition; p.z += depth; p = gl_ModelViewMatrix * p; Position = gl_Vertex.xyz; Position.z += depth; Color = gl_Color; ViewDir = normalize( eyePosition - p.xyz ); LightDir = normalize( lightPosition - p.xyz ); gl_Position = gl_ProjectionMatrix * p; } ================================================================= Code generally works... but it really slows down rendering... when I comment line with texture2D() rendering backs to normal... I've tried many texture types (for example 8bit GL_RGBA), different filtering modes... but nothing helps... I have GeForce 6150... I render not many triangles (about 100)... (my graphic card supports Vertex Texture Fetching and it can use up to 4 textures in VS)... Difference in FPS is huge... without using texture access - 60 FPS, with - 0.5 FPS... I would be very grateful for any kind of help...
Advertisement
For that GPU (GF6 series), vertex textures are hardware accelerated with only a few 32bit float textures. Try internal texture format GL_RGBA32F_ARB or LUMINANCE32F_ARB (ARBTextureFloat) - see NVidia's "GPU Programming Guide", p. 39.

Kind regards,
Nicolai de Haan Brøgger
Ouch is that 6150 the integrated GPU and not a dedicated GFX card? If so that is probably another reason why it's slow...
WOW... You're genius!!! I've been looking for this in docs for a whole day, and I haven't found... Thanks a lot!!!

This topic is closed to new replies.

Advertisement