Cogs.Core
MaterialOptions.h
1#pragma once
2
3#include "Foundation/Reflection/Name.h"
4
5namespace Cogs
6{
7 class StringView;
8
9 namespace Core
10 {
12 enum class BlendMode
13 {
15 Blend = 0,
17 Add,
24 None,
26 Zero,
27
28 One_One_Zero_InverseSourceAlpha,
29
30 InverseSourceAlpha_SourceAlpha,
31 DestinationAlpha_InverseDestinationAlpha,
32
33 Count
34 };
35
37 enum class DepthMode
38 {
40 Default = 0,
42 NoWrite = 1,
44 AlwaysWrite = 2,
46 Disabled = 3,
47 Count
48 };
49
51 enum class DepthFunc
52 {
53 Less = 0,
54 Always = 1,
55 LessOrEqual = 2,
56 NotEqual = 3,
57 Equal = 4,
58 Count
59 };
60
62 enum class CullMode
63 {
65 None = 0,
67 Back,
69 Front,
70 };
71
72 enum class TransparencyMode
73 {
74 None = 0,
75 Off = None,
76 Regular = 1,
77 On = Regular,
78 Auto,
79 Alpha
80 };
81
83 struct DepthBias
84 {
86 float constant = 0.f;
88 float slope = 0.f;
90 float clamp = 0.f;
91 };
92
95 {
98
100 bool depthWriteEnabled = true;
101
103 bool depthTestEnabled = true;
104
106 DepthFunc depthFunc = DepthFunc::Less;
107
109 bool depthBiasEnabled = false;
110
113
115 TransparencyMode transparencyMode = TransparencyMode::None;
116
119
132 int32_t drawOrder = 0;
133 };
134
135 void applyMaterialOption(MaterialOptions & options, const StringView & key, const StringView & value);
136 }
137}
138
139template<> inline Cogs::StringView getName<Cogs::Core::BlendMode>() { return "BlendMode"; }
140template<> inline Cogs::StringView getName<Cogs::Core::DepthMode>() { return "DepthMode"; }
141template<> inline Cogs::StringView getName<Cogs::Core::DepthFunc>() { return "DepthFunc"; }
142template<> inline Cogs::StringView getName<Cogs::Core::CullMode>() { return "CullMode"; }
143template<> inline Cogs::StringView getName<Cogs::Core::TransparencyMode>() { return "TransparencyMode"; }
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
BlendMode
Defines blending modes for rendering.
@ Blend
Render with regular alpha blending.
@ None
No blending enabled for opaque shapes, defaults to Blend for transparent shapes.
@ AlphaToCoverage
Interpret alpha value as a coverage mask.
@ Zero
Disable all color writes.
DepthMode
Defines common depth stencil modes.
@ NoWrite
Depth test enabled, write disabled.
@ AlwaysWrite
Depth write enabled, test mode "Always". Deprecated.
@ Disabled
Depth test/write disabled.
DepthFunc
Defines common depth functions.
@ Regular
Regular transparency, use colormap's alpha channel.
@ Alpha
Fetch elevation from alpha channel of elevation texture.
CullMode
Defines primitive culling modes.
@ Back
Back face of primitives discarded before rasterization.
@ Front
Front face of primitives discarded before rasterization.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Defines data for controlling the depth output when rasterizing geometry.
float constant
Constant factor, applied as a multiple of the smallest resolvable depth buffer value.
float clamp
Clamp the resulting depth bias to be abs(d) <= clamp.
float slope
Slope factor, applied as a multiple of the slope of the rasterized primitive.
Defines options for rendering using a material instance.
BlendMode blendMode
Blend mode to use when rendering geometry with the material instance.
DepthFunc depthFunc
Depth test should pass when the incoming depth is less than current value in depth buffer.
TransparencyMode transparencyMode
Transparency mode.
DepthBias depthBias
Depth bias control values, only applicable if depthBiasEnabled is true.
bool depthWriteEnabled
If depth writes should be enabled rendering the geometry with the material instance.
bool depthTestEnabled
If depth testing should be enabled rendering the geometry with the material instance.
bool depthBiasEnabled
If depth bias should be enabled.
CullMode cullMode
Primitive culling mode to use.