Cogs.Core
BasicTerrainComponent.h
1#pragma once
2
3#include "Components/Core/DynamicComponent.h"
4
5#include "Resources/MaterialOptions.h"
6#include "Resources/ResourceBase.h"
7#include "Resources/Resources.h"
8
9#include <glm/vec2.hpp>
10#include <glm/vec3.hpp>
11#include <glm/vec4.hpp>
12
13namespace Cogs
14{
15 namespace Core
16 {
23 enum struct BasicTerrainElevationChannel : uint32_t
24 {
25 Red,
26 Alpha,
28 };
29
30 enum struct BasicTerrainTransparencyMode : uint32_t
31 {
32 None,
33 Regular,
35 };
36
38 {
39 public:
40 static void registerType();
41
42 void initialize(Context * context);
43
44 void update();
45
46 // Fields:
47 public:
49 TextureHandle elevationMap;
50
53
54 TextureHandle colorMap;
55
57 float vibrance = 1.f;
58
60 glm::vec4 diffuseColor = glm::vec4(1, 1, 1, 1);
61
63 bool noDataEnabled = false;
64
66 float noDataValue = 0.f;
67
69 float elevationBias = 0.f;
70
72 float elevationScale = 1.f;
73
75 float elevationMin = 0.f;
76
78 float elevationMax = 1.f;
79
80
83
84 bool elevationToAlpha = false;
85 float elevationToAlphaMin = 0.f;
86 float elevationToAlphaMax = 1.f;
87 float elevationToAlphaPower = 1.f;
88 CullMode cullMode = CullMode::Back;
89
90 public:
91 bool forceUpdate = false;
93 VariableKey elevationTransformKey = {};
94 VariableKey elevationTexKey = {};
95 ResourceFlags elevationFlags = ResourceFlags::None;
96 VariableKey normalTransformKey = {};
97 VariableKey elevationToAlphaTransformKey = {};
98 VariableKey colorTexKey = {};
99 VariableKey diffuseColorKey = {};
100 VariableKey noDataValueKey = {};
101 VariableKey vibranceKey = {};
102
103 Context* context = nullptr;
104
105 glm::vec4 elevationTransform;
106 glm::vec2 normalTransform;
107 glm::vec3 elevationToAlphaTransform;
108 };
109 }
110}
111
112template<> inline Cogs::StringView getName<Cogs::Core::BasicTerrainComponent>() { return "BasicTerrainComponent"; }
113
114template<> inline Cogs::StringView getName<Cogs::Core::BasicTerrainElevationChannel>() { return "BasicTerrainElevationChannel"; }
115
116template<> inline Cogs::StringView getName<Cogs::Core::BasicTerrainTransparencyMode>() { return "BasicTerrainTransparencyMode"; }
MaterialHandle material
Stored here as actual update may be delayed until all avalable.
BasicTerrainTransparencyMode transparencyMode
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Base class for components implementing dynamic behavior.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
ResourceFlags
Flags for describing resource attributes.
Definition: ResourceBase.h:27
@ None
No transparency, it is safe to store elevation in colormap's alpha channel.
@ BlendWithZWrite
Treat terrain as opaque, but enable blending with colormap's alpha channel.
@ Regular
Regular transparency, use colormap's alpha channel.
@ RedGreenBlue
Concatenate bits from red, green and blue channels.
@ Alpha
Fetch elevation from alpha channel of elevation texture.
@ Red
Fetch elevation from red channel of elevation texture.
CullMode
Defines primitive culling modes.
@ Back
Back face of primitives discarded before rasterization.
uint16_t VariableKey
Used to lookup material properties.
Definition: Resources.h:46
Contains all Cogs related functionality.
Definition: FieldSetter.h:23