- Home /
Question by
manny003 · May 09, 2017 at 04:22 PM ·
graphicsperformance optimization
Converting Script RenderTexture and Blit code to Graphics.CommandBuffer: Need Help
I have the following script that works perfectly to render everything a camera sees onto a smaller RenderTexture and then Blit it to the screen -- for mobile performance:
#pragma strict
import UnityEngine;
import UnityEngine.Rendering;
var myCamera : Camera;
@Range (0, 3)
public var downsample : int;
private var myRenderTexture : RenderTexture;
private var width : float;
private var height : float;
function Start () {
width = Screen.width / (downsample + 1);
height = Screen.height / (downsample + 1);
}
function OnPreRender() {
myRenderTexture = RenderTexture.GetTemporary(width, height, 16);
myCamera.targetTexture = myRenderTexture;
}
function OnPostRender() {
myCamera.targetTexture = null; // null means framebuffer
Graphics.Blit(myRenderTexture, null as RenderTexture);
RenderTexture.ReleaseTemporary(myRenderTexture);
}
It works perfectly as I intended. Now I'm trying to accomplish the same thing using the Graphics CommandBuffer but can't get anything to work.
Can someone help translate the code to CommandBuffers?
Thanks in advance. Manny
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612121640im_/https://answers.unity.com/themes/thub/images/avi.jpg)