Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

[solved] STM unexpectedly rendering behind objects (world space UI + deferred rendering)

A topic by mrtenda created May 16, 2019 Views: 546 Replies: 5
Viewing posts 1 to 6
(2 edits)

Hey! So, I'm using a UI STM on a world space canvas in my scene, and the world space canvas is positioned in front of some objects.

When the camera's "Rendering Path" is set to "Forward", the text correctly renders in front of the objects. However, when it's set to "Deferred", the text is rendered behind the objects, even though the canvas in front of the objects. Other UI elements on the same canvas (such as Images) are correctly displayed in front of the objects, but STM isn't, so I'm wondering if this is an STM specific issue (or some STM setting I need to change?).

I also noticed that this only happens with the Default UI shader. The Outline and Dropshadow UI shaders seem to render in front of and behind objects correctly when deferred rendering is enabled.

As an example, here's a sample scene I set up when the camera is set to forward rendering:

Same scene, but the camera is set to deferred rendering:

Here's a Unity package containing the scene if it helps (tested with Unity 2019.1.2f1 and STM 1.8.16 (from the asset store)):

https://www.dropbox.com/s/cqilauh08n8svgz/STM_Deferred_Test_Scene.unitypackage?d... 

Developer

Hmm... I must have messed up something in the other shader files. Since it's something happening for one shader and not another, hopefully it'll be an easy fix? I'm about to head to bed and will check this out tomorrow, but in SuperTextMesh/Shader, please right click and select "Reimport" on every .gcinc file and effected shader and let me know if anything changes rendering-wise after. Thank you!

(1 edit)

Thanks for the super fast reply! I reimported all the UI shaders and gcinc files, but nothing seem to change... guess it must be something else?

Developer (1 edit)

Alright, it looks like I forgot to apply the new stencil buffer code to the default UI shader... Try opening up STM UI.shader and replacing the Stencil section with this:

Stencil
        {             Ref [_MaskMode] //Customize this value 
            Comp [_MaskComp] //Customize the compare function 
            Pass [_StencilOp]
            ReadMask [_ReadMask]
            WriteMask [_WriteMask]
        }

Lemme know if that works! You might have to right click the shader and reimport it after doing this.

That worked! There were two Stencil sections in STM UI.shader and the first one seemed identical to what you posted, so I replaced the second one with that, and now it renders as I would expect. Thanks a bunch, Kai!

Developer

Oh shoot, well that explains it! I'll make sure that's fixed in the next patch.