Started on graphics configuration and rendering setup. Updated to DirectX 12 back-end, Rendergraph API and introduced some better graphics configuration options and post-processing.
parent
fa27693984
commit
017c769324
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a55ee4efaad27d948ba5f03fc6d7bc80
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ed9b95dc6ed6d0647ad7f1a8f305385d
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
File diff suppressed because it is too large
Load Diff
@ -1,63 +1,97 @@
|
|||||||
|
#nullable enable
|
||||||
|
using System ;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.Rendering.Universal;
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
public class OutlineRenderFeature : ScriptableRendererFeature
|
public class OutlineRenderFeature: ScriptableRendererFeature {
|
||||||
{
|
static Material? outlineMaterial ;
|
||||||
class OutlinePass : ScriptableRenderPass
|
OutlinePass? outlinePass ;
|
||||||
{
|
|
||||||
private RenderTargetHandle tempColorTexture;
|
class OutlinePass: ScriptableRenderPass {
|
||||||
private Material outlineMaterial;
|
RTHandle? tempColorTexture,
|
||||||
private RenderTargetIdentifier cameraTarget;
|
cameraRTHandle ;
|
||||||
|
RenderTargetIdentifier cameraTarget ;
|
||||||
public OutlinePass(Material material)
|
|
||||||
{
|
public OutlinePass( Material material ) => outlineMaterial = material ;
|
||||||
outlineMaterial = material;
|
|
||||||
tempColorTexture.Init("_TemporaryColorTexture");
|
[Obsolete( "This rendering path is for compatibility mode only (when Render Graph is disabled). " +
|
||||||
}
|
"Use Render Graph API instead.", false )]
|
||||||
|
public override void Configure( CommandBuffer cmd,
|
||||||
|
RenderTextureDescriptor cameraTextureDescriptor ) {
|
||||||
|
/*cmd.GetTemporaryRT(tempColorTexture.id, cameraTextureDescriptor); // Create temp texture
|
||||||
|
ConfigureTarget(tempColorTexture.Identifier());*/
|
||||||
|
|
||||||
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
|
// Allocate RTHandles properly
|
||||||
{
|
tempColorTexture = RTHandles.Alloc( cameraTextureDescriptor.width,
|
||||||
cmd.GetTemporaryRT(tempColorTexture.id, cameraTextureDescriptor); // Create temp texture
|
cameraTextureDescriptor.height ) ;
|
||||||
ConfigureTarget(tempColorTexture.Identifier());
|
cameraRTHandle = RTHandles.Alloc( cameraTextureDescriptor.width,
|
||||||
|
cameraTextureDescriptor.height ) ;
|
||||||
|
|
||||||
|
cmd.GetTemporaryRT( Shader.PropertyToID( tempColorTexture?.name ),
|
||||||
|
cameraTextureDescriptor ) ; // Create temp texture
|
||||||
|
|
||||||
|
ConfigureTarget( tempColorTexture ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
[Obsolete( "This rendering path is for compatibility mode only (when Render Graph is disabled). " +
|
||||||
{
|
"Use Render Graph API instead.", false )]
|
||||||
if (outlineMaterial == null) return;
|
public override void Execute( ScriptableRenderContext context,
|
||||||
|
ref RenderingData renderingData ) {
|
||||||
|
/*
|
||||||
|
if ( !outlineMaterial ) return ;
|
||||||
|
|
||||||
CommandBuffer cmd = CommandBufferPool.Get("Outline Pass");
|
CommandBuffer cmd = CommandBufferPool.Get("Outline Pass");
|
||||||
cameraTarget = renderingData.cameraData.renderer.cameraColorTargetHandle; // ✅ Safe usage here
|
cameraTarget = renderingData.cameraData.renderer.cameraColorTargetHandle; // ✅ Safe usage here
|
||||||
|
Blit(cmd, cameraTarget, tempColorTexture ); // Copy to temp texture
|
||||||
|
Blit(cmd, tempColorTexture, cameraTarget, outlineMaterial); // Apply outline effect
|
||||||
|
|
||||||
|
// Use new RTHandles API:
|
||||||
|
Blitter.BlitCameraTexture( cmd, cameraRTHandle, tempColorTexture, Vector4.one ) ;
|
||||||
|
Blitter.BlitCameraTexture( cmd, tempColorTexture,
|
||||||
|
cameraRTHandle, 1, outlineMaterial ) ;
|
||||||
|
|
||||||
Blit(cmd, cameraTarget, tempColorTexture.Identifier()); // Copy to temp texture
|
// Copy to tempRT
|
||||||
Blit(cmd, tempColorTexture.Identifier(), cameraTarget, outlineMaterial); // Apply outline effect
|
|
||||||
|
context.ExecuteCommandBuffer( cmd ) ;
|
||||||
|
CommandBufferPool.Release( cmd ) ;
|
||||||
|
*/
|
||||||
|
if (!outlineMaterial || tempColorTexture == null || cameraRTHandle == null) return;
|
||||||
|
|
||||||
|
CommandBuffer cmd = CommandBufferPool.Get("Outline Pass");
|
||||||
|
|
||||||
|
// Copy camera render target into temp texture
|
||||||
|
Blitter.BlitCameraTexture( cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
|
||||||
|
tempColorTexture, Vector4.one ) ;
|
||||||
|
|
||||||
|
// Apply outline material and write back to camera target
|
||||||
|
Blitter.BlitCameraTexture(cmd, tempColorTexture,
|
||||||
|
renderingData.cameraData.renderer.cameraColorTargetHandle,
|
||||||
|
0, outlineMaterial ) ;
|
||||||
|
|
||||||
context.ExecuteCommandBuffer(cmd);
|
context.ExecuteCommandBuffer(cmd);
|
||||||
CommandBufferPool.Release(cmd);
|
CommandBufferPool.Release(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnCameraCleanup(CommandBuffer cmd)
|
public override void OnCameraCleanup( CommandBuffer cmd ) {
|
||||||
{
|
tempColorTexture?.Release();
|
||||||
cmd.ReleaseTemporaryRT(tempColorTexture.id); // Cleanup
|
cameraRTHandle?.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField] private Material outlineMaterial;
|
public override void Create( ) {
|
||||||
private OutlinePass outlinePass;
|
if ( !outlineMaterial ) {
|
||||||
|
Debug.LogError( "Outline material is not assigned." ) ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Create()
|
outlinePass = new( outlineMaterial ) {
|
||||||
{
|
renderPassEvent = RenderPassEvent.AfterRenderingOpaques, // ✅ Executes after opaque objects
|
||||||
outlinePass = new OutlinePass(outlineMaterial)
|
} ;
|
||||||
{
|
|
||||||
renderPassEvent = RenderPassEvent.AfterRenderingOpaques // ✅ Executes after opaque objects
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
public override void AddRenderPasses( ScriptableRenderer renderer,
|
||||||
{
|
ref RenderingData renderingData ) {
|
||||||
if (outlinePass != null)
|
if ( outlinePass is not null ) renderer.EnqueuePass( outlinePass ) ;
|
||||||
{
|
|
||||||
renderer.EnqueuePass(outlinePass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue