浏览代码

HDRenderPipeline: Rename objectScale to invObjectScale

/stochastic_alpha_test
sebastienlagarde 7 年前
当前提交
b8834451
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 13
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

13
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


#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 = GetWorldToObjectMatrix();
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));
float3 invObjectScale;
float4x4 worldTransform = GetWorldToObjectMatrix(); // Note that we take WorldToObject to get inverse scale
invObjectScale.x = length(float3(worldTransform._m00, worldTransform._m01, worldTransform._m02));
invObjectScale.y = length(float3(worldTransform._m10, worldTransform._m11, worldTransform._m12));
invObjectScale.z = length(float3(worldTransform._m20, worldTransform._m21, worldTransform._m22));
#endif
PerPixelHeightDisplacementParam ppdParam;

float3 viewDirTS = isPlanar ? float3(uvXZ, V.y) : TransformWorldToTangent(V, worldToTangent);
#ifdef _PER_PIXEL_DISPLACEMENT_OBJECT_SCALE
viewDirTS *= objectScale.xzy; // Switch from Y-up to Z-up
viewDirTS *= invObjectScale.xyz; // Switch from Y-up to Z-up
NdotV = viewDirTS.z;
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, saturate(viewDirTS.z));

正在加载...
取消
保存