How to get emissive value of a material in a separate blueprint?

Hey everyone! I’m working on a project where I need a character to stay within a certain area based on the brightness or emissiveness of a material. Basically, there’s a material above the character’s head, masking certain parts of the level. Kind of like fog of war. The foggy area has a lower emission than the areas that are uncovered. I’m doing a raycast upward from the character’s head, and I’m trying to figure out how to find the emissiveness of the material at the raycast’s hitpoint. Is this possible?

That’s not particularly easy. But if you can put the emissive object in a BP, then you can tell where you are with respect to the BP location, which will be proportional to the emissiveness.

I guess that’s true. Here’s a screenshot of what the fog looks like:
image
The fog is a separate blueprint class with its own blueprint. It sits slightly above the ground. I have a village, and the buildings push away the fog in a circle shape.
The raycast above the character’s head does collide with the fog layer, indicated by the red square. Would it be possible to make a variable for the emissiveness in the material’s blueprint, and then access that variable in the character’s blueprint to find the emissiveness of the fog at the raycast’s impact point?

You can make a param in the material, and set it from the blueprint, of course. And like I say, it’s easy to know how far from the pivot point of the BP your hit is. It’s a bit more fiddly to read the emissiveness at that point.

Do you have a texture, or is it a sphere mask? You can read a texture at a given point with

image

There are other similar nodes.

I’m using a material. I do have an emissive parameter in the material:
image
This is what the fog material looks like with 0.75 emissiveness:
image
If I lower it:
image
If I increase it:
image

I’m using a Render Target as a texture sample to cut away parts of the material, thus “uncovering” parts of the fog. I’m doing this by changing the opacity of the material:


Instead of getting the emissiveness, could I maybe get the UV coordinates of the texture at the raycast’s hit point and then get its opacity?

I don’t think you can read the texture, but if the texture has been written to a render target, you can read that, which amounts to the same thing.

It’s very difficult to give a recommendation from here, as there are a lot of unknowns, like

  1. What shape is the material applied to, a sphere?

  2. How do you know which part of the render target / texture you’re referencing with the line trace?

  3. Does the fog move with the player?

Why not use a post process fog?