From: Peter Schaefer Date: Sat, 9 May 2015 23:15:28 +0000 (+0200) Subject: fixed it? X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=58915c4fe4e1b473b962c0ba76944c0e3707afed;p=cgue_weave.git fixed it? --- diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 4e614d9..a81cc2b 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -17,16 +17,16 @@ uniform int uEnableTransp = 1; void main() { - PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 0.f)).xyz; - DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -0.f, 0.f)).xyz); + PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 1.f)).xyz; + DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -1.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.f); } \ No newline at end of file diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index e281291..be5d715 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -16,18 +16,16 @@ void main() float specularConst = material[3]; vec4 uvColor = texture(uColorTexture, fUVs); - 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 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); + float SpecularCosDirection1 = clamp(dot(cameraVec, normalize(reflect(-DirectionalLightDirection1, worldNormal))), 0, 1); SpecularCosPoint1 = 0; //SpecularCosDirection1 = 0; @@ -46,7 +44,7 @@ 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;