From 957338a57d2d7fe6fb76c26953163ea975907bfa Mon Sep 17 00:00:00 2001 From: LockedLunatic Date: Thu, 7 May 2015 14:29:12 +0200 Subject: [PATCH] mid shader change --- shader/basicTexture_VS.hlsl | 12 +++++++----- shader/lightingTexture_FS.hlsl | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index be82fbd..56e442f 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -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); diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index 55695f7..87dd326 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -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); -- 2.47.3