Hi, How i set a variable of type boolean via BluePrint ???
In Blue Print not Show Set Boolean Parameter Value property…
Only Vector, Texture and Scalar Parameter…
Hi, How i set a variable of type boolean via BluePrint ???
In Blue Print not Show Set Boolean Parameter Value property…
Only Vector, Texture and Scalar Parameter…
Try the Scalar one. Boolean is a scalar type.
Short Answer: You can’t.
StaticBoolParameter
“This parameter is named static because it cannot change at runtime, it can only be set in the Material Instance Editor. Static Switches are applied at compile time, not at runtime. This means that whatever branch of the material was dropped will never be executed, so static switches are effectively free at runtime. On the other hand, a new version of the material must be compiled out for every used combination of static parameters in a material, which can lead to a shader explosion if abused. Try to minimize the number of static parameters in the material and the number of permutations of those static parameters that are actually used.”
Silly, right? I mean, in my custom shaders I can set a boolean value without any problems. This would be a nice feature capability to have in UE4.
It’s not silly. “In Editor” is not the same as “In Runtime”. Runtime also applies the game once it’s cooked and packaged and running a PC as a finished product. At that time, shaders are compiled and not more switch can take place. At the point it would be impossible to have a blueprint change the switch value.
A workaround is to use a scalar parameter and an IF node and a fixed scalar 0.
A is your scalar parameter, B is 0 and then you can switch between three different inputs. Really useful to toggle on and off a feature of a material at runtime.
All negative votes reveals voters ignorance
I used another workaround which work very well. I switched the Switch with a Lerp and connected the Scalar to the alpha. Works perfectly!
xlman, using the LERP is a great solutions. Thank you!
“bool” is equal to if else, it’s not efficient in GPU, so do your switch logic in code or blueprint instead of in material.
using lerp looking pretty bad… because shader executes both routes and lerp results…
There’s a node called “Switch Parameter”.
Seems like this is the one~!!!