浏览代码

HDRenderPipeline: Test Per Pixel scale lock

/stochastic_alpha_test
sebastienlagarde 7 年前
当前提交
f4828c10
共有 2 个文件被更改,包括 21 次插入1 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  2. 20
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


m_MaterialEditor.ShaderProperty(ppdMaxSamples, StylesBaseLit.ppdMaxSamplesText);
ppdMinSamples.floatValue = Mathf.Min(ppdMinSamples.floatValue, ppdMaxSamples.floatValue);
m_MaterialEditor.ShaderProperty(ppdLodThreshold, StylesBaseLit.ppdLodThresholdText);
//m_MaterialEditor.ShaderProperty(perPixelDisplacementObjectScale, StylesBaseLit.perPixelDisplacementObjectScaleText);
m_MaterialEditor.ShaderProperty(perPixelDisplacementObjectScale, StylesBaseLit.perPixelDisplacementObjectScaleText);
m_MaterialEditor.ShaderProperty(depthOffsetEnable, StylesBaseLit.depthOffsetEnableText);
EditorGUI.indentLevel--;
}

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


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;

正在加载...
取消
保存