/usr/include/OGRE/RTShaderSystem/OgreShaderParameter.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _ShaderParameter_
#define _ShaderParameter_
#include "OgreShaderPrerequisites.h"
#include "OgreGpuProgram.h"
#include "OgreVector2.h"
#include "OgreVector3.h"
#include "OgreVector4.h"
#include "OgreMatrix4.h"
namespace Ogre {
namespace RTShader {
/** \addtogroup Core
* @{
*/
/** \addtogroup RTShader
* @{
*/
/** A class that represents a shader based program parameter.
*/
class _OgreRTSSExport Parameter : public RTShaderSystemAlloc
{
public:
// Shader parameter semantic.
enum Semantic
{
/// Unknown semantic
SPS_UNKNOWN = 0,
/// Position
SPS_POSITION = 1,
/// Blending weights
SPS_BLEND_WEIGHTS = 2,
/// Blending indices
SPS_BLEND_INDICES = 3,
/// Normal, 3 reals per vertex
SPS_NORMAL = 4,
/// General floating point color.
SPS_COLOR = 5,
/// Texture coordinates
SPS_TEXTURE_COORDINATES = 7,
/// Binormal (Y axis if normal is Z)
SPS_BINORMAL = 8,
/// Tangent (X axis if normal is Z)
SPS_TANGENT = 9
};
// Shader parameter content.
enum Content
{
/// Unknown content
SPC_UNKNOWN,
/// Position in object space
SPC_POSITION_OBJECT_SPACE,
/// Position in world space
SPC_POSITION_WORLD_SPACE,
/// Position in view space
SPC_POSITION_VIEW_SPACE,
/// Position in projective space
SPC_POSITION_PROJECTIVE_SPACE,
/// Position in light space index 0-7
SPC_POSITION_LIGHT_SPACE0,
SPC_POSITION_LIGHT_SPACE1,
SPC_POSITION_LIGHT_SPACE2,
SPC_POSITION_LIGHT_SPACE3,
SPC_POSITION_LIGHT_SPACE4,
SPC_POSITION_LIGHT_SPACE5,
SPC_POSITION_LIGHT_SPACE6,
SPC_POSITION_LIGHT_SPACE7,
/// Normal in object space
SPC_NORMAL_OBJECT_SPACE,
/// Normal in world space
SPC_NORMAL_WORLD_SPACE,
/// Normal in view space
SPC_NORMAL_VIEW_SPACE,
/// Normal in tangent space
SPC_NORMAL_TANGENT_SPACE,
/// View vector in object space
SPC_POSTOCAMERA_OBJECT_SPACE,
/// View vector in world space
SPC_POSTOCAMERA_WORLD_SPACE,
/// View vector in view space
SPC_POSTOCAMERA_VIEW_SPACE,
/// View vector in tangent space
SPC_POSTOCAMERA_TANGENT_SPACE,
/// Light vector in object space index 0-7
SPC_POSTOLIGHT_OBJECT_SPACE0,
SPC_POSTOLIGHT_OBJECT_SPACE1,
SPC_POSTOLIGHT_OBJECT_SPACE2,
SPC_POSTOLIGHT_OBJECT_SPACE3,
SPC_POSTOLIGHT_OBJECT_SPACE4,
SPC_POSTOLIGHT_OBJECT_SPACE5,
SPC_POSTOLIGHT_OBJECT_SPACE6,
SPC_POSTOLIGHT_OBJECT_SPACE7,
/// Light vector in world space index 0-7
SPC_POSTOLIGHT_WORLD_SPACE0,
SPC_POSTOLIGHT_WORLD_SPACE1,
SPC_POSTOLIGHT_WORLD_SPACE2,
SPC_POSTOLIGHT_WORLD_SPACE3,
SPC_POSTOLIGHT_WORLD_SPACE4,
SPC_POSTOLIGHT_WORLD_SPACE5,
SPC_POSTOLIGHT_WORLD_SPACE6,
SPC_POSTOLIGHT_WORLD_SPACE7,
/// Light vector in view space index 0-7
SPC_POSTOLIGHT_VIEW_SPACE0,
SPC_POSTOLIGHT_VIEW_SPACE1,
SPC_POSTOLIGHT_VIEW_SPACE2,
SPC_POSTOLIGHT_VIEW_SPACE3,
SPC_POSTOLIGHT_VIEW_SPACE4,
SPC_POSTOLIGHT_VIEW_SPACE5,
SPC_POSTOLIGHT_VIEW_SPACE6,
SPC_POSTOLIGHT_VIEW_SPACE7,
/// Light vector in tangent space index 0-7
SPC_POSTOLIGHT_TANGENT_SPACE0,
SPC_POSTOLIGHT_TANGENT_SPACE1,
SPC_POSTOLIGHT_TANGENT_SPACE2,
SPC_POSTOLIGHT_TANGENT_SPACE3,
SPC_POSTOLIGHT_TANGENT_SPACE4,
SPC_POSTOLIGHT_TANGENT_SPACE5,
SPC_POSTOLIGHT_TANGENT_SPACE6,
SPC_POSTOLIGHT_TANGENT_SPACE7,
/// Light direction in object space index 0-7
SPC_LIGHTDIRECTION_OBJECT_SPACE0,
SPC_LIGHTDIRECTION_OBJECT_SPACE1,
SPC_LIGHTDIRECTION_OBJECT_SPACE2,
SPC_LIGHTDIRECTION_OBJECT_SPACE3,
SPC_LIGHTDIRECTION_OBJECT_SPACE4,
SPC_LIGHTDIRECTION_OBJECT_SPACE5,
SPC_LIGHTDIRECTION_OBJECT_SPACE6,
SPC_LIGHTDIRECTION_OBJECT_SPACE7,
/// Light direction in world space index 0-7
SPC_LIGHTDIRECTION_WORLD_SPACE0,
SPC_LIGHTDIRECTION_WORLD_SPACE1,
SPC_LIGHTDIRECTION_WORLD_SPACE2,
SPC_LIGHTDIRECTION_WORLD_SPACE3,
SPC_LIGHTDIRECTION_WORLD_SPACE4,
SPC_LIGHTDIRECTION_WORLD_SPACE5,
SPC_LIGHTDIRECTION_WORLD_SPACE6,
SPC_LIGHTDIRECTION_WORLD_SPACE7,
/// Light direction in view space index 0-7
SPC_LIGHTDIRECTION_VIEW_SPACE0,
SPC_LIGHTDIRECTION_VIEW_SPACE1,
SPC_LIGHTDIRECTION_VIEW_SPACE2,
SPC_LIGHTDIRECTION_VIEW_SPACE3,
SPC_LIGHTDIRECTION_VIEW_SPACE4,
SPC_LIGHTDIRECTION_VIEW_SPACE5,
SPC_LIGHTDIRECTION_VIEW_SPACE6,
SPC_LIGHTDIRECTION_VIEW_SPACE7,
/// Light direction in tangent space index 0-7
SPC_LIGHTDIRECTION_TANGENT_SPACE0,
SPC_LIGHTDIRECTION_TANGENT_SPACE1,
SPC_LIGHTDIRECTION_TANGENT_SPACE2,
SPC_LIGHTDIRECTION_TANGENT_SPACE3,
SPC_LIGHTDIRECTION_TANGENT_SPACE4,
SPC_LIGHTDIRECTION_TANGENT_SPACE5,
SPC_LIGHTDIRECTION_TANGENT_SPACE6,
SPC_LIGHTDIRECTION_TANGENT_SPACE7,
/// Light position in object space index 0-7
SPC_LIGHTPOSITION_OBJECT_SPACE0,
SPC_LIGHTPOSITION_OBJECT_SPACE1,
SPC_LIGHTPOSITION_OBJECT_SPACE2,
SPC_LIGHTPOSITION_OBJECT_SPACE3,
SPC_LIGHTPOSITION_OBJECT_SPACE4,
SPC_LIGHTPOSITION_OBJECT_SPACE5,
SPC_LIGHTPOSITION_OBJECT_SPACE6,
SPC_LIGHTPOSITION_OBJECT_SPACE7,
/// Light position in world space index 0-7
SPC_LIGHTPOSITION_WORLD_SPACE0,
SPC_LIGHTPOSITION_WORLD_SPACE1,
SPC_LIGHTPOSITION_WORLD_SPACE2,
SPC_LIGHTPOSITION_WORLD_SPACE3,
SPC_LIGHTPOSITION_WORLD_SPACE4,
SPC_LIGHTPOSITION_WORLD_SPACE5,
SPC_LIGHTPOSITION_WORLD_SPACE6,
SPC_LIGHTPOSITION_WORLD_SPACE7,
/// Light position in view space index 0-7
SPC_LIGHTPOSITIONVIEW_SPACE0,
SPC_LIGHTPOSITIONVIEW_SPACE1,
SPC_LIGHTPOSITIONVIEW_SPACE2,
SPC_LIGHTPOSITIONVIEW_SPACE3,
SPC_LIGHTPOSITIONVIEW_SPACE4,
SPC_LIGHTPOSITIONVIEW_SPACE5,
SPC_LIGHTPOSITIONVIEW_SPACE6,
SPC_LIGHTPOSITIONVIEW_SPACE7,
/// Light position in tangent space index 0-7
SPC_LIGHTPOSITION_TANGENT_SPACE,
/// Tangent vector
SPC_TANGENT,
/// Binormal vector
SPC_BINORMAL,
/// Diffuse color
SPC_COLOR_DIFFUSE,
/// Specular color
SPC_COLOR_SPECULAR,
/// Depth in object space
SPC_DEPTH_OBJECT_SPACE,
/// Depth in world space
SPC_DEPTH_WORLD_SPACE,
/// Depth in view space
SPC_DEPTH_VIEW_SPACE,
/// Depth in projective space
SPC_DEPTH_PROJECTIVE_SPACE,
/// Texture coordinate set index 0-7
SPC_TEXTURE_COORDINATE0,
SPC_TEXTURE_COORDINATE1,
SPC_TEXTURE_COORDINATE2,
SPC_TEXTURE_COORDINATE3,
SPC_TEXTURE_COORDINATE4,
SPC_TEXTURE_COORDINATE5,
SPC_TEXTURE_COORDINATE6,
SPC_TEXTURE_COORDINATE7,
/// Reserved custom content range to be used by user custom shader extensions.
SPC_CUSTOM_CONTENT_BEGIN = 1000,
SPC_CUSTOM_CONTENT_END = 2000
};
// Interface.
public:
/** */
Parameter() {}
/** Class constructor.
@param type The type of this parameter.
@param name The name of this parameter.
@param semantic The semantic of this parameter.
@param index The index of this parameter.
@param content The content of this parameter.
@param variability How this parameter varies (bitwise combination of GpuProgramVariability).
*/
Parameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content);
/** Class destructor */
virtual ~Parameter() {};
/** Get the name of this parameter. */
const String& getName () const { return mName; }
/** Get the type of this parameter. */
GpuConstantType getType () const { return mType; }
/** Get the semantic of this parameter. */
const Semantic& getSemantic () const { return mSemantic; }
/** Get the index of this parameter. */
int getIndex () const { return mIndex; }
/** Return the content of this parameter. */
Content getContent () const { return mContent; }
/** Returns true if this instance is a ConstParameter otherwise false. */
virtual bool isConstParameter () const { return false; }
/** Returns the string representation of this parameter. */
virtual String toString () const { return mName; }
// Attributes.
protected:
String mName; // Name of this parameter.
GpuConstantType mType; // Type of this parameter.
Semantic mSemantic; // Semantic of this parameter.
int mIndex; // Index of this parameter.
Content mContent; // The content of this parameter.
};
typedef SharedPtr<Parameter> ParameterPtr;
typedef vector<ParameterPtr>::type ShaderParameterList;
typedef ShaderParameterList::iterator ShaderParameterIterator;
typedef ShaderParameterList::const_iterator ShaderParameterConstIterator;
/** Uniform parameter class. Allow fast access to GPU parameter updates.
*/
class UniformParameter : public Parameter
{
public:
/** Class constructor.
@param type The type of this parameter.
@param name The name of this parameter.
@param semantic The semantic of this parameter.
@param index The index of this parameter.
@param content The content of this parameter.
@param variability How this parameter varies (bitwise combination of GpuProgramVariability).
*/
UniformParameter(GpuConstantType type, const String& name,
const Semantic& semantic, int index,
const Content& content,
uint16 variability);
/** Class constructor.
@param autoType The auto type of this parameter.
@param fAutoConstantData The real data for this auto constant parameter.
*/
UniformParameter(GpuProgramParameters::AutoConstantType autoType, Real fAutoConstantData);
/** Class constructor.
@param autoType The auto type of this parameter.
@param nAutoConstantData The int data for this auto constant parameter.
*/
UniformParameter(GpuProgramParameters::AutoConstantType autoType, size_t nAutoConstantData);
/** Get auto constant int data of this parameter, in case it is auto constant parameter. */
size_t getAutoConstantIntData () const { return mAutoConstantIntData; }
/** Get auto constant real data of this parameter, in case it is auto constant parameter. */
Real getAutoConstantRealData () const { return mAutoConstantRealData; }
/** Return true if this parameter is a floating point type, false otherwise. */
bool isFloat () const;
/** Return true if this parameter is a texture sampler type, false otherwise. */
bool isSampler () const;
/** Return true if this parameter is an auto constant parameter, false otherwise. */
bool isAutoConstantParameter () const { return mIsAutoConstantReal || mIsAutoConstantInt; }
/** Return true if this parameter an auto constant with int data type, false otherwise. */
bool isAutoConstantIntParameter () const { return mIsAutoConstantInt; }
/** Return true if this parameter an auto constant with real data type, false otherwise. */
bool isAutoConstantRealParameter () const { return mIsAutoConstantReal; }
/** Return the auto constant type of this parameter. */
GpuProgramParameters::AutoConstantType getAutoConstantType () const { return mAutoConstantType; }
/** Return the variability of this parameter. */
uint16 getVariability () const { return mVariability; }
/** Bind this parameter to the corresponding GPU parameter. */
void bind (GpuProgramParametersSharedPtr paramsPtr);
public:
/** Update the GPU parameter with the given value. */
void setGpuParameter(int val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(Real val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(const ColourValue& val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(const Vector2& val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstants(mPhysicalIndex, val.ptr(), 2);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(const Vector3& val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(const Vector4& val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val);
}
}
/** Update the GPU parameter with the given value. */
void setGpuParameter(const Matrix4& val)
{
if (mParamsPtr != NULL)
{
mParamsPtr->_writeRawConstant(mPhysicalIndex, val, 16);
}
}
protected:
bool mIsAutoConstantReal; // Is it auto constant real based parameter.
bool mIsAutoConstantInt; // Is it auto constant int based parameter.
GpuProgramParameters::AutoConstantType mAutoConstantType; // The auto constant type of this parameter.
union
{
size_t mAutoConstantIntData; // Auto constant int data.
Real mAutoConstantRealData; // Auto constant real data.
};
uint16 mVariability; // How this parameter varies (bitwise combination of GpuProgramVariability).
GpuProgramParameters* mParamsPtr; // The actual GPU parameters pointer.
size_t mPhysicalIndex; // The physical index of this parameter in the GPU program.
};
typedef SharedPtr<UniformParameter> UniformParameterPtr;
typedef vector<UniformParameterPtr>::type UniformParameterList;
typedef UniformParameterList::iterator UniformParameterIterator;
typedef UniformParameterList::const_iterator UniformParameterConstIterator;
/** Helper template which is the base for our ConstParameters
*/
template <class valueType>
class ConstParameter : public Parameter
{
public:
ConstParameter( valueType val,
GpuConstantType type,
const Semantic& semantic,
const Content& content)
: Parameter(type, "Constant", semantic, 0, content)
{
mValue = val;
}
virtual ~ConstParameter () {}
/** Returns the native value of this parameter. (for example a Vector3) */
const valueType& getValue () const { return mValue; }
/**
@see Parameter::isConstParameter.
*/
virtual bool isConstParameter () const { return true; }
/**
@see Parameter::toString.
*/
virtual String toString () const = 0;
protected:
valueType mValue;
};
/** Helper utility class that creates common parameters.
*/
class _OgreRTSSExport ParameterFactory
{
// Interface.
public:
static ParameterPtr createInPosition (int index);
static ParameterPtr createOutPosition (int index);
static ParameterPtr createInNormal (int index);
static ParameterPtr createOutNormal (int index);
static ParameterPtr createInBiNormal (int index);
static ParameterPtr createOutBiNormal (int index);
static ParameterPtr createInTangent (int index);
static ParameterPtr createOutTangent (int index);
static ParameterPtr createInColor (int index);
static ParameterPtr createOutColor (int index);
static ParameterPtr createInTexcoord (GpuConstantType type, int index, Parameter::Content content);
static ParameterPtr createOutTexcoord (GpuConstantType type, int index, Parameter::Content content);
static ParameterPtr createInTexcoord1 (int index, Parameter::Content content);
static ParameterPtr createOutTexcoord1 (int index, Parameter::Content content);
static ParameterPtr createInTexcoord2 (int index, Parameter::Content content);
static ParameterPtr createOutTexcoord2 (int index, Parameter::Content content);
static ParameterPtr createInTexcoord3 (int index, Parameter::Content content);
static ParameterPtr createOutTexcoord3 (int index, Parameter::Content content);
static ParameterPtr createInTexcoord4 (int index, Parameter::Content content);
static ParameterPtr createOutTexcoord4 (int index, Parameter::Content content);
static ParameterPtr createConstParamVector2 (Vector2 val);
static ParameterPtr createConstParamVector3 (Vector3 val);
static ParameterPtr createConstParamVector4 (Vector4 val);
static ParameterPtr createConstParamFloat (float val);
static UniformParameterPtr createSampler (GpuConstantType type, int index);
static UniformParameterPtr createSampler1D (int index);
static UniformParameterPtr createSampler2D (int index);
static UniformParameterPtr createSampler3D (int index);
static UniformParameterPtr createSamplerCUBE (int index);
static UniformParameterPtr createUniform (GpuConstantType type, int index, uint16 variability, const String& suggestedName);
};
/** @} */
/** @} */
}
}
#endif
|