Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. Index: code/weapon/beam.cpp
  2. ===================================================================
  3. --- code/weapon/beam.cpp (Revision 7331)
  4. +++ code/weapon/beam.cpp (Arbeitskopie)
  5. @@ -34,6 +34,7 @@
  6. #include "parse/parselo.h"
  7. #include "iff_defs/iff_defs.h"
  8. #include "globalincs/globals.h"
  9. +#include "graphics/gropengl.h"
  10.  
  11.  
  12.  
  13. @@ -1568,7 +1569,7 @@
  14.  
  15. // add a unique light
  16. // noise *= 0.1f; // a little less noise here, since we want the beam to generally cast a bright light
  17. - light_add_point_unique(&near_pt, light_rad * 0.0001f, light_rad, 1.0f, fr, fg, fb, OBJ_INDEX(objp));
  18. + light_add_point_unique(&near_pt, light_rad * 0.0001f, light_rad,1.0f, fr, fg, fb, OBJ_INDEX(objp));
  19. }
  20.  
  21. // call to add a light source to a large object
  22. @@ -1609,7 +1610,18 @@
  23.  
  24. // add a unique light
  25. noise *= 0.1f; // a little less noise here, since we want the beam to generally cast a bright light
  26. - light_add_tube(pt0, pt1, 1.0f, light_rad, 1.0f * noise, fr, fg, fb, OBJ_INDEX(objp));
  27. +
  28. + vec3d near_pt, a, b;
  29. + float dist;
  30. + vm_vec_dist_to_line(&objp->pos, &bm->last_start, &bm->last_shot, &near_pt, &dist);
  31. + vm_vec_sub(&a, &bm->last_shot, &bm->last_start);
  32. + vm_vec_normalize_quick(&a);
  33. + vm_vec_scale_add(&b, &near_pt, &a, bwi->beam_muzzle_radius * (-3.0f)); // Valathil: Move the light away from the ship somewhat
  34. +
  35. + if(dist> light_rad + objp->radius ){
  36. + return;
  37. + }
  38. + light_add_tube(pt0, &b, 1.0f, light_rad, 1.0f * noise, fr, fg, fb, OBJ_INDEX(objp));
  39. }
  40.  
  41. // mark an object as being lit
  42. @@ -1704,12 +1716,13 @@
  43.  
  44. // from a collision
  45. case 2:
  46. + // Valathil: Dont render impact lights, handled by tube lighting
  47. // a few meters from the collision point
  48. - vm_vec_sub(&dir, &l->bm->last_start, &l->c_point);
  49. + /*vm_vec_sub(&dir, &l->bm->last_start, &l->c_point);
  50. vm_vec_normalize_quick(&dir);
  51. vm_vec_scale_add(&pt, &l->c_point, &dir, bwi->beam_muzzle_radius * 5.0f);
  52.  
  53. - beam_add_light_small(l->bm, &Objects[l->objnum], &pt);
  54. + beam_add_light_small(l->bm, &Objects[l->objnum], &pt);*/
  55. break;
  56. }
  57. }
  58. Index: code/graphics/gropengllight.cpp
  59. ===================================================================
  60. --- code/graphics/gropengllight.cpp (Revision 7331)
  61. +++ code/graphics/gropengllight.cpp (Arbeitskopie)
  62. @@ -19,6 +19,7 @@
  63. #include "graphics/gropenglextension.h"
  64. #include "graphics/gropengllight.h"
  65. #include "graphics/gropenglstate.h"
  66. +#include "graphics/gropenglshader.h"
  67. #include "graphics/2d.h"
  68. #include "render/3d.h"
  69. #include "cmdline/cmdline.h"
  70. @@ -91,7 +92,7 @@
  71. switch (FSLight->type) {
  72. case LT_POINT: {
  73. // this crap still needs work...
  74. - GLLight->ConstantAtten = 0.0f;
  75. + GLLight->ConstantAtten = 1.0f;
  76. GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
  77.  
  78. GLLight->Specular[0] *= static_point_factor;
  79. @@ -102,15 +103,35 @@
  80. }
  81.  
  82. case LT_TUBE: {
  83. +
  84. + GLLight->ConstantAtten = 1.0f;
  85. + GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
  86. +
  87. GLLight->Specular[0] *= static_tube_factor;
  88. GLLight->Specular[1] *= static_tube_factor;
  89. GLLight->Specular[2] *= static_tube_factor;
  90.  
  91. - GLLight->SpotDir[0] = FSLight->vec2.xyz.x * 1.5f;
  92. - GLLight->SpotDir[1] = FSLight->vec2.xyz.y * 1.5f;
  93. - GLLight->SpotDir[2] = FSLight->vec2.xyz.z * 1.5f;
  94. - GLLight->SpotCutOff = 90.0f;
  95. + GLLight->Position[0] = FSLight->vec2.xyz.x; // Valathil: Use endpoint of tube as light position
  96. + GLLight->Position[1] = FSLight->vec2.xyz.y;
  97. + GLLight->Position[2] = FSLight->vec2.xyz.z;
  98. + GLLight->Position[3] = 1.0f;
  99.  
  100. + if( Use_GLSL > 1) {
  101. +
  102. + // Valathil: When using shaders pass the beam direction (not normalized IMPORTANT for calculation of tube)
  103. + vec3d a;
  104. + vm_vec_sub(&a, &FSLight->vec2, &FSLight->vec);
  105. + GLLight->SpotDir[0] = a.xyz.x;
  106. + GLLight->SpotDir[1] = a.xyz.y;
  107. + GLLight->SpotDir[2] = a.xyz.z;
  108. + GLLight->SpotCutOff = 90.0f; // Valathil: So shader dectects tube light
  109. + }
  110. + else {
  111. + GLLight->SpotDir[0] = 1.0f; // Valathil: When not using shaders pass a fake spotdir
  112. + GLLight->SpotDir[1] = 0.0f;
  113. + GLLight->SpotDir[2] = 0.0f;
  114. + GLLight->SpotCutOff = 180.0f; //Valathil: Should be a point light not a spot; using tube only for the light sorting
  115. + }
  116. break;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement