Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
1.7 kB
2
Indexable
Never
```csharp public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { CommandBuffer cmd = CommandBufferPool.Get(); using (new ProfilingScope(cmd, new ProfilingSampler("Pixelize Pass"))) { // Clear temporary render target for safety cmd.ClearRenderTarget(true, true, Color.clear); context.ExecuteCommandBuffer(cmd); cmd.Clear(); // Set up temporary render target for 'Arms' layer objects RenderTargetIdentifier tempRenderTarget = pixelBuffer; // Use the already created pixelBuffer cmd.SetRenderTarget(tempRenderTarget); // Render 'Arms' layer into the temporary render target var drawingSettings = CreateDrawingSettings(settings.layerMask, ref renderingData); var filteringSettings = new FilteringSettings(RenderQueueRange.all, settings.layerMask); context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings); // Apply the pixelize effect to the temporary render target Blit(cmd, tempRenderTarget, colorBuffer, material); } context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); } // Helper method to create drawing settings private static DrawingSettings CreateDrawingSettings(LayerMask layerMask, ref RenderingData renderingData) { var sortingSettings = new SortingSettings(renderingData.cameraData.camera) { criteria = SortingCriteria.CommonTransparent }; var drawingSettings = new DrawingSettings(new ShaderTagId("UniversalForward"), sortingSettings) { overrideMaterial = null, overrideMaterialPassIndex = 0, perObjectData = PerObjectData.None }; drawingSettings.SetShaderPassName(1, new ShaderTagId("SRPDefaultUnlit")); // Adjust as needed return drawingSettings; } ```
Leave a Comment