浏览代码

Cleanup & refactor

/Branch_Batching2
Chman 8 年前
当前提交
76ffa244
共有 5 个文件被更改,包括 135 次插入140 次删除
  1. 60
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Editor/PostProcessingEditor.cs
  2. 107
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.cs
  3. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
  4. 95
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.Settings.cs
  5. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.Settings.cs.meta

60
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Editor/PostProcessingEditor.cs


{
serializedObject.Update();
DoColorGradingUI();
DoEyeAdaptationUI();
DoBloomUI();
DoChromaticAberrationUI();
DoVignetteUI();
Do("Color Grading", ColorGradingUI);
Do("Eye Adaptation", EyeAdaptationUI);
Do("Bloom", BloomUI);
Do("Chromatic Aberration", ChromaticAberrationUI);
Do("Vignette", VignetteUI);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(globalDithering);

void DoColorGradingUI()
void Do(string header, Action func)
EditorGUILayout.LabelField("Color Grading", EditorStyles.boldLabel);
EditorGUILayout.Space();
EditorGUILayout.LabelField(header, EditorStyles.boldLabel);
if (func != null)
func();
EditorGUI.indentLevel--;
}
void ColorGradingUI()
{
var camera = (target as PostProcessing).GetComponent<Camera>();
if (camera != null)
{

}
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
void DoEyeAdaptationUI()
void EyeAdaptationUI()
EditorGUILayout.Space();
EditorGUILayout.LabelField("Eye Adaptation", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(eyeAdaptation.enabled);
if (eyeAdaptation.enabled.boolValue)

EditorGUI.indentLevel--;
}
}
EditorGUI.indentLevel--;
void DoBloomUI()
void BloomUI()
EditorGUILayout.Space();
EditorGUILayout.LabelField("Bloom", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(bloomSettings.enabled);
if (bloomSettings.enabled.boolValue)

bloomSettings.threshold.floatValue = Mathf.Max(0f, bloomSettings.threshold.floatValue);
bloomSettings.lensIntensity.floatValue = Mathf.Max(0f, bloomSettings.lensIntensity.floatValue);
}
EditorGUI.indentLevel--;
void DoChromaticAberrationUI()
void ChromaticAberrationUI()
EditorGUILayout.Space();
EditorGUILayout.LabelField("Chromatic Aberration", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(chromaSettings.enabled);
if (chromaSettings.enabled.boolValue)

}
EditorGUI.indentLevel--;
void DoVignetteUI()
void VignetteUI()
EditorGUILayout.Space();
EditorGUILayout.LabelField("Vignette", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(vignetteSettings.enabled);
if (vignetteSettings.enabled.boolValue)

EditorGUILayout.PropertyField(vignetteSettings.intensity);
EditorGUILayout.PropertyField(vignetteSettings.smoothness);
}
EditorGUI.indentLevel--;
}
#region Color grading stuff

107
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.cs


[ExecuteInEditMode, ImageEffectAllowedInSceneView]
[RequireComponent(typeof(Camera))]
public sealed class PostProcessing : MonoBehaviour
public sealed partial class PostProcessing : MonoBehaviour
#region Settings classes
[Serializable]
public sealed class ColorGradingSettings
{
public enum GradingType
{
None,
Neutral,
Custom
}
public GradingType type = GradingType.None;
public float exposure = 0f;
public Texture logLut = null;
[Range(-0.10f, 0.1f)] public float neutralBlackIn = 0.02f;
[Range( 1.00f, 20.0f)] public float neutralWhiteIn = 10f;
[Range(-0.09f, 0.1f)] public float neutralBlackOut = 0f;
[Range( 1.00f, 19.0f)] public float neutralWhiteOut = 10f;
[Range( 0.10f, 20.0f)] public float neutralWhiteLevel = 5.3f;
[Range( 1.00f, 10.0f)] public float neutralWhiteClip = 10f;
}
[Serializable]
public sealed class EyeAdaptationSettings
{
public enum EyeAdaptationType
{
Progressive,
Fixed
}
public bool enabled = false;
public bool showDebugHistogramInGameView = true;
[Range(1f, 99f)] public float lowPercent = 65f;
[Range(1f, 99f)] public float highPercent = 95f;
public float minLuminance = 0.03f;
public float maxLuminance = 2f;
public float exposureCompensation = 0.5f;
public EyeAdaptationType adaptationType = EyeAdaptationType.Progressive;
public float speedUp = 2f;
public float speedDown = 1f;
[Range(-16, -1)] public int logMin = -8;
[Range( 1, 16)] public int logMax = 4;
}
[Serializable]
public sealed class ChromaticAberrationSettings
{
public bool enabled = false;
public Texture spectralTexture;
[Range(0f, 1f)] public float intensity = 0.1f;
}
[Serializable]
public sealed class VignetteSettings
{
public bool enabled = false;
[ColorUsage(false, true, 0f, 10f, 0f, 10f)]
public Color color = new Color(0f, 0f, 0f, 1f);
public Vector2 center = new Vector2(0.5f, 0.5f);
[Range(0f, 1f)] public float intensity = 0.3f;
[Range(0f, 1f)] public float smoothness = 0.3f;
}
[Serializable]
public sealed class BloomSettings
{
public bool enabled = false;
public float intensity = 0.5f;
public float threshold = 1.1f;
[Range(0f, 1f)] public float softKnee = 0.5f;
[Range(1f, 7f)] public float radius = 5f;
public Texture lensTexture;
public float lensIntensity = 3f;
}
#endregion
// Quick & very dirty temporary wrapper used for bloom (easy porting from old school render
// texture blitting to command buffers)
struct RenderTextureWrapper

public ChromaticAberrationSettings chromaSettings = new ChromaticAberrationSettings();
public VignetteSettings vignetteSettings = new VignetteSettings();
public BloomSettings bloomSettings = new BloomSettings();
public bool globalDithering = false;
Material m_EyeAdaptationMaterial;

const int k_HistogramThreadY = 16;
// Holds 64 64x64 Alpha8 textures (256kb total)
Texture2D[] blueNoiseTextures;
int ditheringTexIndex = 0;
Texture2D[] m_BlueNoiseTextures;
int m_DitheringTexIndex = 0;
void OnEnable()
{

m_AutoExposurePool[0] = new RenderTexture(1, 1, 0, RenderTextureFormat.RFloat);
m_AutoExposurePool[1] = new RenderTexture(1, 1, 0, RenderTextureFormat.RFloat);
blueNoiseTextures = new Texture2D[k_BlueNoiseTextureCount];
m_BlueNoiseTextures = new Texture2D[k_BlueNoiseTextureCount];
blueNoiseTextures[i] = Resources.Load<Texture2D>("Textures/LDR_LLL1_" + i);
m_BlueNoiseTextures[i] = Resources.Load<Texture2D>("Textures/LDR_LLL1_" + i);
m_TempRt = Shader.PropertyToID("_Source");

{
m_FinalPassMaterial.EnableKeyword("DITHERING");
if (++ditheringTexIndex >= k_BlueNoiseTextureCount)
ditheringTexIndex = 0;
if (++m_DitheringTexIndex >= k_BlueNoiseTextureCount)
m_DitheringTexIndex = 0;
var noiseTex = blueNoiseTextures[ditheringTexIndex];
var noiseTex = m_BlueNoiseTextures[m_DitheringTexIndex];
m_FinalPassMaterial.SetTexture(Uniforms._DitheringTex, noiseTex);
m_FinalPassMaterial.SetVector(Uniforms._DitheringCoords, new Vector4(
(float)camera.pixelWidth / (float)noiseTex.width,

1
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader


{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoordFlipped : TEXCOORD0;
};
Varyings Vert(Attributes input)

95
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.Settings.cs


using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
partial class PostProcessing
{
[Serializable]
public sealed class ColorGradingSettings
{
public enum GradingType
{
None,
Neutral,
Custom
}
public GradingType type = GradingType.None;
public float exposure = 0f;
public Texture logLut = null;
[Range(-0.10f, 0.1f)] public float neutralBlackIn = 0.02f;
[Range( 1.00f, 20.0f)] public float neutralWhiteIn = 10f;
[Range(-0.09f, 0.1f)] public float neutralBlackOut = 0f;
[Range( 1.00f, 19.0f)] public float neutralWhiteOut = 10f;
[Range( 0.10f, 20.0f)] public float neutralWhiteLevel = 5.3f;
[Range( 1.00f, 10.0f)] public float neutralWhiteClip = 10f;
}
[Serializable]
public sealed class EyeAdaptationSettings
{
public enum EyeAdaptationType
{
Progressive,
Fixed
}
public bool enabled = false;
public bool showDebugHistogramInGameView = true;
[Range(1f, 99f)] public float lowPercent = 65f;
[Range(1f, 99f)] public float highPercent = 95f;
public float minLuminance = 0.03f;
public float maxLuminance = 2f;
public float exposureCompensation = 0.5f;
public EyeAdaptationType adaptationType = EyeAdaptationType.Progressive;
public float speedUp = 2f;
public float speedDown = 1f;
[Range(-16, -1)] public int logMin = -8;
[Range( 1, 16)] public int logMax = 4;
}
[Serializable]
public sealed class ChromaticAberrationSettings
{
public bool enabled = false;
public Texture spectralTexture;
[Range(0f, 1f)] public float intensity = 0.1f;
}
[Serializable]
public sealed class VignetteSettings
{
public bool enabled = false;
[ColorUsage(false, true, 0f, 10f, 0f, 10f)]
public Color color = new Color(0f, 0f, 0f, 1f);
public Vector2 center = new Vector2(0.5f, 0.5f);
[Range(0f, 1f)] public float intensity = 0.3f;
[Range(0f, 1f)] public float smoothness = 0.3f;
}
[Serializable]
public sealed class BloomSettings
{
public bool enabled = false;
public float intensity = 0.5f;
public float threshold = 1.1f;
[Range(0f, 1f)] public float softKnee = 0.5f;
[Range(1f, 7f)] public float radius = 5f;
public Texture lensTexture;
public float lensIntensity = 3f;
}
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/PostProcessing.Settings.cs.meta


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