I am attempting to use OnRenderImage to overlay a texture over my camera.
I am able to overlay the image but I really need to be able to also offset the center of the image (move it left/right) by a specific amount without stretching.
This image shows what I have currently, and the image is stretched to fill the entire canvas (thus dimensions of image must match camera exactly otherwise it will look deformed).
The code example I am using is very simple. But I need to be able to slide that image around based on an offset?
public class PreRenderScript : MonoBehaviour {
[SerializeField]
public Sprite spriteOverlay = null;
[SerializeField]
Material mat;
void OnRenderImage (RenderTexture source, RenderTexture destination)
{
Graphics.Blit (source, destination);
Graphics.Blit (spriteOverlay.texture, destination, mat); //How can I offset the position of the spriteOverlay?
}
}
Could someone please help me figure out how to do this? Thanks!
Original Overlay Image: