GLSL vertex shader issue

Started by
12 comments, last by V-man 15 years, 9 months ago
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?
Keyboard not found. Press F1 to Continue.
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.
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.
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 :(.
Keyboard not found. Press F1 to Continue.
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
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.
Keyboard not found. Press F1 to Continue.
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.
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 :(.
Keyboard not found. Press F1 to Continue.
Try "Simple Vertex Texture" from
http://developer.download.nvidia.com/SDK/9.5/Samples/3dgraphics_samples.html
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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?

This topic is closed to new replies.

Advertisement