Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to fade out a opaque object

My goal is simple. I have a material with opaque surface, and I want to fade it away. It looks very simple at first glance, I can just change opaque to translucent and using opacity to do that. But I want to keep the opaque setting because the object is human and I am using subsurface profile shading model. So(from my guess) if I change to translucent the shading is no longer subsurface anymore(profile cannot be set and opacity no longer stand for the meaning in SS profile shading). I want the correct shading result of skin. So in my mind there are possible two ways to do that but after a long time searching online and doc, neither of them is easily doable.

1.Same material and using scene color and manipulate the final output of material. Two problems here: scene color(scene texture) cannot be used in opaque surface, and UE4 don't provide final fragment(pixel) shader output access(manipulate final color of pixel)

2.Multi-pass and I use output of previous pass as a input of second pass. So I render skin with opaque surface first and next pass use that and scene color in a translucent surface and blend in emissive color channel using unlit shading model. Two problems here: first similar to last solution which is not access to final pixel output, and second is UE4 don't support multi-pass.

There is other similar and "looks work" method online. One can be use post effect and mark human to write custom depth map. Then this can be regard as a solution for getting final pixel value. But in this case I don't know how to transfer the scene color before rendering human to this post effect shader to do the final blend.

Any thoughts is very helpful.

P.S. Other common ways are just not helpful at all such as layered material(material function) which don't support different shading model and is just a parameter blend. Otherwise it can be regarded as a multi-pass.

Product Version: UE 4.10
more ▼

asked Apr 14 '16 at 06:44 PM in Rendering

avatar image

5 1 3 3

avatar image MichaelZhang Apr 14 '16 at 06:50 PM

Two keys: 1. I need to get(use in shader) or store(use in post-effect) scenecolor when render this human. 2. I need a way to simply blend it with color with material output. So blend as base color input doesn't work.

avatar image MichaelZhang Apr 14 '16 at 06:58 PM

The last way I think is writing custom HLSL shader

avatar image MichaelZhang Apr 14 '16 at 07:34 PM

More finding: custom G-Buffer is doable. But quite complicated and need change engine core code.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

This may not be exactly what you want, but I managed to create a fade effect using masked opacity. Here are three different material instances. I apologize for the poor gif quality.

alt text

I achieve this using Noise and Pixel Depth. Basically, each pixel is mapped to a noisy value X in [0,1]. Then I calculate the distance metric D = ( (PixelDepth - FadeStart) / FadeLength ) clamped to [0,1]. I set the opacity to 1 if X > D^FadePower and otherwise 0.

Here are imgur links showing the materials/functions used. First note the comments in this image of the Noise Settings. Performing a multiply on the position comes at a loss of resolution (bug!). To minimize such loss I use 4 separate noise nodes in the MF_Fade material function, which is a bit messy.

Using MF_Fade allows you to create material instances and tweak the noise scale on the fly (at a slight loss of resolution). Using MF_FadeSimple with a material instance would come at a higher loss of resolution. For lossless you can detach the position input in MF_FadeSimple and then tweak the noise settings on the node itself.

I am currently generating a bunch of tileable noise textures that I think will achieve better results. The resultant material will be simpler too. I'll provide an update when I'm done.

more ▼

answered Apr 16 '16 at 04:16 AM

avatar image

Turing Machine
143 4 11 17

avatar image love1993 Apr 16 '16 at 03:35 PM

Thank you. After a long time searching and reading documentation, I finally using a working round exactly the same like you post. Using a noise texture of other similar texture and masked blend model to simulate this effect. Thank you. And the other way which can truly simulate opaque fade out is customized G-BUFFER or customize material channel. Someone has done that but it involved a lot of work and need to change Engine source code. Anyway that you again.

avatar image Atomka Apr 12 '17 at 03:06 PM

Hi, i tried to do the same thing but i cant find your multiple xxxx (scalar) red node ? Same for the MF_Fade. Sorry im very new to UE4 but you've done the exact effect i want to put in my game. Thanks !

avatar image Yan-Jun Li Aug 06 '17 at 04:13 AM

Hi Atomka, Not sure if you find the way.

Step 1

alt text

Step 2

alt text

step1.png (19.5 kB)
step2.png (64.1 kB)
avatar image GoochWookie Dec 19 '18 at 02:15 PM

Is there any way of me applying this fade out technique when the player character enters a room? For example the player enters the room and a wall fades out, when leaving the room the wall fades back in.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question