Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Rendertexture ARGB via code and RGBA via inspector

Discussion in 'General Graphics' started by Magasenakwa, Jan 16, 2023.

  1. Magasenakwa

    Magasenakwa

    Joined:
    Oct 13, 2018
    Posts:
    86
    I was creating my rendertextures using
    Code (csharp):
    1. renderTexture = new RenderTexture(renderTextureSize.x, renderTextureSize.y, 24, RenderTextureFormat.ARGB32);
    but got to a point where I needed to create the rendertexture in the inspector and assign it to multiple prefabs instead.

    When I do this my rendertexture always show only my camera background color, nothing else. If I change the format to something weird I get only a black texture so my choices are black texture or camera fill color. No idea why but obviously I need to specify a valid texture format and while ARGB32 works perfectly in code, that format doesn't exist in the dropdown in the inspector, only R32G32B32A32.

    To my mind ARGB and RGBA can't be used interchangeably so what do I do? How do I define a rendertexture in the inspector and set it to ARGB32 ?
     
  2. Magasenakwa

    Magasenakwa

    Joined:
    Oct 13, 2018
    Posts:
    86
    Turns out the format had nothing to do with it. I changed the RT to have a POT size and then rendering worked perfectly. Doh!