PDA

View Full Version : Use texture as geometry



Foxbat
01-07-2007, 05:52 PM
I have a texture that is used as a texture. However, I'd also like to use the RGB values as XYZ vertex values. What would be the best way to do this?

k_szczech
01-07-2007, 10:00 PM
Two ways actualy - by rendering that texture to vertex buffer or by using this texture in vertex shader.
To use in shader it has to be FLOAT32 format with GL_NEAREST (no filtering and no mipmaps). It will require GeForce 6 / Radeon X1000 to work though.

unsigned void
01-07-2007, 10:27 PM
AFAIK, Radeon X1000 does not support any vertex texture formats...

Komat
01-07-2007, 10:30 PM
Originally posted by k_szczech:
To use in shader it has to be FLOAT32 format with GL_NEAREST (no filtering and no mipmaps). It will require GeForce 6 / Radeon X1000 to work though. No current ATI hw has support for texture fetches in vertex shader so it will work on Nvidia cards only.

Korval
01-07-2007, 11:13 PM
No current ATI hw has support for texture fetches in vertex shader so it will work on Nvidia cards only.I thought the X1xxx cards did have vertex texture support.

k_szczech
01-08-2007, 12:51 AM
Yeah, I thought they have floating point filtering, too. But it turns out that they have fp blending but still no filtering. Seems like when comes to floating point textures ATI is way behind NVIDIA.

knackered
01-08-2007, 03:29 AM
It's like I always say - if in doubt, get the nvidia card.

Bruce Merry
01-10-2007, 01:55 AM
Vertex texture fetch is supposed to have pretty high latency, at least in GeForce 6 and 7 (probably much better in GF8). You're probably better off using a separate vertex buffer for the geometry data.

If the texture is being generated on the GPU (e.g., with a FBO), you can use glReadPixels or glGetTexImage with the VBO bound to GL_PIXEL_PACK_BUFFER to do the copy entirely on the GPU.

knackered
01-11-2007, 12:07 AM
that's a great name you've got, bruce.

Aji Abraham
01-11-2007, 11:40 PM
HI
My name is Aji Abraham. Am now working with OpenGL Game Programming.. Now am in between a Big issue in thread programming.. My problem is that when i try to load GL textures in a thread (To load texture in background) glGenTextures is not working. is der any solution....

knackered
01-11-2007, 11:51 PM
Ok Aji, yours is a great name too. Happy?

(secretly I don't think it's as great a name as Bruce Merry)

yooyo
01-12-2007, 01:11 AM
@knackered:
:) )))))

@Aji Abraham:
OpenGL calls is allowed only from thread that own GL context. ie... when some app thread execute wglMakeCurrent(rc, dc) only that thread may do OpenGL calls.
There is a solution for your problem:
1. load texture data (using separate thread) in mem buffer and notify rendering thread to upload texture.
2. Create another GL context (temp_rc) and share lists (using wglShareLists call) with main rendering context. Then fire up texture-loader-thread and from *this* thread call wglMakeCurrent(temp_rc, dc). Now.. you can load and gen opengl textures from texture-loader-thread.