Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl");
// load LVL
- SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f, 1.0f, 2.5f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png");
+
+ SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f,1.f,2.5f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png");
+
tmp_world->ignore = true;
current_world->addObject(tmp_world);
in vec3 aNormal, aPosition;
in vec2 aUV;
-out vec3 world_Position, worldNormal;
+out vec3 eyePosition, worldNormal;
out vec2 fUVs;
out vec3 PointLightPosition1, DirectionalLightDirection1;
void main()
{
- PointLightPosition1 = (uView * vec4(0.0f, 0.3f, -3.0f, 1.f)).xyz;
- DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -0.f, 0.f)).xyz);
+ PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 1.f)).xyz;
+ DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -.5f, -.5f, 0.f)).xyz);
+
fUVs = aUV;
- world_Position = (uView * uModel * vec4(aPosition, 1)).xyz;
+ eyePosition = (uView * uModel * vec4(aPosition, 1.f)).xyz;
mat3 scale = transpose(mat3(uModel))*mat3(uModel);
vec3 Normal;
for (int i = 0; i < 3; ++i)
Normal[i] = 1/(scale[i][i])*aNormal[i];
worldNormal = normalize((uView * uModel * vec4(Normal, 0.0f)).xyz);
- gl_Position = uProjection * vec4(world_Position,1.f);
+ gl_Position = uProjection * vec4(eyePosition,1.f);
}
\ No newline at end of file
//Fragment Shader
#version 330
-in vec3 world_Position, worldNormal;
+in vec3 eyePosition, worldNormal;
in vec2 fUVs;
in vec3 PointLightPosition1, DirectionalLightDirection1;
out vec4 FragmentColor;
-uniform vec3 cameraPos;
uniform sampler2D uColorTexture;
uniform vec4 material; //vec4 in the form (ambient, point, directional, glossyness); so far it was (1, 1, 1, 3)
float specularConst = material[3];
vec4 uvColor = texture(uColorTexture, fUVs);
- vec3 AmbientLightColor = 0.5 * vec3(0.2f, 0.2f, 0.2f);
- vec3 PointLightColor1 = 1 * vec3(1.0f, 0.0f, 0.0f);
- vec3 DirectionalLightColor1 = 1 * vec3(0.6f, 0.6f, 0.6f);
+ vec3 AmbientLightColor = .5f * vec3(0.1f, 0.1f, 0.1f);
+ vec3 PointLightColor1 = 2 * vec3(1.0f, 1.0f, 1.0f);
+ vec3 DirectionalLightColor1 = 2 * vec3(0.6f, 0.6f, 0.6f);
- vec3 cameraVec = normalize(world_Position);
- vec3 worldPointLightDir1 = PointLightPosition1 - world_Position;
+ vec3 cameraVec = normalize(eyePosition);
+ vec3 worldPointLightDir1 = PointLightPosition1 - eyePosition;
vec3 PointLightDirection1 = normalize(worldPointLightDir1);
float SpecularCosPoint1 = clamp(dot(cameraVec, normalize(reflect(PointLightDirection1, worldNormal))), 0, 1);