// TODO: share this function with tessellation code.
// Displacement with lock object scale require to take into account object scaling except for planar and triplanar that are done in world space in Lit and thus are independent of object scale.
float3 GetInverseObjectScale()
{
float3 invObjectScale = 1;
// Extract scaling from world transform
// To handle object scaling with PPD we need to multiply the view vector by the inverse scale.
// Currently we extract the inverse scale directly by taking worldToObject matrix (instead of ObjectToWorld)
float4x4 worldTransform = GetWorldToObjectMatrix(); // Note that we take WorldToObject to get inverse scale
// TODO: share this function with tessellation code.
float GetHeightmapInverseTilingScale()
{
#ifdef _DISPLACEMENT_LOCK_TILING_SCALE
ppdParam.uv = layerTexCoord.base.uv; // For planar it is uv too, not uvXZ
// Note: The TBN is not normalize as it is based on mikkt. We should normalize it, but POM is always use on simple enough surfarce that mean it is not required (save 2 normalize). Tag: SURFACE_GRADIENT