곱하기 색·스크린색(UE)

업데이트: 2024/09/05

이 페이지에는 알파 버전에 관한 설명이 포함되어 있습니다.

개요

모델에 곱하기 색·스크린색을 적용하여 색조를 실시간으로 변화시킬 수 있습니다.

Cubism Editor상에서 설정한 곱하기 색·스크린색은 Cubism SDK for Unreal Engine을 이용하면 특별히 추가 코딩을 하지 않고 적용됩니다.
Cubism Editor상에서의 곱하기 색·스크린색의 설정은 Editor 매뉴얼의 「곱하기 색·스크린색」을 참조해 주십시오.

또한 필요에 따라 코딩을 수행하여 SDK에서 곱하기 색, 스크린색을 조작하여 다음과 같은 동작도 가능합니다.

  • 인터랙티브에 곱하기 색·스크린색을 적용한다
  • Cubism Editor에서 설정하지 않은 곱하기 색·스크린색 적용
  • Cubism Editor에서 설정한 곱하기 색·스크린색을 비활성화

이후는 그 순서의 설명입니다.

곱하기 색·스크린색 조작 순서

모델, 파츠, 아트메쉬의 3개 단위로 곱하기 색·스크린색을 조작할 수 있습니다.
각 계층마다 곱하기 색과 스크린색의 프로퍼티가 제공됩니다.

조작하려는 대상에 해당하는 프로퍼티는 다음과 같습니다.

  • 모델 단위로 조작하고 싶은 경우: CubismModelComponent 프로퍼티
  • 파츠 단위로 조작하고 싶은 경우: CubismPartComponent 프로퍼티
  • 아트메쉬 단위로 조작하고 싶은 경우: CubismDrawableComponent 프로퍼티

다음은 CubismModelComponent의 관련 프로퍼티를 보여줍니다.

UCLASS(Blueprintable)
class LIVE2DCUBISM_API UCubismModelComponent : public USceneComponent
{
	GENERATED_BODY()

public:

...

	UPROPERTY(EditAnywhere, Category = "Live2D Cubism")
	bool OverwriteFlagForModelMultiplyColors;

	UPROPERTY(EditAnywhere, Category = "Live2D Cubism")
	FLinearColor MultiplyColor = FLinearColor::White;

	UPROPERTY(EditAnywhere, Category = "Live2D Cubism")
	bool OverwriteFlagForModelScreenColors;

	UPROPERTY(EditAnywhere, Category = "Live2D Cubism")
	FLinearColor ScreenColor = FLinearColor::Black;

...

}
TIPS

디폴트로 곱하기 색은 흰색으로, 스크린색은 검은색으로 설정됩니다.

덮어쓰기 플래그에 체크 표시

SDK를 통해 곱하기 색 및 스크린색을 조작하려면 각 모델, 파츠, 아트메쉬에 준비된 곱하기 색 및 스크린색 덮어쓰기 플래그가 true로 설정되어야 합니다.
디폴트는 false인 점에 주의하십시오.

각 계층에 해당하는 덮어쓰기 플래그는 다음과 같습니다.

  • 모델(CubismModelComponent)
    • OverwriteFlagForModelMultiplyColors
    • OverwriteFlagForModelScreenColors
  • 파츠(CubismPartComponent)
    • OverwriteFlagForPartMultiplyColors
    • OverwriteFlagForPartScreenColors
  • 아트메쉬(CubismDrawableComponent)
    • OverwriteFlagForDrawableMultiplyColors
    • OverwriteFlagForDrawableScreenColors

에디터에서도 코드에서도 같은 프로퍼티로서 접근할 수 있습니다.

값 조작

덮어쓰기 플래그에 체크가 되어 있는 경우 각 모델, 파츠, 아트메쉬에 준비되어 있는 MultiplyColorScreenColor의 값을 변경하면 각 단위로 곱하기 색·스크린색을 조작할 수 있습니다.
곱하기 색을 비활성화하려면 MultiplyColor를 흰색으로 설정하고 스크린색을 비활성화하려면 ScreenColor를 검은색으로 설정합니다.

변경한 값은 CubismRendererComponent의 내부 처리에 의해 이하의 형태로 그리기에 반영됩니다.

MultiplyColor, ScreenColor는 RGB 값만 참조되며 알파값은 그리기에 사용되지 않습니다.

for (auto Drawable : Drawables)
{
	UMaterialInstanceDynamic* MaterialInstance = static_cast<UMaterialInstanceDynamic*>(Drawable->GetMaterial(0));

	UTexture2D*  MainTexture   = Drawable->TextureIndex < Model->Textures.Num()? Model->Textures[Drawable->TextureIndex] : nullptr;
	FLinearColor BaseColor     = Drawable->BaseColor;
	FLinearColor MultiplyColor = Drawable->MultiplyColor;
	FLinearColor ScreenColor   = Drawable->ScreenColor;

	{
		if (Model->OverwriteFlagForModelMultiplyColors)
		{
			MultiplyColor = Model->MultiplyColor;
		}

		if (Model->OverwriteFlagForModelScreenColors)
		{
			ScreenColor = Model->ScreenColor;
		}
	}

	if (UCubismPartComponent* ParentPart = Model->GetPart(Drawable->ParentPartIndex))
	{
		if (ParentPart->OverwriteFlagForPartMultiplyColors)
		{
			MultiplyColor = ParentPart->MultiplyColor;
		}
		
		if (ParentPart->OverwriteFlagForPartScreenColors)
		{
			ScreenColor = ParentPart->ScreenColor;
		}
	}

	BaseColor.A *= Model->Opacity * Drawable->Opacity;

	MaterialInstance->SetTextureParameterValue("MainTexture", MainTexture);
	MaterialInstance->SetVectorParameterValue("BaseColor", BaseColor);
	MaterialInstance->SetVectorParameterValue("MultiplyColor", MultiplyColor);
	MaterialInstance->SetVectorParameterValue("ScreenColor", ScreenColor);
}

이 기사가 도움이 되었나요?
아니요
이 기사에 관한 의견 및 요청사항을 보내 주시기 바랍니다.