BsIBLUtility.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsModule.h"
  6. namespace bs { namespace ct
  7. {
  8. /** @addtogroup Renderer-Internal
  9. * @{
  10. */
  11. /** Helper class that handles generation and processing of textures used for image based lighting. */
  12. class BS_CORE_EXPORT IBLUtility : public Module<IBLUtility>
  13. {
  14. public:
  15. /**
  16. * Performs filtering on the cubemap, populating its mip-maps with filtered values that can be used for
  17. * evaluating specular reflections.
  18. *
  19. * @param[in, out] cubemap Cubemap to filter. Its mip level 0 will be read, filtered and written into
  20. * other mip levels.
  21. * @param[in] scratch Temporary cubemap texture to use for the filtering process. Must match the size of
  22. * the source cubemap. Provide null to automatically create a scratch cubemap.
  23. */
  24. virtual void filterCubemapForSpecular(const SPtr<Texture>& cubemap, const SPtr<Texture>& scratch) const = 0;
  25. /**
  26. * Performs filtering on the cubemap, populating the output cubemap with values that can be used for evaluating
  27. * irradiance for use in diffuse lighting. Uses order-5 SH (25 coefficients) and outputs the values in the form of
  28. * a cubemap.
  29. *
  30. * @param[in] cubemap Cubemap to filter. Its mip level 0 will be used as source.
  31. * @param[in] output Output cubemap to store the irradiance data in.
  32. */
  33. virtual void filterCubemapForIrradiance(const SPtr<Texture>& cubemap, const SPtr<Texture>& output) const = 0;
  34. /**
  35. * Performs filtering on the cubemap, populating the output cubemap with values that can be used for evaluating
  36. * irradiance for use in diffuse lighting. Uses order-5 SH (9 coefficients) and outputs the values in the form of
  37. * a cubemap.
  38. *
  39. * @param[in] cubemap Cubemap to filter. Its mip level 0 will be used as source.
  40. * @param[in] output Output buffer in which to place the results. Must be allocated using
  41. * IrradianceReduceMat<ORDER>::createOutputBuffer();
  42. * @param[in] outputIdx Index in the output buffer at which to write the output coefficients to.
  43. */
  44. virtual void filterCubemapForIrradiance(const SPtr<Texture>& cubemap, const SPtr<GpuBuffer>& output,
  45. UINT32 outputIdx) const = 0;
  46. /**
  47. * Scales a cubemap and outputs it in the destination texture, using hardware acceleration. If both textures are the
  48. * same size, performs a copy instead.
  49. *
  50. * @param[in] src Source cubemap to scale.
  51. * @param[in] srcMip Determines which mip level of the source texture to scale.
  52. * @param[in] dst Desination texture to output the scaled data to. Must be usable as a render target.
  53. * @param[in] dstMip Determines which mip level of the destination texture to scale.
  54. */
  55. virtual void scaleCubemap(const SPtr<Texture>& src, UINT32 srcMip, const SPtr<Texture>& dst, UINT32 dstMip) const = 0;
  56. static const UINT32 REFLECTION_CUBEMAP_SIZE;
  57. static const UINT32 IRRADIANCE_CUBEMAP_SIZE;
  58. };
  59. /** Provides easy access to IBLUtility. */
  60. BS_CORE_EXPORT const IBLUtility& gIBLUtility();
  61. /** @} */
  62. }}