Download

Shadow Tactics View Cone Recreation in UE possible?

“The basic principle behind the View-cone calculations is shadow mapping. We first render a depth texture from the eye position of a selected character. When rendering the main camera we generate a mask that holds information for the various vision areas based in the previously generated depth texture (e.g. “full vision”, “fully occluded”, “crouch distance”, “out of bound”). Using this mask we can colour the View-cone in a final full screen pass, where stencil buffer is used to exclude various objects from being rendered to and to add light-source information.”

Shadow Tactics 1.jpg

The para above is what i aim to do its basically a talk from a developer of Shadow tactics about enemy’s vision cone. I have already tried to achieve vision cone via procedural mesh and EQS but they have flaws most important of which is no support for height vision.

I think the method above will work fine but i don’t know anything about shaders or materials. It would be helpful if you can point me to the right direction. And if you think achieving this type of material is easy i would love it of anyone of you can recreate it in UE.

There isn’t much for me to go to because i think naming convention is also different, if I write on google about Depth Textures it just gives me post process materials and some other stuff, I am really hoping for a good explanation on this because i will need to explain that to my teachers as well but first things first Can anyone make this in UE4?

I actually made my own View Cone using procedural mesh and Decals but it starts to bleed into geometry nearby which I think is due to a bug with Mesh Decals and its something that hasn’t been fixed since 2016 so here i am trying this shader method of which i know nothing about.

Yeah, it is actually pretty easy. Search for shadow mapping, and it will get you there.

Linky

VizConez.gif

Have been doing some tweaking with Render Targets, TBH when i search Shadow mapping nothing special comes up related to UE4, there are cascade tutorials but those are not what I want i suppose.
Can you share your material? or Project files? OR make a tutorial if you have time? I have been at it for hours and very little to no chance of doing it, This feature is bottle-necking my entire project.

UPDATE: Here is What I Ended up with, Not useful at my case but still worth a try.

Either way, the suggestion does nothing for culling.
In fact, as I understand it, it only works on the final render/objects.

My suggestion would be to add a view cone mesh to the character that defines the area.

You then get the list of overlapped actors (which you need to properly set collision to define).

With foreach loop - limit this to only when the object list is changed by implementing some sort of buffer array - you then loop the list and do the maths.

The maths can be hard, to decide what to occlude, but in keeping with tradition, use the the bounds of each actor to determine their visibility.

For each object run a line trace from your eye sight point to the objects position plus z bound (the top of the object).
IF the hit object is indeed the object you took the bounds from, the object is visible.
if the hit object is not the same, then it should probably be occluded.

Now.
ideally for all of that to happen every object needs to be in game and visible if you trace visibility channel.

Therefore, in order for the camera to only view the meshes you calculate you’ll need to set each object up with the most ideal view flags for the situation.

asauming the camera changes each actor this may indeed get more complex than the calculations… may very well require C++ to create specific view flags.

Anyway, thats one way I would see to implement the occlusion.
Ofc, you could also try and lift the fustrum culling code the engine uses and apply it directly to the view cone you generate from the character’s view point… it may in fact be more efficient than anything you concoct in BP…

Ps: hiding items with stencil buffer leaves very noticeable artifacts. Even if you never render the item in main pass.

The link I’ve provided gives good base as to what you’d need to do. From there, you will have to extrapolate on your own.

How’s this?

https://forums.unrealengine.com/development-discussion/rendering/81728-camera-projection-cameravectorws
https://forums.unrealengine.com/development-discussion/rendering/103582-projection-mapping-technique-to-projects-video-files-on-objects

Wow, Thanks Guys this definitely seems a lot of work, I am gonna put a hold on Vision Cone for now and continue on the rest of project.