More tangent changes

This commit is contained in:
Dynamitos
2024-12-27 17:06:43 +01:00
parent 7f4d7c7f71
commit f3b6ed31dc
15 changed files with 275 additions and 163 deletions
+5 -6
View File
@@ -14,8 +14,8 @@ struct DirectionalLight : ILightEnv
float3 illuminate<B:IBRDF>(LightingParameter params, B brdf)
{
float3 dir_TS = mul(params.worldToTangent, -normalize(direction.xyz));
return brdf.evaluate(params.viewDir_TS, dir_TS, color.xyz);
float3 dir_WS = normalize(direction.xyz);
return brdf.evaluate(params.tangentToWorld, params.viewDir_WS, dir_WS, color.xyz);
}
};
@@ -26,11 +26,10 @@ struct PointLight : ILightEnv
float3 illuminate<B:IBRDF>(LightingParameter params, B brdf)
{
float3 pos_TS = mul(params.worldToTangent, position_WS.xyz);
float3 lightDir_TS = pos_TS.xyz - params.position_TS;
float d = length(lightDir_TS);
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.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
return illuminance * brdf.evaluate(params.tangentToWorld, params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz);
}
bool insidePlane(Plane plane, float3 position)