struct vertex_input
{
float4 position : POSITION;
float4 normal : NORMAL;
};
Vertex program : POSITION
The input struct to a vertex program often look like this:
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.
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.
But if position from the application is only a float3 vector what happens if the position in the vertex program is a float4 vector?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement