]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
shader stuff
authorLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 23:16:07 +0000 (01:16 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 23:16:07 +0000 (01:16 +0200)
Weave/Game.cpp
Weave/Graphix/ViewPort.cpp
Weave/Graphix/ViewPort.h
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index 0a6af339af388bd6a7ecdfc5e29020fa53ee31e7..861cf158501b3715d2eaba33af977104b7e1ccd7 100644 (file)
@@ -47,7 +47,7 @@ Game::Game() : playing(true)
        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);
 
index ebb112785302aadb9e8713884f7c7ea4fda03563..affc90aba20b5c44f4f02848185729691e4da3c7 100644 (file)
@@ -18,8 +18,7 @@ ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsign
        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);
 }
@@ -66,10 +65,6 @@ void ViewPort::bindView(Shader* shader, vec3 pos) const{
        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){
@@ -87,7 +82,6 @@ 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)));
        }
 
 }
index baf7c328f0f97c9592bbf55aa0077cc969e05242..fdb0a4ecea16c1c31d7291c5385dfac40a4e577e 100644 (file)
@@ -34,8 +34,6 @@ protected:
        unsigned int xpos;
        unsigned int ypos;
 
-       vec3 cameraPosition;
-
        mat4 projection;
        mat4 view;
 
index 4e614d9812741aea9de4849ebde0c234df03525e..a46f53e134c663715d47b50ee88e5ad8d4b02619 100644 (file)
@@ -17,16 +17,16 @@ uniform int uEnableTransp = 1;
 
 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
index e281291d788b85139f249ef93a104417fd069e3f..c394fe2c3be4f926e40f37044a0fe92dc584674e 100644 (file)
@@ -7,7 +7,6 @@ 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)
  
@@ -19,16 +18,16 @@ void main()
 
        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;
 
 
@@ -46,9 +45,9 @@ void main()
                ), 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);
 }