Radium Engine  1.5.20
Loading...
Searching...
No Matches
PlainMaterial.cpp
1#include <Engine/Data/PlainMaterial.hpp>
2
3#include <Engine/Data/ShaderConfigFactory.hpp>
4#include <Engine/Data/ShaderProgramManager.hpp>
5#include <Engine/Data/TextureManager.hpp>
6#include <Engine/RadiumEngine.hpp>
7#include <Engine/Rendering/RenderTechnique.hpp>
8
9#include <fstream>
10
11namespace Ra {
12namespace Engine {
13namespace Data {
14
15static const std::string materialName { "Plain" };
16
17nlohmann::json PlainMaterial::s_parametersMetadata = {};
18
20 SimpleMaterial( instanceName, materialName, Material::MaterialAspect::MAT_OPAQUE ) {}
21
23 // Get the Radium Resource location on the filesystem
24 auto resourcesRootDir { RadiumEngine::getInstance()->getResourcesDir() };
25 auto shaderProgramManager = RadiumEngine::getInstance()->getShaderProgramManager();
26
27 shaderProgramManager->addNamedString( "/Plain.glsl",
28 resourcesRootDir + "Shaders/Materials/Plain/Plain.glsl" );
29 // registering re-usable shaders
31 "Plain",
32 resourcesRootDir + "Shaders/Materials/Plain/Plain.vert.glsl",
33 resourcesRootDir + "Shaders/Materials/Plain/Plain.frag.glsl" );
34
36
37 Data::ShaderConfiguration zprepassconfig(
38 "ZprepassPlain",
39 resourcesRootDir + "Shaders/Materials/Plain/Plain.vert.glsl",
40 resourcesRootDir + "Shaders/Materials/Plain/PlainZPrepass.frag.glsl" );
42
43 // Registering technique
44 Rendering::EngineRenderTechniques::registerDefaultTechnique(
45 materialName, []( Rendering::RenderTechnique& rt, bool ) {
46 // Lighting pass
49 // Z prepass
50 auto zprepass = Data::ShaderConfigurationFactory::getConfiguration( "ZprepassPlain" );
52 } );
53
54 // Registering parameters metadata
55 SimpleMaterial::loadMetaData( s_parametersMetadata );
56}
57
59 Rendering::EngineRenderTechniques::removeDefaultTechnique( "Plain" );
60}
61
63 auto& renderParameters = getParameters();
64 setColor( renderParameters.getVariable<Core::Utils::Color>( "material.color" ) );
65 setColoredByVertexAttrib( renderParameters.getVariable<bool>( "material.perVertexColor" ) );
66}
67
69 return s_parametersMetadata;
70}
71
72} // namespace Data
73} // namespace Engine
74} // namespace Ra
Base class for materials.
Definition Material.hpp:24
MaterialAspect
Identifies the type of the material.
Definition Material.hpp:31
nlohmann::json getParametersMetadata() const override
Get a json containing metadata about the parameters.
PlainMaterial(const std::string &instanceName)
void updateFromParameters() override
Update the attributes of the ShaderParameterProvider to their actual values stored in the renderParam...
Base implementation for simple, monocolored, materials.
static void loadMetaData(nlohmann::json &destination)
Load the material parameter description.
void setColoredByVertexAttrib(bool state) override
Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.
void setConfiguration(const Data::ShaderConfiguration &newConfig, Core::Utils::Index pass=DefaultRenderingPasses::LIGHTING_OPAQUE)
void addConfiguration(const ShaderConfiguration &config)
Core::Utils::optional< ShaderConfiguration > getConfiguration(const std::string &name)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3