Show hidden "message-icon" when specific light color hits mesh surface

In short I want a material that will be on a wall that has a text that doesn’t appear until you hit the wall with a specific light. For example your character can hold a green,a red and a yellow flashlight and only when you aim at the wall with the red one the text will appear otherwise nothing shows up. Is that possible to achieve and if so how easy is it to make that material?

I’d make it simpler and have all the materials that need such functionality use Material Parameter Collection in which you have an int ‘current flashlight’. Set that value in the MPC through code or blueprint when changing the flashlight.

Then in the material, normally react to light (make the text on normalmap or spec) but check for that int whether it matches what you need. Use lerp or switch, both would work. MPC is quite well documented, you should be able to get it up and running quickly.

It sounds simple enough but for some reason I can’t seem to make it work, could you post an example image of what it should look like inside the material for just a random solid color and the text in specular? I’m almost sure if I do something wrong that it’s on the lerp/switch part.

Yes I can. Here you go:

The material:

If A (CurrentFlashlightColor, taken from MPC) equals B (hard typed value, you may want to make this a parameter so you’ll have 3 material instances which you can use, depending on what kind of light given mesh requires) then it will fire the A=+B input to the output pin. Otherwise it will feed the normal one.

I haven’t tested it, so I’ve no idea how it will look. It also requires 2 normal maps instead of one (or spec, if that’s what you’ll end up using). Or both :wink:

The BP (change flashlight):

73831-node.jpg

Here you just add this node to the logic of flashlight. Depending which light you enable, set the variable appropriately so the material will know what it needs to.

Weird this is exactly what I ended up doing on my own (adding a typed value of “1” on B as you mentioned), So I figured something was wrong with the text image, after trying few things I just saved the image in .psd instead of .png and without changing anything suddenly it worked…

To add to this topic. With this method the text appears all the time if the value in the material matches the one in the MPC even if you don’t look at the wall with the hidden text (pretty much acts as a visibility toggle for the text), so is there any way to make it so only if you look at the wall and have the flashlight on that the text will appear? The only solution I’ve found is to use an event tick and line trace to look for the wall but I’m not sure if that’s good optimization wise.

I’d make that writing a decal instead of normal map on a wall. Then, add a volume component to your character and OnComponentBeginOverlap, check if it’s decal, get it’s material and either modify it’s parameter in the MaterialInstanceDynamic, or create new one and replace with the one currently in decal. Even better, make a blueprint with decal as a parent, so you can even better filter out the ComponentOverlap events to not try to modify any other decals in the game. Or if it suits you better - a blueprint with decal component.

You would need to modify the material - add 1 more parameter working as on/off switch on top of the color. And check the flag to be used with decals.

It’s pretty rough solution but relatively quick and easy to do. Also, you do not need to keep more textures for each object you want a writing on - you just add a decal and it will work on everything. The only texture you need is the writing itself.