|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Computes the world space view direction (pointing towards the viewer). |
|
|
|
float3 GetWorldSpaceNormalizeViewDir(float3 positionWS) |
|
|
|
{ |
|
|
|
if (IsPerspectiveProjection()) |
|
|
|
{ |
|
|
|
// Perspective |
|
|
|
float3 V = GetCurrentViewPosition() - positionWS; |
|
|
|
return normalize(V); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// Orthographic |
|
|
|
return -GetViewForwardDir(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
float3 GetWorldSpaceViewDir(float3 positionWS) |
|
|
|
{ |
|
|
|
if (IsPerspectiveProjection()) |
|
|
|
|
|
|
// Orthographic |
|
|
|
return -GetViewForwardDir(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
float3 GetWorldSpaceNormalizeViewDir(float3 positionWS) |
|
|
|
{ |
|
|
|
return normalize(GetWorldSpaceViewDir(positionWS)); |
|
|
|
} |
|
|
|
|
|
|
|
float3x3 CreateWorldToTangent(float3 normal, float3 tangent, float flipSign) |
|
|
|