123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using UnityEngine;
- using UnityEngine.Rendering.Universal;
- namespace SicknessReduction.Visual.Rendering
- {
- public class MaterialBlitFeature : ScriptableRendererFeature
- {
- [System.Serializable]
- public class MyFeatureSettings
- {
- // we're free to put whatever we want here, public fields will be exposed in the inspector
- public bool IsEnabled = true;
- public RenderPassEvent WhenToInsert = RenderPassEvent.AfterRendering;
- public Material MaterialToBlit;
- }
- // MUST be named "settings" (lowercase) to be shown in the Render Features inspector
- public MyFeatureSettings settings = new MyFeatureSettings();
- RenderTargetHandle renderTextureHandle;
- MaterialBlitRenderPass myRenderPass;
- public override void Create()
- {
- myRenderPass = new MaterialBlitRenderPass(
- "Material Blit Render Pass",
- settings.WhenToInsert,
- settings.MaterialToBlit
- );
- }
-
- // called every frame once per camera
- public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
- {
- if (!settings.IsEnabled)
- {
- // we can do nothing this frame if we want
- return;
- }
-
- // Gather up and pass any extra information our pass will need.
- // In this case we're getting the camera's color buffer target
- var cameraColorTargetIdent = renderer.cameraColorTarget;
- myRenderPass.Setup(cameraColorTargetIdent);
- // Ask the renderer to add our pass.
- // Could queue up multiple passes and/or pick passes to use
- renderer.EnqueuePass(myRenderPass);
- }
- }
- }
|