SO3Engine
SO3GBufferLow.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
26
27namespace SO3
28{
29
37
38Ogre::String SGBufferLow::GetGBufferMaterialPixelOutputStructureTypeNameImpl()
39{
40 return "SO3_GBufferLow_PixelShaderOutput";
41}
42
43Ogre::String SGBufferLow::GetGBufferCompositorPixelInputStructureTypeNameImpl()
44{
45 return "SO3_GBufferLow_PixelShaderInput";
46}
47
48Ogre::String SGBufferLow::GenerateGBufferMaterialPixelOutputStructureImpl()
49{
50 Ogre::StringStream ss;
51
52 // Minimal GBuffer for basic usage or low spec machine (Only 2 mrt used).
53 // Specular color is approximated with shininess power.
54 ss << "struct SO3_GBufferLow_PixelShaderOutput : I_GBufferPixelShaderOutput" << std::endl;
55 ss << "{" << std::endl;
56 ss << " float4 mrt0 : COLOR0; // Diffuse (rgb) + Shininess power (a)" << std::endl;
57 ss << " float4 mrt1 : COLOR1; // Normal (rgb) + Depth (a)" << std::endl;
58
59 // Initialize output to default values
60 ss << " void Reset()" << std::endl;
61 ss << " {" << std::endl;
62 ss << " mrt0 = float4(0, 0, 0, 0);" << std::endl;
63 ss << " mrt1 = float4(0, 0, 0, 0);" << std::endl;
64 ss << " }" << std::endl;
65
66 // Get the diffuse term
67 ss << " float3 GetDiffuse()" << std::endl;
68 ss << " {" << std::endl;
69 ss << " return mrt0.rgb;" << std::endl;
70 ss << " }" << std::endl;
71
72 // Set the diffuse term
73 ss << " void SetDiffuse(in float3 diffuse)" << std::endl;
74 ss << " {" << std::endl;
75 ss << " mrt0.rgb = diffuse;" << std::endl;
76 ss << " }" << std::endl;
77
78 // Get the specular term
79 // @remark Not supported by this GBuffer.
80 ss << " float3 GetSpecular()" << std::endl;
81 ss << " {" << std::endl;
82 ss << " return float3(1, 1, 1);" << std::endl;
83 ss << " }" << std::endl;
84
85 // Set the specular term
86 // @remark Not supported by this GBuffer.
87 ss << " void SetSpecular(in float3 specular)" << std::endl;
88 ss << " {" << std::endl;
89 ss << " // Nothing to do" << std::endl;
90 ss << " }" << std::endl;
91
92 // Get the shininess term
93 ss << " float GetShininess()" << std::endl;
94 ss << " {" << std::endl;
95 ss << " return mrt0.a;" << std::endl;
96 ss << " }" << std::endl;
97
98 // Set the shininess term
99 ss << " void SetShininess(in float shininess)" << std::endl;
100 ss << " {" << std::endl;
101 ss << " mrt0.a = shininess;" << std::endl;
102 ss << " }" << std::endl;
103
104 // Get the normal
105 ss << " float3 GetNormal()" << std::endl;
106 ss << " {" << std::endl;
107 ss << " return mrt1.rgb;" << std::endl;
108 ss << " }" << std::endl;
109
110 // Set the normal
111 ss << " void SetNormal(in float3 normal)" << std::endl;
112 ss << " {" << std::endl;
113 ss << " mrt1.rgb = normal;" << std::endl;
114 ss << " }" << std::endl;
115
116 // Get the depth
117 ss << " float GetDepth()" << std::endl;
118 ss << " {" << std::endl;
119 ss << " return mrt1.a;" << std::endl;
120 ss << " }" << std::endl;
121
122 // Set the depth
123 ss << " void SetDepth(in float depth)" << std::endl;
124 ss << " {" << std::endl;
125 ss << " mrt1.a = depth;" << std::endl;
126 ss << " }" << std::endl;
127
128 // Get the emissive term
129 // @remark Not supported by this GBuffer.
130 ss << " float GetEmissive()" << std::endl;
131 ss << " {" << std::endl;
132 ss << " return float(0);" << std::endl;
133 ss << " }" << std::endl;
134
135 // Set the emissive term
136 // @remark Not supported by this GBuffer.
137 ss << " void SetEmissive(in float emissive)" << std::endl;
138 ss << " {" << std::endl;
139 ss << " // Nothing to do" << std::endl;
140 ss << " }" << std::endl;
141
142 // Get the material id
143 // @remark Not supported by this GBuffer.
144 ss << " float GetMaterialID()" << std::endl;
145 ss << " {" << std::endl;
146 ss << " return float(0);" << std::endl;
147 ss << " }" << std::endl;
148
149 // Set the material id term
150 // @remark Not supported by this GBuffer.
151 ss << " void SetMaterialID(in float materialId)" << std::endl;
152 ss << " {" << std::endl;
153 ss << " // Nothing to do" << std::endl;
154 ss << " }" << std::endl;
155
156 // Get the velocity vector
157 // @remark Not supported by this GBuffer.
158 ss << " float2 GetVelocity()" << std::endl;
159 ss << " {" << std::endl;
160 ss << " return float2(0, 0);" << std::endl;
161 ss << " }" << std::endl;
162
163 // Set the velocity vector
164 // @remark Not supported by this GBuffer.
165 ss << " void SetVelocity(in float2 velocity)" << std::endl;
166 ss << " {" << std::endl;
167 ss << " // Nothing to do" << std::endl;
168 ss << " }" << std::endl;
169 ss << "};" << std::endl;
170 ss << std::endl;
171
172 return ss.str();
173}
174
175Ogre::String SGBufferLow::GenerateGBufferCompositorPixelInputStructureImpl()
176{
177 Ogre::StringStream ss;
178
179 // Minimal GBuffer for basic usage or low spec machine (Only 2 mrt used).
180 // "Specular color is approximated with shininess power.
181 ss << "struct SO3_GBufferLow_PixelShaderInput : I_GBufferPixelShaderInput" << std::endl;
182 ss << "{" << std::endl;
183 ss << " uniform sampler2D mrt0 : register(s0); // Diffuse (rgb) + Shininess power (a)" << std::endl;
184 ss << " uniform sampler2D mrt1 : register(s1); // Normal (rgb) + Depth (a)" << std::endl;
185
186 // Get the diffuse term
187 ss << " float3 GetDiffuse(in float2 coordinate)" << std::endl;
188 ss << " {" << std::endl;
189 ss << " return tex2D(mrt0, coordinate).rgb;" << std::endl;
190 ss << " }" << std::endl;
191
192 // Get the specular term
193 // @remark Not supported by this GBuffer.
194 ss << " float3 GetSpecular(in float2 coordinate)" << std::endl;
195 ss << " {" << std::endl;
196 ss << " return float3(0, 0, 0);" << std::endl;
197 ss << " }" << std::endl;
198
199 // Get the shininess term
200 ss << " float GetShininess(in float2 coordinate)" << std::endl;
201 ss << " {" << std::endl;
202 ss << " return tex2D(mrt0, coordinate).a;" << std::endl;
203 ss << " }" << std::endl;
204
205 // Get the normal
206 ss << " float3 GetNormal(in float2 coordinate)" << std::endl;
207 ss << " {" << std::endl;
208 ss << " return tex2D(mrt1, coordinate).rgb;" << std::endl;
209 ss << " }" << std::endl;
210
211 // Get the depth
212 ss << " float GetDepth(in float2 coordinate)" << std::endl;
213 ss << " {" << std::endl;
214 ss << " return tex2D(mrt1, coordinate).a;" << std::endl;
215 ss << " }" << std::endl;
216
217 // Get the emissive term
218 // @remark Not supported by this GBuffer.
219 ss << " float GetEmissive(in float2 coordinate)" << std::endl;
220 ss << " {" << std::endl;
221 ss << " return float(0);" << std::endl;
222 ss << " }" << std::endl;
223
224 // Get the material id
225 // @remark Not supported by this GBuffer.
226 ss << " float GetMaterialID(in float2 coordinate)" << std::endl;
227 ss << " {" << std::endl;
228 ss << " return float(0);" << std::endl;
229 ss << " }" << std::endl;
230
231 // Get the velocity vector
232 // @remark Not supported by this GBuffer.
233 ss << " float2 GetVelocity(in float2 coordinate)" << std::endl;
234 ss << " {" << std::endl;
235 ss << " return float2(0, 0);" << std::endl;
236 ss << " }" << std::endl;
237 ss << "};" << std::endl;
238 ss << std::endl;
239
240 return ss.str();
241}
242
243}
Ogre::uint32 channels
Definition SO3GBuffer.h:53
@ SO3_GBUFFER_SHININESS
Definition SO3GBuffer.h:46