I’m writing a program that works similar to displacement mapping and needs to access texture in vertex shader.
However, my current code works quite slowly, about 0.2 fps.(the rendered result is correct though) After doing some debugging I found that this is caused by the “texture3D” function in the shader. If I remove this statement, the speed goes up to about 50 fps.
So I’m wondering if accessing texture in vertex shader is really that slow, or there’re some potential bugs in my program that I’m not aware of.
Here’s my source code
uniform sampler3D tex;
varying vec4 gl_FrontColor;
gl_Position = gl_ModelViewProjectionMatrix * res;
gl_FrontColor = vec4(1,1,1,0);
Could anyone with the experience of accessing texture in vertex shader give me some advice?
I’m working with a 6800GT, with the lastest driver(Forceware 71.89).
I think to get hardware accelerated vertex textures on Geforce 6 they need to be:
a) float texture format
b) not mipmapped
c) only 2D (possibly Rect?)
Correct me if I am wrong…
Well, I’m already using float texture format(GL_RGB32F_ARB) and mipmapping isn’t turned on.
I tried 2D texture as well but it didn’t make things better.(i.e., with texture2D() it’s quite slow and without it, it’s very fast)
I’m beginning to go mad on this. Is there anywhere I get some samples?
I’ve solved the problem.
What sqrt[-1] said is correct, it works only with 2D float textures.(You can calculate LOD for mipmapping by your own though) Besides, the filtering can only be GL_NEAREST or GL_NEAREST_MIPMAP_NEAREST(for min_filter). Otherwise, the vertices are processed by software and that’s why my program got rather slow.(I was using GL_LINEAR)
This is where I found related materials, it really helped a lot.
Hmmm, according to my own testings, using internal formats other than float luminance 32 would result into horrible slow downs.
This is how I declare my textures:
velocitiesTexture.create2DShell("Velocities Texture", width, height, GL_FLOAT, GL_LUMINANCE32F_ARB,
GL_LUMINANCE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST);
locationsTexture.create2DShell("Locations Texture", width, height, GL_FLOAT, GL_LUMINANCE32F_ARB, GL_LUMINANCE,
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST);
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.