1#include <Engine/Data/VolumetricMaterial.hpp>
3#include <Engine/Data/ShaderConfigFactory.hpp>
4#include <Engine/Data/ShaderProgramManager.hpp>
5#include <Engine/Data/Texture.hpp>
6#include <Engine/Data/TextureManager.hpp>
7#include <Engine/RadiumEngine.hpp>
8#include <Engine/Rendering/RenderTechnique.hpp>
16static const std::string materialName {
"Volumetric" };
18nlohmann::json VolumetricMaterial::s_parametersMetadata = {};
28 updateRenderingParameters();
33 auto& renderParameters = getParameters();
36 m_g = renderParameters.getVariable<Scalar>(
"material.g" );
37 m_scale = renderParameters.getVariable<Scalar>(
"material.scale" );
38 m_stepsize = renderParameters.getVariable<Scalar>(
"material.stepsize" );
41void VolumetricMaterial::updateRenderingParameters() {
42 auto& renderParameters = getParameters();
43 renderParameters.setVariable(
"material.sigma_a",
m_sigma_a );
44 renderParameters.setVariable(
"material.sigma_s",
m_sigma_s );
45 renderParameters.setVariable(
"material.g",
m_g );
46 renderParameters.setVariable(
"material.scale",
m_scale );
51 renderParameters.setVariable(
"material.stepsize", 1._ra / dim );
53 else { renderParameters.setVariable(
"material.stepsize",
m_stepsize ); }
54 renderParameters.setTexture(
"material.density", m_texture );
55 renderParameters.setVariable(
"material.modelToDensity",
m_modelToMedium.matrix() );
64 auto resourcesRootDir { RadiumEngine::getInstance()->getResourcesDir() };
65 auto shaderProgramManager = RadiumEngine::getInstance()->getShaderProgramManager();
67 shaderProgramManager->addShaderProgram(
68 { {
"ComposeVolume" },
69 resourcesRootDir +
"Shaders/2DShaders/Basic2D.vert.glsl",
70 resourcesRootDir +
"Shaders/Materials/Volumetric/ComposeVolumeRender.frag.glsl" } );
73 shaderProgramManager->addNamedString(
74 "/Volumetric.glsl", resourcesRootDir +
"Shaders/Materials/Volumetric/Volumetric.glsl" );
79 resourcesRootDir +
"Shaders/Materials/Volumetric/Volumetric.vert.glsl",
80 resourcesRootDir +
"Shaders/Materials/Volumetric/Volumetric.frag.glsl" );
86 resourcesRootDir +
"Shaders/Materials/Volumetric/Volumetric.vert.glsl",
87 resourcesRootDir +
"Shaders/Materials/Volumetric/VolumetricOIT.frag.glsl" );
101 Rendering::EngineRenderTechniques::registerDefaultTechnique(
121 Rendering::EngineRenderTechniques::removeDefaultTechnique(
"Volumetric" );
Base class for materials.
bool isDirty()
Return dirty state.
void setClean()
Set dirty state to false.
MaterialAspect
Identifies the type of the material.
static void loadMetaData(const std::string &basename, nlohmann::json &destination)
Load the ParameterSet description.
bool isTransparent() const override
Core::Utils::Color m_sigma_s
Scattering coefficient, default to Air (2.55, 3.21, 3.77)
~VolumetricMaterial() override
static void unregisterMaterial()
Scalar m_scale
Scale factor applied to the absorption and scattering coefficients.
Core::Transform m_modelToMedium
VolumetricMaterial(const std::string &name)
static void registerMaterial()
void updateGL() override
Update the OpenGL states used by the ShaderParameterProvider.
Scalar m_g
phase function assymetry factor, default to 0
Core::Utils::Color m_sigma_a
Absorption coefficient, default to Air (0.0011, 0.0024, 0.014)
void updateFromParameters() override
Update the attributes of the ShaderParameterProvider to their actual values stored in the renderParam...
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