Project

General

Profile

SO3Engine
SO3GBuffer.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
27
28namespace SO3
29{
30
31SGBuffer::SGBuffer(Ogre::String gBufferId, unsigned int gbufferMrtNumber) : SData(gBufferId),
32 numberMrt(gbufferMrtNumber)
33{
35}
36
37SGBuffer::SGBuffer() : SData(""),
38 numberMrt(0)
39{
40 // Forbiden ctor
41}
42
43unsigned int SGBuffer::GetNumberMrt() const
44{
45 return numberMrt;
46}
47
52
54{
55 return GenerateGBufferBaseMaterialPixelOutputStructure() + GenerateGBufferMaterialPixelOutputStructureImpl();
56}
57
62
64{
65 return GenerateGBufferBaseCompositorPixelInputStructure() + GenerateGBufferCompositorPixelInputStructureImpl();
66}
67
68Ogre::String SGBuffer::GenerateGBufferBaseMaterialPixelOutputStructure()
69{
70 Ogre::StringStream ss;
71
72 ss << "/*" << std::endl;
73 ss << "Base interface for GBuffer data ordering abstraction" << std::endl;
74 ss << "*/" << std::endl;
75 ss << "interface I_GBufferPixelShaderOutput" << std::endl;
76 ss << "{" << std::endl;
77 ss << " /*!" << std::endl;
78 ss << " Initialize output to default values" << std::endl;
79 ss << " */" << std::endl;
80 ss << " void Reset();" << std::endl;
81
82 ss << " /*!" << std::endl;
83 ss << " Get the diffuse term" << std::endl;
84 ss << " */" << std::endl;
85 ss << " float3 GetDiffuse();" << std::endl;
86
87 ss << " /*!" << std::endl;
88 ss << " Set the diffuse term" << std::endl;
89 ss << " */" << std::endl;
90 ss << " void SetDiffuse(in float3 diffuse);" << std::endl;
91
92 ss << " /*!" << std::endl;
93 ss << " Get the specular term" << std::endl;
94 ss << " */" << std::endl;
95 ss << " float3 GetSpecular();" << std::endl;
96
97 ss << " /*!" << std::endl;
98 ss << " Set the specular term" << std::endl;
99 ss << " */" << std::endl;
100 ss << " void SetSpecular(in float3 specular);" << std::endl;
101
102 ss << " /*!" << std::endl;
103 ss << " Get the shininess term" << std::endl;
104 ss << " */" << std::endl;
105 ss << " float GetShininess();" << std::endl;
106
107 ss << " /*!" << std::endl;
108 ss << " Set the shininess term" << std::endl;
109 ss << " */" << std::endl;
110 ss << " void SetShininess(in float shininess);" << std::endl;
111
112 ss << " /*!" << std::endl;
113 ss << " Get the normal" << std::endl;
114 ss << " */" << std::endl;
115 ss << " float3 GetNormal();" << std::endl;
116
117 ss << " /*!" << std::endl;
118 ss << " Set the normal" << std::endl;
119 ss << " */" << std::endl;
120 ss << " void SetNormal(in float3 normal);" << std::endl;
121
122 ss << " /*!" << std::endl;
123 ss << " Get the depth" << std::endl;
124 ss << " */" << std::endl;
125 ss << " float GetDepth();" << std::endl;
126
127 ss << " /*!" << std::endl;
128 ss << " Set the depth" << std::endl;
129 ss << " */" << std::endl;
130 ss << " void SetDepth(in float depth);" << std::endl;
131
132 ss << " /*!" << std::endl;
133 ss << " Get the emissive term" << std::endl;
134 ss << " */" << std::endl;
135 ss << " float GetEmissive();" << std::endl;
136
137 ss << " /*!" << std::endl;
138 ss << " Set the emissive term" << std::endl;
139 ss << " */" << std::endl;
140 ss << " void SetEmissive(in float emissive);" << std::endl;
141
142 ss << " /*!" << std::endl;
143 ss << " Get the material id" << std::endl;
144 ss << " */" << std::endl;
145 ss << " float GetMaterialID();" << std::endl;
146
147 ss << " /*!" << std::endl;
148 ss << " Set the material id term" << std::endl;
149 ss << " */" << std::endl;
150 ss << " void SetMaterialID(in float materialId);" << std::endl;
151
152 ss << " /*!" << std::endl;
153 ss << " Get the velocity vector" << std::endl;
154 ss << " */" << std::endl;
155 ss << " float2 GetVelocity();" << std::endl;
156
157 ss << " /*!" << std::endl;
158 ss << " Set the velocity vector" << std::endl;
159 ss << " */" << std::endl;
160 ss << " void SetVelocity(in float2 velocity);" << std::endl;
161 ss << "};" << std::endl;
162 ss << std::endl;
163
164 return ss.str();
165}
166
167Ogre::String SGBuffer::GenerateGBufferBaseCompositorPixelInputStructure()
168{
169 Ogre::StringStream ss;
170
171 ss << "/*" << std::endl;
172 ss << "Base interface for GBuffer data ordering abstraction" << std::endl;
173 ss << "*/" << std::endl;
174 ss << "interface I_GBufferPixelShaderInput" << std::endl;
175 ss << "{" << std::endl;
176
177 ss << " /*!" << std::endl;
178 ss << " Get the diffuse term" << std::endl;
179 ss << " */" << std::endl;
180 ss << " float3 GetDiffuse(in float2 coordinate);" << std::endl;
181
182 ss << " /*!" << std::endl;
183 ss << " Get the specular term" << std::endl;
184 ss << " */" << std::endl;
185 ss << " float3 GetSpecular(in float2 coordinate);" << std::endl;
186
187 ss << " /*!" << std::endl;
188 ss << " Get the shininess term" << std::endl;
189 ss << " */" << std::endl;
190 ss << " float GetShininess(in float2 coordinate);" << std::endl;
191
192 ss << " /*!" << std::endl;
193 ss << " Get the normal" << std::endl;
194 ss << " */" << std::endl;
195 ss << " float3 GetNormal(in float2 coordinate);" << std::endl;
196
197 ss << " /*!" << std::endl;
198 ss << " Get the depth" << std::endl;
199 ss << " */" << std::endl;
200 ss << " float GetDepth(in float2 coordinate);" << std::endl;
201
202 ss << " /*!" << std::endl;
203 ss << " Get the emissive term" << std::endl;
204 ss << " */" << std::endl;
205 ss << " float GetEmissive(in float2 coordinate);" << std::endl;
206
207 ss << " /*!" << std::endl;
208 ss << " Get the material id" << std::endl;
209 ss << " */" << std::endl;
210 ss << " float GetMaterialID(in float2 coordinate);" << std::endl;
211
212 ss << " /*!" << std::endl;
213 ss << " Get the velocity vector" << std::endl;
214 ss << " */" << std::endl;
215 ss << " float2 GetVelocity(in float2 coordinate);" << std::endl;
216
217 ss << "};" << std::endl;
218 ss << std::endl;
219
220 return ss.str();
221}
222
224{
225 assert(channels != SO3_GBUFFER_NONE);
227 return channels;
228}
229
230}
Ogre::uint32 GetChannels()
Ogre::String GenerateGBufferCompositorPixelInputStructure()
Ogre::uint32 channels
Definition SO3GBuffer.h:53
Ogre::String GetGBufferMaterialPixelOutputStructureTypeName()
unsigned int GetNumberMrt() const
Ogre::String GenerateGBufferMaterialPixelOutputStructure()
@ SO3_GBUFFER_MANDATORY_MASK
Definition SO3GBuffer.h:50
virtual Ogre::String GenerateGBufferCompositorPixelInputStructureImpl()=0
virtual Ogre::String GenerateGBufferMaterialPixelOutputStructureImpl()=0
virtual Ogre::String GetGBufferMaterialPixelOutputStructureTypeNameImpl()=0
virtual Ogre::String GetGBufferCompositorPixelInputStructureTypeNameImpl()=0
Ogre::String GetGBufferCompositorPixelInputStructureTypeName()