SO3Engine
|
SO3HdrHandler.cpp
Go to the documentation of this file.
39 const Ogre::RenderSystemCapabilities* caps = SRoot::getSingleton().GetOgreRenderSystem()->getCapabilities();
44 (caps->isShaderProfileSupported("ps_3_0") || caps->isShaderProfileSupported("ps_4_0") || (caps->isShaderProfileSupported("arbfp1")) || (caps->isShaderProfileSupported("glsles")) || (caps->isShaderProfileSupported("glsl300es")));
51 inputCompositorInstance = ogreCompositorManager->addCompositor(targetViewport->GetOgreViewPortPointer(), std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr");
71 ogreCompositorManager->removeCompositor(targetViewport->GetOgreViewPortPointer(), std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr");
75 Ogre::CompositorChain* compositorChain = ogreCompositorManager->getCompositorChain(targetViewport->GetOgreViewPortPointer());
97 if (!targetViewport->UpdateStereoCompositorState(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr", isEnable))
98 ogreCompositorManager->setCompositorEnabled(targetViewport->GetOgreViewPortPointer(), std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr", isEnable);
124 Ogre::StringVector resourceGroups = Ogre::ResourceGroupManager::getSingletonPtr()->getResourceGroups();
125 if(std::find(resourceGroups.begin(), resourceGroups.end(), SO3_INTERNAL_RESOURCE_GROUP) == resourceGroups.end())
126 Ogre::ResourceGroupManager::getSingletonPtr()->createResourceGroup(SO3_INTERNAL_RESOURCE_GROUP);
128 // Generate a compositor that will render the scene (without transparent objects), and will old a texture to the blurred SSAO
139 Ogre::CompositorPtr hdrCompositor = ogreCompositorManager->create(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr", SO3_INTERNAL_RESOURCE_GROUP);
143 hdrCompositionTechnique->setCompositorLogicName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Logic");
152 Ogre::CompositionTechnique::TextureDefinition* previousTexture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/Previous");
157 Ogre::CompositionTargetPass* compositionTargetPrevious = hdrCompositionTechnique->createTargetPass();
159 compositionTargetPrevious->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/Previous");
167 Ogre::CompositionTechnique::TextureDefinition* lum4Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum4");
172 Ogre::CompositionTechnique::TextureDefinition* lum3Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum3");
177 Ogre::CompositionTechnique::TextureDefinition* lum2Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum2");
182 Ogre::CompositionTechnique::TextureDefinition* lum1Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum1");
187 Ogre::CompositionTechnique::TextureDefinition* lum0Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum0");
193 Ogre::CompositionTargetPass* compositionTargetLum4 = hdrCompositionTechnique->createTargetPass();
195 compositionTargetLum4->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum4");
201 compositionTargetLum4QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/Previous");
205 Ogre::CompositionTargetPass* compositionTargetLum3 = hdrCompositionTechnique->createTargetPass();
207 compositionTargetLum3->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum3");
213 compositionTargetLum3QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum4");
217 Ogre::CompositionTargetPass* compositionTargetLum2 = hdrCompositionTechnique->createTargetPass();
219 compositionTargetLum2->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum2");
225 compositionTargetLum2QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum3");
229 Ogre::CompositionTargetPass* compositionTargetLum1 = hdrCompositionTechnique->createTargetPass();
231 compositionTargetLum1->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum1");
237 compositionTargetLum1QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum2");
241 Ogre::CompositionTargetPass* compositionTargetLum0 = hdrCompositionTechnique->createTargetPass();
243 compositionTargetLum0->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum0");
249 compositionTargetLum0QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/lum1");
253 Ogre::CompositionTechnique::TextureDefinition* adaptLastlumTexture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptLastLum");
258 Ogre::CompositionTechnique::TextureDefinition* adaptedlumTexture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptedLum");
263 Ogre::CompositionTargetPass* compositionTargetAdaptLastLum = hdrCompositionTechnique->createTargetPass();
265 compositionTargetAdaptLastLum->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptLastLum");
268 Ogre::CompositionPass* compositionTargetAdaptLastLumQuadPass = compositionTargetAdaptLastLum->createPass();
271 compositionTargetAdaptLastLumQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptedLum");
273 Ogre::CompositionTargetPass* compositionTargetAdaptedLum = hdrCompositionTechnique->createTargetPass();
275 compositionTargetAdaptedLum->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptedLum");
278 Ogre::CompositionPass* compositionTargetAdaptedLumQuadPass = compositionTargetAdaptedLum->createPass();
281 compositionTargetAdaptedLumQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/lum0");
282 compositionTargetAdaptedLumQuadPass->setInput(1, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptLastLum");
285 Ogre::CompositionTechnique::TextureDefinition* keyTexture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/key");
290 Ogre::CompositionTargetPass* compositionTargetKey = hdrCompositionTechnique->createTargetPass();
292 compositionTargetKey->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/key");
298 compositionTargetKeyQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/lum0");
304 Ogre::CompositionTechnique::TextureDefinition* brightPassTexture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/brightpass");
309 Ogre::CompositionTargetPass* compositionTargetBrightPass = hdrCompositionTechnique->createTargetPass();
311 compositionTargetBrightPass->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/brightpass");
314 Ogre::CompositionPass* compositionTargetBrightQuadPass = compositionTargetBrightPass->createPass();
317 compositionTargetBrightQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/Previous");
318 compositionTargetBrightQuadPass->setInput(1, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/adaptedLum");
319 compositionTargetBrightQuadPass->setInput(2, std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Hdr/Input/Texture/key");
323 Ogre::CompositionTechnique::TextureDefinition* bloom0Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom0");
328 Ogre::CompositionTechnique::TextureDefinition* bloom1Texture = hdrCompositionTechnique->createTextureDefinition(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom1");
334 Ogre::CompositionTargetPass* compositionTargetBloom1 = hdrCompositionTechnique->createTargetPass();
336 compositionTargetBloom1->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom1");
342 compositionTargetBloom1QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/brightpass");
346 Ogre::CompositionTargetPass* compositionTargetBloom0 = hdrCompositionTechnique->createTargetPass();
348 compositionTargetBloom0->setOutputName(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom0");
354 compositionTargetBloom0QuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom1");
358 Ogre::CompositionTargetPass* compositionOutTarget = hdrCompositionTechnique->getOutputTargetPass();
367 compositionOutTargetQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/Previous");
368 compositionOutTargetQuadPass->setInput(1, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/bloom0");
369 compositionOutTargetQuadPass->setInput(2, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/adaptedLum");
370 compositionOutTargetQuadPass->setInput(3, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/key");
374 //compositionOutTargetQuadPass->setInput(0, std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Input/Texture/brightpass");
379 compMgr.registerCompositorLogic(std::string(SO3_INTERNAL_RESOURCE_GROUP)+"/Hdr/Logic", new SHdrLogic);
383Ogre::CompositorInstance::Listener* SHdrLogic::createListener(Ogre::CompositorInstance* instance)
402 Ogre::CompositionTechnique::TextureDefinitions defList = instance->getTechnique()->getTextureDefinitions();
420 mBloomTexWeights[0][0] = mBloomTexWeights[0][1] = mBloomTexWeights[0][2] = Ogre::Math::gaussianDistribution(0, 0, deviation);
426 mBloomTexWeights[i][0] = mBloomTexWeights[i][1] = mBloomTexWeights[i][2] = 1.25f * Ogre::Math::gaussianDistribution((float)i, 0, deviation);
436 mBloomTexWeights[i][0] = mBloomTexWeights[i][1] = mBloomTexWeights[i][2] = mBloomTexWeights[i - 7][0];
464 Ogre::GpuProgramParametersSharedPtr fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
Definition SO3HdrHandler.h:134
void notifyCompositor(Ogre::CompositorInstance *instance)
Definition SO3HdrHandler.cpp:399
virtual void notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
Definition SO3HdrHandler.cpp:448
float mBloomTexOffsetsVert[15][4]
Definition SO3HdrHandler.h:150
virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
Definition SO3HdrHandler.cpp:485
float mBloomTexOffsetsHorz[15][4]
Definition SO3HdrHandler.h:149
virtual Ogre::CompositorInstance::Listener * createListener(Ogre::CompositorInstance *instance)
Definition SO3HdrHandler.cpp:383
bool GetRttPixelFormat(Ogre::PixelFormat &format, bool alpha=false, bool floattex=false)
Definition SO3Root.cpp:650
Definition SO3ViewPort.h:56
Ogre::Viewport * GetOgreViewPortPointer()
Definition SO3ViewPort.cpp:98
bool UpdateStereoCompositorState(const Ogre::String compname, bool state)
Definition SO3ViewPort.cpp:299
Definition SO3DataScol.h:38
Generated by 1.9.8