Sign in to follow this  
g3k0

vertex texture fetching dramatically slows down rendering

Recommended Posts

g3k0    122
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...

Share this post


Link to post
Share on other sites
ndhb    246
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

Share this post


Link to post
Share on other sites
g3k0    122
WOW... You're genius!!! I've been looking for this in docs for a whole day, and I haven't found... Thanks a lot!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this