Hello everyone,
I’m currently developing a simple 3D game engine in C# using OpenTK. At the moment I’m implementing some lighting into my engine, I have a mesh that I’ve imported into the engine; also a method which calculates normals.
So the issue is this: I’ve created a material structure in GLSL, that hold a vec3 called ‘diffuseColor’, I’ve also created two other structures which define a directional light. Here are the three structures (just to clarify):
struct Material
{
vec3 diffuseColor;
};
struct BaseLight
{
vec3 color;
float energy;
};
struct DirectionalLight
{
BaseLight baseLight;
vec3 direction;
};
For some reason, if I create a directional light in my scene, which a direction of vec3(1, 1, 1), and a color of vec3(1, 1, 1) with energy at 1.0 this is the result:
[ATTACH=CONFIG]1468[/ATTACH]
Here’s the calc light method, any help would be awesome! I’ve been at this for two days now!
vec3 CalculateDirectionalLight(DirectionalLight light, vec3 normal, vec3 viewDirection, Material material)
{
normal = normalize(normal);
vec3 lightDir = normalize(-light.direction);
float diffuseFactor = max(dot(normal, lightDir), 0.0);
vec3 ambient = vec3(0.2, 0.2, 0.2);
vec3 diffuse = (light.baseLight.color * light.baseLight.energy) * (diffuseFactor * material.diffuseColor);
return (ambient + diffuse);
}