Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Material.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_MATERIAL
19#define INCLUDED_MATERIAL
20
21#include "graphics/Color.h"
23#include "graphics/Texture.h"
24#include "ps/CStr.h"
25#include "ps/CStrIntern.h"
27
29{
30public:
31
33 {
34 TextureSampler(const CStr &n, CTexturePtr t) : Name(n), Sampler(t) {}
36
39 };
40
41 typedef std::vector<TextureSampler> SamplersVector;
42
43 CMaterial();
44
45 // Whether this material's shaders use alpha blending, in which case
46 // models using this material need to be rendered in a special order
47 // relative to the alpha-blended water plane
48 void SetUsesAlphaBlending(bool flag) { m_AlphaBlending = flag; }
49 bool UsesAlphaBlending() const { return m_AlphaBlending; }
50
52
53 void SetShaderEffect(const CStr& effect);
55
56 // Must call RecomputeCombinedShaderDefines after this, before rendering with this material
58
60
61 void AddStaticUniform(const char* key, const CVector4D& value);
63
64 void AddSampler(const TextureSampler& texture);
65 const SamplersVector& GetSamplers() const { return m_Samplers; }
66
67 void AddRenderQuery(const char* key);
69
70 void AddRequiredSampler(const CStr& samplerName);
71 const std::vector<CStrIntern>& GetRequiredSampler() const { return m_RequiredSamplers; }
72
73private:
74
75 // This pointer is kept to make it easier for the fixed pipeline to
76 // access the only texture it's interested in.
78
80 std::vector<CStrIntern> m_RequiredSamplers;
81
86
88};
89
90#endif // INCLUDED_MATERIAL
Definition: Material.h:29
const std::vector< CStrIntern > & GetRequiredSampler() const
Definition: Material.h:71
const CShaderDefines & GetShaderDefines() const
Definition: Material.h:59
CStrIntern GetShaderEffect() const
Definition: Material.h:54
SamplersVector m_Samplers
Definition: Material.h:79
CShaderRenderQueries m_RenderQueries
Definition: Material.h:85
void AddRenderQuery(const char *key)
Definition: Material.cpp:50
const CShaderUniforms & GetStaticUniforms() const
Definition: Material.h:62
void AddRequiredSampler(const CStr &samplerName)
Definition: Material.cpp:55
bool UsesAlphaBlending() const
Definition: Material.h:49
const SamplersVector & GetSamplers() const
Definition: Material.h:65
std::vector< TextureSampler > SamplersVector
Definition: Material.h:41
CShaderUniforms m_StaticUniforms
Definition: Material.h:84
CTexturePtr m_DiffuseTexture
Definition: Material.h:77
void SetUsesAlphaBlending(bool flag)
Definition: Material.h:48
const CTexturePtr & GetDiffuseTexture() const
Definition: Material.h:51
void SetShaderEffect(const CStr &effect)
Definition: Material.cpp:28
CStrIntern m_ShaderEffect
Definition: Material.h:82
void AddSampler(const TextureSampler &texture)
Definition: Material.cpp:43
std::vector< CStrIntern > m_RequiredSamplers
Definition: Material.h:80
bool m_AlphaBlending
Definition: Material.h:87
CShaderDefines m_ShaderDefines
Definition: Material.h:83
void AddStaticUniform(const char *key, const CVector4D &value)
Definition: Material.cpp:38
void AddShaderDefine(CStrIntern key, CStrIntern value)
Definition: Material.cpp:33
CMaterial()
Definition: Material.cpp:23
const CShaderRenderQueries & GetRenderQueries() const
Definition: Material.h:68
Represents a mapping of name strings to value strings, for use with #if and #ifdef and similar condit...
Definition: ShaderDefines.h:147
Uniform values that need to be evaluated in the renderer.
Definition: ShaderDefines.h:203
Represents a mapping of name strings to value CVector4Ds, for use with uniforms in shaders.
Definition: ShaderDefines.h:168
Interned 8-bit strings.
Definition: CStrIntern.h:38
Definition: Vector4D.h:31
std::shared_ptr< CTexture > CTexturePtr
Definition: Texture.h:23
Definition: Material.h:33
CTexturePtr Sampler
Definition: Material.h:38
CStrIntern Name
Definition: Material.h:37
TextureSampler(const CStr &n, CTexturePtr t)
Definition: Material.h:34
TextureSampler(const CStrIntern &n, CTexturePtr t)
Definition: Material.h:35
pthread_key_t key
Definition: wpthread.cpp:140