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-2012 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(const 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     // Fog calculation mode.
    00141     CalcMode mCalcMode;
    00142     // Fog formula.
    00143     FogMode mFogMode;
    00144     // Fog colour value.
    00145     ColourValue mFogColourValue;
    00146     // Fog parameters (density, start, end, 1/end-start).
    00147     Vector4 mFogParamsValue;
    00148     // True if the fog parameters should be taken from the pass.
    00149     bool mPassOverrideParams;
    00150
    00151     // World view projection parameter.
    00152     UniformParameterPtr mWorldViewProjMatrix;
    00153     // Fog colour parameter.
    00154     UniformParameterPtr mFogColour;
    00155     // Fog parameters program parameter.
    00156     UniformParameterPtr mFogParams;
    00157     // Vertex shader input position parameter.
    00158     ParameterPtr mVSInPos;
    00159     // Vertex shader output fog colour parameter.
    00160     ParameterPtr mVSOutFogFactor;
    00161     // Pixel shader input fog factor.
    00162     ParameterPtr mPSInFogFactor;
    00163     // Vertex shader output depth.
    00164     ParameterPtr mVSOutDepth;
    00165     // Pixel shader input depth.
    00166     ParameterPtr mPSInDepth;
    00167     // Pixel shader output diffuse colour.
    00168     ParameterPtr mPSOutDiffuse;
    00169 };
    00170
    00171
    00176 class _OgreRTSSExport FFPFogFactory : public SubRenderStateFactory
    00177 {
    00178 public:
    00179
    00183     virtual const String& getType() const;
    00184
    00188     virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
    00189
    00193     virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
    00194
    00195
    00196 protected:
    00197
    00201     virtual SubRenderState* createInstanceImpl();
    00202
    00203
    00204 };
    00205
    00209 }
    00210 }
    00211
    00212 #endif
    00213 #endif
    00214

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:23