浏览代码

Added GBuffer Debug shader.

/main
Julien Ignace 8 年前
当前提交
06725f27
共有 18 个文件被更改,包括 866 次插入51 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset
  2. 98
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 27
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/DisneyGGX.shader
  4. 17
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/DisneyGGX.hlsl
  5. 145
      Assets/TestScenes/HDTest/EnlightenTest.unity
  6. 26
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Gray.mat
  7. 26
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Green.mat
  8. 26
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Red.mat
  9. 95
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Terrain.mat
  10. 26
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test.mat
  11. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug.meta
  12. 257
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat
  13. 8
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat.meta
  14. 25
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl
  15. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl.meta
  16. 112
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/GBufferDebug.shader
  17. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/GBufferDebug.shader.meta

2
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset


m_Script: {fileID: 11500000, guid: 558064ecdbf6b6742892d699acb39aed, type: 3}
m_Name: HDRenderLoop
m_EditorClassIdentifier:
m_MaterialDebugMode: 0
m_GBufferDebugMode: 2

98
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


using UnityEngine;
using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;
using System.Collections.Generic;

{
private static string m_HDRenderLoopPath = "Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset";
// Debugging
public enum MaterialDebugMode
{
None = 0,

Bitangent = 11
}
public MaterialDebugMode m_MaterialDebugMode = MaterialDebugMode.None;
public enum GBufferDebugMode
{
None = 0,
DiffuseColor = 1,
Normal = 2,
Depth = 3,
BakedDiffuse = 4,
SpecularColor = 5,
SpecularOcclustion = 6,
Smoothness = 7,
MaterialId = 8,
}
public MaterialDebugMode m_MaterialDebugMode = MaterialDebugMode.None;
public MaterialDebugMode materialDebugMode
{
get { return m_MaterialDebugMode; }

public GBufferDebugMode m_GBufferDebugMode = GBufferDebugMode.None;
public GBufferDebugMode gBufferDebugMode
{
get { return m_GBufferDebugMode; }
set { m_GBufferDebugMode = value; }
}
HDRenderLoopDebugMenu m_DebugMenu = null;
#if UNITY_EDITOR
[MenuItem("Renderloop/HDRenderLoop/CreateHDRenderLoop")]
static void CreateHDRenderLoop()

HDRenderLoop renderLoop = AssetDatabase.LoadAssetAtPath(m_HDRenderLoopPath, typeof(HDRenderLoop)) as HDRenderLoop;
if(renderLoop != null)
{
//renderLoop.ToggleDebugMenu();
if (renderLoop.materialDebugMode == HDRenderLoop.MaterialDebugMode.None)
renderLoop.materialDebugMode = HDRenderLoop.MaterialDebugMode.Normal;
else

Material m_DeferredMaterial;
Material m_FinalPassMaterial;
// Debug
Material m_GBufferDebugMaterial;
GBufferManager gbufferManager = new GBufferManager();
static private int s_CameraColorBuffer;

if (s_punctualLightList != null)
s_punctualLightList.Release();
}
Material CreateEngineMaterial(string shaderPath)
{
Material mat = new Material(Shader.Find(shaderPath) as Shader);
mat.hideFlags = HideFlags.HideAndDontSave;
return mat;
}
void Rebuild()
{

s_punctualLightList = new ComputeBuffer(MaxLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualLightData)));
Shader deferredMaterial = Shader.Find("Hidden/Unity/LightingDeferred") as Shader;
m_DeferredMaterial = new Material(deferredMaterial);
m_DeferredMaterial.hideFlags = HideFlags.HideAndDontSave;
m_DeferredMaterial = CreateEngineMaterial("Hidden/Unity/LightingDeferred");
m_FinalPassMaterial = CreateEngineMaterial("Hidden/Unity/FinalPass");
Shader finalPassShader = Shader.Find("Hidden/Unity/FinalPass") as Shader;
m_FinalPassMaterial = new Material(finalPassShader);
m_FinalPassMaterial.hideFlags = HideFlags.HideAndDontSave;
// Debug
m_GBufferDebugMaterial = CreateEngineMaterial("Hidden/Unity/GBufferDebug");
// m_ShadowPass = new ShadowRenderPass (m_ShadowSettings);
}

cmd.Dispose();
}
void RenderGBufferDebug(Camera camera, RenderLoop renderLoop)
{
Matrix4x4 invViewProj = GetViewProjectionMatrix(camera).inverse;
m_GBufferDebugMaterial.SetMatrix("_InvViewProjMatrix", invViewProj);
Vector4 screenSize = ComputeScreenSize(camera);
m_GBufferDebugMaterial.SetVector("_ScreenSize", screenSize);
m_GBufferDebugMaterial.SetFloat("_DebugMode", (float)m_GBufferDebugMode);
// gbufferManager.BindBuffers(m_DeferredMaterial);
// TODO: Bind depth textures
var cmd = new CommandBuffer();
cmd.name = "GBuffer Debug";
cmd.Blit(null, new RenderTargetIdentifier(s_CameraColorBuffer), m_GBufferDebugMaterial, 0);
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
Matrix4x4 GetViewProjectionMatrix(Camera camera)
{
// The actual projection matrix used in shaders is actually massaged a bit to work across all platforms

return gpuVP;
}
Vector4 ComputeScreenSize(Camera camera)
{
Vector4 screenSize = new Vector4();
screenSize.x = camera.pixelWidth;
screenSize.y = camera.pixelHeight;
screenSize.z = 1.0f / camera.pixelWidth;
screenSize.w = 1.0f / camera.pixelHeight;
return screenSize;
}
Vector4 screenSize = new Vector4();
screenSize.x = camera.pixelWidth;
screenSize.y = camera.pixelHeight;
screenSize.z = 1.0f / camera.pixelWidth;
screenSize.w = 1.0f / camera.pixelHeight;
Vector4 screenSize = ComputeScreenSize(camera);
m_DeferredMaterial.SetVector("_ScreenSize", screenSize);
// gbufferManager.BindBuffers(m_DeferredMaterial);

RenderForward(cullResults, camera, renderLoop);
if(m_GBufferDebugMode != GBufferDebugMode.None)
{
RenderGBufferDebug(camera, renderLoop);
}
FinalPass(renderLoop);
}
else

// Post effects
}
//void ToggleDebugMenu()
//{
// if(m_DebugMenu == null)
// {
// m_DebugMenu = new HDRenderLoopDebugMenu(this);
// }
// m_DebugMenu.Toggle();
//}
#if UNITY_EDITOR
public override UnityEditor.SupportedRenderingFeatures GetSupportedRenderingFeatures()
{

}
#endif
}
}
}

27
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/DisneyGGX.shader


int g_MaterialDebugMode;
#include "Assets/ScriptableRenderLoop/ShaderLibrary/Color.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl"
#include "TemplateDisneyGGX.hlsl"
float4 FragDebug( PackedVaryings packedInput ) : SV_Target

float3 result = float3(1.0, 1.0, 0.0);
bool outputIsLinear = false;
if(g_MaterialDebugMode == DebugDiffuseColor)
if(g_MaterialDebugMode == MaterialDebugDiffuseColor)
else if (g_MaterialDebugMode == DebugNormal)
else if (g_MaterialDebugMode == MaterialDebugNormal)
else if (g_MaterialDebugMode == DebugDepth)
else if (g_MaterialDebugMode == MaterialDebugDepth)
else if (g_MaterialDebugMode == DebugAO)
else if (g_MaterialDebugMode == MaterialDebugAO)
else if (g_MaterialDebugMode == DebugSpecularColor)
else if (g_MaterialDebugMode == MaterialDebugSpecularColor)
else if (g_MaterialDebugMode == DebugSpecularOcclusion)
else if (g_MaterialDebugMode == MaterialDebugSpecularOcclusion)
else if (g_MaterialDebugMode == DebugSmoothness)
else if (g_MaterialDebugMode == MaterialDebugSmoothness)
else if (g_MaterialDebugMode == DebugMaterialId)
else if (g_MaterialDebugMode == MaterialDebugMaterialId)
outputIsLinear = true;
else if (g_MaterialDebugMode == DebugUV0)
else if (g_MaterialDebugMode == MaterialDebugUV0)
outputIsLinear = true;
else if (g_MaterialDebugMode == DebugTangent)
else if (g_MaterialDebugMode == MaterialDebugTangent)
else if (g_MaterialDebugMode == DebugBitangent)
else if (g_MaterialDebugMode == MaterialDebugBitangent)
{
result = input.tangentToWorld[1].xyz * 0.5 + 0.5;
outputIsLinear = true;

// So in the meantime we apply the inverse transform to linear data to compensate.
if(outputIsLinear)
result = SRGBToLinear(result);
result = SRGBToLinear(max(0, result));
return float4(result, 0.0);
}

17
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/DisneyGGX.hlsl


float3 diffuseLightingAndEmissive;
};
// List of debug modes. Keep in sync with HDRenderLoop.DebugMode
#define DebugNone 0,
#define DebugDiffuseColor 1
#define DebugNormal 2
#define DebugDepth 3
#define DebugAO 4
#define DebugSpecularColor 5
#define DebugSpecularOcclusion 6
#define DebugSmoothness 7
#define DebugMaterialId 8
#define DebugUV0 9
#define DebugTangent 10
#define DebugBitangent 11
//-----------------------------------------------------------------------------
// conversion function for forward and deferred
//-----------------------------------------------------------------------------

}
}
#endif // UNITY_MATERIAL_DISNEYGGX_INCLUDED
#endif // UNITY_MATERIAL_DISNEYGGX_INCLUDED

145
Assets/TestScenes/HDTest/EnlightenTest.unity


m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 124873432}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &655124104
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 655124106}
- component: {fileID: 655124105}
m_Layer: 0
m_Name: DebugMenu
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!223 &655124105
Canvas:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 655124104}
m_Enabled: 1
serializedVersion: 2
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &655124106
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 655124104}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1027688890
GameObject:
m_ObjectHideFlags: 0

- {fileID: 1893534340}
- {fileID: 1330031309}
- {fileID: 124873433}
- {fileID: 1185747105}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_Father: {fileID: 1271727142}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1185747104
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1185747105}
- component: {fileID: 1185747108}
- component: {fileID: 1185747107}
- component: {fileID: 1185747106}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1185747105
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1185747104}
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 11.384, y: 0, z: -6.65}
m_LocalScale: {x: 0.6293558, y: 0.6293558, z: 2.0375917}
m_Children: []
m_Father: {fileID: 1027688891}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
--- !u!23 &1185747106
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1185747104}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 6816da50441b49245843695729d8968c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!64 &1185747107
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1185747104}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1185747108
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1185747104}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1192842089
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1879932837}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalRotation: {x: 0.07759436, y: -0.72047704, z: 0.08170084, w: 0.6842638}
m_LocalPosition: {x: 25.43, y: 9.08, z: 40.21}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 12.939001, y: -92.953, z: 0}
--- !u!114 &1879932843
MonoBehaviour:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1893534339}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.093494415, y: -2.4372234, z: -4.1745696}
m_LocalPosition: {x: 0.093494415, y: 0.3, z: -4.1745696}
m_LocalScale: {x: 2, y: 2, z: 2}
m_Children: []
m_Father: {fileID: 1027688891}

26
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Gray.mat


m_PrefabInternal: {fileID: 0}
m_Name: Gray
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _EMISSION _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}

m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:

name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 0
- first:
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0

name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:

second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength

26
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Green.mat


m_PrefabInternal: {fileID: 0}
m_Name: Green
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _EMISSION _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}

m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:

name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 0
- first:
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0

name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:

second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength

26
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Red.mat


m_PrefabInternal: {fileID: 0}
m_Name: Red
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _EMISSION _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}

m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:

name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 0
- first:
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0

name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:

second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength

95
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Terrain.mat


m_PrefabInternal: {fileID: 0}
m_Name: Terrain
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _EMISSION _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

- first:
name: _BaseColorMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BumpMap
second:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DiffuseLightingMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DiffuseMap
second:
m_Texture: {fileID: 0}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SubSurfaceRadiusMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _CullMode
second: 2
- first:
name: _Cutoff
second: 0.5
- first:

name: _DoubleSidedMode
second: 0
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0
- first:
name: _GlossMapScale
second: 1
- first:

name: _GlossyReflections
second: 1
- first:
name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:
name: _MaterialId
second: 0
- first:
name: _Mettalic
second: 0
- first:
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength

name: _SrcBlend
second: 1
- first:
name: _SubSurfaceRadius
second: 0
- first:
name: _SurfaceType
second: 0
- first:
name: _UVSec
second: 0
- first:

- first:
name: _BaseColor
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _Color
second: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- first:

name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _SpecColor

26
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test.mat


m_PrefabInternal: {fileID: 0}
m_Name: test
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _EMISSION _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}

m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:

name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 0
- first:
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0

name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:

second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug.meta


fileFormatVersion: 2
guid: ee4b12281385a0a4791e3128dd34eae4
folderAsset: yes
timeCreated: 1475748186
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

257
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Blue_Alpha
m_Shader: {fileID: 4800000, guid: e1a84346ee54f9f4993c2f05c59805a0, type: 3}
m_ShaderKeywords: _EMISSION _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _AmbientOcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BaseColorMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DiffuseLightingMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissiveColorMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _HeightMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MaskMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MettalicMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SmoothnessMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecularOcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SubSurfaceRadiusMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _BumpScale
second: 1
- first:
name: _CullMode
second: 0
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DoubleSided
second: 1
- first:
name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 1
- first:
name: _DstBlend
second: 10
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:
name: _MaterialID
second: 0
- first:
name: _MaterialId
second: 0
- first:
name: _Metallic
second: 0
- first:
name: _Mettalic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _Smoothness
second: 0.5
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 5
- first:
name: _SubSurfaceRadius
second: 0
- first:
name: _SurfaceType
second: 1
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 0
m_Colors:
- first:
name: _BaseColor
second: {r: 0.1557093, g: 0.33766845, b: 0.5882352, a: 0.672}
- first:
name: _Color
second: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor
second: {r: 0, g: 0, b: 0, a: 1}

8
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/Blue_Alpha.mat.meta


fileFormatVersion: 2
guid: 6816da50441b49245843695729d8968c
timeCreated: 1475573357
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

25
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl


// List of material debug modes. Keep in sync with HDRenderLoop.MaterialDebugMode
#define MaterialDebugNone 0,
#define MaterialDebugDiffuseColor 1
#define MaterialDebugNormal 2
#define MaterialDebugDepth 3
#define MaterialDebugAO 4
#define MaterialDebugSpecularColor 5
#define MaterialDebugSpecularOcclusion 6
#define MaterialDebugSmoothness 7
#define MaterialDebugMaterialId 8
#define MaterialDebugUV0 9
#define MaterialDebugTangent 10
#define MaterialDebugBitangent 11
// List of GBuffer debug modes. Keep in sync with HDRenderLoop.GBufferDebugMode
#define GBufferDebugNone 0
#define GBufferDebugDiffuseColor 1
#define GBufferDebugNormal 2
#define GBufferDebugDepth 3
#define GBufferDebugBakedDiffuse 4
#define GBufferDebugSpecularColor 5
#define GBufferDebugSpecularOcclustion 6
#define GBufferDebugSmoothness 7
#define GBufferDebugMaterialId 8

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl.meta


fileFormatVersion: 2
guid: 3babddf8b47eecd48ac0a07efc211c0c
timeCreated: 1475754031
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

112
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/GBufferDebug.shader


Shader "Hidden/Unity/GBufferDebug"
{
SubShader
{
Pass
{
ZWrite Off
Blend One Zero
HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma vertex VertDeferred
#pragma fragment FragDeferred
// CAUTION: In case deferred lighting need to support various lighting model statically, we will require to do multicompile with different define like UNITY_MATERIAL_DISNEYGXX
#define UNITY_MATERIAL_DISNEYGXX // Need to be define before including Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Lighting.hlsl" // This include Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugCommon.hlsl"
#include "Assets/ScriptableRenderLoop/ShaderLibrary/Color.hlsl"
DECLARE_GBUFFER_TEXTURE(_CameraGBufferTexture);
Texture2D _CameraDepthTexture;
float4 _ScreenSize;
float _DebugMode;
float4x4 _InvViewProjMatrix;
struct Attributes
{
float3 positionOS : POSITION;
};
struct Varyings
{
float4 positionHS : SV_POSITION;
};
Varyings VertDeferred(Attributes input)
{
// TODO: implement SV_vertexID full screen quad
// Lights are draw as one fullscreen quad
Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
return output;
}
float4 FragDeferred(Varyings input) : SV_Target
{
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
float depth = _CameraDepthTexture.Load(uint3(coord.unPositionSS, 0)).x;
FETCH_GBUFFER(gbuffer, _CameraGBufferTexture, coord.unPositionSS);
BSDFData bsdfData = DECODE_FROM_GBUFFER(gbuffer);
float3 result = float3(1.0, 1.0, 0.0);
bool outputIsLinear = false;
if (_DebugMode == GBufferDebugDiffuseColor)
{
result = bsdfData.diffuseColor;
}
else if (_DebugMode == GBufferDebugNormal)
{
result = bsdfData.normalWS * 0.5 + 0.5;
bool outputIsLinear = true;
}
else if (_DebugMode == GBufferDebugDepth)
{
result = bsdfData.diffuseColor;
}
else if (_DebugMode == GBufferDebugBakedDiffuse)
{
result = bsdfData.diffuseLightingAndEmissive;
outputIsLinear = true;
}
else if (_DebugMode == GBufferDebugSpecularColor)
{
result = bsdfData.fresnel0;
}
else if (_DebugMode == GBufferDebugSpecularOcclustion)
{
result = bsdfData.specularOcclusion.xxx;
outputIsLinear = true;
}
else if (_DebugMode == GBufferDebugSmoothness)
{
result = (1.0 - bsdfData.perceptualRoughness).xxx;
outputIsLinear = true;
}
else if (_DebugMode == GBufferDebugMaterialId)
{
result = bsdfData.materialId.xxx;
outputIsLinear = true;
}
if (outputIsLinear)
result = SRGBToLinear(max(0, result));
return float4(result, 1.0);
}
ENDHLSL
}
}
Fallback Off
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/GBufferDebug.shader.meta


fileFormatVersion: 2
guid: beffb29605949f0429be0427db7a9993
timeCreated: 1475748193
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存