Translucent material appears as gray checkboard

We are making a game where entering stealth mode will make you become translucent. However, when I tried to swap the player’s material to any translucent material (even default ones such as M_Glass and M_Ice_Interactive), they always appear as grayish checkerboard opaque texture in play mode.

This problem was fixed when I assign the translucent texture to something inside the level and allow shader to recompile without even entering play mode. I changed the texture back to original and did not leave any other translucent object in the level, but the stealth function still works. My guess is that UE4 only compiles the necessary shaders for materials that are in the scene for optimization purpose, thus translucent materials will not show up correctly if there is no translucent shader compiled.

I am wondering if there is a better way to solve this rather than inserting a small translucent object below the floor, while the “hacky” way works, if anyone else can offer a more elegant solution, it will be greatly appreciated.

Hey Mintslime -

Can be more specific as how you are changing your Material at runtime? Are you setting up a blend material and using a Material Parameter to switch between the two, or are you using a Dynamic Material Instance in the Character’s Blueprint setup?

Let me know -

Ketchum

Hi ,

I am still very new to Unreal so I guess I might be doing this totally wrong, the way we did material swapping is like this:

Whenever the character enters the “stealth volume” he will trigger a event(this part is C++ code), and in the blueprint event graph of the character we have a “set material” function following the event setting material to M_Glass. The scene is the 3rd person shooter template with a few custom meshes.

I know it may not be the best way to work with materials but since it never went wrong with opaque material I just decided to go with it.

Hey Mintslime -

So in the Construction Script of your Character set a Dynamic Material Instance and assign your base Material (non Stealth) and create another Dynamic Material Instance and assign your Stealth Material. Also Set a Material Variable from each Dynamic Material Instance. In your event graph, when you set material use that variables to change the look of your Character’s Mesh.

Try this and let me know if you are still having problems.

Thank You

Ketchum

Hi ,

Interestingly, even after I closed the engine and recompiled it today, the glass material still shows up as translucent. Is it because the shaders compiled are saved to the umap file? If so, I guess now this bug is “fixed” and everything will appear normal in our game?

Also thank you very much for your method, sorry I can’t tell if it works or not.

Hey Mintslime -

You cannot change the Blend Method of a Material at runtime, so a Translucent material will always be a Translucent Material. You can switch the materials used on a particular mesh from one to another, each with its own unique Blend Method.

Ketchum