// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license.

#pragma once

#include "SimplygonUE4UI.h"

#if WITH_EDITOR
#include "SimplygonPluginMeshReduction/Public/SimplygonMaterialChannelConverter.h"
#endif

#include "SimplygonPropertyCasters.generated.h"

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Base Color" ) )
class SIMPLYGONUOBJECTS_API UBaseColorCaster : public USimplygonColorCaster
{
	GENERATED_BODY()

public:

	UBaseColorCaster() : USimplygonColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Diffuse, ColorCasterSettings.MaterialChannel));
#endif
		ColorCasterSettings.OutputSRGB = true;
		ColorCasterSettings.Dilation = 10;
		ColorCasterSettings.OutputPixelFormat = EOutputPixelFormat::R8G8B8;
		ColorCasterSettings.DitherType = EDitherType::NoDither;
		ColorCasterSettings.FillMode = EFillMode::Interpolate;
	}
};

UCLASS(meta = (DisplayName = "Metallic"))
class SIMPLYGONUOBJECTS_API UMetallicCaster : public UBaseColorCaster
{
	GENERATED_BODY()

public:

	UMetallicCaster() : UBaseColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Metallic, ColorCasterSettings.MaterialChannel));
#endif
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Specular" ) )
class SIMPLYGONUOBJECTS_API USpecualarCaster : public UBaseColorCaster
{
	GENERATED_BODY()

public:

	USpecualarCaster() : UBaseColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Specular, ColorCasterSettings.MaterialChannel));
#endif
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Roughness" ) )
class SIMPLYGONUOBJECTS_API URoughnessCaster : public UBaseColorCaster
{
	GENERATED_BODY()

public:

	URoughnessCaster() : UBaseColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Roughness, ColorCasterSettings.MaterialChannel));
#endif
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Normal" ) )
class SIMPLYGONUOBJECTS_API UNormalCaster : public USimplygonNormalCaster
{
	GENERATED_BODY()

public:

	UNormalCaster() : USimplygonNormalCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Normal, NormalCasterSettings.MaterialChannel));
#endif
		NormalCasterSettings.GenerateTangentSpaceNormals = true;
		NormalCasterSettings.FlipBackfacingNormals = false;
		NormalCasterSettings.FlipGreen = false;
		NormalCasterSettings.Dilation = 10;
		NormalCasterSettings.OutputPixelFormat = EOutputPixelFormat::R8G8B8;
		NormalCasterSettings.DitherType = EDitherType::NoDither;
		NormalCasterSettings.FillMode = EFillMode::NearestNeighbor;
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Opacity" ) )
class SIMPLYGONUOBJECTS_API UOpacityCaster : public USimplygonOpacityCaster
{
	GENERATED_BODY()

public:

	UOpacityCaster() 
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Opacity, OpacityCasterSettings.MaterialChannel));
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Opacity, OpacityCasterSettings.OpacityChannel));
#endif
		OpacityCasterSettings.Dilation = 0;
		OpacityCasterSettings.DitherType = EDitherType::NoDither;
		OpacityCasterSettings.FillMode = EFillMode::NoFill;
		OpacityCasterSettings.OutputOpacityType = EOutputOpacityType::Opacity;
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Emissive" ) )
class SIMPLYGONUOBJECTS_API UEmissiveCaster : public UBaseColorCaster
{
	GENERATED_BODY()

public:

	UEmissiveCaster() : UBaseColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::Emissive, ColorCasterSettings.MaterialChannel));
#endif
		ColorCasterSettings.OutputPixelFormat = EOutputPixelFormat::R16G16B16;
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Opacity Mask" ) )
class SIMPLYGONUOBJECTS_API UOpacityMaskCaster : public USimplygonOpacityCaster
{
	GENERATED_BODY()

public:

	UOpacityMaskCaster()
	{
#if WITH_EDITOR
		check( FSimplygonMaterialChannelConverter::MaterialPropertyToChannel( EFlattenMaterialProperties::OpacityMask, OpacityCasterSettings.MaterialChannel ) );
		check( FSimplygonMaterialChannelConverter::MaterialPropertyToChannel( EFlattenMaterialProperties::OpacityMask, OpacityCasterSettings.OpacityChannel ) );
#endif
		OpacityCasterSettings.Dilation = 0;
		OpacityCasterSettings.DitherType = EDitherType::NoDither;
		OpacityCasterSettings.FillMode = EFillMode::NoFill;
		OpacityCasterSettings.OutputOpacityType = EOutputOpacityType::Opacity;
	}
};

UCLASS( BlueprintType, Blueprintable, meta = ( DisplayName = "Ambient Occlusion" ) )
class SIMPLYGONUOBJECTS_API UAmbientOcclusionMaskCaster : public UBaseColorCaster
{
	GENERATED_BODY()

public:

	UAmbientOcclusionMaskCaster() : UBaseColorCaster()
	{
#if WITH_EDITOR
		check(FSimplygonMaterialChannelConverter::MaterialPropertyToChannel(EFlattenMaterialProperties::AmbientOcclusion, ColorCasterSettings.MaterialChannel));
#endif
		ColorCasterSettings.OutputSRGB = false;
	}
};
