lens_flare.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_LENS_FLARE_H
  9. #define IGL_LENS_FLARE_H
  10. #ifndef IGL_NO_OPENGL
  11. #include <igl/OpenGL_convenience.h>
  12. #include <Eigen/Core>
  13. #include "igl_inline.h"
  14. #include <vector>
  15. namespace igl
  16. {
  17. struct Flare{
  18. int type; /* flare texture index, 0..5 */
  19. float scale;
  20. float loc; /* postion on axis */
  21. float color[3];
  22. Flare():
  23. type(-1),
  24. scale(0),
  25. loc(0)
  26. {}
  27. Flare(int type, float location, float scale, const float color[3], float colorScale) :
  28. type(type),
  29. scale(scale),
  30. loc(location)
  31. {
  32. this->color[0] = color[0] * colorScale;
  33. this->color[1] = color[1] * colorScale;
  34. this->color[2] = color[2] * colorScale;
  35. }
  36. };
  37. // Initialize shared data for lens flates
  38. //
  39. // Inputs:
  40. // start_id starting texture id location (should have at least id:id+16 free)
  41. // Outputs:
  42. // shine list of texture ids for shines
  43. // flare list of texture ids for flares
  44. IGL_INLINE void lens_flare_load_textures(
  45. std::vector<GLuint> & shine_ids,
  46. std::vector<GLuint> & flare_ids);
  47. // Create a set of lens flares
  48. //
  49. // Inputs:
  50. // A primary color
  51. // B secondary color
  52. // C secondary color
  53. // Outputs:
  54. // flares list of flare objects
  55. IGL_INLINE void lens_flare_create(
  56. const float * A,
  57. const float * B,
  58. const float * C,
  59. std::vector<Flare> & flares);
  60. // Draw lens flares
  61. //
  62. // Inputs:
  63. // flares list of Flare objects
  64. // shine_ids list of shine textures
  65. // flare_ids list of flare texture ids
  66. // light position of light
  67. // near_clip near clipping plane
  68. // shine_tic current "tic" in shine textures
  69. // Outputs:
  70. // shine_tic current "tic" in shine textures
  71. IGL_INLINE void lens_flare_draw(
  72. const std::vector<Flare> & flares,
  73. const std::vector<GLuint> & shine_ids,
  74. const std::vector<GLuint> & flare_ids,
  75. const Eigen::Vector3f & light,
  76. const float near_clip,
  77. int & shine_tic);
  78. };
  79. #ifndef IGL_STATIC_LIBRARY
  80. # include "lens_flare.cpp"
  81. #endif
  82. #endif
  83. #endif