[148] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | |
---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
---|
| 11 | in the Software without restriction, including without limitation the rights |
---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
---|
| 14 | furnished to do so, subject to the following conditions: |
---|
| 15 | |
---|
| 16 | The above copyright notice and this permission notice shall be included in |
---|
| 17 | all copies or substantial portions of the Software. |
---|
| 18 | |
---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 25 | THE SOFTWARE. |
---|
| 26 | ----------------------------------------------------------------------------- |
---|
| 27 | */ |
---|
| 28 | #ifndef __CompositionPass_H__ |
---|
| 29 | #define __CompositionPass_H__ |
---|
| 30 | |
---|
| 31 | #include "OgrePrerequisites.h" |
---|
| 32 | #include "OgreMaterial.h" |
---|
| 33 | #include "OgreRenderSystem.h" |
---|
| 34 | #include "OgreRenderQueue.h" |
---|
| 35 | #include "OgreHeaderPrefix.h" |
---|
| 36 | |
---|
| 37 | namespace Ogre { |
---|
| 38 | /** \addtogroup Core |
---|
| 39 | * @{ |
---|
| 40 | */ |
---|
| 41 | /** \addtogroup Effects |
---|
| 42 | * @{ |
---|
| 43 | */ |
---|
| 44 | /** Object representing one pass or operation in a composition sequence. This provides a |
---|
| 45 | method to conveniently interleave RenderSystem commands between Render Queues. |
---|
| 46 | */ |
---|
| 47 | class _OgreExport CompositionPass : public CompositorInstAlloc |
---|
| 48 | { |
---|
| 49 | public: |
---|
| 50 | CompositionPass(CompositionTargetPass *parent); |
---|
| 51 | ~CompositionPass(); |
---|
| 52 | |
---|
| 53 | /** Enumeration that enumerates the various composition pass types. |
---|
| 54 | */ |
---|
| 55 | enum PassType |
---|
| 56 | { |
---|
| 57 | PT_CLEAR, /// Clear target to one colour |
---|
| 58 | PT_STENCIL, /// Set stencil operation |
---|
| 59 | PT_RENDERSCENE, /// Render the scene or part of it |
---|
| 60 | PT_RENDERQUAD, /// Render a full screen quad |
---|
| 61 | PT_RENDERCUSTOM /// Render a custom sequence |
---|
| 62 | }; |
---|
| 63 | |
---|
| 64 | /** Set the type of composition pass */ |
---|
| 65 | void setType(PassType type); |
---|
| 66 | /** Get the type of composition pass */ |
---|
| 67 | PassType getType() const; |
---|
| 68 | |
---|
| 69 | /** Set an identifier for this pass. This identifier can be used to |
---|
| 70 | "listen in" on this pass with an CompositorInstance::Listener. |
---|
| 71 | */ |
---|
| 72 | void setIdentifier(uint32 id); |
---|
| 73 | /** Get the identifier for this pass */ |
---|
| 74 | uint32 getIdentifier() const; |
---|
| 75 | |
---|
| 76 | /** Set the material used by this pass |
---|
| 77 | @note applies when PassType is RENDERQUAD |
---|
| 78 | */ |
---|
| 79 | void setMaterial(const MaterialPtr& mat); |
---|
| 80 | /** Set the material used by this pass |
---|
| 81 | @note applies when PassType is RENDERQUAD |
---|
| 82 | */ |
---|
| 83 | void setMaterialName(const String &name); |
---|
| 84 | /** Get the material used by this pass |
---|
| 85 | @note applies when PassType is RENDERQUAD |
---|
| 86 | */ |
---|
| 87 | const MaterialPtr& getMaterial() const; |
---|
| 88 | /** Set the first render queue to be rendered in this pass (inclusive) |
---|
| 89 | @note applies when PassType is RENDERSCENE |
---|
| 90 | */ |
---|
| 91 | void setFirstRenderQueue(uint8 id); |
---|
| 92 | /** Get the first render queue to be rendered in this pass (inclusive) |
---|
| 93 | @note applies when PassType is RENDERSCENE |
---|
| 94 | */ |
---|
| 95 | uint8 getFirstRenderQueue() const; |
---|
| 96 | /** Set the last render queue to be rendered in this pass (inclusive) |
---|
| 97 | @note applies when PassType is RENDERSCENE |
---|
| 98 | */ |
---|
| 99 | void setLastRenderQueue(uint8 id); |
---|
| 100 | /** Get the last render queue to be rendered in this pass (inclusive) |
---|
| 101 | @note applies when PassType is RENDERSCENE |
---|
| 102 | */ |
---|
| 103 | uint8 getLastRenderQueue() const; |
---|
| 104 | |
---|
| 105 | /** Set the material scheme used by this pass. |
---|
| 106 | @remarks |
---|
| 107 | Only applicable to passes that render the scene. |
---|
| 108 | @see Technique::setScheme. |
---|
| 109 | */ |
---|
| 110 | void setMaterialScheme(const String& schemeName); |
---|
| 111 | /** Get the material scheme used by this pass. |
---|
| 112 | @remarks |
---|
| 113 | Only applicable to passes that render the scene. |
---|
| 114 | @see Technique::setScheme. |
---|
| 115 | */ |
---|
| 116 | const String& getMaterialScheme(void) const; |
---|
| 117 | |
---|
| 118 | /** Would be nice to have for RENDERSCENE: |
---|
| 119 | flags to: |
---|
| 120 | exclude transparents |
---|
| 121 | override material (at least -- color) |
---|
| 122 | */ |
---|
| 123 | |
---|
| 124 | /** Set the viewport clear buffers (defaults to FBT_COLOUR|FBT_DEPTH) |
---|
| 125 | @param val is a combination of FBT_COLOUR, FBT_DEPTH, FBT_STENCIL. |
---|
| 126 | @note applies when PassType is CLEAR |
---|
| 127 | */ |
---|
| 128 | void setClearBuffers(uint32 val); |
---|
| 129 | /** Get the viewport clear buffers. |
---|
| 130 | @note applies when PassType is CLEAR |
---|
| 131 | */ |
---|
| 132 | uint32 getClearBuffers() const; |
---|
| 133 | /** Set the viewport clear colour (defaults to 0,0,0,0) |
---|
| 134 | @note applies when PassType is CLEAR |
---|
| 135 | */ |
---|
| 136 | void setClearColour(ColourValue val); |
---|
| 137 | /** Get the viewport clear colour (defaults to 0,0,0,0) |
---|
| 138 | @note applies when PassType is CLEAR |
---|
| 139 | */ |
---|
| 140 | const ColourValue &getClearColour() const; |
---|
| 141 | /** Set the viewport clear depth (defaults to 1.0) |
---|
| 142 | @note applies when PassType is CLEAR |
---|
| 143 | */ |
---|
| 144 | void setClearDepth(Real depth); |
---|
| 145 | /** Get the viewport clear depth (defaults to 1.0) |
---|
| 146 | @note applies when PassType is CLEAR |
---|
| 147 | */ |
---|
| 148 | Real getClearDepth() const; |
---|
| 149 | /** Set the viewport clear stencil value (defaults to 0) |
---|
| 150 | @note applies when PassType is CLEAR |
---|
| 151 | */ |
---|
| 152 | void setClearStencil(uint32 value); |
---|
| 153 | /** Get the viewport clear stencil value (defaults to 0) |
---|
| 154 | @note applies when PassType is CLEAR |
---|
| 155 | */ |
---|
| 156 | uint32 getClearStencil() const; |
---|
| 157 | |
---|
| 158 | /** Set stencil check on or off. |
---|
| 159 | @note applies when PassType is STENCIL |
---|
| 160 | */ |
---|
| 161 | void setStencilCheck(bool value); |
---|
| 162 | /** Get stencil check enable. |
---|
| 163 | @note applies when PassType is STENCIL |
---|
| 164 | */ |
---|
| 165 | bool getStencilCheck() const; |
---|
| 166 | /** Set stencil compare function. |
---|
| 167 | @note applies when PassType is STENCIL |
---|
| 168 | */ |
---|
| 169 | void setStencilFunc(CompareFunction value); |
---|
| 170 | /** Get stencil compare function. |
---|
| 171 | @note applies when PassType is STENCIL |
---|
| 172 | */ |
---|
| 173 | CompareFunction getStencilFunc() const; |
---|
| 174 | /** Set stencil reference value. |
---|
| 175 | @note applies when PassType is STENCIL |
---|
| 176 | */ |
---|
| 177 | void setStencilRefValue(uint32 value); |
---|
| 178 | /** Get stencil reference value. |
---|
| 179 | @note applies when PassType is STENCIL |
---|
| 180 | */ |
---|
| 181 | uint32 getStencilRefValue() const; |
---|
| 182 | /** Set stencil mask. |
---|
| 183 | @note applies when PassType is STENCIL |
---|
| 184 | */ |
---|
| 185 | void setStencilMask(uint32 value); |
---|
| 186 | /** Get stencil mask. |
---|
| 187 | @note applies when PassType is STENCIL |
---|
| 188 | */ |
---|
| 189 | uint32 getStencilMask() const; |
---|
| 190 | /** Set stencil fail operation. |
---|
| 191 | @note applies when PassType is STENCIL |
---|
| 192 | */ |
---|
| 193 | void setStencilFailOp(StencilOperation value); |
---|
| 194 | /** Get stencil fail operation. |
---|
| 195 | @note applies when PassType is STENCIL |
---|
| 196 | */ |
---|
| 197 | StencilOperation getStencilFailOp() const; |
---|
| 198 | /** Set stencil depth fail operation. |
---|
| 199 | @note applies when PassType is STENCIL |
---|
| 200 | */ |
---|
| 201 | void setStencilDepthFailOp(StencilOperation value); |
---|
| 202 | /** Get stencil depth fail operation. |
---|
| 203 | @note applies when PassType is STENCIL |
---|
| 204 | */ |
---|
| 205 | StencilOperation getStencilDepthFailOp() const; |
---|
| 206 | /** Set stencil pass operation. |
---|
| 207 | @note applies when PassType is STENCIL |
---|
| 208 | */ |
---|
| 209 | void setStencilPassOp(StencilOperation value); |
---|
| 210 | /** Get stencil pass operation. |
---|
| 211 | @note applies when PassType is STENCIL |
---|
| 212 | */ |
---|
| 213 | StencilOperation getStencilPassOp() const; |
---|
| 214 | /** Set two sided stencil operation. |
---|
| 215 | @note applies when PassType is STENCIL |
---|
| 216 | */ |
---|
| 217 | void setStencilTwoSidedOperation(bool value); |
---|
| 218 | /** Get two sided stencil operation. |
---|
| 219 | @note applies when PassType is STENCIL |
---|
| 220 | */ |
---|
| 221 | bool getStencilTwoSidedOperation() const; |
---|
| 222 | |
---|
| 223 | /// Inputs (for material used for rendering the quad) |
---|
| 224 | struct InputTex |
---|
| 225 | { |
---|
| 226 | /// Name (local) of the input texture (empty == no input) |
---|
| 227 | String name; |
---|
| 228 | /// MRT surface index if applicable |
---|
| 229 | size_t mrtIndex; |
---|
| 230 | InputTex() : name(StringUtil::BLANK), mrtIndex(0) {} |
---|
| 231 | InputTex(const String& _name, size_t _mrtIndex = 0) |
---|
| 232 | : name(_name), mrtIndex(_mrtIndex) {} |
---|
| 233 | }; |
---|
| 234 | |
---|
| 235 | /** Set an input local texture. An empty string clears the input. |
---|
| 236 | @param id Input to set. Must be in 0..OGRE_MAX_TEXTURE_LAYERS-1 |
---|
| 237 | @param input Which texture to bind to this input. An empty string clears the input. |
---|
| 238 | @param mrtIndex Which surface of an MRT to retrieve |
---|
| 239 | @note applies when PassType is RENDERQUAD |
---|
| 240 | */ |
---|
| 241 | void setInput(size_t id, const String &input=StringUtil::BLANK, size_t mrtIndex=0); |
---|
| 242 | |
---|
| 243 | /** Get the value of an input. |
---|
| 244 | @param id Input to get. Must be in 0..OGRE_MAX_TEXTURE_LAYERS-1. |
---|
| 245 | @note applies when PassType is RENDERQUAD |
---|
| 246 | */ |
---|
| 247 | const InputTex &getInput(size_t id) const; |
---|
| 248 | |
---|
| 249 | /** Get the number of inputs used. |
---|
| 250 | @note applies when PassType is RENDERQUAD |
---|
| 251 | */ |
---|
| 252 | size_t getNumInputs() const; |
---|
| 253 | |
---|
| 254 | /** Clear all inputs. |
---|
| 255 | @note applies when PassType is RENDERQUAD |
---|
| 256 | */ |
---|
| 257 | void clearAllInputs(); |
---|
| 258 | |
---|
| 259 | /** Get parent object |
---|
| 260 | @note applies when PassType is RENDERQUAD |
---|
| 261 | */ |
---|
| 262 | CompositionTargetPass *getParent(); |
---|
| 263 | |
---|
| 264 | /** Determine if this target pass is supported on the current rendering device. |
---|
| 265 | */ |
---|
| 266 | bool _isSupported(void); |
---|
| 267 | |
---|
| 268 | /** Set quad normalised positions [-1;1]x[-1;1] |
---|
| 269 | @note applies when PassType is RENDERQUAD |
---|
| 270 | */ |
---|
| 271 | void setQuadCorners(Real left,Real top,Real right,Real bottom); |
---|
| 272 | |
---|
| 273 | /** Get quad normalised positions [-1;1]x[-1;1] |
---|
| 274 | @note applies when PassType is RENDERQUAD |
---|
| 275 | */ |
---|
| 276 | bool getQuadCorners(Real & left,Real & top,Real & right,Real & bottom) const; |
---|
| 277 | |
---|
| 278 | /** Sets the use of camera frustum far corners provided in the quad's normals |
---|
| 279 | @note applies when PassType is RENDERQUAD |
---|
| 280 | */ |
---|
| 281 | void setQuadFarCorners(bool farCorners, bool farCornersViewSpace); |
---|
| 282 | |
---|
| 283 | /** Returns true if camera frustum far corners are provided in the quad. |
---|
| 284 | @note applies when PassType is RENDERQUAD |
---|
| 285 | */ |
---|
| 286 | bool getQuadFarCorners() const; |
---|
| 287 | |
---|
| 288 | /** Returns true if the far corners provided in the quad are in view space |
---|
| 289 | @note applies when PassType is RENDERQUAD |
---|
| 290 | */ |
---|
| 291 | bool getQuadFarCornersViewSpace() const; |
---|
| 292 | |
---|
| 293 | /** Set the type name of this custom composition pass. |
---|
| 294 | @note applies when PassType is RENDERCUSTOM |
---|
| 295 | @see CompositorManager::registerCustomCompositionPass |
---|
| 296 | */ |
---|
| 297 | void setCustomType(const String& customType); |
---|
| 298 | |
---|
| 299 | /** Get the type name of this custom composition pass. |
---|
| 300 | @note applies when PassType is RENDERCUSTOM |
---|
| 301 | @see CompositorManager::registerCustomCompositionPass |
---|
| 302 | */ |
---|
| 303 | const String& getCustomType() const; |
---|
| 304 | |
---|
| 305 | private: |
---|
| 306 | /// Parent technique |
---|
| 307 | CompositionTargetPass *mParent; |
---|
| 308 | /// Type of composition pass |
---|
| 309 | PassType mType; |
---|
| 310 | /// Identifier for this pass |
---|
| 311 | uint32 mIdentifier; |
---|
| 312 | /// Material used for rendering |
---|
| 313 | MaterialPtr mMaterial; |
---|
| 314 | /// [first,last] render queue to render this pass (in case of PT_RENDERSCENE) |
---|
| 315 | uint8 mFirstRenderQueue; |
---|
| 316 | uint8 mLastRenderQueue; |
---|
| 317 | /// Material scheme name |
---|
| 318 | String mMaterialScheme; |
---|
| 319 | /// Clear buffers (in case of PT_CLEAR) |
---|
| 320 | uint32 mClearBuffers; |
---|
| 321 | /// Clear colour (in case of PT_CLEAR) |
---|
| 322 | ColourValue mClearColour; |
---|
| 323 | /// Clear depth (in case of PT_CLEAR) |
---|
| 324 | Real mClearDepth; |
---|
| 325 | /// Clear stencil value (in case of PT_CLEAR) |
---|
| 326 | uint32 mClearStencil; |
---|
| 327 | /** Inputs (for material used for rendering the quad). |
---|
| 328 | An empty string signifies that no input is used */ |
---|
| 329 | InputTex mInputs[OGRE_MAX_TEXTURE_LAYERS]; |
---|
| 330 | /// Stencil operation parameters |
---|
| 331 | bool mStencilCheck; |
---|
| 332 | CompareFunction mStencilFunc; |
---|
| 333 | uint32 mStencilRefValue; |
---|
| 334 | uint32 mStencilMask; |
---|
| 335 | StencilOperation mStencilFailOp; |
---|
| 336 | StencilOperation mStencilDepthFailOp; |
---|
| 337 | StencilOperation mStencilPassOp; |
---|
| 338 | bool mStencilTwoSidedOperation; |
---|
| 339 | |
---|
| 340 | /// True if quad should not cover whole screen |
---|
| 341 | bool mQuadCornerModified; |
---|
| 342 | /// quad positions in normalised coordinates [-1;1]x[-1;1] (in case of PT_RENDERQUAD) |
---|
| 343 | Real mQuadLeft; |
---|
| 344 | Real mQuadTop; |
---|
| 345 | Real mQuadRight; |
---|
| 346 | Real mQuadBottom; |
---|
| 347 | |
---|
| 348 | bool mQuadFarCorners, mQuadFarCornersViewSpace; |
---|
| 349 | /// The type name of the custom composition pass. |
---|
| 350 | String mCustomType; |
---|
| 351 | }; |
---|
| 352 | /** @} */ |
---|
| 353 | /** @} */ |
---|
| 354 | |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | #include "OgreHeaderSuffix.h" |
---|
| 358 | |
---|
| 359 | #endif |
---|