Hello Everyone~
I’m currently having a complex issue relating to Scene Capture Component 2D rendering transparent actors.
Background
I have a mini map in my game that draws a vector outline of the surrounding area, and then highlights enemies as well as their vision cone. You can see an example here:
The mini map is created via combining three textures from three Scene Capture Component 2Ds.
The first one (Outline Scan) scans the level geometry and outlines it with a post processing shader, and ignores objects that have a certain stencil value.
The enabled Show Flags are:
- Static Meshes.
- Post-Processing.
The second only (Stencil Scan) renders Static Meshes and Translucent meshes, and then masks it through a post processing material that hides fragments if they are on a stencil value higher than 0. The material can be seen here:
The enabled Show Flags are:
- Static Meshes.
- Translucency.
- Post-Processing.
The third and final (Vision Cone Scan) is redundant, but it is designed to get translucent objects with a stencil value to render onto the mini map. This is primarily for vision cones.
The enabled Show Flags are:
- Translucency.
- Post-Processing.
Every Scene Component has the capture source as Final Color (LDR) in RGB.
All together, (and some shader magic to give it scan lines, breathing effect, etc) it creates a nice mini map.
The Problem
The problem occurs when capturing Translucent actors in the scene, and therefore we only need to worry about the 2nd and 3rd scene capture 2ds.
I realised that since that vision cone you see in the example is a procedural mesh, it technically isn’t a static mesh. Therefore if you untick “Static Mesh” on the show flags, it will still show, and since I have translucency ticked, it will show it because it is a translucent mesh.
The problem is, I want to show objects that are translucent that are static meshes that have stencil values, but it’s a huge pain.
I am aware that stencils aren’t readily enabled for translucent objects, therefore for the transparent shader I am using, I enabled “Allow Custom Depth Writes” to ensure it has a stencil unless the opacity is at 0.
It works, but then it blends to what’s behind the translucent object. See the image below:
As you can see, the blue colour fades to white because it is capturing what is underneath the transparent object, even though that background object doesn’t have a stencil (I understand Scene components don’t get the stencil data of the object itself so it is to be expected). I could fix this by unticking “Static Mesh” in the scene capture Component, but then the transparent object goes away since it is also a static mesh.
The behaviour I ultimately want is what I have for the vision cone, where it captures only it’s opacity and colour essentially:
In essence, I want to achieve the effect you get when you enable the opacity buffer in the viewport.
Right now, if I want the behaviour I want, I need to have all translucent objects I want to show to be procedural meshes, which is not a good idea.
Sorry for the long explanation and question, it’s been driving me up a wall for ages . Does anyone have any advice, or should I be looking at a different angle? Any help would be greatly appreciated
Please let me know if I should explain the issue more clearly.
EDIT: Clearer first image.