Posts

World scan effect material

Image
Step 0. Let's make a world(level) scan effect material. Step 1.  We can make it with 'Post Process material' with 'Absolute World Position' material node.  Use almost the same features as previous posts. Step 2.  Change material parameter. Step 3.  If you use other material domain instead of 'Post Process', you can get different effects.

health indicator with character body material(CS:GO style HP)

Image
Step 0. Let's make CS:GO health indicator. Step 1.  It's very easy to make the system in Unreal Engine 4. 'Absolute World Position' node is the key feature.  Make a material function. Copy MaterialAttributes Input/Break/Make/Output nodes from other material if possible.  In this time, modify the EmissiveColor only.  Do NOT calculate health ratio in the material. Just calculate it once in the character blueprint. Step 2.  Duplicate 'M_UE4Man_Body' Material. and insert the material function we made just before. Step 3.  Make a character blueprint.  Assign new material to the mesh and set scalar parameters.

Night Vision(Toggle in real time)

Image
Step 0. Let's make night vision system just like a kind of 'witcher sense'. Step 1.  It's very easy to make the system in Unreal Engine 4.  Make a material from 'Material Parameter Collection'. Step 2.  Use the material collection parameter. These are example screen shots. Assign the materials to the meshes in the level. Step 3.  Change scalar parameter values when user press or release 'V' key.  You can make a smooth change with a timeline component.

Enhanced Outline Material

Image
Step 0. You can see how to make a outline material and an unsolved problem on the previous post(Can't see outline behind a outlined object). More detail :  Draw outline Step 1.  - Find file from Unreal Engine 4 source code(UE4 version 4.14) : Engine\Source\Runtime\Renderer\Private\CustomDepthRendering.cpp  - Remark SetDepthStencilState Operation and add new stencil buffer operation code. This code is a little bad to avoid 'expression must have a constant value' error. But you can make it better... /// Original. //RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), CustomDepthStencilValue); /// GameEngineBread : Outline switch ( CustomDepthStencilValue ) { case 1 : RHICmdList.SetDepthStencilState( TStaticDepthStencilState< true , CF_Always, true , CF_Always, SO_Keep, SO_Replace, SO_Replace, false , CF_Always, SO_Keep, SO...

Draw outline

Image
Step 0. We will use a stencil buffer to draw outlines. Step 1. First of all, enable stencil buffers.  Menu -> Edit -> Project Settings -> Custom Depth-Stencil Pass -> set 'Enabled with Stencil' For each actor that you want to draw with outline,  Select Actor in viewport -> See Details Windows-> Check 'Render Custom Depth Pass'  Select Actor in viewport -> See  Details Window-> Change 'CustomDepth Stencil Pass' to 'Enabled with Stencil'. There are many ways to draw outline, but this is the best material to start : https://answers.unrealengine.com/questions/316814/how-to-hide-outline-post-process-effect-behind-obj.html This is a little enhanced version. Draw each line with a different color.  Step 3. Near outline object removes other outlines. Maybe it is not what you want. We can fix this with Unreal Engine code modification. It's too long to describe now, so I will show you it next post. ...

Change Material Parameters in Runtime

Image
Step 0. You can change materials of post process volume but it's very hard without native code. Using 'Post Process Component' is more simple and working without c++. Step 1. Add a 'Post Process Component' to my PlayerController. Step 2.  - Add a member variable. Type is 'Material Instance Dynamic'.  - On BeginPlay, Create a new instance and make the post process component of this controller use it.  - Add Some key events for testing.

Screen Wave Effect Material

Image
Step 0. Let's make a screen wave post process material. It's good for dizzy or drunken effects. Step 1. This is the final unreal engine material. In this time, I made horizontal wave nodes only. Step 2. To avoid boundary error(stretching), need more operations. You can see the modified material in the image below. It is not perfect, but it tells you how it works.