Possible to read current material instance properties during runtime?

How can i read my material current opacity or the custom stencil color affecting it?
I need to be able to check if it is affected by the custom stencil, and change(enable/disable) his collision accordingly.

My actor material is set in a way that hides the actor at certain situation using the custom stencil.
Since it is invisible, i also need to block his interaction(in this case, i need to disable its collisions).

Thanks.

Assuming you are using a UMaterialInstanceDynamic to drive the opacity you can call GetVectorParameter to retrieve the value, however in that case you would have a variable driving the material already that could be used instead to determine if your actor is visible or not.


I am looking for the resulted Opacity from the calculation above^

This didn’t worked for me, so i’m starting to think it is not possible.
GetVectorParameter generally did worked, but only for parameter that gets inputted to the material which is not helping in my case.
What i was looking for is to get some output from a material, but i’m getting the feeling that it might be backed and hence impossible to get.
I was thinking that a work around is to try and get the customstencil and make the material calculation outside, but that information seems to maybe also be backed.

It would have been nice if it was possible to have an easy way to output information from the material.

Can you not use the value you’re pushing into your StencilValue parameter to determine the opacity?


Here you can see what i’m trying to do.
Masking out some actors.
The stencils seemed to me like the best way to achieve this.
Problem is, I don’t know how to calculate which is currently hidden and which is being shown to the user, after knowing, i need to disable the colliders of invisible ones(the invisible widgets are blocking the hittest/hitresult).

Some person said i may look into reading the stencil buffer, although i not sure where to start about how to be doing it.

A easier solution could be to setup an animation in your widget that will drive the Opacity to zero. You can then raise an event in your code and in BP start the animation, at the end of the animation you can then disable collision of whatever you need to. You’d also know which widgets are hidden since you can store that in the widget object.

In your widget class:

UFUNCTION(BlueprintImplementableEvent, Category = "Whatever")
		void OnStartAnimation();

In cpp:

void UMyUserWidget::StartAnimation(){
  IsHidden = true;
  OnStartAnimation();
}

But then how i can decide which would be hidden? the stencil automatically lets me mask out from any angle

Oh, I see. Not sure then sorry. Hopefully someone else has experience with using Stencil or possibly using something else

I really appreciate the effort

I’d highly recommend the Unreal Slackers discord, very active and I’m sure someone there could assist
https://discord.gg/unrealslackers

1 Like