lightAPI.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 
  2. #ifndef DFPSR_DEFERRED_LIGHT_ENGINE
  3. #define DFPSR_DEFERRED_LIGHT_ENGINE
  4. #include <assert.h>
  5. #include "../../DFPSR/includeFramework.h"
  6. #include "orthoAPI.h"
  7. namespace dsr {
  8. // Light-space is like camera-space, but with the Y-axis straight up in world-space instead of leaning forward.
  9. // Light space has its origin in the center of camera space.
  10. // The X axis goes to the right side in image-space.
  11. // The Z axis goes away from the camera and is aligned with Y = 0.
  12. // Light sources are given in relative coordinates, but calculated in light-space.
  13. // Send positions as (world-space - cameraPosition).
  14. // Send directions in world-space.
  15. // Send normalToWorldSpace to define the rotation from light-space to world-space.
  16. // The filters will rotate the light sources from world-space to light-space using the inverse of normalToWorldSpace.
  17. // screenDepthProjection defines the coordinate system being used for placing light.
  18. // OrthoSystem in the sprite API can automatically create a light projection system for camera space in whole tile units.
  19. // It's X axis defines how much the Y=0 position moves along an X pixel.
  20. // It's Y axis defines how much the Y=0 position moves along a Y pixel.
  21. // It's Z axis defines how much the final 3D position moves along a tile unit of depth based on the depth-buffers
  22. // Deferred light operations
  23. void setDirectedLight(const OrthoView& camera, OrderedImageRgbaU8& lightBuffer, const OrderedImageRgbaU8& normalBuffer, const FVector3D& lightDirection, float lightIntensity, const ColorRgbI32& lightColor);
  24. void addDirectedLight(const OrthoView& camera, OrderedImageRgbaU8& lightBuffer, const OrderedImageRgbaU8& normalBuffer, const FVector3D& lightDirection, float lightIntensity, const ColorRgbI32& lightColor);
  25. void addPointLight(const OrthoView& camera, const IVector2D& worldCenter, OrderedImageRgbaU8& lightBuffer, const OrderedImageRgbaU8& normalBuffer, const AlignedImageF32& heightBuffer, const FVector3D& lightPosition, float lightRadius, float lightIntensity, const ColorRgbI32& lightColor, const AlignedImageF32& shadowCubeMap);
  26. void addPointLight(const OrthoView& camera, const IVector2D& worldCenter, OrderedImageRgbaU8& lightBuffer, const OrderedImageRgbaU8& normalBuffer, const AlignedImageF32& heightBuffer, const FVector3D& lightPosition, float lightRadius, float lightIntensity, const ColorRgbI32& lightColor);
  27. void blendLight(AlignedImageRgbaU8& targetColor, const OrderedImageRgbaU8& diffuseBuffer, const OrderedImageRgbaU8& lightBuffer);
  28. }
  29. #endif