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
32 Count
33 };
34
36 enum class DepthMode
37 {
39 Default = 0,
41 NoWrite = 1,
43 AlwaysWrite = 2,
45 Disabled = 3,
46 Count
47 };
48
50 enum class DepthFunc
51 {
52 Less = 0,
53 Always = 1,
54 LessOrEqual = 2,
55 NotEqual = 3,
56 Equal = 4,
57 Count
58 };
59
61 enum class CullMode
62 {
64 None = 0,
66 Back,
68 Front,
69 };
70
71 enum class TransparencyMode
72 {
73 None = 0,
74 Off = None,
75 Regular = 1,
76 On = Regular,
77 Auto,
78 Alpha
79 };
80
82 struct DepthBias
83 {
85 float constant = 0.f;
87 float slope = 0.f;
89 float clamp = 0.f;
90 };
91
94 {
97
99 bool depthWriteEnabled = true;
100
102 bool depthTestEnabled = true;
103
105 DepthFunc depthFunc = DepthFunc::Less;
106
108 bool depthBiasEnabled = false;
109
112
114 TransparencyMode transparencyMode = TransparencyMode::None;
115
118
131 int32_t drawOrder = 0;
132 };
133
134 void applyMaterialOption(MaterialOptions & options, const StringView & key, const StringView & value);
135 }
136}
137
138template<> inline Cogs::StringView getName<Cogs::Core::BlendMode>() { return "BlendMode"; }
139template<> inline Cogs::StringView getName<Cogs::Core::DepthMode>() { return "DepthMode"; }
140template<> inline Cogs::StringView getName<Cogs::Core::DepthFunc>() { return "DepthFunc"; }
141template<> inline Cogs::StringView getName<Cogs::Core::CullMode>() { return "CullMode"; }
142template<> inline Cogs::StringView getName<Cogs::Core::TransparencyMode>() { return "TransparencyMode"; }
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
@ Off
Disable capture and camera, consume no rendering resources.
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.