]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
mid shader change
authorLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 00:24:59 +0000 (02:24 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 00:24:59 +0000 (02:24 +0200)
Weave/Graphix/ViewPort.cpp
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index aad59887b429c29fbdacd75cd7278c3f3ba0fab1..d252aa0780215d31ff55360668a4c7bd5049ef2f 100644 (file)
@@ -40,13 +40,14 @@ void ViewPort::bindView(Shader* shader) const{
        tmp = shader->getUniformLocation("uProjection");
        if (tmp >= 0)
                glUniformMatrix4fv(tmp, 1, false, value_ptr(projection));
-       tmp = shader->getUniformLocation("uInvProjection");
-       if (tmp >= 0)
-               glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection)));
+
+       //tmp = shader->getUniformLocation("uInvProjection");
+       //if (tmp >= 0)
+       //      glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection)));
 
        tmp = shader->getUniformLocation("uView");
        if (tmp >= 0)
-               glUniformMatrix4fv(shader->getUniformLocation("uView"), 1, false, value_ptr(view));
+               glUniformMatrix4fv(tmp, 1, false, value_ptr(view));
 }
 
 void ViewPort::bindView(Shader* shader, vec3 pos) const{
@@ -56,9 +57,10 @@ void ViewPort::bindView(Shader* shader, vec3 pos) const{
        tmp = shader->getUniformLocation("uProjection");
        if (tmp>=0)
                glUniformMatrix4fv(tmp, 1, false, value_ptr(projection));
-       tmp = shader->getUniformLocation("uInvProjection");
-       if (tmp >= 0)
-               glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection)));
+
+       //tmp = shader->getUniformLocation("uInvProjection");
+       //if (tmp >= 0)
+       //      glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection)));
 
        tmp = shader->getUniformLocation("uView");
        if (tmp >= 0)
index 56e442f2811ea5e5d8514ef9471aee881df4322d..370d418cd4f52a265c50c1db7f099f6ecf81ebba 100644 (file)
@@ -5,12 +5,12 @@ in vec3 aNormal, aPosition;
 //in vec3 lightPosition
 in vec2 aUV;
 
-out vec3 worldNormal, worldLightPoint1, DirectionalLightDirection1, cameraVec;
+out vec3 worldNormal, worldLightPoint1, DirectionalLightDirection1;// , cameraVec;
 out vec2 fUVs;
-//out float SpecularCosPoint1, SpecularCosDirection1;
+out float SpecularCosPoint1, SpecularCosDirection1;
 
 uniform mat4 uProjection, uView, uModel;
-uniform vec3 cameraPos;
+//uniform vec3 cameraPos;
 
 uniform int uEnableBloom = 1;
 uniform int uEnableTransp = 1;
@@ -21,8 +21,8 @@ void main()
        //for every directional light source define Direction and SpecularCos
        //everything else is in the Fragment Shader
 
-       vec3 PointLightPosition1 = vec3(0.0f, 5.0f, 0.0f);
-       vec3 DirectionalLightDirection1 = normalize(vec3(-0.0f, -1.0f, -0.0f));
+       vec3 PointLightPosition1 = vec3(0.0f, 1.0f, 0.0f);
+       vec3 DirectionalLightDirection1 = normalize(vec3(-1.0f, -1.0f, -1.0f));
 
 
        fUVs = aUV;
@@ -32,9 +32,9 @@ void main()
        gl_Position = uProjection * uView * world_Position;
        worldNormal = (uModel * vec4(aNormal, 0.0f)).xyz;
 
-       //SpecularCosPoint1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(-PointLightPosition1, worldNormal), 0.0f)).xyz)), 0, 1);
-       //SpecularCosDirection1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(-DirectionalLightDirection1, worldNormal), 0.0f)).xyz)), 0, 1);
-       cameraVec = cameraPos - world_Position.xyz;
+       SpecularCosPoint1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(PointLightPosition1 - world_Position.xyz, worldNormal), 0.0f)).xyz)), 0, 1);
+       SpecularCosDirection1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(-DirectionalLightDirection1, worldNormal), 0.0f)).xyz)), 0, 1);
+       //cameraVec = normalize(cameraPos - world_Position.xyz);
 
 
        //worldnormal = vec3(SpecularCos, SpecularCos, SpecularCos);
index 87dd32684cea579035870560d14006dcd254a451..10ec95f92b8359e93819735c26e7b541e9d04dae 100644 (file)
@@ -1,6 +1,6 @@
 //Fragment Shader
 #version 330
-in vec3 worldNormal, worldLightPoint1, DirectionalLightDirection1, cameraVec;
+in vec3 worldNormal, worldLightPoint1, DirectionalLightDirection1;// , cameraVec;
 in vec2 fUVs;
 in float visNormal, SpecularCosPoint1, SpecularCosDirection1;
 
@@ -20,15 +20,15 @@ void main()
        vec3 AmbientLightColor = 0 * vec3(0.2f, 0.2f, 0.2f);
 
        vec3 PointLightDirection1 = normalize(worldLightPoint1);
-       vec3 PointLightColor1 = 0 * vec3(30.0f, 30.0f, 30.0f);
+       vec3 PointLightColor1 = 1 * vec3(1.0f, 1.0f, 1.0f);
 
-       vec3 DirectionalLightColor1 = vec3(5.6f, 5.6f, 5.6f);
+       vec3 DirectionalLightColor1 = 0 * vec3(0.6f, 0.6f, 0.6f);
 
 
-       //float cosThetaPoint1 = clamp(dot(normal, PointLightDirection1), 0, 1);
-       //float cosThetaDirection1 = clamp(dot(normal, DirectionalLightDirection1), 0, 1);
-       float cosThetaPoint1 = clamp(dot(cameraVec, PointLightDirection1), 0, 1);
-       float cosThetaDirection1 = clamp(dot(cameraVec, DirectionalLightDirection1), 0, 1);
+       float cosThetaPoint1 = clamp(dot(normal, PointLightDirection1), 0, 1);
+       float cosThetaDirection1 = clamp(dot(normal, DirectionalLightDirection1), 0, 1);
+       //float cosThetaPoint1 = clamp(dot(cameraVec, PointLightDirection1), 0, 1);
+       //float cosThetaDirection1 = clamp(dot(cameraVec, DirectionalLightDirection1), 0, 1);
 
        float squaredist1 = worldLightPoint1.x * worldLightPoint1.x + worldLightPoint1.y * worldLightPoint1.y + worldLightPoint1.z * worldLightPoint1.z;
 
@@ -37,10 +37,10 @@ void main()
 
 
        FragmentColor = vec4(uvColor.rgb * (AmbientLightColor * material[0]
-               //+ PointLightColor1 * material[1] * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1
-               + PointLightColor1 * material[1] * (pow(cosThetaPoint1, specularConst)) / squaredist1
-               //+ DirectionalLightColor1 * material[2] * (cosThetaDirection1 + pow(SpecularCosDirection1, specularConst))
-               + DirectionalLightColor1 * material[2] * (pow(cosThetaDirection1, specularConst))
+               + PointLightColor1 * material[1] * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1
+               //+ PointLightColor1 * material[1] * (pow(cosThetaPoint1, specularConst)) / squaredist1
+               + DirectionalLightColor1 * material[2] * (cosThetaDirection1 + pow(SpecularCosDirection1, specularConst))
+               //+ DirectionalLightColor1 * material[2] * (pow(cosThetaDirection1, specularConst))
                ), uvColor.a);