Search Unity

Bug Canvas Render Texture issues with Transparent Alpha Cutoff Shaders of 3D Mesh

Discussion in 'UGUI & TextMesh Pro' started by bamncan, Oct 17, 2022.

  1. bamncan

    bamncan

    Joined:
    Dec 15, 2013
    Posts:
    47
    I'm using Unity 2021.3.3 at the moment, and I have a RenderTexture setup to display my characters easily in the UI. TLDR is that for some reason when my characters' are using a shader with transparency, the character renders ghost-like when put through the RenderTexture.

    For clarification in case I just have an incorrect setting somewhere. Here's what I'm doing:

    3D World Space has my 3D Modeled Character with a transparent labeled shader that has alpha cutoff for my hair textures. Specifically, I'm using the LUX URP shader, but I've verified this happens as well with the default Unity transparency shader. The shader has an alpha cutoff for an Albedo texture.

    I have a camera in world space facing the character mesh with the properties as such:
    Render Type: Camera
    Rendering:
    Culling Mask: Character Layer​
    Environment:
    Background Type: Solid
    Background: #000000FF (Black)
    Volume Mask: Character Layer​
    Output:
    Render Texture: Character.renderTexture​

    The Render Texture properties are as follows:
    Dimension: 2D
    Size: 960 x1080
    Anti-aliasing: None
    Enable Compatible Force: True
    Color Format: R8G8B8A8_UNORM
    Depth Stencil Format: D24_UNORM_S8_UINT
    Enable Mip Maps: False
    Dynamic Scaling: False
    Wrap Mode: Clamp
    Filter Mode: Point​

    So I created a Raw Image in my Canvas UI to render out the camera view to the screen. Here's my current Canvas settings:
    Render Mode: Screen Space - Overlay
    Additional Shader Channels:
    TexCoord1, Normal, Tangent​

    And the Raw Image's settings:
    Texture: Character.renderTexture
    Color: #FFFFFFFF (White)
    Material: None
    Raycast Target: True
    Maskable: True​

    I'm unable to figure out how to get the character mesh to render properly in the Render Texture. Any help in resolving this issue I'm faced with would be greatly appreciated. Below, in the spoiler tags, are screens of the issue.

    Character being rendered in the canvas through the render texture:
    rt001.jpg

    rt002.jpg

    Character in-game with World Space camera and no canvas:

    rtig001.jpg


     
  2. bamncan

    bamncan

    Joined:
    Dec 15, 2013
    Posts:
    47
    Update: this issue is resolved on Unity v2022.1.20. thanks to the added Depth Texture Mode in the Universal Renderer properties.