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

# OgreTerrainVertexProgram.cpp

Go to the documentation of this file.

    00001
    00002 /*
    00003 -----------------------------------------------------------------------------
    00004 This source file is part of OGRE
    00005 (Object-oriented Graphics Rendering Engine)
    00006 For the latest info, see http://www.ogre3d.org/
    00007
    00008 Copyright © 2000-2004 The OGRE Team
    00009 Also see acknowledgements in Readme.html
    00010
    00011 This program is free software; you can redistribute it and/or modify it under
    00012 the terms of the GNU Lesser General Public License as published by the Free Software
    00013 Foundation; either version 2 of the License, or (at your option) any later
    00014 version.
    00015
    00016 This program is distributed in the hope that it will be useful, but WITHOUT
    00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00019
    00020 You should have received a copy of the GNU Lesser General Public License along with
    00021 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00023 http://www.gnu.org/copyleft/lesser.txt.
    00024 -----------------------------------------------------------------------------
    00025 */
    00026
    00027 #include "OgreTerrainVertexProgram.h"
    00028
    00029 namespace Ogre {
    00030
    00031     String TerrainVertexProgram::mNoFogArbvp1 =
    00032         "!!ARBvp1.0\n"
    00033         "PARAM c5 = { 1, 1, 1, 1 };\n"
    00034         "#var float4x4 worldViewProj :  : c[0], 4 : 8 : 1\n"
    00035         "#var float morphFactor :  : c[4] : 9 : 1\n"
    00036         "TEMP R0;\n"
    00037         "ATTRIB v17 = vertex.weight;\n"
    00038         "ATTRIB v25 = vertex.texcoord[1];\n"
    00039         "ATTRIB v24 = vertex.texcoord[0];\n"
    00040         "ATTRIB v16 = vertex.position;\n"
    00041         "PARAM c0[4] = { program.local[0..3] };\n"
    00042         "PARAM c4 = program.local[4];\n"
    00043         "   MOV result.texcoord[0], v24;\n"
    00044         "   MOV result.texcoord[1], v25;\n"
    00045         "   MOV R0, v16;\n"
    00046         "   MAD R0.y, v17.x, c4.x, R0.y;\n"
    00047         "   DP4 result.position.x, c0[0], R0;\n"
    00048         "   DP4 result.position.y, c0[1], R0;\n"
    00049         "   DP4 result.position.z, c0[2], R0;\n"
    00050         "   DP4 result.position.w, c0[3], R0;\n"
    00051         "   MOV result.color.front.primary, c5.x;\n"
    00052         "END\n";
    00053
    00054     String TerrainVertexProgram::mLinearFogArbvp1 =
    00055         "!!ARBvp1.0\n"
    00056         "PARAM c5 = { 1, 1, 1, 1 };\n"
    00057         "#var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00058         "#var float morphFactor :  : c[4] : 10 : 1\n"
    00059         "TEMP R0, R1;\n"
    00060         "ATTRIB v17 = vertex.weight;\n"
    00061         "ATTRIB v25 = vertex.texcoord[1];\n"
    00062         "ATTRIB v24 = vertex.texcoord[0];\n"
    00063         "ATTRIB v16 = vertex.position;\n"
    00064         "PARAM c0[4] = { program.local[0..3] };\n"
    00065         "PARAM c4 = program.local[4];\n"
    00066         "   MOV result.texcoord[0], v24;\n"
    00067         "   MOV result.texcoord[1], v25;\n"
    00068         "   MOV R1, v16;\n"
    00069         "   MAD R1.y, v17.x, c4.x, R1.y;\n"
    00070         "   DP4 R0.x, c0[0], R1;\n"
    00071         "   DP4 R0.y, c0[1], R1;\n"
    00072         "   DP4 R0.z, c0[2], R1;\n"
    00073         "   DP4 R0.w, c0[3], R1;\n"
    00074         "   MOV result.fogcoord.x, R0.z;\n"
    00075         "   MOV result.position, R0;\n"
    00076         "   MOV result.color.front.primary, c5.x;\n"
    00077         "END\n";
    00078     String TerrainVertexProgram::mExpFogArbvp1 =
    00079         "!!ARBvp1.0\n"
    00080         "PARAM c6 = { 1, 1, 1, 1 };\n"
    00081         "PARAM c7 = { 2.71828, 0, 0, 0 };\n"
    00082         "#var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00083         "#var float morphFactor :  : c[4] : 10 : 1\n"
    00084         "#var float fogDensity :  : c[5] : 11 : 1\n"
    00085         "TEMP R0, R1;\n"
    00086         "ATTRIB v17 = vertex.weight;\n"
    00087         "ATTRIB v25 = vertex.texcoord[1];\n"
    00088         "ATTRIB v24 = vertex.texcoord[0];\n"
    00089         "ATTRIB v16 = vertex.position;\n"
    00090         "PARAM c5 = program.local[5];\n"
    00091         "PARAM c0[4] = { program.local[0..3] };\n"
    00092         "PARAM c4 = program.local[4];\n"
    00093         "   MOV result.texcoord[0], v24;\n"
    00094         "   MOV result.texcoord[1], v25;\n"
    00095         "   MOV R1, v16;\n"
    00096         "   MAD R1.y, v17.x, c4.x, R1.y;\n"
    00097         "   DP4 R0.x, c0[0], R1;\n"
    00098         "   DP4 R0.y, c0[1], R1;\n"
    00099         "   DP4 R0.z, c0[2], R1;\n"
    00100         "   DP4 R0.w, c0[3], R1;\n"
    00101         "   MOV result.position, R0;\n"
    00102         "   MOV result.color.front.primary, c6.x;\n"
    00103         "   MUL R0.zw, R0.z, c5.x;\n"
    00104         "   MOV R0.xy, c7.x;\n"
    00105         "   LIT R0.z, R0;\n"
    00106         "   RCP result.fogcoord.x, R0.z;\n"
    00107         "END\n";
    00108     String TerrainVertexProgram::mExp2FogArbvp1 =
    00109         "!!ARBvp1.0\n"
    00110         "PARAM c6 = { 1, 1, 1, 1 };\n"
    00111         "PARAM c7 = { 0.002, 2.71828, 0, 0 };\n"
    00112         "#var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00113         "#var float morphFactor :  : c[4] : 10 : 1\n"
    00114         "#var float fogDensity :  : c[5] : 11 : 1\n"
    00115         "TEMP R0, R1;\n"
    00116         "ATTRIB v17 = vertex.weight;\n"
    00117         "ATTRIB v25 = vertex.texcoord[1];\n"
    00118         "ATTRIB v24 = vertex.texcoord[0];\n"
    00119         "ATTRIB v16 = vertex.position;\n"
    00120         "PARAM c0[4] = { program.local[0..3] };\n"
    00121         "PARAM c4 = program.local[4];\n"
    00122         "   MOV result.texcoord[0], v24;\n"
    00123         "   MOV result.texcoord[1], v25;\n"
    00124         "   MOV R1, v16;\n"
    00125         "   MAD R1.y, v17.x, c4.x, R1.y;\n"
    00126         "   DP4 R0.x, c0[0], R1;\n"
    00127         "   DP4 R0.y, c0[1], R1;\n"
    00128         "   DP4 R0.z, c0[2], R1;\n"
    00129         "   DP4 R0.w, c0[3], R1;\n"
    00130         "   MOV result.position, R0;\n"
    00131         "   MOV result.color.front.primary, c6.x;\n"
    00132         "   MUL R0.x, R0.z, c7.x;\n"
    00133         "   MUL R0.zw, R0.x, R0.x;\n"
    00134         "   MOV R0.xy, c7.y;\n"
    00135         "   LIT R0.z, R0;\n"
    00136         "   RCP result.fogcoord.x, R0.z;\n"
    00137         "END\n";
    00138
    00139     String TerrainVertexProgram::mNoFogVs_1_1 =
    00140         "vs_1_1\n"
    00141         "def c5, 1, 1, 1, 1\n"
    00142         "//var float4x4 worldViewProj :  : c[0], 4 : 8 : 1\n"
    00143         "//var float morphFactor :  : c[4] : 9 : 1\n"
    00144         "dcl_blendweight v1\n"
    00145         "dcl_texcoord1 v8\n"
    00146         "dcl_texcoord0 v7\n"
    00147         "dcl_position v0\n"
    00148         "   mov oT0.xy, v7\n"
    00149         "   mov oT1.xy, v8\n"
    00150         "   mov r0, v0\n"
    00151         "   mad r0.y, v1.x, c4.x, r0.y\n"
    00152         "   dp4 oPos.x, c0, r0\n"
    00153         "   dp4 oPos.y, c1, r0\n"
    00154         "   dp4 oPos.z, c2, r0\n"
    00155         "   dp4 oPos.w, c3, r0\n"
    00156         "   mov oD0, c5.x\n";
    00157     String TerrainVertexProgram::mLinearFogVs_1_1 =
    00158         "vs_1_1\n"
    00159         "def c5, 1, 1, 1, 1\n"
    00160         "//var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00161         "//var float morphFactor :  : c[4] : 10 : 1\n"
    00162         "dcl_blendweight v1\n"
    00163         "dcl_texcoord1 v8\n"
    00164         "dcl_texcoord0 v7\n"
    00165         "dcl_position v0\n"
    00166         "   mov oT0.xy, v7\n"
    00167         "   mov oT1.xy, v8\n"
    00168         "   mov r1, v0\n"
    00169         "   mad r1.y, v1.x, c4.x, r1.y\n"
    00170         "   dp4 r0.x, c0, r1\n"
    00171         "   dp4 r0.y, c1, r1\n"
    00172         "   dp4 r0.z, c2, r1\n"
    00173         "   dp4 r0.w, c3, r1\n"
    00174         "   mov oFog, r0.z\n"
    00175         "   mov oPos, r0\n"
    00176         "   mov oD0, c5.x\n";
    00177     String TerrainVertexProgram::mExpFogVs_1_1 =
    00178         "vs_1_1\n"
    00179         "def c6, 1, 1, 1, 1\n"
    00180         "def c7, 2.71828, 0, 0, 0\n"
    00181         "//var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00182         "//var float morphFactor :  : c[4] : 10 : 1\n"
    00183         "//var float fogDensity :  : c[5] : 11 : 1\n"
    00184         "dcl_blendweight v1\n"
    00185         "dcl_texcoord1 v8\n"
    00186         "dcl_texcoord0 v7\n"
    00187         "dcl_position v0\n"
    00188         "   mov oT0.xy, v7\n"
    00189         "   mov oT1.xy, v8\n"
    00190         "   mov r1, v0\n"
    00191         "   mad r1.y, v1.x, c4.x, r1.y\n"
    00192         "   dp4 r0.x, c0, r1\n"
    00193         "   dp4 r0.y, c1, r1\n"
    00194         "   dp4 r0.z, c2, r1\n"
    00195         "   dp4 r0.w, c3, r1\n"
    00196         "   mov oPos, r0\n"
    00197         "   mov oD0, c6.x\n"
    00198         "   mul r0.zw, r0.z, c5.x\n"
    00199         "   mov r0.xy, c7.x\n"
    00200         "   lit r0.z, r0\n"
    00201         "   rcp oFog, r0.z\n";
    00202     String TerrainVertexProgram::mExp2FogVs_1_1 =
    00203         "vs_1_1\n"
    00204         "def c6, 1, 1, 1, 1\n"
    00205         "def c7, 0.002, 2.71828, 0, 0\n"
    00206         "//var float4x4 worldViewProj :  : c[0], 4 : 9 : 1\n"
    00207         "//var float morphFactor :  : c[4] : 10 : 1\n"
    00208         "//var float fogDensity :  : c[5] : 11 : 1\n"
    00209         "dcl_blendweight v1\n"
    00210         "dcl_texcoord1 v8\n"
    00211         "dcl_texcoord0 v7\n"
    00212         "dcl_position v0\n"
    00213         "   mov oT0.xy, v7\n"
    00214         "   mov oT1.xy, v8\n"
    00215         "   mov r1, v0\n"
    00216         "   mad r1.y, v1.x, c4.x, r1.y\n"
    00217         "   dp4 r0.x, c0, r1\n"
    00218         "   dp4 r0.y, c1, r1\n"
    00219         "   dp4 r0.z, c2, r1\n"
    00220         "   dp4 r0.w, c3, r1\n"
    00221         "   mov oPos, r0\n"
    00222         "   mov oD0, c6.x\n"
    00223         "   mul r0.x, r0.z, c7.x\n"
    00224         "   mul r0.zw, r0.x, r0.x\n"
    00225         "   mov r0.xy, c7.y\n"
    00226         "   lit r0.z, r0\n"
    00227         "   rcp oFog, r0.z\n";
    00228
    00229     const String& TerrainVertexProgram::getProgramSource(
    00230         FogMode fogMode, const String syntax)
    00231     {
    00232         switch(fogMode)
    00233         {
    00234         case FOG_NONE:
    00235             if (syntax == "arbvp1")
    00236             {
    00237                 return mNoFogArbvp1;
    00238             }
    00239             else
    00240             {
    00241                 return mNoFogVs_1_1;
    00242             }
    00243             break;
    00244         case FOG_LINEAR:
    00245             if (syntax == "arbvp1")
    00246             {
    00247                 return mLinearFogArbvp1;
    00248             }
    00249             else
    00250             {
    00251                 return mLinearFogVs_1_1;
    00252             }
    00253             break;
    00254         case FOG_EXP:
    00255             if (syntax == "arbvp1")
    00256             {
    00257                 return mExpFogArbvp1;
    00258             }
    00259             else
    00260             {
    00261                 return mExpFogVs_1_1;
    00262             }
    00263             break;
    00264         case FOG_EXP2:
    00265             if (syntax == "arbvp1")
    00266             {
    00267                 return mExp2FogArbvp1;
    00268             }
    00269             else
    00270             {
    00271                 return mExp2FogVs_1_1;
    00272             }
    00273             break;
    00274         };
    00275         // default
    00276         return StringUtil::BLANK;
    00277
    00278     }
    00279 }

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