lightAPI.h 2.5 KB

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