본문 바로가기
이펙트 (FX)/이펙트 팁 : Unreal

[Unreal/Material] 머티리얼에서 MPC 조건 분기 처리하는 법 (bool, If 대체)

by Minkyu Lee 2025. 5. 14.

개요

MPC를 사용하여 머티리얼에서 분기를 치고 싶을 때 (조건따라 작동),

bool값을 사용하지 못하는 문제가 있다.

가끔 가장 효율적인 방법을 까먹어서 시간 낭비를 할 때가 있다.

해결하는 방법을 소개한다.

 

방법

- step과 lerp를 조합한다.

아래처럼 구성시,

0이면 Lerp의 A 값이 사용되고, 1이면 Lerp의 B값이 사용된다.

참고로 MPC에서는 scalar 아니면 vector 값만 넣을 수 있으므로 scalar로 받아오게 구성한 것이다.

 

참고링크

https://forums.unrealengine.com/t/controlling-a-staticswitch-with-a-float-scalar-constant-1-in-a-material/299743

 

controlling a StaticSwitch with a Float/Scalar/Constant 1 in a Material

Hey Guys, i want to control a StaticSwitch with a Float… currently iam trying to do this with a IF Node. but i get an errors Error [SM5] (Node If) Attempting to perform arithmetic on non-numeric types: static bool static bool Error [SM5] (Node If) Cannot

forums.unrealengine.com

- bool 값을 사용하는 switch 노드는 왜 사용 못하는가?

머티리얼 에디터에서 Switch는 "Static Switch"로 작동하며, 런타임 동작이 아니라 컴파일 타임 조건 분기다.

따라서 Material Parameter Collection이나 Dynamic Parameter로 실시간 제어하고 싶다면 Static Bool이나 Switch는 쓸 수 없다.

댓글