heatHazeWithMaskAndVertex.vertex 3.3 KB

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