Skip to content
Snippets Groups Projects
Commit a554adbb authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

Experiment on the volume rendering shaders from Radium.

parent c8cff983
Branches
No related tags found
No related merge requests found
Pipeline #358 passed
......@@ -178,6 +178,9 @@ void VolumeLightingPass::execute( const Ra::Engine::Data::ViewingParameters& vie
GL_ASSERT( glDisable( GL_BLEND ) );
}
// for now, Radium shaders need a light source with the right emission power. Volume gets
// dark when rendered with headlight. So, we use or own shaders that multitply by 100 the source color
//#define USE_RADIUM_VOLUMETRIC_SHADERS
bool VolumeLightingPass::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const {
std::string resourcesRootDir = getResourcesDir();
......@@ -185,6 +188,10 @@ bool VolumeLightingPass::buildRenderTechnique( const Ra::Engine::Rendering::Rend
// Only volumes are used by this pass
if ( mat->getMaterialAspect() != Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY )
{ return false; }
#ifdef USE_RADIUM_VOLUMETRIC_SHADERS
auto passconfig = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( "Volumetric" );
rt.setConfiguration( *passconfig, passIndex() );
#else
if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration(
{"VolumeLightingPass::" + mat->getMaterialName()} ) )
{ rt.setConfiguration( *cfg, passIndex() ); }
......@@ -205,6 +212,7 @@ bool VolumeLightingPass::buildRenderTechnique( const Ra::Engine::Rendering::Rend
// Add to the RenderTechniq
rt.setConfiguration( theConfig, passIndex() );
}
#endif
rt.setParametersProvider( mat, passIndex() );
return true;
......
......@@ -25,9 +25,6 @@ namespace RadiumNBR {
class VolumeLightingPass : public RenderPass
{
public:
using RGBSpectrum = std::array<float, 3>; // pbrt::Spectrum
using TransferMatrix = std::vector<RGBSpectrum>;
VolumeLightingPass( const std::vector<RenderObjectPtr>* objectsToRender,
const Ra::Core::Utils::Index& idx );
~VolumeLightingPass() override;
......
......@@ -121,7 +121,7 @@ vec3 inscatter(Material volume, vec3 p, vec3 dir, Light l) {
vec3 dirLight = getLightDirection(l, p);
return Inv4Pi*volume.sigma_s.rgb * phaseHG(dot(dir, dirLight), volume.g) * lightColor(volume, p, l);
}
#endif
#endif
/* ---------------------------------------------------------------------------------------- */
/*
......@@ -201,6 +201,7 @@ void main() {
}
// compute the light information in canonical space
Light l = transformLight(light, material.modelToDensity * world2model );
l.color.rgb *= 100;
switch (light.type) {
case 0: break;
case 1: l.point.position/= texSize;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment