Torque3D Documentation / _generateds / shaderMaterialParameters.h

shaderMaterialParameters.h

Engine/source/materials/shaderMaterialParameters.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SHADERMATERIALPARAMETERS_H_
 25#define _SHADERMATERIALPARAMETERS_H_
 26
 27#ifndef _MATERIALPARAMETERS_H_
 28#include "materials/materialParameters.h"
 29#endif
 30#ifndef _GFXSHADER_H_
 31#include "gfx/gfxShader.h"
 32#endif
 33
 34
 35class ShaderMaterialParameterHandle : public MaterialParameterHandle
 36{
 37   friend class ShaderMaterialParameters;
 38public:
 39   virtual ~ShaderMaterialParameterHandle();
 40
 41   ShaderMaterialParameterHandle(const String& name);
 42   ShaderMaterialParameterHandle(const String& name, Vector<GFXShader*>& shaders);
 43
 44   virtual const String& getName() const { return mName; } 
 45   virtual S32 getSamplerRegister( U32 pass ) const;
 46
 47   // NOTE: We always return true here instead of querying the
 48   // children... often there is only one element, so lets just
 49   // hit the loop once on the set.
 50   virtual bool isValid() const { return true; };      
 51
 52protected:
 53   Vector< GFXShaderConstHandle*> mHandles;   
 54   String mName;   
 55};
 56
 57// This is the union of all of the shaders contained in a material
 58class ShaderMaterialParameters : public MaterialParameters
 59{
 60public:
 61   ShaderMaterialParameters();
 62   virtual ~ShaderMaterialParameters();
 63
 64   void setBuffers(Vector<GFXShaderConstDesc>& constDesc, Vector<GFXShaderConstBufferRef>& buffers);   
 65   GFXShaderConstBuffer* getBuffer(U32 i) { return mBuffers[i]; }
 66
 67   ///
 68   /// MaterialParameter interface
 69   ///
 70
 71   /// Returns the material parameter handle for name.
 72   virtual void set(MaterialParameterHandle* handle, const F32 f);
 73   virtual void set(MaterialParameterHandle* handle, const Point2F& fv);
 74   virtual void set(MaterialParameterHandle* handle, const Point3F& fv);
 75   virtual void set(MaterialParameterHandle* handle, const Point4F& fv);
 76   virtual void set(MaterialParameterHandle* handle, const PlaneF& fv);
 77   virtual void set(MaterialParameterHandle* handle, const LinearColorF& fv);
 78   virtual void set(MaterialParameterHandle* handle, const S32 f);
 79   virtual void set(MaterialParameterHandle* handle, const Point2I& fv);
 80   virtual void set(MaterialParameterHandle* handle, const Point3I& fv);
 81   virtual void set(MaterialParameterHandle* handle, const Point4I& fv);
 82   virtual void set(MaterialParameterHandle* handle, const AlignedArray<F32>& fv);
 83   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point2F>& fv);
 84   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point3F>& fv);
 85   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point4F>& fv);
 86   virtual void set(MaterialParameterHandle* handle, const AlignedArray<S32>& fv);
 87   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point2I>& fv);
 88   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point3I>& fv);
 89   virtual void set(MaterialParameterHandle* handle, const AlignedArray<Point4I>& fv);
 90   virtual void set(MaterialParameterHandle* handle, const MatrixF& mat, const GFXShaderConstType matrixType = GFXSCT_Float4x4);
 91   virtual void set(MaterialParameterHandle* handle, const MatrixF* mat, const U32 arraySize, const GFXShaderConstType matrixType = GFXSCT_Float4x4);
 92
 93   virtual U32 getAlignmentValue(const GFXShaderConstType constType);
 94
 95private:
 96   Vector<GFXShaderConstBufferRef> mBuffers;   
 97
 98   void releaseBuffers();
 99};
100
101#endif
102