|
|
|
|
|
|
float2 minUvSize = GetMinUvSize(layerTexCoord); |
|
|
|
float lod = ComputeTextureLOD(minUvSize); |
|
|
|
|
|
|
|
// TODO: This should be an uniform for the object, this code should be remove (and is specific to Lit.shader) once we have it. - Workaround for now |
|
|
|
// Extract scaling from world transform |
|
|
|
#ifdef _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE |
|
|
|
// 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) |
|
|
|
float3 objectScale; |
|
|
|
float4x4 worldTransform = GetObjectToWorldMatrix(); |
|
|
|
objectScale.x = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02)); |
|
|
|
objectScale.y = length(float3(worldTransform._m10, worldTransform._m11, worldTransform._m12)); |
|
|
|
objectScale.z = length(float3(worldTransform._m20, worldTransform._m21, worldTransform._m22)); |
|
|
|
#endif |
|
|
|
|
|
|
|
PerPixelHeightDisplacementParam ppdParam; |
|
|
|
|
|
|
|
float height; // final height processed |
|
|
|
|
|
|
|
|
|
|
float3x3 worldToTangent = input.worldToTangent; |
|
|
|
|
|
|
|
#ifdef _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE |
|
|
|
//V *= objectScale; |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE |
|
|
|
viewDirTS *= 1.0 / objectScale; |
|
|
|
#endif |
|
|
|
|
|
|
|
NdotV = viewDirTS.z; |
|
|
|
|
|
|
|