-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed CustomPass to render a nyan cat overlay
- Loading branch information
Showing
11 changed files
with
185 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Shader "Hidden/SIGGRAPH Studio/CustomBlit" | ||
{ | ||
Properties | ||
{ | ||
_BlitTex("BlitTexture", 2D) = "white" {} | ||
} | ||
SubShader | ||
{ | ||
Tags { "RenderPipeline" = "LightweightPipeline" } | ||
|
||
Pass | ||
{ | ||
Blend SrcAlpha OneMinusSrcAlpha | ||
HLSLPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "LWRP/ShaderLibrary/Core.hlsl" | ||
|
||
TEXTURE2D(_BlitTex); | ||
SAMPLER(sampler_BlitTex); | ||
|
||
struct VertexOutput | ||
{ | ||
float4 positionCS : SV_POSITION; | ||
float3 uv0 : TEXCOORD0; | ||
}; | ||
|
||
VertexOutput vert (float4 positionOS : POSITION, float uv0 : TEXCOORD0) | ||
{ | ||
VertexOutput OUT; | ||
OUT.positionCS = TransformObjectToHClip(positionOS.xyz); | ||
OUT.uv0 = uv0; | ||
return OUT; | ||
} | ||
|
||
half4 frag (VertexOutput IN) : SV_Target | ||
{ | ||
half3 color = SAMPLE_TEXTURE2D(_BlitTex, sampler_BlitTex, IN.uv0).rgb; | ||
return half4(color, 0.5); | ||
} | ||
ENDHLSL | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,53 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.Experimental.Rendering; | ||
using UnityEngine.Experimental.Rendering.LightweightPipeline; | ||
using UnityEngine.Rendering; | ||
|
||
public class CustomPassGetter : MonoBehaviour, IAfterOpaquePass | ||
using UnityEngine.Rendering; | ||
|
||
namespace UnityEngine.Experimental.Rendering.LightweightPipeline | ||
{ | ||
private CustomPass pass = new CustomPass(); | ||
|
||
public ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorAttachmentHandle, | ||
RenderTargetHandle depthAttachmentHandle) | ||
public class CustomPassGetter : MonoBehaviour, IAfterOpaquePass | ||
{ | ||
pass.Setup(colorAttachmentHandle, depthAttachmentHandle); | ||
return pass; | ||
public Texture2D m_OverlayTexture; | ||
private CustomPass pass = new CustomPass(); | ||
|
||
public ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, | ||
RenderTargetHandle colorAttachmentHandle, | ||
RenderTargetHandle depthAttachmentHandle) | ||
{ | ||
pass.Setup(colorAttachmentHandle, m_OverlayTexture); | ||
return pass; | ||
} | ||
} | ||
} | ||
|
||
|
||
public class CustomPass : ScriptableRenderPass | ||
{ | ||
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, | ||
ref RenderingData renderingData) | ||
public class CustomPass : ScriptableRenderPass | ||
{ | ||
CommandBuffer cmd = CommandBufferPool.Get("Render"); | ||
cmd.SetRenderTarget(colorhandle.Identifier(), depthHandle.Identifier()); | ||
cmd.ClearRenderTarget(true, true, Color.blue); | ||
context.ExecuteCommandBuffer(cmd); | ||
CommandBufferPool.Release(cmd); | ||
} | ||
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context, | ||
ref CullResults cullResults, | ||
ref RenderingData renderingData) | ||
{ | ||
if (m_Material == null) | ||
m_Material = CoreUtils.CreateEngineMaterial(Shader.Find("Hidden/SIGGRAPH Studio/CustomBlit")); | ||
m_Material.SetTexture("_BlitTex", m_OverlayTexture); | ||
|
||
public void Setup(RenderTargetHandle colorAttachmentHandle, RenderTargetHandle depthAttachmentHandle) | ||
{ | ||
this.colorhandle = colorAttachmentHandle; | ||
this.depthHandle = depthAttachmentHandle; | ||
} | ||
if (m_OverlayTexture != null) | ||
{ | ||
MaterialPropertyBlock props = new MaterialPropertyBlock(); | ||
props.SetTexture("_BlitTex", m_OverlayTexture); | ||
} | ||
|
||
CommandBuffer cmd = CommandBufferPool.Get("Render Overlay"); | ||
cmd.Blit(m_OverlayTexture, colorAttachment.Identifier(), m_Material); | ||
context.ExecuteCommandBuffer(cmd); | ||
CommandBufferPool.Release(cmd); | ||
} | ||
|
||
RenderTargetHandle colorhandle { get; set; } | ||
public void Setup(RenderTargetHandle colorAttachmentHandle, Texture2D overlayTexture) | ||
{ | ||
colorAttachment = colorAttachmentHandle; | ||
m_OverlayTexture = overlayTexture; | ||
} | ||
|
||
RenderTargetHandle depthHandle { get; set; } | ||
private Material m_Material = null; | ||
private RenderTargetHandle colorAttachment; | ||
private Texture2D m_OverlayTexture; | ||
|
||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
Assets/_Completed/TraditionalDeferredRenderer/TraditionalDeferredRenderer.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
Assets/_Completed/TraditionalDeferredRenderer/TraditionalDeferredRenderer.cs.meta
This file was deleted.
Oops, something went wrong.