PDA

View Full Version : GL_TEXTURE_3D in CG v1.4 vertex shader?



nitschke
03-27-2006, 08:34 AM
hi guys!

is it possible to do a tex3d(sampler3D, float3) call to access a 3d texture in a cg vertex shader?

the whitepaper from nvidia about using vertex textures only mentions the use of a 2d texture.
(http://developer.nvidia.com/object/using_vertex_textures.html)

thanks a lot!
chris

Relic
03-27-2006, 09:25 AM
That same document contains this sentence:
"GeForce 6800 supports D3DFMT_R32F and D3DFMT_A32B32G32R32F texture
formats (2D, cubemap, volume) for vertex texturing."
Give it a try.

nitschke
03-29-2006, 12:22 AM
ok thanks,
but when i want to use opengl, i can just use sampler2D... or?

Relic
03-29-2006, 03:13 AM
Cg and GLSL both contain sampler3D types. There should be no difference using Cg, GLSL or ARB_vertex_program assembly interface to do a vertex texture lookup. Should just work on a board supporting GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS > 0.

nitschke
03-30-2006, 08:58 AM
yes, i know.
but i wanted to say, that i want to use opengl, not direct3d.
the sentence from the document, that you mentioned is related to directx, but not opengl.

cg and glsl, both contain sampler3d types, but in the vertex shader together with opengl only sampler2d could be used (stated in the document, but the last revision is from 2004, so i thought, there might be changes).

when i try sampler3d, i get no compilation error, but the rendering result turns black.

Relic
03-30-2006, 10:58 AM
Originally posted by nitschke:
but in the vertex shader together with opengl only sampler2d could be used (stated in the document, but the last revision is from 2004, so i thought, there might be changes).
You mean the sentence Vertex textures are bound using the standard texture calls, using the GL_TEXTURE_2D texture targets.

I guess that goes for the given example.



when i try sampler3d, i get no compilation error, but the rendering result turns black.
Ok, does it work with a 2D map?
You're sure everything else is setup correctly?
Filtering set to GL_NEAREST?
Add glGetError calls to debug.

Don't use black glClearColor during debug to see if you rendered something black on black.

Simplest test would be to put the texture data into the gl_FrontColor in the vertex shader to see if it affects it.

Show the vertex shader, the texture setup and the view and geometry code.

nitschke
04-03-2006, 05:06 AM
thanks for your help.

but i switched my approach. now i am using 2d textures and map the 3d texture into on large 2d texture.
i have heard, that its faster to access 2d textures anyway, so i tried this method. and 2d textures definetely work with vertex shaders.