Align managed raster RenderGraph authoring with URP
This commit is contained in:
@@ -7,12 +7,6 @@ using XCEngine.Rendering.Universal;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
internal static class BuiltinShaderPaths
|
||||
{
|
||||
public const string ColorScalePostProcess =
|
||||
"builtin://shaders/color-scale-post-process";
|
||||
}
|
||||
|
||||
internal static class ProbeFinalColorSettingsFactory
|
||||
{
|
||||
public static FinalColorSettings Create()
|
||||
@@ -141,12 +135,6 @@ namespace Gameplay
|
||||
Transparent
|
||||
}
|
||||
|
||||
internal enum FullscreenPassKind
|
||||
{
|
||||
ColorScale,
|
||||
ShaderVector
|
||||
}
|
||||
|
||||
internal sealed class ScenePhasePass : ScriptableRenderPass
|
||||
{
|
||||
private readonly ScenePhaseKind m_phaseKind;
|
||||
@@ -197,9 +185,6 @@ namespace Gameplay
|
||||
|
||||
internal sealed class FullscreenPass : ScriptableRenderPass
|
||||
{
|
||||
private readonly FullscreenPassKind m_passKind;
|
||||
private readonly Vector4 m_vectorPayload;
|
||||
private readonly string m_shaderPath;
|
||||
private readonly string m_passName;
|
||||
|
||||
public FullscreenPass(
|
||||
@@ -207,22 +192,14 @@ namespace Gameplay
|
||||
Vector4 colorScale)
|
||||
{
|
||||
renderPassEvent = passEvent;
|
||||
m_passKind = FullscreenPassKind.ColorScale;
|
||||
m_vectorPayload = colorScale;
|
||||
m_shaderPath = string.Empty;
|
||||
m_passName = string.Empty;
|
||||
}
|
||||
|
||||
public FullscreenPass(
|
||||
RenderPassEvent passEvent,
|
||||
string shaderPath,
|
||||
Vector4 vectorPayload,
|
||||
string passName = null)
|
||||
string passName)
|
||||
{
|
||||
renderPassEvent = passEvent;
|
||||
m_passKind = FullscreenPassKind.ShaderVector;
|
||||
m_vectorPayload = vectorPayload;
|
||||
m_shaderPath = shaderPath ?? string.Empty;
|
||||
m_passName = passName ?? string.Empty;
|
||||
}
|
||||
|
||||
@@ -238,21 +215,32 @@ namespace Gameplay
|
||||
private bool RecordFullscreen(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
switch (m_passKind)
|
||||
RenderGraphTextureHandle sourceColor =
|
||||
context.sourceColorTexture;
|
||||
RenderGraphTextureHandle outputColor =
|
||||
context.primaryColorTarget;
|
||||
if (!sourceColor.isValid ||
|
||||
!outputColor.isValid)
|
||||
{
|
||||
case FullscreenPassKind.ColorScale:
|
||||
return RecordColorScaleFullscreenPass(
|
||||
context,
|
||||
m_vectorPayload);
|
||||
case FullscreenPassKind.ShaderVector:
|
||||
return RecordShaderVectorFullscreenPass(
|
||||
context,
|
||||
m_shaderPath,
|
||||
m_vectorPayload,
|
||||
m_passName);
|
||||
default:
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return context
|
||||
.AddRasterPass(ResolvePassName())
|
||||
.UseColorSource(sourceColor)
|
||||
.SetColorAttachment(outputColor)
|
||||
.SetRenderFunc(
|
||||
rasterContext =>
|
||||
{
|
||||
})
|
||||
.Commit();
|
||||
}
|
||||
|
||||
private string ResolvePassName()
|
||||
{
|
||||
return string.IsNullOrEmpty(m_passName)
|
||||
? "Gameplay.GenericFullscreenRasterPass"
|
||||
: m_passName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,14 +523,10 @@ namespace Gameplay
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
firstVectorPayload,
|
||||
"ColorScale"),
|
||||
"ManagedPostProcess.First"),
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.AfterRenderingPostProcessing,
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
secondVectorPayload,
|
||||
"ColorScale")));
|
||||
"ManagedPostProcess.Second")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,10 +538,10 @@ namespace Gameplay
|
||||
{
|
||||
AddFeature(new DefaultSceneFeature(onOpaqueRecorded));
|
||||
AddFeature(
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
postProcessScale)));
|
||||
new ColorScalePostProcessRendererFeature
|
||||
{
|
||||
colorScale = postProcessScale
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2131,8 +2115,6 @@ namespace Gameplay
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
new Vector4(1.05f, 1.0f, 0.95f, 1.0f),
|
||||
"ManagedCameraOverridePostProcess")));
|
||||
}
|
||||
}
|
||||
@@ -2607,11 +2589,13 @@ namespace Gameplay
|
||||
return context != null &&
|
||||
context
|
||||
.AddRasterPass(
|
||||
"Managed.InvalidMainSceneRasterPass")
|
||||
"Managed.MainSceneGenericRasterPass")
|
||||
.SetColorAttachment(
|
||||
context.primaryColorTarget)
|
||||
.SetColorScaleFullscreenExecution(
|
||||
new Vector4(1.0f, 1.0f, 1.0f, 1.0f))
|
||||
.SetRenderFunc(
|
||||
rasterContext =>
|
||||
{
|
||||
})
|
||||
.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user