View Full Version : vertex textures and glsl
02-23-2006, 06:53 AM
guys, i'm having a whale of a time getting acceleration with texture fetches in my vertex shaders :(
to be clear, it works, but it's not accelerated.
tried these formats:
using texture2DLod(s, xy, 0.0) for sampling.
it seem some folks have had success with fiddling with the texture format, but try as i might i can't get it to budge.
the opengl vertex texturing demo from nvidia works nicely, but uses nv_vertex_program3.
3dlabs validate says all is ok. infologs are clean. no opengl errors either :-)
p.s. it strikes me as incredibly freaky to need a 3rd party tool to tell me what my own compiler should :-)
geforce 6800 gs
forceware 82.12 and 83.90 (beta, no official drivers exist for this board, yet)
glsl 1.10 via cg 1.3 compiler
windows xp sp2
02-23-2006, 10:51 AM
On GeForce 6600 I used GL_LUMINANCE_FLOAT32_ATI, GL_NEAREST filtering but I used texture2D instead of texture2DLod.
My hints for you:
1. use texture2D instead of texture2DLod
2. do not use mipmaps on this texture (you said you use nearest filtering - I assume you don't have mipmaps)
3. make sure you have set GL_NEAREST to both min and mag filter
02-23-2006, 11:52 AM
thank you for the hints, k_szczech.
it doesn't seem to make any difference. i've tried all sorts of permutations with 2D: lod/no lod, and mips/no mips, even fiddled with texenv (GL_REPLACE seemed reasonable, but it doesn't seem to matter).
vertex texture fetching works like a charm in hlsl and cg on this board with these drivers, so i'm betting it's a glsl implementation thing with the cg compiler... or something.
just updated to the beta 83.90 drivers to no avail. ah well, such is life.
by the way, i'm just rendering a single spinning quad :-)
p.s. i'm using the 2.0 core entry points: would that make a difference?
02-23-2006, 03:45 PM
This is how I create texture:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_FLOAT32_ATI, sizeX, sizeY, 0,
GL_LUMINANCE, GL_FLOAT, data);This is how I use it from vertex shader:
vec4 pos = gl_Vertex;
pos.y += texture2D( myTexture, myTexCoord).r;
gl_Position = gl_ModelViewProjectionMatrix * pos;Everything else is left default (so wrap is GL_REPEAT). As you can see I really don't care about anything except that I turn off texture filtering.
It makes no difference what kind of texenv or blending you use - there are per-fragment operations.
I use OpenGL 1.5 entry points but this should really make no difference.
My next hint - check if you have your sampler2D uniform variable initialized properly - if you accidentally fetch sample from wrong texture unit in your vertex shader then you may end up trying to fetch from texture not supported by hardware.
If it's not the case then simplify your shader/application to minimum. Such approach worked for me when I ran into ATI's linker bug recently (I posted it 2 days ago).
If it still doesn't help then I'm gonna ask you to post some fragments of code - maybe this way I would be able to help.
Thee solution is out there...
PS. I've just checked clamping - works with GL_REPEAT, GL_CLAMP and GL_CLAMP_TO_EDGE on GeForce7800
02-23-2006, 05:13 PM
My next hint - check if you have your sampler2D uniform variable initialized properly - if you accidentally fetch sample from wrong texture unit in your vertex shader then you may end up trying to fetch from texture not supported by hardware.bingo. glGetUniformLocation isn't returning what i first assumed. you've earned your keep my friend. i'm going to tinker with this some more and i'll post results later.
by the way, does texture2DLod throw you into software on that 6600?
02-23-2006, 06:41 PM
well, it seems this has all been an unfortunate chain of blunders and missteps on my part. first was forgetting to convert my unicode names to ansi for glGetUniformLocation, and second was assuming that opengl would raise an error on supplying a -1 location to glUniform*, which it quietly ignores (sigh).
for the record, this works fine with all the texture formats listed (and perhaps others), with mipmaps or no, clamp or repeat wrap modes, and with texture2D and texture2DLod.
edit: this document outlines vertex texture use on nvidia hardware with gl 2.0:
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.