浏览代码

Renames and cleanup

- Rename all instance of "Distortion" to "Opaque"
- Change cbuffer name to "Opaque Copy"
- Fix require/requires inconsistency
- Fix relative path in sampling shader
/LW-DistortionPass
Matt Dean 6 年前
当前提交
09db20ac
共有 4 个文件被更改,包括 37 次插入37 次删除
  1. 14
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  2. 26
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs
  3. 32
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  4. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightSampling.shader

14
ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] private bool m_SupportsVertexLight = false;
[SerializeField] private bool m_RequireDepthTexture = false;
[SerializeField] private bool m_RequireSoftParticles = false;
[SerializeField] private bool m_RequiresDistortionTexture = false;
[SerializeField] private TextureScale m_DistortionTextureScale = TextureScale.Half;
[SerializeField] private bool m_RequireOpaqueTexture = false;
[SerializeField] private TextureScale m_OpaqueTextureScale = TextureScale.Half;
[SerializeField] private bool m_SupportsHDR = false;
[SerializeField] private MSAAQuality m_MSAA = MSAAQuality._4x;
[SerializeField] private float m_RenderScale = 1.0f;

get { return m_RequireSoftParticles; }
}
public bool RequireDistortionTexture
public bool RequireOpaqueTexture
get { return m_RequiresDistortionTexture; }
get { return m_RequireOpaqueTexture; }
public TextureScale DistortionTextureScale
public TextureScale OpaqueTextureScale
get { return m_DistortionTextureScale; }
set { m_DistortionTextureScale = value; }
get { return m_OpaqueTextureScale; }
set { m_OpaqueTextureScale = value; }
}
public bool SupportsHDR

26
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs


public static GUIContent requireSoftParticles = new GUIContent("Soft Particles", "If enabled the pipeline will enable SOFT_PARTICLES keyword.");
public static GUIContent requireDistortionTexture = new GUIContent("Distortion Texture", "If enabled the pipeline will copy the screen to texture after opaque objects are drawn. For transparent objects this can be bound in shaders as _CameraDistortionTexture.");
public static GUIContent requireOpaqueTexture = new GUIContent("Opaque Texture", "If enabled the pipeline will copy the screen to texture after opaque objects are drawn. For transparent objects this can be bound in shaders as _CameraOpaqueTexture.");
public static GUIContent distortionTextureScale = new GUIContent("Distortion Scale", "The scale of the original screen size that is used for the distortion texture");
public static GUIContent opaqueTextureScale = new GUIContent("Opaque Scale", "The scale of the original screen size that is used for the opaque texture");
public static GUIContent shadowType = new GUIContent("Type",
"Global shadow settings. Options are NO_SHADOW, HARD_SHADOWS and SOFT_SHADOWS.");

}
AnimBool m_ShowSoftParticles = new AnimBool();
AnimBool m_ShowDistortionTextureScale = new AnimBool();
AnimBool m_ShowOpaqueTextureScale = new AnimBool();
private int kMaxSupportedPixelLights = 8;

private SerializedProperty m_SupportsVertexLightProp;
private SerializedProperty m_RequireDepthTextureProp;
private SerializedProperty m_RequireSoftParticlesProp;
private SerializedProperty m_RequireDistortionTextureProp;
private SerializedProperty m_DistortionTextureScaleProp;
private SerializedProperty m_RequireOpaqueTextureProp;
private SerializedProperty m_OpaqueTextureScaleProp;
private SerializedProperty m_ShadowTypeProp;
private SerializedProperty m_ShadowNearPlaneOffsetProp;
private SerializedProperty m_ShadowDistanceProp;

m_SupportsVertexLightProp = serializedObject.FindProperty("m_SupportsVertexLight");
m_RequireDepthTextureProp = serializedObject.FindProperty("m_RequireDepthTexture");
m_RequireSoftParticlesProp = serializedObject.FindProperty("m_RequireSoftParticles");
m_RequireDistortionTextureProp = serializedObject.FindProperty("m_RequiresDistortionTexture");
m_DistortionTextureScaleProp = serializedObject.FindProperty("m_DistortionTextureScale");
m_RequireOpaqueTextureProp = serializedObject.FindProperty("m_RequireOpaqueTexture");
m_OpaqueTextureScaleProp = serializedObject.FindProperty("m_OpaqueTextureScale");
m_ShadowTypeProp = serializedObject.FindProperty("m_ShadowType");
m_ShadowNearPlaneOffsetProp = serializedObject.FindProperty("m_ShadowNearPlaneOffset");
m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");

m_ShowSoftParticles.valueChanged.AddListener(Repaint);
m_ShowSoftParticles.value = m_RequireSoftParticlesProp.boolValue;
m_ShowDistortionTextureScale.valueChanged.AddListener(Repaint);
m_ShowDistortionTextureScale.value = m_DistortionTextureScaleProp.boolValue;
m_ShowOpaqueTextureScale.valueChanged.AddListener(Repaint);
m_ShowOpaqueTextureScale.value = m_OpaqueTextureScaleProp.boolValue;
m_ShowDistortionTextureScale.valueChanged.RemoveListener(Repaint);
m_ShowOpaqueTextureScale.valueChanged.RemoveListener(Repaint);
m_ShowDistortionTextureScale.target = m_RequireDistortionTextureProp.boolValue;
m_ShowOpaqueTextureScale.target = m_RequireOpaqueTextureProp.boolValue;
}
void DrawAnimatedProperty(SerializedProperty prop, GUIContent content, AnimBool animation)

EditorGUILayout.PropertyField(m_SupportsVertexLightProp, Styles.enableVertexLightLabel);
EditorGUILayout.PropertyField(m_RequireDepthTextureProp, Styles.requireDepthTexture);
DrawAnimatedProperty(m_RequireSoftParticlesProp, Styles.requireSoftParticles, m_ShowSoftParticles);
EditorGUILayout.PropertyField(m_RequireDistortionTextureProp, Styles.requireDistortionTexture);
DrawAnimatedProperty(m_DistortionTextureScaleProp, Styles.distortionTextureScale, m_ShowDistortionTextureScale);
EditorGUILayout.PropertyField(m_RequireOpaqueTextureProp, Styles.requireOpaqueTexture);
DrawAnimatedProperty(m_OpaqueTextureScaleProp, Styles.opaqueTextureScale, m_ShowOpaqueTextureScale);
EditorGUILayout.PropertyField(m_HDR, Styles.hdrContent);
EditorGUILayout.PropertyField(m_MSAA, Styles.msaaContent);

32
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


// If soft particles are enabled and no depth prepass is performed we need to copy depth.
public static int depthCopy;
// Camera distortion target. Used for accessing screen contents during transparent pass.
public static int distortion;
// Camera opaque target. Used for accessing screen contents during transparent pass.
public static int opaque;
}
public class LightweightPipeline : RenderPipeline

private RenderTargetIdentifier m_DepthRT;
private RenderTargetIdentifier m_CopyDepth;
private RenderTargetIdentifier m_Color;
private RenderTargetIdentifier m_DistortionRT;
private RenderTargetIdentifier m_OpaqueRT;
private bool m_IntermediateTextureArray;
private bool m_RequireDepthTexture;

CameraRenderTargetID.copyColor = Shader.PropertyToID("_CameraCopyColorRT");
CameraRenderTargetID.depth = Shader.PropertyToID("_CameraDepthTexture");
CameraRenderTargetID.depthCopy = Shader.PropertyToID("_CameraCopyDepthTexture");
CameraRenderTargetID.distortion = Shader.PropertyToID("_CameraDistortionTexture");
CameraRenderTargetID.opaque = Shader.PropertyToID("_CameraOpaqueTexture");
m_ShadowMapRT = new RenderTargetIdentifier(m_ShadowMapRTID);
m_ScreenSpaceShadowMapRT = new RenderTargetIdentifier(m_ScreenSpaceShadowMapRTID);

m_DepthRT = new RenderTargetIdentifier(CameraRenderTargetID.depth);
m_CopyDepth = new RenderTargetIdentifier(CameraRenderTargetID.depthCopy);
m_DistortionRT = new RenderTargetIdentifier(CameraRenderTargetID.distortion);
m_OpaqueRT = new RenderTargetIdentifier(CameraRenderTargetID.opaque);
m_PostProcessRenderContext = new PostProcessRenderContext();
m_CopyTextureSupport = SystemInfo.copyTextureSupport;

StopStereoRendering(ref context, frameRenderingConfiguration);
}
private void DistortionPass(ref ScriptableRenderContext context)
private void OpaqueTexturePass(ref ScriptableRenderContext context)
CommandBuffer cmd = CommandBufferPool.Get("Distortion");
switch(m_Asset.DistortionTextureScale)
CommandBuffer cmd = CommandBufferPool.Get("Opaque Copy");
switch(m_Asset.OpaqueTextureScale)
cmd.GetTemporaryRT(CameraRenderTargetID.distortion, m_CurrCamera.pixelWidth / 2, m_CurrCamera.pixelHeight / 2, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.distortion, m_SamplingMaterial, 0);
cmd.GetTemporaryRT(CameraRenderTargetID.opaque, m_CurrCamera.pixelWidth / 2, m_CurrCamera.pixelHeight / 2, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.opaque, m_SamplingMaterial, 0);
cmd.GetTemporaryRT(CameraRenderTargetID.distortion, m_CurrCamera.pixelWidth / 4, m_CurrCamera.pixelHeight / 4, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.distortion, m_SamplingMaterial, 1);
cmd.GetTemporaryRT(CameraRenderTargetID.opaque, m_CurrCamera.pixelWidth / 4, m_CurrCamera.pixelHeight / 4, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.opaque, m_SamplingMaterial, 1);
cmd.GetTemporaryRT(CameraRenderTargetID.distortion, m_CurrCamera.pixelWidth, m_CurrCamera.pixelHeight, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.distortion);
cmd.GetTemporaryRT(CameraRenderTargetID.opaque, m_CurrCamera.pixelWidth, m_CurrCamera.pixelHeight, 0, FilterMode.Bilinear, m_ColorFormat);
cmd.Blit(m_CurrCameraColorRT, CameraRenderTargetID.opaque);
break;
}
SetRenderTarget(cmd, m_CurrCameraColorRT, m_DepthRT);

context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
if(m_Asset.RequireDistortionTexture)
if(m_Asset.RequireOpaqueTexture)
DistortionPass(ref context);
OpaqueTexturePass(ref context);
}
}

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightSampling.shader


}
HLSLINCLUDE
#include "../ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Core.hlsl"
struct VertexInput
{

正在加载...
取消
保存