heatHazeWithMask.vertex 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. };
  38. void main( VS_IN vertex, out VS_OUT result ) {
  39. #include "skinning.inc"
  40. // texture 0 takes the texture coordinates unmodified
  41. result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 );
  42. // texture 1 takes the texture coordinates and adds a scroll
  43. const float4 textureScroll = rpUser0;
  44. result.texcoord1 = float4( vertex.texcoord.xy, 0, 0 ) + textureScroll;
  45. // texture 2 takes the deform magnitude and scales it by the projection distance
  46. float4 vec = float4( 0, 1, 0, 1 );
  47. vec.z = dot4( modelPosition, rpModelViewMatrixZ );
  48. // magicProjectionAdjust is a magic scalar that scales the projection since we changed from
  49. // using the X axis to the Y axis to calculate R1. It is an approximation to closely match
  50. // what the original game did
  51. const float magicProjectionAdjust = 0.43f;
  52. float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
  53. float w = dot4 ( vec, rpProjectionMatrixW );
  54. // don't let the recip get near zero for polygons that cross the view plane
  55. w = max( w, 1.0 );
  56. x /= w;
  57. //x = x * ( 1.0f / ( w + 0.00001f ) );
  58. // clamp the distance so the the deformations don't get too wacky near the view
  59. x = min( x, 0.02 );
  60. const float4 deformMagnitude = rpUser1;
  61. result.texcoord2 = x * deformMagnitude;
  62. }