So I have an array of OpenTK.Vector3 that I want to pass into a shader, but it seems that GL.Uniform3 has no overload for that. How should I go about doing this? I want to use an unsized array, and iterate over it in the shader
Frag Shader:
#version 330 core
uniform vec4 ambient; //ambient lightining
uniform vec3[2] lightDir; //directional light direction array
uniform vec4[2] lightColor; //light color array
smooth in vec4 fragColor;
in vec3 _normal;
out vec4 outputColor;
void main(void){
vec4 diff = vec4(0.0f);
//iterates over all lights and calculate diffuse
for(int i = 0; i < lightDir.length(); i++) {
diff += max(dot(_normal, normalize(-lightDir[i])), 0.0f) * lightColor[i];
}
outputColor = fragColor * (diff + ambient);
}
F# Code:
let lamps = [
{
direction = Vector3(0.0f, -1.0f, 0.0f)
color = Vector4(0.0f, 0.0f, 1.0f, 1.0f)
},
{
direction = Vector3(2.0f, 1.0f, 1.0f)
color = Vector4(1.0f, 0.0f, 0.0f, 1.0f)
}
]
let ambientLocation = GL.GetUniformLocation(program, "ambient")
GL.Uniform4(ambientLocation, Vector4(0.2f, 0.2f, 0.2f, 1.0f))
let lightDirLocation = GL.GetUniformLocation(program, "lightDir")
GL.Uniform3(lightDirLocation, (lamps |> List.map (fun l -> l.direction) |> List.toArray))
let lightColorLocation = GL.GetUniformLocation(program, "lightColor")
GL.Uniform4(lightColorLocation, (lamps |> List.map (fun l -> l.color) |> List.toArray))
The Editor informs me that Vector3 [] is not compatible with Vector3 or Vector3 ref How should I go about this?