浏览代码

Minor optimizatoin, precompute inverse TexWorldScale

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

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


using System;
using System;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;

// Precompute.
InvTilingScale[layerIndex].floatValue = 2 / (Mathf.Abs(baseColorMap[layerIndex].textureScaleAndOffset.x) + Mathf.Abs(baseColorMap[layerIndex].textureScaleAndOffset.y));
if ((uvBaseMapping == UVBaseMapping.Planar) || (uvBaseMapping == UVBaseMapping.Triplanar))
{
InvTilingScale[layerIndex].floatValue = InvTilingScale[layerIndex].floatValue / TexWorldScale[layerIndex].floatValue;
}
EditorGUI.indentLevel--;
EditorGUILayout.Space();

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


float GetDisplacementInverseTilingScale()
{
// Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y)
// Inverse tiling scale *= (1 / _TexWorldScale) if planar or triplanar
return _InvTilingScale
#if defined(_MAPPING_PLANAR) || defined(_MAPPING_TRIPLANAR)
* rcp(_TexWorldScale)
#endif
;
return _InvTilingScale;
#else
return 1.0;
#endif

正在加载...
取消
保存