浏览代码

Merge pull request #143 from Unity-Technologies/Add-Blend-Mask-Tiling-param

Add blend mask tiling param
/Branch_Batching2
GitHub 8 年前
当前提交
9e9fcce9
共有 5 个文件被更改,包括 45 次插入11 次删除
  1. 22
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  2. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  3. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  4. 15
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  5. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl

22
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask");
public readonly GUIContent vertexColorModeText = new GUIContent("Vertex Color Mode", "Mode multiply: vertex color is multiply with the mask. Mode additive: vertex color values are remapped between -1 and 1 and added to the mask (neutral at 0.5 vertex color).");
public readonly GUIContent layerCountText = new GUIContent("Layer Count", "Number of layers.");
public readonly GUIContent layerTilingBlendMaskText = new GUIContent("Tiling", "Tiling for the blend mask.");
public readonly GUIContent layerTilingText = new GUIContent("Tiling", "Tiling factor applied to UVSet");
public readonly GUIContent layerTexWorldScaleText = new GUIContent("Tiling", "Tiling factor applied to Planar/Trilinear mapping");
public readonly GUIContent UVBaseText = new GUIContent("Base UV Mapping", "Base UV Mapping mode of the layer.");

MaterialProperty[] layerUVDetail = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVDetailsMappingMask = new MaterialProperty[kMaxLayerCount];
const string kLayerTilingBlendMask = "_LayerTilingBlendMask";
MaterialProperty layerTilingBlendMask = null;
const string kLayerTiling = "_LayerTiling";
MaterialProperty[] layerTiling = new MaterialProperty[kMaxLayerCount];
const string kkUseMainLayerInfluence = "_UseMainLayerInfluence";

useMainLayerInfluence = FindProperty(kkUseMainLayerInfluence, props);
useHeightBasedBlend = FindProperty(kUseHeightBasedBlend, props);
useDensityMode = FindProperty(kUseDensityMode, props);
useDensityMode = FindProperty(kUseDensityMode, props);
layerTilingBlendMask = FindProperty(kLayerTilingBlendMask, props);
for (int i = 0; i < kMaxLayerCount; ++i)
{

layerChanged = true;
}
if (((LayerUVBaseMapping)layerUVBase[0].floatValue == LayerUVBaseMapping.Planar) ||
((LayerUVBaseMapping)layerUVBase[0].floatValue == LayerUVBaseMapping.Triplanar))
{
// for now reuse settings from main layer
}
else
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(layerTilingBlendMask, styles.layerTilingBlendMaskText);
EditorGUI.indentLevel--;
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = useMainLayerInfluence.hasMixedValue;

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


_OpacityAsDensity2("_OpacityAsDensity2", Range(0, 1.0)) = 0.0
_OpacityAsDensity3("_OpacityAsDensity3", Range(0, 1.0)) = 0.0
_LayerTiling0("LayerTiling0", Float) = 1
_LayerTiling1("LayerTiling1", Float) = 1
_LayerTiling2("LayerTiling2", Float) = 1
_LayerTiling3("LayerTiling3", Float) = 1
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


_OpacityAsDensity2("_OpacityAsDensity2", Range(0, 1.0)) = 0.0
_OpacityAsDensity3("_OpacityAsDensity3", Range(0, 1.0)) = 0.0
_LayerTiling0("LayerTiling0", Float) = 1
_LayerTiling1("LayerTiling1", Float) = 1
_LayerTiling2("LayerTiling2", Float) = 1
_LayerTiling3("LayerTiling3", Float) = 1
_LayerTilingBlendMask("_LayerTilingBlendMask", Float) = 1
_LayerTiling0("_LayerTiling0", Float) = 1
_LayerTiling1("_LayerTiling1", Float) = 1
_LayerTiling2("_LayerTiling2", Float) = 1
_LayerTiling3("_LayerTiling3", Float) = 1
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

15
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl


LayerUV details1;
LayerUV details2;
LayerUV details3;
// Dedicated for blend mask
LayerUV blendMask;
#endif
// triplanar weight

// Be sure that the compiler is aware that we don't touch UV1 to UV3 for main layer so it can optimize code
_UVMappingMask0.yzw = float3(0.0, 0.0, 0.0);
ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3,
// Note: Our BlendMask use the same uv mapping than the base layer but with its own tiling.
// Here we get a first time the base0 but with _LayerTilingBlendMask. Save the result and recall the function regularly for the main layer.
// It is just to share code.
ComputeLayerTexCoord0( texCoord0, float2(0.0, 0.0), float2(0.0, 0.0), float2(0.0, 0.0),
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTilingBlendMask);
layerTexCoord.blendMask = layerTexCoord.base0;
ComputeLayerTexCoord0( texCoord0, float2(0.0, 0.0), float2(0.0, 0.0), float2(0.0, 0.0),
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling0);
isTriplanar = false;

// Blend mask are Main Layer A - Layer 1 R - Layer 2 G - Layer 3 B
// Value for main layer is not use for blending itself but for alternate weighting like density.
// Settings this specific Main layer blend mask in alpha allow to be transparent in case we don't use it and 1 is provide by default.
float4 blendMasks = useLodSampling ? SAMPLE_LAYER_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0, lod) : SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.base0);
float4 blendMasks = useLodSampling ? SAMPLE_LAYER_TEXTURE2D_LOD(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask, lod) : SAMPLE_LAYER_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, layerTexCoord.blendMask);
#if defined(_LAYER_MASK_VERTEX_COLOR_MUL)
blendMasks *= vertexColor;

1
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl


float _InheritBaseColorThreshold1;
float _InheritBaseColorThreshold2;
float _InheritBaseColorThreshold3;
float _LayerTilingBlendMask;
PROP_DECL(float, _LayerTiling);
float3 _EmissiveColor;

正在加载...
取消
保存