Cogs.Core
MaterialComponent.h
1#pragma once
2
3#include "Rendering/SamplerState.h"
4
5#include "Resources/Resources.h"
6#include "Resources/MaterialOptions.h"
7
8#include "Renderer/IRenderer.h"
9
10namespace Cogs
11{
12 namespace Core
13 {
22 {
26
27 //NOTE: The fields of the material component that contain the actual material properties,
28 // sans master material connection, are used to determine a hash value to make material
29 // sharing automatic.
30 //
31 // If any changes are made to the section below, review and update the corresponding functionality
32 // in the method Cogs::Core::getMaterialHash in MaterialSystem.cpp.
33
34 // Begin hash section.
38 glm::vec4 diffuseColor = glm::vec4(1, 1, 1, 1);
39 glm::vec4 emissiveColor = glm::vec4(0, 0, 0, 1);
40 glm::vec4 specularColor = glm::vec4(0, 0, 0, 1);
41 glm::vec4 ambientColor = glm::vec4(0, 0, 0, 1);
42 glm::vec2 diffuseMapScale = glm::vec2(1, 1);
43 glm::vec2 normalMapScale = glm::vec2(1, 1);
44 glm::vec2 specularMapScale = glm::vec2(1, 1);
45 float specularPower = 80;
46 float transparency = 0;
47 float lineWidth = 1.0f;
48 float pointSize = 1.0f;
49 float depthBiasConstant = 0.f;
50 float depthBiasSlope = 0.f;
51 float depthBiasClamp = 0.f;
52 float normalMapFactor = 1.0f;
53 uint32_t stippleFactor = 1;
54 uint32_t stipplePattern = 0xFFFFFFFF;
55 int32_t drawOrder = 0;
57 CullMode cullMode = CullMode::None;
58 BlendMode blendMode = BlendMode::None;
61 bool instancedLine = false;
62 bool vertexColor = false;
63 bool backdrop = false;
64 bool enableLighting = true;
65 bool shadowReceiver = true;
66 bool depthWriteEnabled = true;
67 bool depthTestEnabled = true;
68 bool depthTestAlwaysPass = false;
69 bool depthBiasEnable = false;
70 bool enableOverride = false;
71 bool enableColorOverride = true;
72 bool enableAlphaOverride = true;
73 bool enableTextureOverride = true;
74 // End hash section
75
76 // Copy all the property values from the source component.
77 void COGSCORE_DLL_API copyProperties(const MaterialComponent* source);
78
79 static void registerType();
80 };
81 }
82}
83
84template<> inline Cogs::StringView getName<Cogs::Core::MaterialComponent>() { return "MaterialComponent"; }
Base class for Component instances.
Definition: Component.h:143
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
std::weak_ptr< ComponentModel::Entity > WeakEntityPtr
Weak Smart pointer for Entity access.
Definition: EntityPtr.h:18
BlendMode
Defines blending modes for rendering.
@ None
No blending enabled for opaque shapes, defaults to Blend for transparent shapes.
CullMode
Defines primitive culling modes.
@ None
No primitive culling performed.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Exposes material properties for legacy entities and code.
bool shadowReceiver
If false, object never gets shadowed.
int32_t drawOrder
Manages draw order, maps to MaterialOptions::drawOrder.
bool backdrop
If true the MaterialFlags::Backdrop on the material instance.
bool instancedLine
Lines rendered with instancing.
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.
EPrimitiveType
Primitive type enumeration.
Definition: Common.h:114
@ TriangleList
List of triangles.
Definition: Common.h:116
AddressMode
Addressing modes to use when sampling textures.
Definition: SamplerState.h:15
@ Wrap
Texture coordinates automatically wrap around to [0, 1] range.
Definition: SamplerState.h:19
FilterMode
Filter modes to specify how texture data is treated when sampled.
Definition: SamplerState.h:31
@ MinMagMipLinear
Linear sampling for both minification and magnification.
Definition: SamplerState.h:35