From: LockedLunatic Date: Sat, 9 May 2015 00:24:59 +0000 (+0200) Subject: mid shader change X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=548ee29d250eb3303e0b4642dc8de31c105f3581;p=cgue_weave.git mid shader change --- diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index aad5988..d252aa0 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -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) diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 56e442f..370d418 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -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); diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index 87dd326..10ec95f 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -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);