Hello there,
in the past I always used NVidia Cg for my Shaders in my applications. For a recent project we decided to switch to GLSL in order to try it out and learn it.
I have a little bit of trouble adjusting to it. One thing I can't wrap my head around is how to define input and output data in a proper way. It seems GLSL is very "loose". If I write
varying vec3 lightDir;
in both the vertex and the fragment shader, it seems its data is "magically" ;) available in both shaders. Anyway what I would like to hear from the GLSL users is, how you "properly" define your input and output variables. For instance, in Cg you can specifically assign the data of a hardware register to a variable. In Cg I always used structs like
struct a2v
{
float4 pos : POSITION;
float3 normal : NORMAL;
float2 texcoord : TEXCOORD0;
float4 tangent : TEXCOORD1;
float3 binormal : TEXCOORD2;
};
for the input of the vertex shader and
struct v2f
{
float4 color : COLOR0;
float4 hpos : POSITION;
float2 texcoord : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 normal : TEXCOORD2;
float3 tangent : TEXCOORD3;
float3 binormal : TEXCOORD4;
float3 view : TEXCOORD5;
float3 scale : TEXCOORD6;
};
for the input of the fragment shader, for example.
But what is a good, clean and readable way to do the same in GLSL?