Skip to content
Snippets Groups Projects
Commit c2f3684d authored by ZaOniRinku's avatar ZaOniRinku Committed by Mathias Paulin
Browse files

reorganization of premade nodes

parent 2e73c25a
No related branches found
No related tags found
No related merge requests found
Showing
with 381 additions and 208 deletions
...@@ -43,7 +43,7 @@ using namespace Ra::Core::Utils; // for LOG( logLEVEL ) ...@@ -43,7 +43,7 @@ using namespace Ra::Core::Utils; // for LOG( logLEVEL )
#include <Engine/Data/ShaderConfigFactory.hpp> #include <Engine/Data/ShaderConfigFactory.hpp>
#include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/DifferenceNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp>
template <typename T> template <typename T>
class NodeCreator class NodeCreator
......
...@@ -32,19 +32,24 @@ set(sources ...@@ -32,19 +32,24 @@ set(sources
RadiumNBR/Renderer/FakeNBRRenderer.cpp RadiumNBR/Renderer/FakeNBRRenderer.cpp
RadiumNBR/Renderer/NodeGraphController.cpp RadiumNBR/Renderer/NodeGraphController.cpp
RadiumNBR/NodeGraph/PremadeNodes/AccessibilityBufferNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/DisplaySinkNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/EmissivityNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/ClearColorNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/EnvLightNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/LocalLightNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/TextureNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/TransparencyNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/UINode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/VolumeNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.cpp
RadiumNBR/NodeGraph/PremadeNodes/VolumeVizualisationNode.cpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/WireframeNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/ZGeomPrepassNode.cpp RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.cpp
RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.cpp
RadiumNBR/NodeGraph/RenderGraph.cpp RadiumNBR/NodeGraph/RenderGraph.cpp
RadiumNBR/NodeGraph/NodeFactory.cpp RadiumNBR/NodeGraph/NodeFactory.cpp
...@@ -84,29 +89,36 @@ set(public_headers ...@@ -84,29 +89,36 @@ set(public_headers
RadiumNBR/NodeGraph/RenderGraph.hpp RadiumNBR/NodeGraph/RenderGraph.hpp
RadiumNBR/NodeGraph/NodeFactory.hpp RadiumNBR/NodeGraph/NodeFactory.hpp
RadiumNBR/NodeGraph/PremadeNodes/AccessibilityBufferNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/ClearColorNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/EmissivityNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/EnvLightNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/DataNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/LocalLightNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/TransparencyNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/VolumeNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/VolumeVizualisationNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/FilterNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.hpp
RadiumNBR/NodeGraph/PremadeNodes/FilterROByNameNode.hpp RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/FilterROByTypeNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/SinkNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/SourceNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/ColorTextureNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/DepthTextureNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/TextureNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/ZGeomPrepassNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/UINode.hpp RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/WireframeNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/DisplaySinkNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/Demo/DifferenceNode.hpp
RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp
# MULTI PASS # MULTI PASS
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "ConnectionStatusData.hpp" #include "ConnectionStatusData.hpp"
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterROByNameNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
#include <iostream> #include <iostream>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "ConnectionStatusData.hpp" #include "ConnectionStatusData.hpp"
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterROByTypeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
#include <iostream> #include <iostream>
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp>
#include <RadiumNBR/NodeGraph/Node.hpp> #include <RadiumNBR/NodeGraph/Node.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DataNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DisplaySinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp>
#include <RadiumNBR/Gui/RendererPanel.hpp> #include <RadiumNBR/Gui/RendererPanel.hpp>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/ColorTextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
#include <iostream> #include <iostream>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "ConnectionStatusData.hpp" #include "ConnectionStatusData.hpp"
#include <RadiumNBR/NodeGraph/PremadeNodes/DepthTextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
#include <iostream> #include <iostream>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <nodes/NodeDataModel> #include <nodes/NodeDataModel>
#include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/SourceNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
template <typename T> template <typename T>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/NodeBasedRendererMacro.hpp>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DisplaySinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp>
#include <Core/Resources/Resources.hpp> #include <Core/Resources/Resources.hpp>
#include <Engine/Rendering/Renderer.hpp> #include <Engine/Rendering/Renderer.hpp>
......
#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp>
DifferenceNode::DifferenceNode( const std::string& name ) : Node( name ) {
auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this );
addInput( portInColor1 );
portInColor1->mustBeLinked();
auto portInColor2 = new PortIn<NodeTypeTexture>( "inColorTexture2", this );
addInput( portInColor2 );
portInColor2->mustBeLinked();
Ra::Engine::Data::TextureParameters colorTexParams = { "Color Texture",
gl::GL_TEXTURE_2D,
1,
1,
1,
gl::GL_RGBA,
gl::GL_RGBA32F,
gl::GL_FLOAT,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_LINEAR,
gl::GL_LINEAR,
nullptr };
m_colorTexture = new Ra::Engine::Data::Texture( colorTexParams );
auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
addOutput( portOutColorTex, m_colorTexture );
}
void DifferenceNode::init() {
m_framebuffer = new globjects::Framebuffer();
Ra::Core::Geometry::TriangleMesh mesh =
Ra::Core::Geometry::makeZNormalQuad( Ra::Core::Vector2( -1.f, 1.f ) );
auto qm = std::make_unique<Ra::Engine::Data::Mesh>( "caller" );
qm->loadGeometry( std::move( mesh ) );
m_quadMesh = std::move( qm );
m_quadMesh->updateGL();
const std::string composeVertexShader{ "layout (location = 0) in vec3 in_position;\n"
"out vec2 varTexcoord;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(in_position, 1.0);\n"
" varTexcoord = (in_position.xy + 1.0) * 0.5;\n"
"}\n" };
const std::string composeFragmentShader{
"layout (location = 0) out vec4 out_tex;\n"
"uniform sampler2D tex1_sampler;\n"
"uniform sampler2D tex2_sampler;\n"
"in vec2 varTexcoord;\n"
"void main() {\n"
" out_tex = texture(tex1_sampler, varTexcoord) - texture(tex2_sampler, varTexcoord);\n"
"}" };
Ra::Engine::Data::ShaderConfiguration config{ "ComposeDifference" };
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader );
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT,
composeFragmentShader );
auto added = m_shaderMngr->addShaderProgram( config );
if ( added ) { m_shader = added.value(); }
}
void DifferenceNode::update() {}
void DifferenceNode::execute() {
Ra::Engine::Data::RenderParameters inPassParams;
// Texture 1
auto inputColor1 = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() );
NodeTypeTexture* texColor1 = &inputColor1->getData();
// Texture 2
auto inputColor2 = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() );
NodeTypeTexture* texColor2 = &inputColor2->getData();
m_framebuffer->bind();
m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() );
const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 };
gl::glDrawBuffers( 1, buffers );
gl::glDisable( gl::GL_DEPTH_TEST );
gl::glDepthMask( gl::GL_FALSE );
gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE );
float clearBlack[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
gl::glClearBufferfv( gl::GL_COLOR, 0, clearBlack );
gl::glDisable( gl::GL_BLEND );
m_shader->bind();
m_shader->setUniform( "tex1_sampler", texColor1, 0 );
m_shader->setUniform( "tex2_sampler", texColor2, 1 );
m_quadMesh->render( m_shader );
m_framebuffer->detach( gl::GL_COLOR_ATTACHMENT0 );
m_framebuffer->unbind();
}
void DifferenceNode::destroy() {
delete m_framebuffer;
delete m_colorTexture;
}
void DifferenceNode::resize( uint32_t width, uint32_t height ) {
m_colorTexture->resize( width, height );
}
void DifferenceNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const {}
\ No newline at end of file
#pragma once
#include <RadiumNBR/NodeGraph/Node.hpp>
#include <globjects/Framebuffer.h>
#include <Core/Geometry/MeshPrimitives.hpp>
#include <Engine/Data/Mesh.hpp>
#include <Engine/Data/RenderParameters.hpp>
class NodeBasedRenderer_LIBRARY_API DifferenceNode : public Node
{
public:
explicit DifferenceNode( const std::string& name );
void init() override;
void update() override;
void execute() override;
void destroy() override;
void resize( uint32_t width, uint32_t height ) override;
void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const override;
static const std::string getTypename() { return "Difference"; }
private:
Ra::Engine::Data::Texture* m_colorTexture{ nullptr };
std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr };
const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr };
globjects::Framebuffer* m_framebuffer{ nullptr };
};
#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp>
SumNode::SumNode( const std::string& name ) : Node( name ) {
auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this );
addInput( portInColor1 );
portInColor1->mustBeLinked();
auto portInColor2 = new PortIn<NodeTypeTexture>( "inColorTexture2", this );
addInput( portInColor2 );
portInColor2->mustBeLinked();
Ra::Engine::Data::TextureParameters colorTexParams = { "Color Texture",
gl::GL_TEXTURE_2D,
1,
1,
1,
gl::GL_RGBA,
gl::GL_RGBA32F,
gl::GL_FLOAT,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_LINEAR,
gl::GL_LINEAR,
nullptr };
m_colorTexture = new Ra::Engine::Data::Texture( colorTexParams );
auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
addOutput( portOutColorTex, m_colorTexture );
}
void SumNode::init() {
m_framebuffer = new globjects::Framebuffer();
Ra::Core::Geometry::TriangleMesh mesh =
Ra::Core::Geometry::makeZNormalQuad( Ra::Core::Vector2( -1.f, 1.f ) );
auto qm = std::make_unique<Ra::Engine::Data::Mesh>( "caller" );
qm->loadGeometry( std::move( mesh ) );
m_quadMesh = std::move( qm );
m_quadMesh->updateGL();
const std::string composeVertexShader{ "layout (location = 0) in vec3 in_position;\n"
"out vec2 varTexcoord;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(in_position, 1.0);\n"
" varTexcoord = (in_position.xy + 1.0) * 0.5;\n"
"}\n" };
const std::string composeFragmentShader{
"layout (location = 0) out vec4 out_tex;\n"
"uniform sampler2D tex1_sampler;\n"
"uniform sampler2D tex2_sampler;\n"
"in vec2 varTexcoord;\n"
"void main() {\n"
" out_tex = texture(tex1_sampler, varTexcoord) + texture(tex2_sampler, varTexcoord);\n"
"}" };
Ra::Engine::Data::ShaderConfiguration config{ "ComposeSum" };
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader );
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT,
composeFragmentShader );
auto added = m_shaderMngr->addShaderProgram( config );
if ( added ) { m_shader = added.value(); }
}
void SumNode::update() {}
void SumNode::execute() {
Ra::Engine::Data::RenderParameters inPassParams;
// Texture 1
auto inputColor1 = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() );
NodeTypeTexture* texColor1 = &inputColor1->getData();
// Texture 2
auto inputColor2 = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() );
NodeTypeTexture* texColor2 = &inputColor2->getData();
m_framebuffer->bind();
m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() );
const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 };
gl::glDrawBuffers( 1, buffers );
gl::glDisable( gl::GL_DEPTH_TEST );
gl::glDepthMask( gl::GL_FALSE );
gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE );
float clearBlack[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
gl::glClearBufferfv( gl::GL_COLOR, 0, clearBlack );
gl::glDisable( gl::GL_BLEND );
m_shader->bind();
m_shader->setUniform( "tex1_sampler", texColor1, 0 );
m_shader->setUniform( "tex2_sampler", texColor2, 1 );
m_quadMesh->render( m_shader );
m_framebuffer->detach( gl::GL_COLOR_ATTACHMENT0 );
m_framebuffer->unbind();
}
void SumNode::destroy() {
delete m_framebuffer;
delete m_colorTexture;
}
void SumNode::resize( uint32_t width, uint32_t height ) {
m_colorTexture->resize( width, height );
}
void SumNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const {}
#pragma once
#include <RadiumNBR/NodeGraph/Node.hpp>
#include <globjects/Framebuffer.h>
#include <Core/Geometry/MeshPrimitives.hpp>
#include <Engine/Data/Mesh.hpp>
#include <Engine/Data/RenderParameters.hpp>
class NodeBasedRenderer_LIBRARY_API SumNode : public Node
{
public:
explicit SumNode( const std::string& name );
void init() override;
void update() override;
void execute() override;
void destroy() override;
void resize( uint32_t width, uint32_t height ) override;
void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const override;
static const std::string getTypename() { return "Sum"; }
private:
Ra::Engine::Data::Texture* m_colorTexture{ nullptr };
std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr };
const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr };
globjects::Framebuffer* m_framebuffer{ nullptr };
};
#pragma once
#include <RadiumNBR/NodeGraph/Node.hpp>
#include <globjects/Framebuffer.h>
#include <Core/Geometry/MeshPrimitives.hpp>
#include <Engine/Data/Mesh.hpp>
#include <Engine/Data/RenderParameters.hpp>
class NodeBasedRenderer_LIBRARY_API DifferenceNode : public Node
{
public:
explicit DifferenceNode( const std::string& name ) : Node( name ) {
auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this );
addInput( portInColor1 );
portInColor1->mustBeLinked();
auto portInColor2 = new PortIn<NodeTypeTexture>( "inColorTexture2", this );
addInput( portInColor2 );
portInColor2->mustBeLinked();
Ra::Engine::Data::TextureParameters colorTexParams = { "Color Texture",
gl::GL_TEXTURE_2D,
1,
1,
1,
gl::GL_RGBA,
gl::GL_RGBA32F,
gl::GL_FLOAT,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_CLAMP_TO_EDGE,
gl::GL_LINEAR,
gl::GL_LINEAR,
nullptr };
m_colorTexture = new Ra::Engine::Data::Texture( colorTexParams );
auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
addOutput( portOutColorTex, m_colorTexture );
}
void init() override {
m_framebuffer = new globjects::Framebuffer();
Ra::Core::Geometry::TriangleMesh mesh =
Ra::Core::Geometry::makeZNormalQuad( Ra::Core::Vector2( -1.f, 1.f ) );
auto qm = std::make_unique<Ra::Engine::Data::Mesh>( "caller" );
qm->loadGeometry( std::move( mesh ) );
m_quadMesh = std::move( qm );
m_quadMesh->updateGL();
const std::string composeVertexShader{ "layout (location = 0) in vec3 in_position;\n"
"out vec2 varTexcoord;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(in_position, 1.0);\n"
" varTexcoord = (in_position.xy + 1.0) * 0.5;\n"
"}\n" };
const std::string composeFragmentShader{
"layout (location = 0) out vec4 out_diff;\n"
"uniform sampler2D tex1_sampler;\n"
"uniform sampler2D tex2_sampler;\n"
"in vec2 varTexcoord;\n"
"void main() {\n"
" out_diff = texture(tex1_sampler, varTexcoord) - texture(tex2_sampler, varTexcoord);\n"
"}" };
Ra::Engine::Data::ShaderConfiguration config{ "ComposeDifference" };
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX,
composeVertexShader );
config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT,
composeFragmentShader );
auto added = m_shaderMngr->addShaderProgram( config );
if ( added ) { m_shader = added.value(); }
}
void update() override {}
void execute() override {
Ra::Engine::Data::RenderParameters inPassParams;
// Texture 1
auto inputColor1 =
dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() );
NodeTypeTexture* texColor1 = &inputColor1->getData();
// Texture 2
auto inputColor2 = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() );
NodeTypeTexture* texColor2 = &inputColor2->getData();
m_framebuffer->bind();
m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() );
const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 };
gl::glDrawBuffers( 1, buffers );
gl::glDisable( gl::GL_DEPTH_TEST );
gl::glDepthMask( gl::GL_FALSE );
gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE );
float clearBlack[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
gl::glClearBufferfv( gl::GL_COLOR, 0, clearBlack );
gl::glDisable( gl::GL_BLEND );
m_shader->bind();
m_shader->setUniform( "tex1_sampler", texColor1, 0 );
m_shader->setUniform( "tex2_sampler", texColor2, 1 );
m_quadMesh->render( m_shader );
m_framebuffer->detach( gl::GL_COLOR_ATTACHMENT0 );
m_framebuffer->unbind();
}
void destroy() override {
delete m_framebuffer;
delete m_colorTexture;
}
void resize( uint32_t width, uint32_t height ) override {
m_colorTexture->resize( width, height );
}
void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro,
Ra::Engine::Rendering::RenderTechnique& rt ) const override {
}
static const std::string getTypename() { return "Difference"; }
private:
Ra::Engine::Data::Texture* m_colorTexture{ nullptr };
std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr };
const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr };
globjects::Framebuffer* m_framebuffer{ nullptr };
};
#pragma once #pragma once
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp>
#include <regex> #include <regex>
class FilterROByNameNode : public FilterNode<NodeTypeRenderObject> { class FilterROByNameNode : public FilterNode<NodeTypeRenderObject> {
......
#pragma once #pragma once
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp>
#include <Engine/Data/Material.hpp> #include <Engine/Data/Material.hpp>
class FilterROByTypeNode : public FilterNode<NodeTypeRenderObject> class FilterROByTypeNode : public FilterNode<NodeTypeRenderObject>
......
#pragma once #pragma once
#include <RadiumNBR/NodeGraph/PremadeNodes/AccessibilityBufferNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/ClearColorNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DataNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DisplaySinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/EmissivityNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/EnvLightNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterROByNameNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/FilterROByTypeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/LocalLightNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/SinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/SourceNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/ColorTextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/DepthTextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/TextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/TransparencyNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/UINode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/VolumeNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/VolumeVizualisationNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/WireframeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/ZGeomPrepassNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/DifferenceNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp>
\ No newline at end of file #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp>
#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp>
\ No newline at end of file
#include <RadiumNBR/NodeGraph/PremadeNodes/AccessibilityBufferNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp>
#include <Core/Geometry/MeshPrimitives.hpp> #include <Core/Geometry/MeshPrimitives.hpp>
#include <Engine/Data/Mesh.hpp> #include <Engine/Data/Mesh.hpp>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment