-
Shaders and VBO
Hi there,
I having a problem with Shaders updating VBO, my question is
Can I have a shader that modify the vertex of a mesh and then recover the info of that modified vertex???
and if the answer is YES, How???
What I'm doing is this:
1.- The mesh geometry is in a VBO
2.- I applied the vertex shader to move the vertex...
3.- With glGetBufferData recover the supposing modified mesh data.
But when I check the data is the same as the source data.
I'm not sure that the shader modify the data of the VBO...
this is a piece of code of the shader
void main()
{
float k = heightMax - heightMin;
vec4 newVertexPos;
vec4 dv;
float df;
dv = texture2D(tex1,gl_MultiTexCoord0.xy);
float dim = (dimX + dimZ)*0.5;
dim = dim * dv.y;
k = k * dv.y ;
k = (k + dim)*0.1;
k = 10.0;
df = 0.30*dv.x + 0.59*dv.y + 0.11*dv.z;
normal = normalize(gl_NormalMatrix * gl_Normal);
newVertexPos = gl_Vertex + vec4(gl_Normal*df*k,0.0);
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;
}
Thanks
-
Senior Member
OpenGL Pro
Re: Shaders and VBO
Yes you can. It's called transform feedback.
You'll need either GL 3.0 or the ARB_TransformFeedback extension.
Basically you render a vertex buffer and capture the output into a different vertex buffer.
-
Re: Shaders and VBO
Thank you very much about the information, Now I'm looking for examples and try to recover the data...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules