]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
mid shader change
authorLockedLunatic <locked.lunatic@aon.at>
Thu, 7 May 2015 12:29:12 +0000 (14:29 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Thu, 7 May 2015 12:29:12 +0000 (14:29 +0200)
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index be82fbd5dc5bddb4f1599e1033269a2c7d4d9408..56e442f2811ea5e5d8514ef9471aee881df4322d 100644 (file)
@@ -5,11 +5,12 @@ in vec3 aNormal, aPosition;
 //in vec3 lightPosition
 in vec2 aUV;
 
-out vec3 worldNormal, worldLightPoint1;
+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 int uEnableBloom = 1;
 uniform int uEnableTransp = 1;
@@ -21,7 +22,7 @@ void main()
        //everything else is in the Fragment Shader
 
        vec3 PointLightPosition1 = vec3(0.0f, 5.0f, 0.0f);
-       vec3 DirectionalLightDirection1 = normalize(vec3(-2.0f, -2.0f, -2.0f));
+       vec3 DirectionalLightDirection1 = normalize(vec3(-0.0f, -1.0f, -0.0f));
 
 
        fUVs = aUV;
@@ -31,8 +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);
+       //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;
 
 
        //worldnormal = vec3(SpecularCos, SpecularCos, SpecularCos);
index 55695f7376e94c82dc8eb426b3caeefa0ea446ec..87dd32684cea579035870560d14006dcd254a451 100644 (file)
@@ -1,6 +1,6 @@
 //Fragment Shader
 #version 330
-in vec3 worldNormal, worldLightPoint1;
+in vec3 worldNormal, worldLightPoint1, DirectionalLightDirection1, cameraVec;
 in vec2 fUVs;
 in float visNormal, SpecularCosPoint1, SpecularCosDirection1;
 
@@ -17,17 +17,18 @@ void main()
        vec4 uvColor = texture(uColorTexture, fUVs);
 
 
-       vec3 AmbientLightColor = vec3(0.2f, 0.2f, 0.2f);
+       vec3 AmbientLightColor = 0 * vec3(0.2f, 0.2f, 0.2f);
 
        vec3 PointLightDirection1 = normalize(worldLightPoint1);
-       vec3 PointLightColor1 = vec3(30.0f, 30.0f, 30.0f);
+       vec3 PointLightColor1 = 0 * vec3(30.0f, 30.0f, 30.0f);
 
-       vec3 DirectionalLightDirection1 = normalize(vec3(-2.0f, -2.0f, -2.0f));
-       vec3 DirectionalLightColor1 = vec3(0.6f, 0.6f, 0.6f);
+       vec3 DirectionalLightColor1 = vec3(5.6f, 5.6f, 5.6f);
 
 
-       float cosThetaPoint1 = clamp(dot(normal, PointLightDirection1), 0, 1);
-       float cosThetaDirection1 = clamp(dot(normal, 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;
 
@@ -36,8 +37,10 @@ void main()
 
 
        FragmentColor = vec4(uvColor.rgb * (AmbientLightColor * material[0]
-               + PointLightColor1 * material[1] * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1
-               + DirectionalLightColor1 * material[2] * (cosThetaDirection1 + pow(SpecularCosDirection1, 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);