浏览代码

Merge pull request #121 from Unity-Technologies/Add-tiling-paramater-for-layered

Add tiling paramater for layered
/main
GitHub 8 年前
当前提交
342f3efc
共有 10 个文件被更改,包括 49 次插入22 次删除
  1. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  2. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  3. 11
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  4. 11
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  5. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  6. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  7. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  8. 9
      Assets/TestScenes/HDTest/Leaf.meta
  9. 9
      Assets/TestScenes/HDTest/Leaf/GroundLeaf.meta

6
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


// Keep these settings safe to recover when leaving the render pipeline
bool previousLightsUseLinearIntensity;
bool previousLightsUseCCT;
bool previousLightsUseColorTemperature;
// This must be allocate outside of Build() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
BaseLightLoop m_lightLoop;

#endif
previousLightsUseLinearIntensity = UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity;
previousLightsUseCCT = UnityEngine.Rendering.GraphicsSettings.lightsUseColorTemperature;
previousLightsUseColorTemperature = UnityEngine.Rendering.GraphicsSettings.lightsUseColorTemperature;
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = true;
UnityEngine.Rendering.GraphicsSettings.lightsUseColorTemperature = true;

UnityEditor.SupportedRenderingFeatures.active = UnityEditor.SupportedRenderingFeatures.Default;
#endif
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = previousLightsUseLinearIntensity;
UnityEngine.Rendering.GraphicsSettings.lightsUseColorTemperature = previousLightsUseCCT;
UnityEngine.Rendering.GraphicsSettings.lightsUseColorTemperature = previousLightsUseColorTemperature;
}
void InitAndClearBuffer(Camera camera, ScriptableRenderContext renderContext)

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


public readonly GUIContent syncButtonText = new GUIContent("Re-Synchronize Layers", "Re-synchronize all layers's properties with the referenced Material");
public readonly GUIContent layersText = new GUIContent("Layers");
public readonly GUIContent emissiveText = new GUIContent("Emissive");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask (multiplied by vertex color if enabled)");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer 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.");
public readonly GUIContent UVDetailText = new GUIContent("Detail UV Mapping", "Detail UV Mapping mode of the layer.");

MaterialProperty[] layerUVDetail = new MaterialProperty[kMaxLayerCount];
MaterialProperty[] layerUVDetailsMappingMask = new MaterialProperty[kMaxLayerCount];
const string kLayerTiling = "_LayerTiling";
MaterialProperty[] layerTiling = new MaterialProperty[kMaxLayerCount];
const string kkUseMainLayerInfluence = "_UseMainLayerInfluence";
MaterialProperty useMainLayerInfluence = null;
const string kUseHeightBasedBlend = "_UseHeightBasedBlend";

layerUVMappingPlanar[i] = FindProperty(string.Format("{0}{1}", kUVMappingPlanar, i), props);
layerUVDetail[i] = FindProperty(string.Format("{0}{1}", kUVDetail, i), props);
layerUVDetailsMappingMask[i] = FindProperty(string.Format("{0}{1}", kUVDetailsMappingMask, i), props);
layerTiling[i] = FindProperty(string.Format("{0}{1}", kLayerTiling, i), props);
if(i != 0)
{

SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex);
result = true;
}
if (((LayerUVBaseMapping)layerUVBase[layerIndex].floatValue == LayerUVBaseMapping.Planar) ||
((LayerUVBaseMapping)layerUVBase[layerIndex].floatValue == LayerUVBaseMapping.Triplanar))
{

}
else
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(layerTiling[layerIndex], styles.layerTilingText);
EditorGUI.indentLevel--;
EditorGUI.BeginChangeCheck();
m_MaterialEditor.ShaderProperty(layerUVDetail[layerIndex], styles.UVDetailText);
if (EditorGUI.EndChangeCheck())

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


_DetailAOScale2("_DetailAOScale2", Range(-2.0, 2.0)) = 1
_DetailAOScale3("_DetailAOScale3", Range(-2.0, 2.0)) = 1
// Specific to planar mapping
_TexWorldScale0("TexWorldScale0", Float) = 1.0
_TexWorldScale1("TexWorldScale1", Float) = 1.0
_TexWorldScale2("TexWorldScale2", Float) = 1.0
_TexWorldScale3("TexWorldScale3", Float) = 1.0
// Layer blending options
_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0

_OpacityAsDensity1("_OpacityAsDensity1", Range(0, 1.0)) = 0.0
_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
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

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


_DetailAOScale2("_DetailAOScale2", Range(-2.0, 2.0)) = 1
_DetailAOScale3("_DetailAOScale3", Range(-2.0, 2.0)) = 1
// Specific to planar mapping
_TexWorldScale0("TexWorldScale0", Float) = 1.0
_TexWorldScale1("TexWorldScale1", Float) = 1.0
_TexWorldScale2("TexWorldScale2", Float) = 1.0
_TexWorldScale3("TexWorldScale3", Float) = 1.0
// Layer blending options
_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0

_OpacityAsDensity1("_OpacityAsDensity1", Range(0, 1.0)) = 0.0
_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
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

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


isTriplanar = true;
#endif
ComputeLayerTexCoord0( texCoord0, texCoord1, texCoord2, texCoord3,
positionWS, normalWS, isTriplanar, layerTexCoord);
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling0);
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR_1

positionWS, normalWS, isTriplanar, layerTexCoord);
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling1);
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR_2

positionWS, normalWS, isTriplanar, layerTexCoord);
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling2);
isTriplanar = false;
#ifdef _LAYER_MAPPING_TRIPLANAR_3

positionWS, normalWS, isTriplanar, layerTexCoord);
positionWS, normalWS, isTriplanar, layerTexCoord, _LayerTiling3);
}
void ApplyPerPixelDisplacement(FragInputs input, float3 V, inout LayerTexCoord layerTexCoord)

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


void ADD_IDX(ComputeLayerTexCoord)( float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3,
float3 positionWS, float3 normalWS, bool isTriplanar, inout LayerTexCoord layerTexCoord)
float3 positionWS, float3 normalWS, bool isTriplanar, inout LayerTexCoord layerTexCoord, float additionalTiling = 1.0)
{
// Handle uv0, uv1, uv2, uv3 based on _UVMappingMask weight (exclusif 0..1)
float2 uvBase = ADD_IDX(_UVMappingMask).x * texCoord0 +

uvBase *= additionalTiling.xx;
float2 uvDetails = ADD_IDX(_UVDetailsMappingMask).x * texCoord0 +

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


float _OpacityAsDensity1;
float _OpacityAsDensity2;
float _OpacityAsDensity3;
PROP_DECL(float, _LayerTiling);
float3 _EmissiveColor;
TEXTURE2D(_EmissiveColorMap);

9
Assets/TestScenes/HDTest/Leaf.meta


fileFormatVersion: 2
guid: 01cfa4863006ad6499396fb0d4802c7e
folderAsset: yes
timeCreated: 1475755141
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/HDTest/Leaf/GroundLeaf.meta


fileFormatVersion: 2
guid: 582c65a5691faa94183a3a24350b12e0
folderAsset: yes
timeCreated: 1475755103
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存