浏览代码

HDRenderLoop debug params are now in a struct. Added an Inspector for HDRenderLoop

/main
Julien Ignace 8 年前
当前提交
526fbc6f
共有 5 个文件被更改,包括 134 次插入20 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset
  2. 43
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  3. 4
      Assets/TestScenes/HDTest/EnlightenTest.unity
  4. 93
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs
  5. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs.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: 0

43
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


DiffuseColor = 1,
Normal = 2,
Depth = 3,
AmbiantOcclusion = 4,
AmbientOcclusion = 4,
SpecularColor = 5,
SpecularOcclustion = 6,
Smoothness = 7,

MaterialId = 8,
}
public MaterialDebugMode m_MaterialDebugMode = MaterialDebugMode.None;
public MaterialDebugMode materialDebugMode
public class DebugParameters
get { return m_MaterialDebugMode; }
set { m_MaterialDebugMode = value; }
private MaterialDebugMode m_MaterialDebugMode = MaterialDebugMode.None;
private GBufferDebugMode m_GBufferDebugMode = GBufferDebugMode.None;
public MaterialDebugMode materialDebugMode
{
get { return m_MaterialDebugMode; }
set { m_MaterialDebugMode = value; }
}
public GBufferDebugMode gBufferDebugMode
{
get { return m_GBufferDebugMode; }
set { m_GBufferDebugMode = value; }
}
public GBufferDebugMode m_GBufferDebugMode = GBufferDebugMode.None;
public GBufferDebugMode gBufferDebugMode
private DebugParameters m_DebugParameters = new DebugParameters();
public DebugParameters debugParameters
get { return m_GBufferDebugMode; }
set { m_GBufferDebugMode = value; }
get { return m_DebugParameters; }
//HDRenderLoopDebugMenu m_DebugMenu = null;

if(renderLoop != null)
{
//renderLoop.ToggleDebugMenu();
if (renderLoop.materialDebugMode == HDRenderLoop.MaterialDebugMode.None)
renderLoop.materialDebugMode = HDRenderLoop.MaterialDebugMode.Normal;
if (renderLoop.debugParameters.materialDebugMode == HDRenderLoop.MaterialDebugMode.None)
renderLoop.debugParameters.materialDebugMode = HDRenderLoop.MaterialDebugMode.Normal;
renderLoop.materialDebugMode = HDRenderLoop.MaterialDebugMode.None;
renderLoop.debugParameters.materialDebugMode = HDRenderLoop.MaterialDebugMode.None;
EditorUtility.SetDirty(renderLoop);
}

renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();
Shader.SetGlobalInt("g_MaterialDebugMode", (int)m_MaterialDebugMode);
Shader.SetGlobalInt("g_MaterialDebugMode", (int)debugParameters.materialDebugMode);
DrawRendererSettings settings = new DrawRendererSettings(cull, camera, new ShaderPassName("Debug"));
settings.sorting.sortOptions = SortOptions.SortByMaterialThenMesh;

Vector4 screenSize = ComputeScreenSize(camera);
m_GBufferDebugMaterial.SetVector("_ScreenSize", screenSize);
m_GBufferDebugMaterial.SetFloat("_DebugMode", (float)m_GBufferDebugMode);
m_GBufferDebugMaterial.SetFloat("_DebugMode", (float)debugParameters.gBufferDebugMode);
// gbufferManager.BindBuffers(m_DeferredMaterial);
// TODO: Bind depth textures

//UpdateLightConstants(cullResults.culledLights /*, ref shadows */);
if (m_MaterialDebugMode == MaterialDebugMode.None)
if (debugParameters.materialDebugMode == MaterialDebugMode.None)
{
UpdatePunctualLights(cullResults.culledLights);

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

4
Assets/TestScenes/HDTest/EnlightenTest.unity


- component: {fileID: 1185747107}
- component: {fileID: 1185747106}
m_Layer: 0
m_Name: Plane
m_Name: TransparentPlane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1457550750}
m_LocalRotation: {x: -0.2494351, y: -0.3202937, z: 0.3963061, w: -0.8234898}
m_LocalRotation: {x: -0.24943511, y: -0.32029372, z: 0.39630613, w: -0.82348984}
m_LocalPosition: {x: 0, y: 9.18, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

93
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs


using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;
using System.Collections.Generic;
using System;
using UnityEditor;
//using EditorGUIUtility=UnityEditor.EditorGUIUtility;
namespace UnityEngine.ScriptableRenderLoop
{
[CustomEditor(typeof(HDRenderLoop))]
public class HDRenderLoopInspector : Editor
{
private class Styles
{
public readonly GUIContent debugParameters = new GUIContent("Debug Parameters");
public readonly GUIContent materialDebugMode = new GUIContent("Material Debug Mode", "Display various properties of Materials.");
public readonly GUIContent gBufferDebugMode = new GUIContent("GBuffer Debug Mode", "Display various properties of contained in the GBuffer.");
public readonly GUIContent[] materialDebugStrings = { new GUIContent("None"),
new GUIContent("Diffuse Color"),
new GUIContent("Normal"),
new GUIContent("Depth"),
new GUIContent("Ambient Occlusion"),
new GUIContent("Specular Color"),
new GUIContent("Specular Occlusion"),
new GUIContent("Smoothness"),
new GUIContent("MaterialId"),
new GUIContent("UV0"),
new GUIContent("Tangent"),
new GUIContent("Bitangent")
};
public readonly int[] materialDebugValues = { (int)HDRenderLoop.MaterialDebugMode.None,
(int)HDRenderLoop.MaterialDebugMode.DiffuseColor,
(int)HDRenderLoop.MaterialDebugMode.Normal,
(int)HDRenderLoop.MaterialDebugMode.Depth,
(int)HDRenderLoop.MaterialDebugMode.AmbientOcclusion,
(int)HDRenderLoop.MaterialDebugMode.SpecularColor,
(int)HDRenderLoop.MaterialDebugMode.SpecularOcclustion,
(int)HDRenderLoop.MaterialDebugMode.Smoothness,
(int)HDRenderLoop.MaterialDebugMode.MaterialId,
(int)HDRenderLoop.MaterialDebugMode.UV0,
(int)HDRenderLoop.MaterialDebugMode.Tangent,
(int)HDRenderLoop.MaterialDebugMode.Bitangent
};
public readonly GUIContent[] gBufferDebugStrings = { new GUIContent("None"),
new GUIContent("Diffuse Color"),
new GUIContent("Normal"),
new GUIContent("Depth"),
new GUIContent("Baked Diffuse"),
new GUIContent("Specular Color"),
new GUIContent("Specular Occlusion"),
new GUIContent("Smoothness"),
new GUIContent("MaterialId")
};
public readonly int[] gBufferDebugValues = { (int)HDRenderLoop.GBufferDebugMode.None,
(int)HDRenderLoop.GBufferDebugMode.DiffuseColor,
(int)HDRenderLoop.GBufferDebugMode.Normal,
(int)HDRenderLoop.GBufferDebugMode.Depth,
(int)HDRenderLoop.GBufferDebugMode.BakedDiffuse,
(int)HDRenderLoop.GBufferDebugMode.SpecularColor,
(int)HDRenderLoop.GBufferDebugMode.SpecularOcclustion,
(int)HDRenderLoop.GBufferDebugMode.Smoothness,
(int)HDRenderLoop.GBufferDebugMode.MaterialId
};
}
private static Styles s_Styles = null;
private static Styles styles { get { if (s_Styles == null) s_Styles = new Styles(); return s_Styles; } }
public override void OnInspectorGUI()
{
HDRenderLoop renderLoop = target as HDRenderLoop;
if(renderLoop)
{
HDRenderLoop.DebugParameters debugParameters = renderLoop.debugParameters;
EditorGUILayout.LabelField(styles.debugParameters);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
debugParameters.gBufferDebugMode = (HDRenderLoop.GBufferDebugMode)EditorGUILayout.IntPopup(styles.gBufferDebugMode, (int)debugParameters.gBufferDebugMode, styles.gBufferDebugStrings, styles.gBufferDebugValues);
debugParameters.materialDebugMode = (HDRenderLoop.MaterialDebugMode)EditorGUILayout.IntPopup(styles.materialDebugMode, (int)debugParameters.materialDebugMode, styles.materialDebugStrings, styles.materialDebugValues);
if(EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
}
EditorGUI.indentLevel--;
}
}
}
}

12
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs.meta


fileFormatVersion: 2
guid: 6e8669cdde22f4948a090da4b5fb5b7c
timeCreated: 1475763911
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存