12 #ifndef hifi_image_CubeMap_h
13 #define hifi_image_CubeMap_h
15 #include <gpu/Texture.h>
16 #include <glm/vec4.hpp>
33 CubeMap(
int width,
int height,
int mipCount);
34 CubeMap(
const std::vector<Image>& faces,
int mipCount,
const std::atomic<bool>& abortProcessing =
false);
36 void reset(
int width,
int height,
int mipCount);
37 void copyTo(CubeMap& other)
const;
39 void applyGamma(
float value);
41 gpu::uint16 getMipCount()
const {
return (gpu::uint16)_mips.size(); }
42 int getMipWidth(gpu::uint16 mipLevel)
const {
43 return std::max(1, _width >> mipLevel);
45 int getMipHeight(gpu::uint16 mipLevel)
const {
46 return std::max(1, _height >> mipLevel);
48 gpu::Vec2i getMipDimensions(gpu::uint16 mipLevel)
const {
49 return gpu::Vec2i(getMipWidth(mipLevel), getMipHeight(mipLevel));
52 size_t getMipLineStride(gpu::uint16 mipLevel)
const {
53 return getMipWidth(mipLevel) + 2 * EDGE_WIDTH;
56 glm::vec4* editFace(gpu::uint16 mipLevel,
int face) {
57 return _mips[mipLevel][face].data() + (getMipLineStride(mipLevel) + 1)*EDGE_WIDTH;
60 const glm::vec4* getFace(gpu::uint16 mipLevel,
int face)
const {
61 return _mips[mipLevel][face].data() + (getMipLineStride(mipLevel) + 1)*EDGE_WIDTH;
64 Image getFaceImage(gpu::uint16 mipLevel,
int face)
const;
66 void convolveForGGX(CubeMap& output,
const std::atomic<bool>& abortProcessing)
const;
67 glm::vec4 fetchLod(
const glm::vec3& dir,
float lod)
const;
75 using Face = std::vector<glm::vec4>;
76 using Faces = std::array<Face, 6>;
80 std::vector<Faces> _mips;
82 static void getFaceUV(
const glm::vec3& dir,
int* index, glm::vec2* uv);
83 static void generateGGXSamples(GGXSamples& data,
float roughness,
const int resolution);
84 static void copyFace(
int width,
int height,
const glm::vec4* source,
size_t srcLineStride, glm::vec4* dest,
size_t dstLineStride);
85 void convolveMipFaceForGGX(
const GGXSamples& samples, CubeMap& output, gpu::uint16 mipLevel,
int face,
const std::atomic<bool>& abortProcessing)
const;
86 glm::vec4 computeConvolution(
const glm::vec3& normal,
const GGXSamples& samples)
const;