Jump to content


OpenGL VBO + displacement shader


4 replies to this topic

#1 gz0

    New Member

  • Members
  • Pip
  • 5 posts

Posted 04 July 2007 - 05:49 AM

Probably a newbie question/error, but please bear with me.
I have a VBO with mesh data. I'm trying to displace the vertexes, based on a float texture with the vertex shader.

The displacement shader works in immediate mode, 100%. But somehow when I apply the shader on the VBO things go wrong. It looks like the shader can't read the texel values from the texture when using VBO.

dv0 = texture2D(hData, gl_MultiTexCoord0.st);

When displacing with dv0.x (height values are stored in "red"), it is like it reads the value 0, cuz no vertex changes position. If I just displace the vertex, with texture coordinates multiplied with a scaling factor(just to check that the displacement indeed works). I get a nice inclined plane, as expected.

The fragment shader however, reads the value of the texel just fine.

Format of the height texture.

glGenTextures(1, &m_HeightTex);

glBindTexture(GL_TEXTURE_2D, m_HeightTex);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA_FLOAT32_ATI, 256,256,0,GL_RGBA,GL_FLOAT, tex);

I just wonder if it's anything special with VBO, some state or something I have ignored.
;-)

#2 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 482 posts
  • LocationNowhere whenever

Posted 04 July 2007 - 06:37 AM

gz0 said:

Probably a newbie question/error, but please bear with me.
I have a VBO with mesh data. I'm trying to displace the vertexes, based on a float texture with the vertex shader.

Most likely your card does not support texture fetches from vertex shaders (pretty much none do currently). Thus the vertex shader is run on the CPU, which then can't access the VBO for some reason..
http://iki.fi/sol - my schtuphh

#3 gz0

    New Member

  • Members
  • Pip
  • 5 posts

Posted 04 July 2007 - 06:47 AM

ty, will do it another way then =)
;-)

#4 martinsm

    Member

  • Members
  • PipPip
  • 88 posts

Posted 05 July 2007 - 07:26 AM

Nvidia 6x, 7x and 8x videocards supports texture fetches in vertex shader in OpenGL.
ATI doesn't (in OpenGL).

#5 gz0

    New Member

  • Members
  • Pip
  • 5 posts

Posted 07 July 2007 - 02:31 AM

Not via texture2D call though, you must use texture2DLod, someone could have told me that :P
;-)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users