Wall Hiding System
v1.0
Note: If you are encountering visual artifacts on the screen during the game, you need to set "Custom Depth-Stencil Pass" to "Enabled with Stencil" In Project Settings.
See the 'Additional Information' section for additional information.
Note: If it's too dark inside the Buildings (engine versions 5.0+), read the fix at the end of the documentation.
If you're having problems with integrating asset into your project:
Create an empty project, add a Wall Hiding System into it, then set the game mode to GM_Demo in Project Settings.
After that, everything should work the same way it does in the demo.
Turn the Hide effect on or off during gameplay
To add a hiding effect you need to:
Open the material that you want to hide (the material that is applied to the mesh) and Switch Blend Mode to Masked
Right сlick on the materials column, add the "Material Function Call" node
Highlight the node and select one of the hiding functions shown below:
Add a Collection Parameter node in a similar manner
Highlight the Collection Parameter node and select MPC_Walls
Then select one of the Collection Parameters
Connect the Collection Parameter node to the MF_Hide function, and the MF_Hide node to the Material Opacity Mask channel
Next, you need to create logic that will change the coordinates of the variable in the material collection. It is better to do this in the Event Tick player controller.
Create a "Set Vector Parameter Value" node, select MPC_Walls in the Collection Parameter node, then select one of the parameters of this collection.
The example below shows one of possible ways to get the coordinates of a character controlled by the player.
Parameters Collection stores variables that a material can use. You can add your own parameters there if needed (to make multiple hiding places, for example.)
The example below uses two variables in the Parameter Collection to hide the walls around both the character and the cursor. You can, for example, hide walls around multiple players in a similar fashion.
The Materials folder contains examples of how the hiding functions can be used, examples of how to use them together with vegetation masks and examples of how to combine several masks together.
You can, for example, combine several hiding functions in a way shown below:
Note: Combining multiple functions in such a way can create performance-intensive materials. It is advised to check Shader Complexity from time to time by pressing F5 when the game is running.
Asset includes 7 Material Functions that are designed for hiding objects, they are located at this path:
Content\Wall_Hiding_System\Materials\Material_Functions
This function is designed for hiding walls and works best with long meshes (Large size along one of the axes, or scaled along one of the axes). For large, square meshes, it is better to use a function that has a hiding capsule, it's called MF_Hide_Capsule.
It only hides the walls that overlap a character.
Very similar to MF_Hide, but has a Dithering effect.
Ghosting effect can be removed by switching antialiasing type to FXAA in the settings of your project.
A simplified version of MF_Hide that is less performance-intensive. It is well suited for hiding roofs and other objects that are above the character. Anything within the capsule of a specified radius, that is located between the camera and the player, will be hidden.
Very similar to MF_Hide_Capsule, but has a Dithering effect.
Ghosting effect can be removed by switching antialiasing type to FXAA in project settings.
This is a variant of the MF_Hide_Capsule function.
It has a vertical mask that leaves the bottom part of a mesh visible. This is meant to be used in situations where you need to hide objects like poles, antennas and trees, which can overlap the player's character at a great distance, but at the same time you also need the base of the object, e.g. a tree stump, to remain visible.
It can also be used in place of MF_Hide as a cheaper option in terms of performance.
This is an inverted hiding material. Meshes start to appear when the player approaches them.
This function completely hides an object that is located between the player and camera at any distance. Quite handy for hiding vegetation.
In the demo level, some meshes like trees or walls with windows have 2 material channels, one channel uses a normal material, and the other channel uses a hiding material.
This can be useful for hiding only the foliage of trees while leaving branches or stumps visible, for example. Or it can be used to have visible doorways while the walls themselves are hidden, so that if a player is behind a hidden wall that has a doorway, he will always be able to find the entrance to a building.
This is a list of parameters that are found in some or all of the Material Functions.
Location (V3)
World Location of the space where the object will be hidden
Radius (S)
The size of the area that will be hidden
Radius Falloff (S)
Feathering of the hiding area. If set to 0, the hidden area will have a sharp border.
Capsule Radius (S)
Width of the capsule that is aimed from the camera to the hiding point. Everything inside the capsule will be hidden.
Capsule Radius Falloff (S)
Feathering of the hiding capsule borders. If set to 0, the hidden area will have a sharp border.
Height (S)
The height of the mask at which the bottom of the mesh remains visible.
Height Falloff (S)
Feathering of the vertical mask. If set to 0, the hidden area will have a sharp border.
Enable Noise Texture (B)
Enables a noise texture around the edges of the hidden area.
Noise Texture (T2d)
Selects the noise texture that will be used around the edges of the hidden area.
3 texture variants can be found in the Noises folder.
Noise Texture Size (V3)
Tiling of the noise texture.
You can compress or stretch it along one of the axes with this parameter.
Opacity (S)
Opacity value of the material.
Start Offset (S)
Positive values offset the capsule closer to the camera, negative values move the capsule further away.
In the demo, the Camera channel is used to get the coordinates under the cursor so that the character starts moving to that space.
For this reason, all wall, roof and tree meshes and other objects that can prevent mouse clicking on them have the Camera channel disabled in their collision settings. This is done to make it for the player to move their character.
To enable character outline, follow these steps:
https://drive.google.com/file/d/1EHbBtsBOn59lWhxvVR_v-F4PR-t9EVwS/view?usp=drive_link
If the inside of buildings is too dark, you will need to disable Global Illumination in the project settings.
The video was recorded on the engine version 4.27, in version 5 the lighting model changed.
You can also switch the lighting model to the old one.
To make it even lighter, you can change the intensity of Sky.
Also look at the post process parameters, there you can additionally make the falling shadows not so dark or reduce the AO.