Trying to fix shading

This commit is contained in:
Dynamitos
2023-12-03 00:29:02 +01:00
parent 6c156d3bc2
commit 178f48120d
12 changed files with 115 additions and 45 deletions
+2 -2
View File
@@ -25,12 +25,12 @@ struct BlinnPhong : IBRDF
float3 evaluate(float3x3 tbn, float3 viewDir_WS, float3 lightDir_WS, float3 lightColor)
{
float3 normal_WS = mul(tbn, normal);
float3 normal_WS = mul(normal, tbn);
float diffuse = max(dot(normal_WS, lightDir_WS), 0);
float3 h = lightDir_WS + viewDir_WS;
float specular = dot(normal_WS, h);
return baseColor * (diffuse + specular) * lightColor;
return (viewDir_WS + float3(1, 1, 1)) / 2;//baseColor * (diffuse + specular) * lightColor;
}
};
+1 -1
View File
@@ -28,7 +28,7 @@ struct PointLight : ILightEnv
float3 lightDir_WS = position_WS.xyz - params.position_WS;
float d = length(lightDir_WS);
float illuminance = max(1 - d / colorRange.w, 0);
return illuminance * brdf.evaluate(params.tbn, params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz);
return brdf.evaluate(params.tbn, params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz);
}
bool insidePlane(Plane plane)
+1 -1
View File
@@ -39,7 +39,7 @@ struct FragmentParameter
LightingParameter result;
result.tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
result.position_WS = position_WS;
result.viewDir_WS = viewDir_WS;
result.viewDir_WS = normalize(viewDir_WS);
return result;
}
};