浏览代码

Added support to BakedIndirect and CopyColor to emulate grabpass.

/LightweightPipelineExperimental
Felipe Lira 7 年前
当前提交
dba19ad6
共有 4 个文件被更改,包括 42 次插入13 次删除
  1. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  2. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs
  3. 43
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  4. 1
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineUtils.cs

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


[SerializeField] private int m_MaxPixelLights = 4;
[SerializeField] private bool m_SupportsVertexLight = false;
[SerializeField] private bool m_RequireCameraDepthTexture = false;
[SerializeField] private bool m_RequireCameraColorTexture = false;
[SerializeField] private bool m_SupportsHDR = false;
[SerializeField] private MSAAQuality m_MSAA = MSAAQuality._4x;
[SerializeField] private float m_RenderScale = 1.0f;

public bool RequireCameraDepthTexture
{
get { return m_RequireCameraDepthTexture; }
}
public bool RequireCameraColorTexture
{
get { return m_RequireCameraColorTexture; }
}
public bool SupportsHDR

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


public static GUIContent requireCameraDepthTexture = new GUIContent("Camera Depth Texture", "If enabled the pipeline will generate camera's depth that can be bound in shaders as _CameraDepthTexture. This is necessary for some effect like Soft Particles.");
public static GUIContent requireCameraColorTexture = new GUIContent("Camera Color Texture", "If enabled the pipeline will generate camera's color that can be bound in shaders as _CameraColorTexture.");
public static GUIContent shadowType = new GUIContent("Type",
"Global shadow settings. Options are NO_SHADOW, HARD_SHADOWS and SOFT_SHADOWS.");

private SerializedProperty m_MaxPixelLights;
private SerializedProperty m_SupportsVertexLightProp;
private SerializedProperty m_RequireCameraDepthTextureProp;
private SerializedProperty m_RequireCameraColorTextureProp;
private SerializedProperty m_ShadowTypeProp;
private SerializedProperty m_ShadowNearPlaneOffsetProp;
private SerializedProperty m_ShadowDistanceProp;

m_MaxPixelLights = serializedObject.FindProperty("m_MaxPixelLights");
m_SupportsVertexLightProp = serializedObject.FindProperty("m_SupportsVertexLight");
m_RequireCameraDepthTextureProp = serializedObject.FindProperty("m_RequireCameraDepthTexture");
m_RequireCameraColorTextureProp = serializedObject.FindProperty("m_RequireCameraColorTexture");
m_ShadowTypeProp = serializedObject.FindProperty("m_ShadowType");
m_ShadowNearPlaneOffsetProp = serializedObject.FindProperty("m_ShadowNearPlaneOffset");
m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");

m_MaxPixelLights.intValue = EditorGUILayout.IntSlider(m_MaxPixelLights.intValue, 0, kMaxSupportedPixelLights);
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(m_SupportsVertexLightProp, Styles.enableVertexLightLabel);
EditorGUILayout.PropertyField(m_RequireCameraColorTextureProp, Styles.requireCameraColorTexture);
EditorGUILayout.PropertyField(m_RequireCameraDepthTextureProp, Styles.requireCameraDepthTexture);
EditorGUILayout.PropertyField(m_HDR, Styles.hdrContent);
EditorGUILayout.PropertyField(m_MSAA, Styles.msaaContent);

43
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


m_ShadowMapRTID = Shader.PropertyToID("_ShadowMap");
CameraRenderTargetID.color = Shader.PropertyToID("_CameraColorRT");
CameraRenderTargetID.copyColor = Shader.PropertyToID("_CameraCopyColorRT");
CameraRenderTargetID.copyColor = Shader.PropertyToID("_CameraColorTexture");
CameraRenderTargetID.depth = Shader.PropertyToID("_CameraDepthTexture");
CameraRenderTargetID.depthCopy = Shader.PropertyToID("_CameraCopyDepthTexture");

{
reflectionProbeSupportFlags = SupportedRenderingFeatures.ReflectionProbeSupportFlags.None,
defaultMixedLightingMode = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive,
supportedMixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive,
supportedMixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeMode.Subtractive | SupportedRenderingFeatures.LightmapMixedBakeMode.IndirectOnly,
supportedLightmapBakeTypes = LightmapBakeType.Baked | LightmapBakeType.Mixed,
supportedLightmapsModes = LightmapsMode.CombinedDirectional | LightmapsMode.NonDirectional,
rendererSupportsLightProbeProxyVolumes = false,

private void AfterOpaque(ref ScriptableRenderContext context, FrameRenderingConfiguration config)
{
bool requireColorTexture = LightweightUtils.HasFlag(config, FrameRenderingConfiguration.RequireColorTexture);
if (requireColorTexture)
{
cmd.SetGlobalTexture(m_BlitTexID, m_ColorRT);
cmd.SetGlobalTexture(CameraRenderTargetID.copyColor, m_CopyColorRT);
}
// When only one opaque effect is active we need to blit to a work RT. We blit to copy color.
// TODO: We can check if there are more than one opaque postfx and avoid an extra blit.

m_CurrCameraColorRT = m_CopyColorRT;
}
if (requireColorTexture)
{
cmd.Blit(m_CurrCameraColorRT, m_CopyColorRT, m_BlitMaterial);
m_CurrCameraColorRT = m_CopyColorRT;
}
if (LightweightUtils.HasFlag(config, FrameRenderingConfiguration.DepthCopy))
{
CopyTexture(cmd, m_DepthRT, m_CopyDepth, m_CopyDepthMaterial);

if (m_CameraPostProcessLayer.HasOpaqueOnlyEffects(m_PostProcessRenderContext))
configuration |= FrameRenderingConfiguration.BeforeTransparentPostProcess;
// Resolving depth msaa requires texture2DMS. Currently if msaa is enabled we do a depth pre-pass.
if (msaaEnabled)
configuration |= FrameRenderingConfiguration.DepthPass;
}
// In case of soft particles we need depth copy. If depth copy not supported fallback to depth prepass

intermediateTexture = true;
bool supportsDepthCopy = m_CopyTextureSupport != CopyTextureSupport.None && m_Asset.CopyDepthShader.isSupported;
// currently fallback to depth prepass if msaa is enabled since. We need texture2DMS to support depth resolve.
configuration |= (msaaEnabled || !supportsDepthCopy) ? FrameRenderingConfiguration.DepthPass : FrameRenderingConfiguration.DepthCopy;
}
if (msaaEnabled)

Rect cameraRect = m_CurrCamera.rect;
if (!(Math.Abs(cameraRect.x) > 0.0f || Math.Abs(cameraRect.y) > 0.0f || Math.Abs(cameraRect.width) < 1.0f || Math.Abs(cameraRect.height) < 1.0f))
configuration |= FrameRenderingConfiguration.DefaultViewport;
if (m_Asset.RequireCameraColorTexture)
{
intermediateTexture = true;
m_RequiredDepth = true;
configuration |= (FrameRenderingConfiguration.RequireColorTexture | FrameRenderingConfiguration.DepthCopy);
}
// Resolving depth msaa requires texture2DMS. Currently if msaa is enabled we do a depth pre-pass.
if (m_RequiredDepth && msaaEnabled)
{
configuration |= FrameRenderingConfiguration.DepthPass;
}
if (intermediateTexture)
configuration |= FrameRenderingConfiguration.IntermediateTexture;

// When postprocessing is enabled we might have a before transparent effect. In that case we need to
// use the camera render target as input. We blit to an opaque RT and then after before postprocessing is done
// we blit to the final camera RT. If no postprocessing we blit to final camera RT from beginning.
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.BeforeTransparentPostProcess))
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.BeforeTransparentPostProcess) || LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.RequireColorTexture))
cmd.GetTemporaryRT(CameraRenderTargetID.copyColor, colorRTDesc, FilterMode.Point);
}

if (!m_IsOffscreenCamera)
colorRT = m_CurrCameraColorRT;
if (m_RequiredDepth && !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DepthPass))
if (m_RequiredDepth || !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DepthPass))
depthRT = m_DepthRT;
}

1
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineUtils.cs


DepthCopy = (1 << 5),
DefaultViewport = (1 << 6),
IntermediateTexture = (1 << 7),
RequireColorTexture = (1 << 8)
}
public static class LightweightUtils

正在加载...
取消
保存