After over a decade in OpenGL I finally poked at some DirectX. I'm curious how the driver deals with this if anyone knows. Might be confusing but the basics are my mesh data below doesn't have a w coordinate for obvious data reasons. In DirectX I can simply bind the position data as a float4, and just set the w coordinate. In OpenGL I am not allowed to modify the w coordinate of an input. I have to create a temporary vec4 from the input and set w to 1.
My assumption here is that in Directx the vertex shader input is already copied to a useable temp variable that I can modify without modifying the actual mesh buffer. In openGL my assumption is that this the input coming in is actually the input buffer itself which it will not let me modify or my mesh buffer would be changing.
Mesh buffer layout: [float x, float y, float z, float textureU, float textureV]
DirectX layout/shader:
struct Input{float4 position, float2 uv};
main(){ position.w = 1.0; // do stuff here}
OpenGL layout/shader (Works)
(layout location = 0) in vec3 position;
(layout location = 1) in vec2 uv;
main(){ float4 newPosition = vec4(position, 1.0); // do stuff} works
OpenGL layout/shader (fails compilation, can't modify varying)
(layout location = 0) in vec4 position;
(layout location = 1) in vec2 uv;
main(){ position.w = 1.0); // do stuff} // compilation error modifying input varying