Evgenii Golubev 8 年前
当前提交
3d558256
共有 21 个文件被更改,包括 80 次插入23 次删除
  1. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  2. 3
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta
  3. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  4. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs
  5. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset.meta
  6. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset
  7. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset.meta
  8. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs
  9. 3
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  10. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  11. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  12. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  13. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  14. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  15. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  16. 5
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  17. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  18. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  19. 13
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  20. 19
      Assets/ScriptableRenderLoop/HDRenderPipeline/DefaultCommonSettings.asset
  21. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/DefaultCommonSettings.asset.meta

4
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3}
m_Name:
m_Name: HDRenderPipeline
m_EditorClassIdentifier:
m_CommonSettings:
m_ShadowMaxDistance: 1000

m_ShadowCascadeSplit2: 0.3
m_SkyParameters: {fileID: 11400000, guid: 12b814c3b2e53c246a0c9f1594c01532, type: 2}
m_SkyParameters: {fileID: 0}
m_LightLoopProducer: {fileID: 11400000, guid: bf8cd9ae03ff7d54c89603e67be0bfc5,
type: 2}
m_ShadowSettings:

3
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta


fileFormatVersion: 2
guid: e185fecca3c73cd47a09f1092663ef32
timeCreated: 1484329328
timeCreated: 1485857876
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


AssetDatabase.CreateAsset(instance, k_HDRenderPipelinePath);
}
[UnityEditor.MenuItem("RenderPipeline/UpdateHDLoop")]
static void UpdateHDLoop()
[UnityEditor.MenuItem("HDRenderPipeline/UpdateHDRenderPipeline")]
static void UpdateHDRenderPipeline()
var loop = AssetDatabase.LoadAssetAtPath<HDRenderPipeline>(path);
// loop.m_Setup = AssetDatabase.LoadAssetAtPath<TilePassSetup>("Assets/HDRenderPipelineSetup.asset");
EditorUtility.SetDirty(loop);
var pipeline = AssetDatabase.LoadAssetAtPath<HDRenderPipeline>(path);
EditorUtility.SetDirty(pipeline);
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TileLightLoopProducer.cs


#if UNITY_EDITOR
public const string TilePassProducer = "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset";
[UnityEditor.MenuItem("RenderPipeline/Create TileLightLoopProducer")]
[UnityEditor.MenuItem("HDRenderPipeline/TilePass/Create TileLightLoopProducer")]
static void CreateTileLightLoopProducer()
{
var instance = CreateInstance<TileLightLoopProducer>();

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset.meta


fileFormatVersion: 2
guid: bf8cd9ae03ff7d54c89603e67be0bfc5
timeCreated: 1485447725
timeCreated: 1485857933
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset


m_DebugViewMaterialGBuffer: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d,
type: 3}
m_InitPreFGD: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.asset.meta


fileFormatVersion: 2
guid: 7f2998544b2ac3848822b80ec3e6c446
timeCreated: 1485447672
timeCreated: 1485857936
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePassResources.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class TilePassResources : ScriptableObject
{

[UnityEditor.MenuItem("RenderPipeline/CreateTilePassResources")]
[UnityEditor.MenuItem("HDRenderPipeline/TilePass/CreateTilePassResources")]
static void CreateTilePassSetup()
{
var instance = CreateInstance<TilePassResources>();

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


bool layerChanged = DoLayersGUI(materialImporter);
EditorGUILayout.Space();
GUILayout.Label(Styles.emissiveText, EditorStyles.boldLabel);
GUILayout.Label(Styles.lightingText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
EditorGUI.indentLevel--;
CheckLayerConsistency();

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


_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0

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


_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


public static GUIContent distortionOnlyText = new GUIContent("Distortion Only", "This shader will only be use to render distortion");
public static GUIContent distortionDepthTestText = new GUIContent("Distortion Depth Test", "Enable the depth test for distortion");
public static GUIContent depthOffsetEnableText = new GUIContent("DepthOffset", "EnableDepthOffset on this shader (Use with heightmap)");
public static GUIContent horizonFadeText = new GUIContent("HorizonFade", "horizon fade is use to control specular occlusion");
public static readonly string[] surfaceTypeNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendModeNames = Enum.GetNames(typeof(BlendMode));

distortionOnly = FindProperty(kDistortionOnly, props);
distortionDepthTest = FindProperty(kDistortionDepthTest, props);
depthOffsetEnable = FindProperty(kDepthOffsetEnable, props);
horizonFade = FindProperty(kHorizonFade, props);
// tessellation specific, silent if not found
tessellationMode = FindProperty(kTessellationMode, props, false);

const string kDistortionDepthTest = "_DistortionDepthTest";
MaterialProperty depthOffsetEnable = null;
const string kDepthOffsetEnable = "_DepthOffsetEnable";
protected MaterialProperty horizonFade = null;
const string kHorizonFade = "_HorizonFade";
// tessellation params
protected MaterialProperty tessellationMode = null;

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


}
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
m_MaterialEditor.ShaderProperty(horizonFade, Styles.horizonFadeText);
EditorGUI.indentLevel--;
EditorGUILayout.Space();

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader


[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0

[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
}
HLSLINCLUDE

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


float3 normalTS;
float alpha = GetSurfaceData(input, layerTexCoord, surfaceData, normalTS);
GetNormalAndTangentWS(input, V, normalTS, surfaceData.normalWS, surfaceData.tangentWS);
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion *= GetHorizonOcclusion(V, surfaceData.normalWS, input.tangentToWorld[2].xyz, _HorizonFade);
// Caution: surfaceData must be fully initialize before calling GetBuiltinData
GetBuiltinData(input, surfaceData, alpha, depthOffset, builtinData);

float3 normalTS = BlendLayeredVector3(normalTS0, normalTS1, normalTS2, normalTS3, weights);
#endif
surfaceData.specularOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, specularOcclusion, weights);
surfaceData.perceptualSmoothness = SURFACEDATA_BLEND_SCALAR(surfaceData, perceptualSmoothness, weights);
surfaceData.ambientOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, ambientOcclusion, weights);
surfaceData.metallic = SURFACEDATA_BLEND_SCALAR(surfaceData, metallic, weights);

surfaceData.specularColor = float3(0.0, 0.0, 0.0);
GetNormalAndTangentWS(input, V, normalTS, surfaceData.normalWS, surfaceData.tangentWS);
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, specularOcclusion, weights);
surfaceData.specularOcclusion *= GetHorizonOcclusion(V, surfaceData.normalWS, input.tangentToWorld[2].xyz, _HorizonFade);
GetBuiltinData(input, surfaceData, alpha, depthOffset, builtinData);
}

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


// TODO: Do something. For now just take alpha channel
surfaceData.specularOcclusion = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_SpecularOcclusionMap), ADD_ZERO_IDX(sampler_SpecularOcclusionMap), ADD_IDX(layerTexCoord.base)).a;
#else
// Horizon Occlusion for Normal Mapped Reflections: http://marmosetco.tumblr.com/post/81245981087
//surfaceData.specularOcclusion = saturate(1.0 + horizonFade * dot(r, input.tangentToWorld[2].xyz);
// smooth it
//surfaceData.specularOcclusion *= surfaceData.specularOcclusion;
// The specular occlusion will be perform outside the internal loop
surfaceData.specularOcclusion = 1.0;
#endif
surfaceData.normalWS = float3(0.0, 0.0, 0.0); // Need to init this so that the compiler leaves us alone.

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


float _AlphaCutoff;
float _HorizonFade;
float _TexWorldScale;
float _UVMappingPlanar;
float4 _UVMappingMask;

PROP_DECL(float4, _UVDetailsMappingMask);
float _AlphaCutoff;
float _HorizonFade;
float _PPDMaxSamples;
float _PPDMinSamples;

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader


[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_HorizonFade("Horizon fade", Range(0.0, 5.0)) = 1.0
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0

13
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


}
//-----------------------------------------------------------------------------
// Lighting functions
//-----------------------------------------------------------------------------
// Ref: Horizon Occlusion for Normal Mapped Reflections: http://marmosetco.tumblr.com/post/81245981087
float GetHorizonOcclusion(float3 V, float3 normalWS, float3 vertexNormal, float horizonFade)
{
float3 R = reflect(-V, normalWS);
float specularOcclusion = saturate(1.0 + horizonFade * dot(R, vertexNormal));
// smooth it
return specularOcclusion * specularOcclusion;
}
//-----------------------------------------------------------------------------
// Helper functions
//-----------------------------------------------------------------------------

19
Assets/ScriptableRenderLoop/HDRenderPipeline/DefaultCommonSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc357c46587fc9d4cb8f311794d7d2f3, type: 3}
m_Name: DefaultCommonSettings
m_EditorClassIdentifier:
m_Settings:
m_ShadowMaxDistance: 1000
m_ShadowCascadeCount: 4
m_ShadowCascadeSplit0: 0.05
m_ShadowCascadeSplit1: 0.2
m_ShadowCascadeSplit2: 0.3

9
Assets/ScriptableRenderLoop/HDRenderPipeline/DefaultCommonSettings.asset.meta


fileFormatVersion: 2
guid: d8980cba5cb12414ca57fe2c5fabe2f3
timeCreated: 1485858348
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存