Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Changing camera screen texture graphics format ?

Discussion in 'Universal Render Pipeline' started by mangax, Oct 4, 2022.

  1. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334
    hi,

    how to change URP camera screen rendering graphics format?
    currently it is by default set as B10G11R11 the only way i find it posted everywhere is by using target render texture then changing it from texture format settings..

    but i do not want to resort to use it... as it requires more management in terms of texture size with different screen sizes.. plus the need of using another camera and so on..

    any help will be appreciated.

    regards,
     
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, you can try the latest 2022.2b URP version (or higher) if you don't want to modify the URP package.

    32 Bits: B10G11R11
    64 Bits: fp16 (R16G16B16A16)
    URP_HDR_Precision.png
     

    Attached Files:

  3. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334
    Thanks for your help..

    What i really want is 32 bit per channel... which is 128 bits..
     
  4. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, I think you'll have to modify URP package.

    Open the "Project Folder\Library\PackageCache" folder, and move "com.unity.render-pipelines.universal@version" to "Project Folder\Packages" folder.​

    In "URP-package\Runtime\UniversalRenderPipelineCore.cs".

    Find the following content (line 529 if using URP 13):
    Code (CSharp):
    1. static GraphicsFormat MakeRenderTextureGraphicsFormat(bool isHdrEnabled, bool needsAlpha)
    2. {
    3.     if (isHdrEnabled)
    4.     {
    5.         if (!needsAlpha && RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.B10G11R11_UFloatPack32, FormatUsage.Linear | FormatUsage.Render))
    6.             return GraphicsFormat.B10G11R11_UFloatPack32;
    7.         if (RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R16G16B16A16_SFloat, FormatUsage.Linear | FormatUsage.Render))
    8.             return GraphicsFormat.R16G16B16A16_SFloat;
    9.         return SystemInfo.GetGraphicsFormat(DefaultFormat.HDR); // This might actually be a LDR format on old devices.
    10.     }
    11.  
    12.     return SystemInfo.GetGraphicsFormat(DefaultFormat.LDR);
    13. }
    Replace it with something like this:
    Code (CSharp):
    1. static GraphicsFormat MakeRenderTextureGraphicsFormat(bool isHdrEnabled, bool needsAlpha)
    2. {
    3.     if (isHdrEnabled)
    4.     {
    5.         // URP 13 (2022.1)
    6.         // HDR enabled, use R32G32B32A32 if supported.
    7.         if (RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R32G32B32A32_SFloat, FormatUsage.Linear | FormatUsage.Render))
    8.             return GraphicsFormat.R32G32B32A32_SFloat;
    9.         // else fall back to R16G16B16A16 if supported.
    10.         if (RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R16G16B16A16_SFloat, FormatUsage.Linear | FormatUsage.Render))
    11.             return GraphicsFormat.R16G16B16A16_SFloat;
    12.         // Fall back to default HDR (mostly B10G11R11)
    13.         return SystemInfo.GetGraphicsFormat(DefaultFormat.HDR); // This might actually be a LDR format on old devices.
    14.     }
    15.  
    16.     return SystemInfo.GetGraphicsFormat(DefaultFormat.LDR);
    17. }
     
  5. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334

    thanks for your help!
    when i modify the file.. unity immediately compiles scripts then remove any changes..
    how to retain these changes?
    i tried copying the package into the assets folder, then remove it from package manager.. but still throws errors.
     
    Last edited: Oct 6, 2022
  6. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    I think you can try moving the package to "Project Folder\Packages", instead of "Project Folder\Assets".

    Step:
    Open the "Your Project\Library\PackageCache" folder, and move "com.unity.render-pipelines.universal@version" to "Your Project\Packages" folder.​

    That's because if you move the package to Assets folder (so there's no URP-package in "Project Folder\Library\PackageCache" ), Unity will automatically add the missing URP-package in "PackageCache" folder.
     
    mangax likes this.
  7. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334
    yes it works now!
    thanks alot!
     
    wwWwwwW1 likes this.
  8. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334
    There is something i really don't understand...

    although am building for android device supporting Vulkan it seems build still renders on 16bit.
    even without graphics check, still device can't render on 32 bit.

    i thought vulkan 1.1 does support these formats.. what i am missing? is this unity limitation?
     
  9. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, maybe it's something related to shader precision (half precision by default).

    You can try enabling "force full precision" on these platforms.

    Note: This is for Built-In RP, so I don't think it will work.
    ShaderPrecision.png

    I think a better solution is to create a shader-graph-based Lit shader. (set graph precision to single)

    If you're using post-processing effects, don't forget to modify those shaders. (replace half with float)
     
    mangax likes this.
  10. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    334
    actually this option solved the issue! thanks alot!

    btw am already using custom shader-graph shaders with graph precision set as single (as well as all nodes shows single).. but still somehow it was forced to lower precision on build..i really think this is a bug..
     
    wwWwwwW1 likes this.
  11. OrbitalDuck

    OrbitalDuck

    Joined:
    Oct 26, 2013
    Posts:
    60
    URP-No 64 bit.png

    Just updated to unity 2022.17 and there is no option to set the precision in the URP 14.07? is there something else that needs to be set before this becomes available ? any help would be appreicted
     
  12. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Some SRP properties are hidden by default, you can unhide them in preferences.
    HiddenProperties.jpg
     
  13. OrbitalDuck

    OrbitalDuck

    Joined:
    Oct 26, 2013
    Posts:
    60
    Thank you for explaining. Very much appreciated:)
     
    wwWwwwW1 likes this.
  14. OrbitalDuck

    OrbitalDuck

    Joined:
    Oct 26, 2013
    Posts:
    60
  15. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    I don't think it's possible now, but it's on the roadmap.

    However, you can modify URP's post-processing shader and see if it works.