Material Emissive Value Based on Player Proximity?

I’m not really sure if something like this is even possible, but I thought I’d ask just to be sure:

To give some background, I have a Player Controller in a 2.5D side scroller I am making (2D Gameplay with 3D Assets). The game’s visual style is strongly based on silhouettes and emission.

So, what I want to achieve: is that I have various surfaces that have emissive values in their materials (but they are hidden by default) and I’d like them to light up when the player is close enough. But I don’t want the entire material and mesh to light up, only parts of the surface that are close to the player.

One example is that I have a log mesh and material that is driven along a spline. By default it is normal, but I can drive an alpha value that makes the crevices in the bark glow. But this affects the whole mesh, when really I’d like to be able to only make the surface that is close to the player glow, as opposed to the entire mesh.

Is this even possible to produce? Thanks.

Look into global material parameters.

You can store the players location in there then have your materials sample their own world position and the players position from the global value to do some funky things.

That sounds like a plausible solution. Can you confirm that this would work? Really, all I need to do is be able to layer a disk shape over the surface when I’m close enough to it, then I can just use that as a mask. If that’s possible then I’m sure I could apply it.

And would you have any links on how to get the materials world position? I can’t say i have ever tried this before. So that would be a massive help, thanks!

I’m not sure I fully understand your idea, but you can try to use simple sphere mask.

In case your camera is always on fixed distance from player, you can get camera position in material, add offset vector to it, and use it as position for sphere mask.

and use this as emissive mask for every material you want.

Also you can map some clamped spherical texture to camera position in world coordinates with world position offset.

For this try to start from WorldProjectedTexture material function.

AHA! This is perfect! What a brilliant little bit of Ue4 functionality. And so simple. Thank you for that.