Project

General

Profile

SO3Engine
SO3DeferredCompositorGBuffer.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
28
29namespace SO3
30{
31
35
36Ogre::CompositorPtr SDeferredCompositorGBuffer::GenerateCompositor(SGBuffer* gBuffer)
37{
38 Ogre::String compoName = "SO3/Deferred/Compositor/GBuffer/"+ gBuffer->GetName();
39
40 // Create compo
41 Ogre::CompositorPtr compositor = Ogre::CompositorManager::getSingleton().create(compoName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
42
43 // Clear the technique
44 Ogre::CompositionTechnique* compositionTechnique = compositor->createTechnique();
45 compositionTechnique->removeAllTargetPasses();
46 compositionTechnique->removeAllTextureDefinitions();
47
48 // Create mrt rtts
49 Ogre::CompositionTechnique::TextureDefinition* gBufferTexture = compositionTechnique->createTextureDefinition("mrt_output");
50 gBufferTexture->width = 0;
51 gBufferTexture->height = 0;
52 Ogre::PixelFormatList pixelFormatList;
53 unsigned int numberMrt = gBuffer->GetNumberMrt();
54 for(unsigned int i = 0; i<numberMrt; i++)
55 pixelFormatList.push_back(Ogre::PF_FLOAT16_RGBA);
56 gBufferTexture->formatList = pixelFormatList;
57 gBufferTexture->scope = Ogre::CompositionTechnique::TS_CHAIN;
58
59 // Create the output target
60 Ogre::CompositionTargetPass* compositionTargetPass = compositionTechnique->createTargetPass();
61 compositionTargetPass->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
62 compositionTargetPass->setOutputName("mrt_output");
63
64 // Create a "clear" pass on the target
65 Ogre::CompositionPass* compositionPass = compositionTargetPass->createPass();
66 compositionPass->setType(Ogre::CompositionPass::PT_CLEAR);
67
68 // Further configuration on the target
69 compositionTargetPass->setShadowsEnabled(false);
70 compositionTargetPass->setMaterialScheme("GBuffer");
71
72 // Create the GBuffer render pass
73 compositionPass = compositionTargetPass->createPass();
74 compositionPass->setType(Ogre::CompositionPass::PT_RENDERSCENE);
75 compositionPass->setFirstRenderQueue(SDeferredShading::PRE_GBUFFER_RENDER_QUEUE);
76 compositionPass->setLastRenderQueue(SDeferredShading::POST_GBUFFER_RENDER_QUEUE - 1);
77
78 // Compositor is created!
79 return compositor;
80}
81
82}
std::string GetName() const
static const Ogre::uint8 PRE_GBUFFER_RENDER_QUEUE
static const Ogre::uint8 POST_GBUFFER_RENDER_QUEUE
unsigned int GetNumberMrt() const