source: OGRE/trunk/ogrenew/Docs/api/html/OgreTerrainVertexProgram_8h-source.html @ 657

Revision 657, 19.7 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1<html>
2<head>
3<title>OgreTerrainVertexProgram.h Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4<link type="text/css" rel="stylesheet" href="style.css">
5</head>
6
7<body>
8<!-- Generated by Doxygen 1.3.6 -->
9<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
10<h1>OgreTerrainVertexProgram.h</h1><a href="OgreTerrainVertexProgram_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>
1100002 <span class="comment">-----------------------------------------------------------------------------</span>
1200003 <span class="comment">This source file is part of OGRE</span>
1300004 <span class="comment">(Object-oriented Graphics Rendering Engine)</span>
1400005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span>
1500006 <span class="comment"></span>
1600007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span>
1700008 <span class="comment">Also see acknowledgements in Readme.html</span>
1800009 <span class="comment"></span>
1900010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span>
2000011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span>
2100012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span>
2200013 <span class="comment">version.</span>
2300014 <span class="comment"></span>
2400015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span>
2500016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span>
2600017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span>
2700018 <span class="comment"></span>
2800019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span>
2900020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span>
3000021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span>
3100022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span>
3200023 <span class="comment">-----------------------------------------------------------------------------</span>
3300024 <span class="comment">*/</span>
3400025
3500026 <span class="preprocessor">#ifndef __TERRAINVERTEXPROGRAM_H__</span>
3600027 <span class="preprocessor"></span><span class="preprocessor">#define __TERRAINVERTEXPROGRAM_H__</span>
3700028 <span class="preprocessor"></span>
3800029 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span>
3900030 <span class="preprocessor">#include "<a class="code" href="OgreCommon_8h.html">OgreCommon.h</a>"</span>
4000031 <span class="preprocessor">#include "<a class="code" href="OgreString_8h.html">OgreString.h</a>"</span>
4100032
4200033 <span class="keyword">namespace </span>Ogre {
4300034
4400035     <span class="comment">/*</span>
4500036 <span class="comment">    Static class containing the source to vertex programs used to </span>
4600037 <span class="comment">    morph the terrain LOD levels. The programs are generated from </span>
4700038 <span class="comment">    the following Cg:</span>
4800039 <span class="comment">    @code   </span>
4900040 <span class="comment">    // No fog morphing terrain</span>
5000041 <span class="comment">    void terrain_vp(</span>
5100042 <span class="comment">        float4 position : POSITION,</span>
5200043 <span class="comment">        float2 uv1      : TEXCOORD0,</span>
5300044 <span class="comment">        float2 uv2      : TEXCOORD1,</span>
5400045 <span class="comment">        float delta     : BLENDWEIGHT,</span>
5500046 <span class="comment"></span>
5600047 <span class="comment">        out float4 oPosition : POSITION,</span>
5700048 <span class="comment">        out float2 oUv1      : TEXCOORD0,</span>
5800049 <span class="comment">        out float2 oUv2      : TEXCOORD1,</span>
5900050 <span class="comment">        out float4 colour    : COLOR,</span>
6000051 <span class="comment">        uniform float4x4 worldViewProj,</span>
6100052 <span class="comment">        uniform float morphFactor</span>
6200053 <span class="comment">        )</span>
6300054 <span class="comment">    {</span>
6400055 <span class="comment">        // Apply morph</span>
6500056 <span class="comment">        position.y = position.y + (delta.x * morphFactor);</span>
6600057 <span class="comment">        // world / view / projection</span>
6700058 <span class="comment">        oPosition = mul(worldViewProj, position);</span>
6800059 <span class="comment">        // Main texture coords</span>
6900060 <span class="comment">        oUv1 = uv1;</span>
7000061 <span class="comment">        // Detail texture coords</span>
7100062 <span class="comment">        oUv2 = uv2;</span>
7200063 <span class="comment">        // Full bright (no lighting)</span>
7300064 <span class="comment">        colour = float4(1,1,1,1);</span>
7400065 <span class="comment">    }</span>
7500066 <span class="comment"></span>
7600067 <span class="comment"></span>
7700068 <span class="comment">    // Linear fogged morphing terrain</span>
7800069 <span class="comment">    void terrain_vp_linear(</span>
7900070 <span class="comment">        float4 position : POSITION,</span>
8000071 <span class="comment">        float2 uv1      : TEXCOORD0,</span>
8100072 <span class="comment">        float2 uv2      : TEXCOORD1,</span>
8200073 <span class="comment">        float delta     : BLENDWEIGHT,</span>
8300074 <span class="comment"></span>
8400075 <span class="comment">        out float4 oPosition : POSITION,</span>
8500076 <span class="comment">        out float2 oUv1      : TEXCOORD0,</span>
8600077 <span class="comment">        out float2 oUv2      : TEXCOORD1,</span>
8700078 <span class="comment">        out float4 colour    : COLOR,</span>
8800079 <span class="comment">        out float fog        : FOG,</span>
8900080 <span class="comment">        uniform float4x4 worldViewProj,</span>
9000081 <span class="comment">        uniform float morphFactor</span>
9100082 <span class="comment">        )</span>
9200083 <span class="comment">    {</span>
9300084 <span class="comment">        // Apply morph</span>
9400085 <span class="comment">        position.y = position.y + (delta.x * morphFactor);</span>
9500086 <span class="comment">        // world / view / projection</span>
9600087 <span class="comment">        oPosition = mul(worldViewProj, position);</span>
9700088 <span class="comment">        // Main texture coords</span>
9800089 <span class="comment">        oUv1 = uv1;</span>
9900090 <span class="comment">        // Detail texture coords</span>
10000091 <span class="comment">        oUv2 = uv2;</span>
10100092 <span class="comment">        // Full bright (no lighting)</span>
10200093 <span class="comment">        colour = float4(1,1,1,1);</span>
10300094 <span class="comment">        // Fog </span>
10400095 <span class="comment">        // f = end - camz / end - start</span>
10500096 <span class="comment">        // when start / end has been set, fog value is distance</span>
10600097 <span class="comment">        fog = oPosition.z;</span>
10700098 <span class="comment">    }</span>
10800099 <span class="comment"></span>
10900100 <span class="comment"></span>
11000101 <span class="comment">    // Exp fogged morphing terrain</span>
11100102 <span class="comment">    void terrain_vp_exp(</span>
11200103 <span class="comment">        float4 position : POSITION,</span>
11300104 <span class="comment">        float2 uv1      : TEXCOORD0,</span>
11400105 <span class="comment">        float2 uv2      : TEXCOORD1,</span>
11500106 <span class="comment">        float delta     : BLENDWEIGHT,</span>
11600107 <span class="comment"></span>
11700108 <span class="comment">        out float4 oPosition : POSITION,</span>
11800109 <span class="comment">        out float2 oUv1      : TEXCOORD0,</span>
11900110 <span class="comment">        out float2 oUv2      : TEXCOORD1,</span>
12000111 <span class="comment">        out float4 colour    : COLOR,</span>
12100112 <span class="comment">        out float fog        : FOG,</span>
12200113 <span class="comment">        uniform float4x4 worldViewProj,</span>
12300114 <span class="comment">        uniform float morphFactor,</span>
12400115 <span class="comment">        uniform float fogDensity)</span>
12500116 <span class="comment">    {</span>
12600117 <span class="comment">        // Apply morph</span>
12700118 <span class="comment">        position.y = position.y + (delta.x * morphFactor);</span>
12800119 <span class="comment">        // world / view / projection</span>
12900120 <span class="comment">        oPosition = mul(worldViewProj, position);</span>
13000121 <span class="comment">        // Main texture coords</span>
13100122 <span class="comment">        oUv1 = uv1;</span>
13200123 <span class="comment">        // Detail texture coords</span>
13300124 <span class="comment">        oUv2 = uv2;</span>
13400125 <span class="comment">        // Full bright (no lighting)</span>
13500126 <span class="comment">        colour = float4(1,1,1,1);</span>
13600127 <span class="comment">        // Fog </span>
13700128 <span class="comment">        // f = 1 / e ^ (camz x density)</span>
13800129 <span class="comment">        // note pow = exp(src1 * log(src0)).</span>
13900130 <span class="comment">        fog = 1 / (exp((oPosition.z * fogDensity) * log(2.718281828)));</span>
14000131 <span class="comment">    }</span>
14100132 <span class="comment"></span>
14200133 <span class="comment"></span>
14300134 <span class="comment">    // Exp2 fogged morphing terrain</span>
14400135 <span class="comment">    void terrain_vp_exp2(</span>
14500136 <span class="comment">        float4 position : POSITION,</span>
14600137 <span class="comment">        float2 uv1      : TEXCOORD0,</span>
14700138 <span class="comment">        float2 uv2      : TEXCOORD1,</span>
14800139 <span class="comment">        float delta     : BLENDWEIGHT,</span>
14900140 <span class="comment"></span>
15000141 <span class="comment">        out float4 oPosition : POSITION,</span>
15100142 <span class="comment">        out float2 oUv1      : TEXCOORD0,</span>
15200143 <span class="comment">        out float2 oUv2      : TEXCOORD1,</span>
15300144 <span class="comment">        out float4 colour    : COLOR,</span>
15400145 <span class="comment">        out float fog        : FOG,</span>
15500146 <span class="comment">        uniform float4x4 worldViewProj,</span>
15600147 <span class="comment">        uniform float morphFactor,</span>
15700148 <span class="comment">        uniform float fogDensity)</span>
15800149 <span class="comment">    {</span>
15900150 <span class="comment">        // Apply morph</span>
16000151 <span class="comment">        position.y = position.y + (delta.x * morphFactor);</span>
16100152 <span class="comment">        // world / view / projection</span>
16200153 <span class="comment">        oPosition = mul(worldViewProj, position);</span>
16300154 <span class="comment">        // Main texture coords</span>
16400155 <span class="comment">        oUv1 = uv1;</span>
16500156 <span class="comment">        // Detail texture coords</span>
16600157 <span class="comment">        oUv2 = uv2;</span>
16700158 <span class="comment">        // Full bright (no lighting)</span>
16800159 <span class="comment">        colour = float4(1,1,1,1);</span>
16900160 <span class="comment">        // Fog </span>
17000161 <span class="comment">        // f = 1 / e ^ (camz x density)^2</span>
17100162 <span class="comment">        // note pow = exp(src1 * log(src0)).</span>
17200163 <span class="comment">        float src1 = oPosition.z * 0.002;</span>
17300164 <span class="comment">        fog = 1 / (exp((src1*src1) * log(2.718281828f)));</span>
17400165 <span class="comment">    }</span>
17500166 <span class="comment"></span>
17600167 <span class="comment">    // Shadow receiver vertex program</span>
17700168 <span class="comment">    void terrain_shadow_receiver_vp(</span>
17800169 <span class="comment">        float4 position : POSITION,</span>
17900170 <span class="comment">        float2 uv1      : TEXCOORD0,</span>
18000171 <span class="comment">        float2 uv2      : TEXCOORD1,</span>
18100172 <span class="comment">        float delta     : BLENDWEIGHT,</span>
18200173 <span class="comment"></span>
18300174 <span class="comment">        out float4 oPosition : POSITION,</span>
18400175 <span class="comment">        out float2 oUv1      : TEXCOORD0,</span>
18500176 <span class="comment">        out float4 colour    : COLOR,</span>
18600177 <span class="comment">        uniform float4x4 worldViewProj,</span>
18700178 <span class="comment">        uniform float4x4 world,</span>
18800179 <span class="comment">        uniform float4x4 textureViewProj,</span>
18900180 <span class="comment">        uniform float morphFactor</span>
19000181 <span class="comment">        )</span>
19100182 <span class="comment">    {</span>
19200183 <span class="comment">        // Apply morph</span>
19300184 <span class="comment">        position.y = position.y + (delta.x * morphFactor);</span>
19400185 <span class="comment">        // world / view / projection</span>
19500186 <span class="comment">        oPosition = mul(worldViewProj, position);</span>
19600187 <span class="comment">        </span>
19700188 <span class="comment">        // Main texture coords</span>
19800189 <span class="comment">        float4 worldpos = mul(world, position);</span>
19900190 <span class="comment">        float4 projuv = mul(textureViewProj, worldpos);</span>
20000191 <span class="comment">        oUv1.xy = projuv.xy / projuv.w;</span>
20100192 <span class="comment">        // Full bright (no lighting)</span>
20200193 <span class="comment">        colour = float4(1,1,1,1);</span>
20300194 <span class="comment">    }</span>
20400195 <span class="comment"></span>
20500196 <span class="comment">    @endcode</span>
20600197 <span class="comment">    */</span>
207<a name="l00198"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html">00198</a>     <span class="keyword">class </span><a class="code" href="classOgre_1_1TerrainVertexProgram.html">TerrainVertexProgram</a>
20800199     {
20900200     <span class="keyword">private</span>:
210<a name="l00201"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv0">00201</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv0">mNoFogArbvp1</a>;
211<a name="l00202"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv1">00202</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv1">mLinearFogArbvp1</a>;
212<a name="l00203"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv2">00203</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv2">mExpFogArbvp1</a>;
213<a name="l00204"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv3">00204</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv3">mExp2FogArbvp1</a>;
214<a name="l00205"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv4">00205</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv4">mShadowReceiverArbvp1</a>;
21500206
216<a name="l00207"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv5">00207</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv5">mNoFogVs_1_1</a>;
217<a name="l00208"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv6">00208</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv6">mLinearFogVs_1_1</a>;
218<a name="l00209"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv7">00209</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv7">mExpFogVs_1_1</a>;
219<a name="l00210"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv8">00210</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv8">mExp2FogVs_1_1</a>;
220<a name="l00211"></a><a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv9">00211</a>         <span class="keyword">static</span> <a class="code" href="namespaceOgre.html#a426">String</a> <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexProgramv9">mShadowReceiverVs_1_1</a>;
22100212
22200213     <span class="keyword">public</span>:
22300215         <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceOgre.html#a426">String</a>&amp; <a class="code" href="classOgre_1_1TerrainVertexProgram.html#Ogre_1_1TerrainVertexPrograme0">getProgramSource</a>(FogMode fogMode,
22400216             <span class="keyword">const</span> <a class="code" href="namespaceOgre.html#a426">String</a> syntax, <span class="keywordtype">bool</span> shadowReceiver = <span class="keyword">false</span>);
22500217
22600218
22700219     };
22800220 }
22900221
23000222 <span class="preprocessor">#endif</span>
231</pre></div><hr>
232<p>
233Copyright &copy; 2000-2005 by The OGRE Team<br />
234<!--Creative Commons License--><a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.png"/></a><br/>
235This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike 2.5 License</a>.<br/>
236                <!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
237                <Work rdf:about="">
238                        <license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" />
239        <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
240                </Work>
241                <License rdf:about="http://creativecommons.org/licenses/by-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License></rdf:RDF> -->
242
243Last modified Sun Feb 12 12:59:53 2006
244</p>
245</body>
246</html>
Note: See TracBrowser for help on using the repository browser.