Sky.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /******************************************************************************
  2. Use 'Sky' to set custom sky.
  3. /******************************************************************************/
  4. struct SkyClass
  5. {
  6. // manage
  7. SkyClass& clear( ); // disable sky rendering
  8. SkyClass& frac (Flt frac); Flt frac()C {return _frac;} // set/get sky fraction (fraction of the Viewport range where the sky starts), 0..1, default=0.8, (1 is the fastest)
  9. Bool is ()C {return _is ;} // if sky rendering is enabled
  10. // atmospheric sky
  11. SkyClass& atmospheric ( ); // enable drawing sky as atmospheric sky
  12. SkyClass& atmosphericDensityExponent ( Flt exp ); Flt atmosphericDensityExponent ()C {return _dns_exp ;} // set/get density exponent , 0..1 , default=1.0, (1 is the fastest)
  13. SkyClass& atmosphericHorizonExponent ( Flt exp ); Flt atmosphericHorizonExponent ()C {return _hor_exp ;} // set/get horizon exponent , 0..Inf , default=3.5, (this affects at what height the horizon color will be selected instead of the sky color)
  14. SkyClass& atmosphericHorizonColor (C Vec4 &color ); Vec4 atmosphericHorizonColor ()C {return _hor_col ;} // set/get horizon color , (0,0,0,0)..(1,1,1,1) , default=(0.32, 0.46, 0.58, 1.0) here alpha specifies opacity to combine with star map when used
  15. SkyClass& atmosphericSkyColor (C Vec4 &color ); Vec4 atmosphericSkyColor ()C {return _sky_col ;} // set/get sky color , (0,0,0,0)..(1,1,1,1) , default=(0.16, 0.36, 0.54, 1.0) here alpha specifies opacity to combine with star map when used
  16. SkyClass& atmosphericStars (C ImagePtr &cube ); C ImagePtr& atmosphericStars ()C {return _stars ;} // set/get sky star map , image must be in IMAGE_CUBE format, default=null
  17. SkyClass& atmosphericStarsOrientation(C Matrix3 &orn ); Matrix3 atmosphericStarsOrientation()C {return _stars_m ;} // set/get sky star orientation, 'orn' must be normalized , default=MatrixIdentity
  18. SkyClass& atmosphericPrecision ( Bool per_pixel); Bool atmosphericPrecision ()C {return _precision;} // set/get sky precision , true/false , default=true (false for OpenGL ES), if false is set then sky calculations are done per-vertex with lower quality
  19. SkyClass& atmosphericColor(C Vec4 &horizon_color, C Vec4 &sky_color) {return atmosphericHorizonColor(horizon_color).atmosphericSkyColor(sky_color);} // set atmospheric horizon and sky color
  20. // sky from skybox
  21. SkyClass& skybox (C ImagePtr &image ); C ImagePtr &skybox ()C {return _image[0] ;} // enable drawing sky as skybox
  22. SkyClass& skybox (C ImagePtr &a, C ImagePtr &b); C ImagePtr &skybox2 ()C {return _image[1] ;} // enable drawing sky as blend between 2 skyboxes
  23. SkyClass& skyboxBlend( Flt blend ); Flt skyboxBlend()C {return _box_blend;} // set/get blend factor between 2 skyboxes, 0..1, default=0.5
  24. #if EE_PRIVATE
  25. Bool isActual ()C {return _is && FovPerspective(D.viewFovMode());}
  26. SkyClass& del ();
  27. SkyClass& create ();
  28. Bool wantDepth ()C;
  29. void draw ();
  30. void setFracMulAdd();
  31. #endif
  32. SkyClass();
  33. #if !EE_PRIVATE
  34. private:
  35. #endif
  36. Bool _is, _precision;
  37. Flt _frac, _dns_exp, _hor_exp, _box_blend;
  38. Vec4 _hor_col, _sky_col;
  39. Matrix3 _stars_m;
  40. MeshRender _mshr;
  41. ImagePtr _image[2], _stars;
  42. }extern
  43. Sky; // Main Sky
  44. /******************************************************************************/