pegasy
04-28-2005, 12:39 AM
hi.
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;
void main(void)
{
vec4 res=gl_Vertex;
vec3 sum=vec3(0,0,0);
sum=texture3D(tex,gl_MultiTexCoord0.xyz).xyz;
res+=vec4(sum,0);
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?
Thanks.
I'm working with a 6800GT, with the lastest driver(Forceware 71.89).
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;
void main(void)
{
vec4 res=gl_Vertex;
vec3 sum=vec3(0,0,0);
sum=texture3D(tex,gl_MultiTexCoord0.xyz).xyz;
res+=vec4(sum,0);
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?
Thanks.
I'm working with a 6800GT, with the lastest driver(Forceware 71.89).