-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDeferredLightCP.h
78 lines (60 loc) · 2.44 KB
/
DeferredLightCP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html
You may use this sample code for anything you like, it is not covered by the
same license as the rest of the engine.
-----------------------------------------------------------------------------
*/
#ifndef _DEFERRED_LIGHT_CP_H
#define _DEFERRED_LIGHT_CP_H
#include "OgreCompositorInstance.h"
#include "OgreCustomCompositionPass.h"
#include "DLight.h"
#include "MaterialGenerator.h"
#include "AmbientLight.h"
//The render operation that will be called each frame in the custom composition pass
//This is the class that will send the actual render calls of the spheres (point lights),
//cones (spotlights) and quads (directional lights) after the GBuffer has been constructed
class DeferredLightRenderOperation : public Ogre::CompositorInstance::RenderSystemOperation
{
public:
DeferredLightRenderOperation(Ogre::CompositorInstance* instance, const Ogre::CompositionPass* pass);
/** @copydoc CompositorInstance::RenderSystemOperation::execute */
virtual void execute(Ogre::SceneManager *sm, Ogre::RenderSystem *rs);
virtual ~DeferredLightRenderOperation();
private:
/** Create a new deferred light
*/
DLight *createDLight(Ogre::Light* light);
//The texture names of the GBuffer components
Ogre::String mTexName0;
Ogre::String mTexName1;
//The material generator for the light geometry
MaterialGenerator* mLightMaterialGenerator;
//The map of deferred light geometries already constructed
typedef std::map<Ogre::Light*, DLight*> LightsMap;
LightsMap mLights;
//The ambient light used to render the scene
AmbientLight* mAmbientLight;
//The viewport that we are rendering to
Ogre::Viewport* mViewport;
};
//The custom composition pass that is used for rendering the light geometry
//This class needs to be registered with the CompositorManager
class DeferredLightCompositionPass : public Ogre::CustomCompositionPass
{
public:
/** @copydoc CustomCompositionPass::createOperation */
virtual Ogre::CompositorInstance::RenderSystemOperation* createOperation(
Ogre::CompositorInstance* instance, const Ogre::CompositionPass* pass)
{
return OGRE_NEW DeferredLightRenderOperation(instance, pass);
}
protected:
virtual ~DeferredLightCompositionPass() {}
};
#endif