Commit dee1e93f authored by nicoo's avatar nicoo

[WIP] add PostProcessing

- this class should apply a "white" shader on the screen.
parent 105b172f
Pipeline #25966596 passed with stage
in 34 minutes and 22 seconds
......@@ -21,7 +21,7 @@ add_openmw_dir (mwrender
actors objects renderingmanager animation rotatecontroller sky npcanimation vismask
creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation
bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation
renderbin actoranimation landmanager
renderbin actoranimation landmanager postprocessing
)
add_openmw_dir (mwinput
......
#include "postprocessing.hpp"
#include <iostream>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/shader/shadermanager.hpp>
namespace nicoo
{
static void
print(const std::string& body, void* from = nullptr)
{
std::cerr << std::endl;
std::cerr << " *****" << std::endl;
std::cerr << " ** [" << body << "]" << std::endl;
std::cerr << " ** from: " << (from ? from : "nullptr") << std::endl;
std::cerr << " *****" << std::endl;
std::cerr << std::endl;
}
}
namespace MWRender
{
PostProcessing::PostProcessing(Resource::ResourceSystem *resourceSystem)
: mResourceSystem(resourceSystem)
{
nicoo::print("PostProcessing()", static_cast<void*>(this));
updatePostProcessing();
}
PostProcessing::~PostProcessing()
{
nicoo::print("~PostProcessing()", static_cast<void*>(this));
}
void
PostProcessing::TEST()
{
nicoo::print("TEST()", static_cast<void*>(this));
}
void
PostProcessing::updatePostProcessing()
{
nicoo::print("updatePostProcessing()", static_cast<void*>(this));
createShaderPostProcessingStateSet();
}
void
PostProcessing::createShaderPostProcessingStateSet()
{
nicoo::print("createShaderPostProcessingStateSet()", static_cast<void*>(this));
auto& shaderMgr = mResourceSystem->getSceneManager()->getShaderManager();
const char* fragmentSource =
"void main()"
"{"
"gl_FragColor = {1.0, 1.0, 1.0, 1.0};"
"}";
const char* vertexSource =
"void main()"
"{"
"}";
osg::ref_ptr<osg::Shader> fragmentShader = new osg::Shader( osg::Shader::FRAGMENT);
fragmentShader->setShaderSource(fragmentSource);
osg::ref_ptr<osg::Shader> vertexShader = new osg::Shader( osg::Shader::VERTEX);
vertexShader->setShaderSource(vertexSource);
auto program = shaderMgr.getProgram(vertexShader, fragmentShader);
osg::ref_ptr<osg::StateSet> shaderStateset = new osg::StateSet;
shaderStateset->setAttributeAndModes(program, osg::StateAttribute::ON);
}
}
#ifndef OPENMW_MWRENDER_POSTPROCESSING_H
#define OPENMW_MWRENDER_POSTPROCESSING_H
#include <osg/ref_ptr>
namespace Resource
{
class ResourceSystem;
}
namespace MWRender
{
class PostProcessing
{
void updatePostProcessing();
void createShaderPostProcessingStateSet();
Resource::ResourceSystem* mResourceSystem;
public:
PostProcessing(Resource::ResourceSystem* resourceSystem);
~PostProcessing();
void TEST();
};
}
#endif
......@@ -60,6 +60,7 @@
#include "water.hpp"
#include "terrainstorage.hpp"
#include "util.hpp"
#include "postprocessing.hpp"
namespace
{
......@@ -327,6 +328,7 @@ namespace MWRender
mUniformNear = mRootNode->getOrCreateStateSet()->getUniform("near");
mUniformFar = mRootNode->getOrCreateStateSet()->getUniform("far");
updateProjectionMatrix();
mPostProcessing.reset(new PostProcessing(mResourceSystem));
}
RenderingManager::~RenderingManager()
......
......@@ -68,6 +68,7 @@ namespace MWRender
class Water;
class TerrainStorage;
class LandManager;
class PostProcessing;
class RenderingManager : public MWRender::RenderingInterface
{
......@@ -244,6 +245,7 @@ namespace MWRender
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> mPlayerNode;
std::unique_ptr<Camera> mCamera;
osg::Vec3f mCurrentCameraPos;
std::unique_ptr<PostProcessing> mPostProcessing;
osg::ref_ptr<StateUpdater> mStateUpdater;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment