Skip to content

Instantly share code, notes, and snippets.

@mminer
Created February 18, 2021 21:39
Show Gist options
  • Save mminer/816ff2b8a9599a9dd342e553d189e03f to your computer and use it in GitHub Desktop.
Save mminer/816ff2b8a9599a9dd342e553d189e03f to your computer and use it in GitHub Desktop.
Unity function to vertically flip a render texture.
/// <summary>
/// Vertically flips a render texture in-place.
/// </summary>
/// <param name="target">Render texture to flip.</param>
public static void VerticallyFlipRenderTexture(RenderTexture target)
{
var temp = RenderTexture.GetTemporary(target.descriptor);
Graphics.Blit(target, temp, new Vector2(1, -1), new Vector2(0, 1));
Graphics.Blit(temp, target);
RenderTexture.ReleaseTemporary(temp);
}
@LewisSean
Copy link

thanks, it really helps me!

@LucasVanHooste
Copy link

Helped me too! Tried doing this but forgot the offset of 1 at the end.

@13Flo
Copy link

13Flo commented Jun 26, 2022

Incredibly helpful, thank you.

@RoxDevvv
Copy link

very hepful thank you

@mihaniania25
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment