#pragma once #include namespace XCEngine { namespace Resources { enum class MaterialCullMode : Core::uint8 { None = 0, Front = 1, Back = 2 }; enum class MaterialComparisonFunc : Core::uint8 { Never = 0, Less = 1, Equal = 2, LessEqual = 3, Greater = 4, NotEqual = 5, GreaterEqual = 6, Always = 7 }; enum class MaterialBlendOp : Core::uint8 { Add = 0, Subtract = 1, ReverseSubtract = 2, Min = 3, Max = 4 }; enum class MaterialBlendFactor : Core::uint8 { Zero = 0, One = 1, SrcColor = 2, InvSrcColor = 3, SrcAlpha = 4, InvSrcAlpha = 5, DstAlpha = 6, InvDstAlpha = 7, DstColor = 8, InvDstColor = 9, SrcAlphaSat = 10, BlendFactor = 11, InvBlendFactor = 12, Src1Color = 13, InvSrc1Color = 14, Src1Alpha = 15, InvSrc1Alpha = 16 }; enum class MaterialStencilOp : Core::uint8 { Keep = 0, Zero = 1, Replace = 2, IncrSat = 3, DecrSat = 4, Invert = 5, IncrWrap = 6, DecrWrap = 7 }; struct MaterialStencilFaceState { MaterialStencilOp failOp = MaterialStencilOp::Keep; MaterialStencilOp passOp = MaterialStencilOp::Keep; MaterialStencilOp depthFailOp = MaterialStencilOp::Keep; MaterialComparisonFunc func = MaterialComparisonFunc::Always; bool operator==(const MaterialStencilFaceState& other) const { return failOp == other.failOp && passOp == other.passOp && depthFailOp == other.depthFailOp && func == other.func; } bool operator!=(const MaterialStencilFaceState& other) const { return !(*this == other); } }; struct MaterialStencilState { bool enabled = false; Core::uint8 readMask = 0xFF; Core::uint8 writeMask = 0xFF; Core::uint8 reference = 0; MaterialStencilFaceState front = {}; MaterialStencilFaceState back = {}; bool operator==(const MaterialStencilState& other) const { return enabled == other.enabled && readMask == other.readMask && writeMask == other.writeMask && reference == other.reference && front == other.front && back == other.back; } bool operator!=(const MaterialStencilState& other) const { return !(*this == other); } }; struct MaterialRenderState { bool blendEnable = false; MaterialBlendFactor srcBlend = MaterialBlendFactor::One; MaterialBlendFactor dstBlend = MaterialBlendFactor::Zero; MaterialBlendFactor srcBlendAlpha = MaterialBlendFactor::One; MaterialBlendFactor dstBlendAlpha = MaterialBlendFactor::Zero; MaterialBlendOp blendOp = MaterialBlendOp::Add; MaterialBlendOp blendOpAlpha = MaterialBlendOp::Add; Core::uint8 colorWriteMask = 0xF; bool depthTestEnable = true; bool depthWriteEnable = true; MaterialComparisonFunc depthFunc = MaterialComparisonFunc::Less; MaterialCullMode cullMode = MaterialCullMode::None; float depthBiasFactor = 0.0f; Core::int32 depthBiasUnits = 0; MaterialStencilState stencil = {}; bool operator==(const MaterialRenderState& other) const { return blendEnable == other.blendEnable && srcBlend == other.srcBlend && dstBlend == other.dstBlend && srcBlendAlpha == other.srcBlendAlpha && dstBlendAlpha == other.dstBlendAlpha && blendOp == other.blendOp && blendOpAlpha == other.blendOpAlpha && colorWriteMask == other.colorWriteMask && depthTestEnable == other.depthTestEnable && depthWriteEnable == other.depthWriteEnable && depthFunc == other.depthFunc && cullMode == other.cullMode && depthBiasFactor == other.depthBiasFactor && depthBiasUnits == other.depthBiasUnits && stencil == other.stencil; } bool operator!=(const MaterialRenderState& other) const { return !(*this == other); } }; } // namespace Resources } // namespace XCEngine