# OgreShaderFFPFog.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org
    00006
    00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
    00008 Permission is hereby granted, free of charge, to any person obtaining a copy
    00009 of this software and associated documentation files (the "Software"), to deal
    00010 in the Software without restriction, including without limitation the rights
    00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00012 copies of the Software, and to permit persons to whom the Software is
    00013 furnished to do so, subject to the following conditions:
    00014
    00015 The above copyright notice and this permission notice shall be included in
    00016 all copies or substantial portions of the Software.
    00017
    00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00024 THE SOFTWARE.
    00025 -----------------------------------------------------------------------------
    00026 */
    00027 #ifndef _ShaderFFPFog_
    00028 #define _ShaderFFPFog_
    00029
    00030 #include "OgreShaderPrerequisites.h"
    00031 #ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
    00032 #include "OgreShaderParameter.h"
    00033 #include "OgreShaderSubRenderState.h"
    00034 #include "OgreVector4.h"
    00035
    00036 namespace Ogre {
    00037 namespace RTShader {
    00038
    00050 class _OgreRTSSExport FFPFog : public SubRenderState
    00051 {
    00052 public:
    00053
    00054     // Fog calculation mode enum.
    00055     enum CalcMode
    00056     {
    00057         CM_PER_VERTEX   = 1,        // Per vertex fog calculations. (Default).
    00058         CM_PER_PIXEL    = 2         // Per pixel fog calculations.
    00059     };
    00060
    00061 // Interface.
    00062 public:
    00063
    00065     FFPFog();
    00066
    00070     virtual const String&   getType                 () const;
    00071
    00075     virtual int             getExecutionOrder       () const;
    00076
    00080     virtual void            updateGpuProgramsParams (Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
    00081
    00085     virtual void            copyFrom                (const SubRenderState& rhs);
    00086
    00090     virtual bool            preAddToRenderState     (RenderState* renderState, Pass* srcPass, Pass* dstPass);
    00091
    00101     void            setFogProperties                (FogMode fogMode,
    00102         const ColourValue& fogColour,
    00103         float fogStart,
    00104         float fogEnd,
    00105         float fogDensity);
    00106
    00111     void            setCalcMode                     (CalcMode calcMode) { mCalcMode = calcMode; }
    00112
    00116     CalcMode        getCalcMode                     () const { return mCalcMode; }
    00117
    00118     static String Type;
    00119
    00120 // Protected methods
    00121 protected:
    00122
    00126     virtual bool            resolveParameters       (ProgramSet* programSet);
    00127
    00131     virtual bool            resolveDependencies     (ProgramSet* programSet);
    00132
    00136     virtual bool            addFunctionInvocations  (ProgramSet* programSet);
    00137
    00138 // Attributes.
    00139 protected:
    00140     CalcMode            mCalcMode;              // Fog calculation mode.
    00141     FogMode             mFogMode;               // Fog formula.
    00142     ColourValue         mFogColourValue;        // Fog colour value.
    00143     Vector4             mFogParamsValue;        // Fog parameters (density, start, end, 1/end-start).
    00144     bool                mPassOverrideParams;    // True if the fog parameters should be taken from the pass.
    00145
    00146     UniformParameterPtr mWorldViewProjMatrix;   // World view projection parameter.
    00147     UniformParameterPtr mFogColour;             // Fog colour parameter.
    00148     UniformParameterPtr mFogParams;             // Fog parameters program parameter.
    00149     ParameterPtr        mVSInPos;               // Vertex shader input position parameter.
    00150     ParameterPtr        mVSOutFogFactor;        // Vertex shader output fog colour parameter.
    00151     ParameterPtr        mPSInFogFactor;         // Pixel shader input fog factor.
    00152     ParameterPtr        mVSOutDepth;            // Vertex shader output depth.
    00153     ParameterPtr        mPSInDepth;             // Pixel shader input depth.
    00154     ParameterPtr        mPSOutDiffuse;          // Pixel shader output diffuse colour.
    00155 };
    00156
    00157
    00162 class _OgreRTSSExport FFPFogFactory : public SubRenderStateFactory
    00163 {
    00164 public:
    00165
    00169     virtual const String&   getType             () const;
    00170
    00174     virtual SubRenderState* createInstance      (ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass);
    00175
    00179     virtual void            writeInstance       (MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
    00180
    00181
    00182 protected:
    00183
    00187     virtual SubRenderState* createInstanceImpl  ();
    00188
    00189
    00190 };
    00191
    00195 }
    00196 }
    00197
    00198 #endif
    00199 #endif
    00200

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52