• Advertisement
Sign in to follow this  

GLSL vertex shader issue

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

Hi, i'm dealing with the following issue:i've written a shader which uses a 1d texture to offset the height of a terrain such as: vec4 height_map = texture1D(heightmap_sampler, gl_MultiTexCoord0.x); vec4 vertex = gl_Vertex; max_height = 0.0; vertex.y = max_height * height_map; . . . Result is: On a relatively new card (quadro :)) i get a drop of 15fps on a 60k triangle mesh (400fps - 385fps). On my other pc though (7800gt) i get 3fps!!!!!!! Is there an issue on this card with glsl texture fetching on vertex shaders?any workaround? p.s. is there any way to see which profile my card support?

Share this post


Link to post
Share on other sites
Advertisement
Vertex texture fetch is generally not very fast but 3fps sounds excessively slow. You should take a look at the shader info log that is generated on the slower card. Maybe that gives you a clue on why it is that slow.

And also make sure there are no gl errors in your application.

Share this post


Link to post
Share on other sites
What kind of texture format and filtering did you setup? Sounds like you are in software mode.

GL_RGBA_FLOAT32_ATI and maybe the RGB variant and only GL_NEAREST for filtering only for GF7&6 series I am not sure what is supported on GF8 series, but I am guessing filtering is allowed finally.

Share this post


Link to post
Share on other sites
this is my texture setup.
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glClear(GL_COLOR_BUFFER_BIT);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);

how can i be in software mode?

p.s. the shader info log says nothing. shaders are compiled, linked and validated fine :(.

Share this post


Link to post
Share on other sites
Can you post the entire shader code?

There seem to be some weird things going on in that code like:
vertex.y = max_height * height_map; <- storing an array in a float

Share this post


Link to post
Share on other sites
sure:

i noticed what you said and im just passing a float instead of a vec

the problem is that glsldevil doesnt do shader debugging on any pc ive tried with my app. apparently it doesnt like gldrawarrays

uniform mat4 world_matrix;
uniform sampler2D heightmap_sampler;
varying float height;
float max_height;

void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 height_map = texture2D(heightmap_sampler, gl_TexCoord[0].xy);

vec4 vertex = gl_Vertex;
max_height = 800.0;
vertex.y = max_height * height_map.r;
height = vertex.y;

gl_Position = gl_ModelViewProjectionMatrix * world_matrix * vertex;
}

EDIT: actually im generating the texture as GL_BGR format and GL_RGB internal format since im reading from a bmp. this shouldnt make a difference but im mentioning it anyways.

Share this post


Link to post
Share on other sites
You are in software mode from your code posting

here is a correct setup

GLuint vertex_texture;
glGenTextures(1, &vertex_texture);
glBindTexture(GL_TEXTURE_2D, vertex_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_FLOAT32_ATI, width, height, 0,
GL_LUMINANCE, GL_FLOAT, data);




Vertex textures are bound using the standard texture calls, using the
GL_TEXTURE_2D texture targets. Currently only the
GL_LUMINANCE_FLOAT32_ATI and GL_RGBA_FLOAT32_ATI formats are
supported for vertex textures. These formats contain a single or four channels of
32-bit floating point data, respectively. Be aware that using other texture formats or
unsupported filtering modes may cause the driver to drop back to software vertex
processing, with a commensurate drop in interactive performance.

Share this post


Link to post
Share on other sites
ok i tried sending my texture as GL_LUMINANCE_FLOAT32_ATI but there was no difference in fps :(.

Ok im in software mode since im using this. so how can i be in hardware mode and how do i know the things i need to change? i havent found a good reference on that :(.

Share this post


Link to post
Share on other sites
Quote:
MARS_999
Currently only the GL_LUMINANCE_FLOAT32_ATI and GL_RGBA_FLOAT32_ATI formats are supported for vertex textures.


I might be misunderstanding, but I'd be very surprised if I couldn't use other formats in vertex textures (e.g. GL_RGBA8).

Also, is GL_LUMINANCE_FLOAT32_ATI the same as GL_LUMINANCE32F_ARB?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement