Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl");
// load LVL
- SceneObject* tmp_world = new SceneObject(shader1, scale(3.f * vec3(1.f, .32f, 1.f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png");
+ SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(3.f)), 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);
view_angle_x(0),
view_angle_y(0),
view_dist(2),
- view(0.f),
- cameraPosition(vec3(0.0f, 0.0f, -2.0f))
+ view(0.f)
{
rotateView(0.f, -.5f);
}
tmp = shader->getUniformLocation("uView");
if (tmp >= 0)
glUniformMatrix4fv(tmp, 1, false, value_ptr(translate(view,-pos)));
-
- tmp = shader->getUniformLocation("cameraPos");
- if (tmp >= 0)
- glUniform3fv(tmp, 1, value_ptr(cameraPosition));
}
void ViewPort::rotateView(float angle_x, float angle_y){
view_angle_y = VIEW_BOT_LIM;
view = translate(vec3(0.f, 0.f, -view_dist))*rotate(view_angle_y *(float)M_PI_2, vec3(1.f, 0.f, 0.f))*rotate(view_angle_x * (float)M_PI_2, vec3(0.f, 1.f, 0.f));
- cameraPosition = vec3(((rotate(view_angle_x * (float)M_PI_2, vec3(0.f, 1.f, 0.f)) * rotate(view_angle_y *(float)M_PI_2, vec3(1.f, 0.f, 0.f))) * vec4(0.f, 0.f, view_dist, 1.0f)));
}
}
unsigned int xpos;
unsigned int ypos;
- vec3 cameraPosition;
-
mat4 projection;
mat4 view;
void main()
{
- PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 0.f)).xyz;
+ PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 1.f)).xyz;
DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -0.f, 0.f)).xyz);
fUVs = aUV;
- vec4 world_Position = uView * uModel * vec4(aPosition, 1);
+ world_Position = (uView * uModel * vec4(aPosition, 1)).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((uModel * vec4(Normal, 0.0f)).xyz);
+ worldNormal = normalize((uView * uModel * vec4(Normal, 0.0f)).xyz);
- gl_Position = uProjection * world_Position;
+ gl_Position = uProjection * vec4(world_Position, 1);
}
\ No newline at end of file
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)
vec3 AmbientLightColor = 0 * vec3(0.2f, 0.2f, 0.2f);
vec3 PointLightColor1 = 0 * vec3(1.0f, 1.0f, 1.0f);
- vec3 DirectionalLightColor1 = 1 * vec3(0.6f, 0.6f, 0.6f);
+ vec3 DirectionalLightColor1 = 10 * vec3(0.6f, 0.6f, 0.6f);
- vec3 cameraVec = normalize(-world_Position.xyz);
- vec3 worldPointLightDir1 = PointLightPosition1 - world_Position.xyz;
+ vec3 cameraVec = normalize(-world_Position);
+ vec3 worldPointLightDir1 = PointLightPosition1 - world_Position;
vec3 PointLightDirection1 = normalize(worldPointLightDir1);
float SpecularCosPoint1 = clamp(dot(cameraVec, normalize(reflect(PointLightDirection1, worldNormal))), 0, 1);
float SpecularCosDirection1 = clamp(dot(cameraVec, -normalize(reflect(-DirectionalLightDirection1, worldNormal))), 0, 1);
- SpecularCosPoint1 = 0;
+ //SpecularCosPoint1 = 0;
//SpecularCosDirection1 = 0;
), uvColor.a);
- FragmentColor = vec4((normalize(worldNormal)+1)/2, 1.0f);
+ //FragmentColor = vec4((normalize(worldNormal)+1)/2, 1.0f);
//FragmentColor = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f);
//vec3 uvColor = texture(uColorTexture, fUVs).rgb;
- //FragmentColor = vec4(uvColor, 1.0);
+ FragmentColor = vec4(SpecularCosDirection1, SpecularCosDirection1, SpecularCosDirection1, 1.0);
}