1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using UnityEngine;
- using UnityEngine.Rendering.Universal;
- namespace SicknessReduction.Visual.Rendering
- {
- public class MaterialBlitFeature : ScriptableRendererFeature
- {
- // MUST be named "settings" (lowercase) to be shown in the Render Features inspector
- public MyFeatureSettings settings = new MyFeatureSettings();
- private MaterialBlitRenderPass myRenderPass;
- private RenderTargetHandle renderTextureHandle;
- 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);
- }
- [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;
- }
- }
- }
|