• Advertisement
Sign in to follow this  

Vertex program : POSITION

This topic is 3381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The input struct to a vertex program often look like this:
struct vertex_input
{
  float4 position : POSITION; 
  float4 normal   : NORMAL; 
};

But I have also stumbled across vertex programs where 'position' is just a float3 vector. If we assume that the data from the application does not change but we only change the position from float4 to float3 then what happens? I am pretty sure that the data from the application only contains 3 elements per vertex so I also wonder why position is sometimes defined as a float4.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
But I have also stumbled across vertex programs where 'position' is just a float3 vector. If we assume that the data from the application does not change but we only change the position from float4 to float3 then what happens?


It depends on what you are doing in the shader.
I'm guessing the vertex gets multiplied by a 4x4 matrix so if you make the vertex into a float3, then multiplying no longer becomes possible.
The Cg compiler would spit out some error message.

Share this post


Link to post
Share on other sites
But if position from the application is only a float3 vector what happens if the position in the vertex program is a float4 vector?

Share this post


Link to post
Share on other sites
afaik, if the VBO's vertex-pos data was specified via glVertexPointer, the .w=1.0f , but if you specify the vertex-pos via glVertexAttribPointer, w=0.

Share this post


Link to post
Share on other sites
Ok is there anyway to print out the elements in the position vector?

Share this post


Link to post
Share on other sites
From the shader? If so, then draw into a RGBA32f FBO, then glReadPixels. I usually do MRT (drawing to 4 textures at once) while debugging stuff like that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement