lens_flare.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_OPENGL2_LENS_FLARE_H
  9. #define IGL_OPENGL2_LENS_FLARE_H
  10. #include "../opengl/OpenGL_convenience.h"
  11. #include "../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include <vector>
  14. namespace igl
  15. {
  16. namespace opengl2
  17. {
  18. struct Flare{
  19. int type; /* flare texture index, 0..5 */
  20. float scale;
  21. float loc; /* postion on axis */
  22. float color[3];
  23. Flare():
  24. type(-1),
  25. scale(0),
  26. loc(0)
  27. {}
  28. Flare(int type, float location, float scale, const float color[3], float colorScale) :
  29. type(type),
  30. scale(scale),
  31. loc(location)
  32. {
  33. this->color[0] = color[0] * colorScale;
  34. this->color[1] = color[1] * colorScale;
  35. this->color[2] = color[2] * colorScale;
  36. }
  37. };
  38. // Initialize shared data for lens flates
  39. //
  40. // Inputs:
  41. // start_id starting texture id location (should have at least id:id+16 free)
  42. // Outputs:
  43. // shine list of texture ids for shines
  44. // flare list of texture ids for flares
  45. IGL_INLINE void lens_flare_load_textures(
  46. std::vector<GLuint> & shine_ids,
  47. std::vector<GLuint> & flare_ids);
  48. // Create a set of lens flares
  49. //
  50. // Inputs:
  51. // A primary color
  52. // B secondary color
  53. // C secondary color
  54. // Outputs:
  55. // flares list of flare objects
  56. IGL_INLINE void lens_flare_create(
  57. const float * A,
  58. const float * B,
  59. const float * C,
  60. std::vector<Flare> & flares);
  61. // Draw lens flares
  62. //
  63. // Inputs:
  64. // flares list of Flare objects
  65. // shine_ids list of shine textures
  66. // flare_ids list of flare texture ids
  67. // light position of light
  68. // near_clip near clipping plane
  69. // shine_tic current "tic" in shine textures
  70. // Outputs:
  71. // shine_tic current "tic" in shine textures
  72. IGL_INLINE void lens_flare_draw(
  73. const std::vector<Flare> & flares,
  74. const std::vector<GLuint> & shine_ids,
  75. const std::vector<GLuint> & flare_ids,
  76. const Eigen::Vector3f & light,
  77. const float near_clip,
  78. int & shine_tic);
  79. }
  80. };
  81. #ifndef IGL_STATIC_LIBRARY
  82. # include "lens_flare.cpp"
  83. #endif
  84. #endif