heatHazeWithMaskAndVertex.vertex (3395B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 #include "global.inc" 30 31 uniform matrices_ubo { float4 matrices[408]; }; 32 33 uniform float4 rpUser0 : register(c128); // rpScroll 34 uniform float4 rpUser1 : register(c129); // rpDeformMagnitude 35 36 struct VS_IN { 37 float4 position : POSITION; 38 float2 texcoord : TEXCOORD0; 39 float4 normal : NORMAL; 40 float4 tangent : TANGENT; 41 float4 color : COLOR0; 42 float4 color2 : COLOR1; 43 }; 44 45 struct VS_OUT { 46 float4 position : POSITION; 47 float4 texcoord0 : TEXCOORD0; 48 float4 texcoord1 : TEXCOORD1; 49 float4 texcoord2 : TEXCOORD2; 50 float4 color : COLOR0; 51 }; 52 53 void main( VS_IN vertex, out VS_OUT result ) { 54 55 #include "skinning.inc" 56 57 // texture 0 takes the texture coordinates unmodified 58 result.texcoord0 = float4( vertex.texcoord, 0 , 0 ); 59 60 // texture 1 takes the texture coordinates and adds a scroll 61 const float4 textureScroll = rpUser0; 62 result.texcoord1 = float4( vertex.texcoord, 0, 0 ) + textureScroll; 63 64 // texture 2 takes the deform magnitude and scales it by the projection distance 65 float4 vec = float4( 0, 1, 0, 1 ); 66 vec.z = dot4( modelPosition, rpModelViewMatrixZ ); 67 68 // magicProjectionAdjust is a magic scalar that scales the projection since we changed from 69 // using the X axis to the Y axis to calculate x. It is an approximation to closely match 70 // what the original game did 71 const float magicProjectionAdjust = 0.43f; 72 float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust; 73 float w = dot4( vec, rpProjectionMatrixW ); 74 75 // don't let the recip get near zero for polygons that cross the view plane 76 w = max( w, 1.0f ); 77 x /= w; 78 //x = x * ( 1.0f / w ); 79 80 // clamp the distance so the the deformations don't get too wacky near the view 81 x = min( x, 0.02f ); 82 83 const float4 deformMagnitude = rpUser1; 84 result.texcoord2 = x * deformMagnitude; 85 result.color = swizzleColor( vertex.color ); 86 }