diff --git a/WickedEngine/dirLightHF.hlsli b/WickedEngine/dirLightHF.hlsli index 0cfaf281e..a951ec19b 100644 --- a/WickedEngine/dirLightHF.hlsli +++ b/WickedEngine/dirLightHF.hlsli @@ -55,8 +55,6 @@ inline void dirLight(in float3 P, in float3 N, in float3 V, in float roughness, specular = g_xDirLight_col.rgb * BRDF_SPECULAR(roughness, f0); diffuse = g_xDirLight_col.rgb * BRDF_DIFFUSE(roughness); - specular += EnvironmentReflection(N, V, P, roughness, f0); - float sh = max(NdotL, 0); float4 ShPos[3]; ShPos[0] = mul(float4(P,1),g_xDirLight_ShM[0]); @@ -92,6 +90,8 @@ inline void dirLight(in float3 P, in float3 N, in float3 V, in float roughness, diffuse *= sh; specular *= sh; + specular += EnvironmentReflection(N, V, P, roughness, f0); + diffuse = max(diffuse, 0); specular = max(specular, 0); } diff --git a/WickedEngine/envReflectionHF.hlsli b/WickedEngine/envReflectionHF.hlsli index 1fbefee46..1a5c633a0 100644 --- a/WickedEngine/envReflectionHF.hlsli +++ b/WickedEngine/envReflectionHF.hlsli @@ -12,7 +12,7 @@ inline float3 EnvironmentReflection(in float3 N, in float3 V, in float3 P, in fl float2 size1; float mipLevels1; texture_env1.GetDimensions(mip1, size1.x, size1.y, mipLevels1); - float3 ref = reflect(N, V); + float3 ref = -reflect(V, N); float4 envCol0 = texture_env0.SampleLevel(sampler_linear_clamp, ref, roughness*mipLevels0); float4 envCol1 = texture_env1.SampleLevel(sampler_linear_clamp, ref, roughness*mipLevels0); #ifdef ENVMAP_CAMERA_BLEND diff --git a/WickedEngine/objectHF.hlsli b/WickedEngine/objectHF.hlsli index 361f2b40b..de52cc975 100644 --- a/WickedEngine/objectHF.hlsli +++ b/WickedEngine/objectHF.hlsli @@ -98,15 +98,15 @@ inline void DirectionalLight(in float3 N, in float3 V, in float3 P, in float3 f0 float3 lightColor = GetSunColor(); BRDF_MAKE(N, L, V); specular = lightColor * BRDF_SPECULAR(roughness, f0); - diffuse = lightColor * BRDF_DIFFUSE(roughness); - - specular += EnvironmentReflection(N, V, P, roughness, f0); + diffuse = lightColor * BRDF_DIFFUSE(roughness); float sh = max(NdotL, 0); diffuse *= sh; specular *= sh; + specular += EnvironmentReflection(N, V, P, roughness, f0); + diffuse = max(diffuse, 0); specular = max(specular, 0); }