Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreTerrainVertexProgram.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 © 2000-2004 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025
    00026 #ifndef __TERRAINVERTEXPROGRAM_H__
    00027 #define __TERRAINVERTEXPROGRAM_H__
    00028
    00029 #include "OgrePrerequisites.h"
    00030 #include "OgreCommon.h"
    00031 #include "OgreString.h"
    00032
    00033 namespace Ogre {
    00034
    00035     /*
    00036     Static class containing the source to vertex programs used to
    00037     morph the terrain LOD levels. The programs are generated from
    00038     the following Cg:
    00039     @code
    00040     // No fog morphing terrain
    00041     void terrain_vp(
    00042         float4 position : POSITION,
    00043         float2 uv1      : TEXCOORD0,
    00044         float2 uv2      : TEXCOORD1,
    00045         float delta     : BLENDWEIGHT,
    00046
    00047         out float4 oPosition : POSITION,
    00048         out float2 oUv1      : TEXCOORD0,
    00049         out float2 oUv2      : TEXCOORD1,
    00050         out float4 colour    : COLOR,
    00051         uniform float4x4 worldViewProj,
    00052         uniform float morphFactor
    00053         )
    00054     {
    00055         // Apply morph
    00056         position.y = position.y + (delta.x * morphFactor);
    00057         // world / view / projection
    00058         oPosition = mul(worldViewProj, position);
    00059         // Main texture coords
    00060         oUv1 = uv1;
    00061         // Detail texture coords
    00062         oUv2 = uv2;
    00063         // Full bright (no lighting)
    00064         colour = float4(1,1,1,1);
    00065     }
    00066
    00067
    00068     // Linear fogged morphing terrain
    00069     void terrain_vp_linear(
    00070         float4 position : POSITION,
    00071         float2 uv1      : TEXCOORD0,
    00072         float2 uv2      : TEXCOORD1,
    00073         float delta     : BLENDWEIGHT,
    00074
    00075         out float4 oPosition : POSITION,
    00076         out float2 oUv1      : TEXCOORD0,
    00077         out float2 oUv2      : TEXCOORD1,
    00078         out float4 colour    : COLOR,
    00079         out float fog        : FOG,
    00080         uniform float4x4 worldViewProj,
    00081         uniform float morphFactor
    00082         )
    00083     {
    00084         // Apply morph
    00085         position.y = position.y + (delta.x * morphFactor);
    00086         // world / view / projection
    00087         oPosition = mul(worldViewProj, position);
    00088         // Main texture coords
    00089         oUv1 = uv1;
    00090         // Detail texture coords
    00091         oUv2 = uv2;
    00092         // Full bright (no lighting)
    00093         colour = float4(1,1,1,1);
    00094         // Fog
    00095         // f = end - camz / end - start
    00096         // when start / end has been set, fog value is distance
    00097         fog = oPosition.z;
    00098     }
    00099
    00100
    00101     // Exp fogged morphing terrain
    00102     void terrain_vp_exp(
    00103         float4 position : POSITION,
    00104         float2 uv1      : TEXCOORD0,
    00105         float2 uv2      : TEXCOORD1,
    00106         float delta     : BLENDWEIGHT,
    00107
    00108         out float4 oPosition : POSITION,
    00109         out float2 oUv1      : TEXCOORD0,
    00110         out float2 oUv2      : TEXCOORD1,
    00111         out float4 colour    : COLOR,
    00112         out float fog        : FOG,
    00113         uniform float4x4 worldViewProj,
    00114         uniform float morphFactor,
    00115         uniform float fogDensity)
    00116     {
    00117         // Apply morph
    00118         position.y = position.y + (delta.x * morphFactor);
    00119         // world / view / projection
    00120         oPosition = mul(worldViewProj, position);
    00121         // Main texture coords
    00122         oUv1 = uv1;
    00123         // Detail texture coords
    00124         oUv2 = uv2;
    00125         // Full bright (no lighting)
    00126         colour = float4(1,1,1,1);
    00127         // Fog
    00128         // f = 1 / e ^ (camz x density)
    00129         // note pow = exp(src1 * log(src0)).
    00130         fog = 1 / (exp((oPosition.z * fogDensity) * log(2.718281828)));
    00131     }
    00132
    00133
    00134     // Exp2 fogged morphing terrain
    00135     void terrain_vp_exp2(
    00136         float4 position : POSITION,
    00137         float2 uv1      : TEXCOORD0,
    00138         float2 uv2      : TEXCOORD1,
    00139         float delta     : BLENDWEIGHT,
    00140
    00141         out float4 oPosition : POSITION,
    00142         out float2 oUv1      : TEXCOORD0,
    00143         out float2 oUv2      : TEXCOORD1,
    00144         out float4 colour    : COLOR,
    00145         out float fog        : FOG,
    00146         uniform float4x4 worldViewProj,
    00147         uniform float morphFactor,
    00148         uniform float fogDensity)
    00149     {
    00150         // Apply morph
    00151         position.y = position.y + (delta.x * morphFactor);
    00152         // world / view / projection
    00153         oPosition = mul(worldViewProj, position);
    00154         // Main texture coords
    00155         oUv1 = uv1;
    00156         // Detail texture coords
    00157         oUv2 = uv2;
    00158         // Full bright (no lighting)
    00159         colour = float4(1,1,1,1);
    00160         // Fog
    00161         // f = 1 / e ^ (camz x density)^2
    00162         // note pow = exp(src1 * log(src0)).
    00163         float src1 = oPosition.z * 0.002;
    00164         fog = 1 / (exp((src1*src1) * log(2.718281828f)));
    00165     }
    00166
    00167     @endcode
    00168     */
    00169     class TerrainVertexProgram
    00170     {
    00171     private:
    00172         static String mNoFogArbvp1;
    00173         static String mLinearFogArbvp1;
    00174         static String mExpFogArbvp1;
    00175         static String mExp2FogArbvp1;
    00176
    00177         static String mNoFogVs_1_1;
    00178         static String mLinearFogVs_1_1;
    00179         static String mExpFogVs_1_1;
    00180         static String mExp2FogVs_1_1;
    00181
    00182     public:
    00184         static const String& getProgramSource(FogMode fogMode, const String syntax);
    00185
    00186
    00187     };
    00188 }
    00189
    00190 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:49 2004