GlistEngine
Loading...
Searching...
No Matches
gSkybox.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Nitra Games Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef GRAPHICS_GSKYBOX_H_
18#define GRAPHICS_GSKYBOX_H_
19
20#include <array>
21#include <string>
22#include "gNode.h"
23#include "gVbo.h"
24#include "gImage.h"
25
29class gSkybox : public gNode {
30public:
32 virtual ~gSkybox();
33
34 unsigned int getTextureId() const;
35
40 unsigned int loadTextures(const std::vector<std::string>& texturePaths);
41
46 unsigned int load(const std::vector<std::string>& fullPaths);
47
48 unsigned int loadEquirectangular(const std::string& fullPath);
49 unsigned int loadTextureEquirectangular(const std::string& texturePath);
50
51 void loadFromData(std::array<int, 6> widths, std::array<int, 6> heights, std::array<void*, 6> rawdata, std::array<bool, 6> ishdr);
52
57 void draw();
58
61
62 void loadSkybox(gImage* images);
63 void loadDataSkybox(std::string* data, int width, int height);
64private:
65 unsigned int id;
66 // The six faces as ordinary 2D textures, for the Vulkan path. That backend has
67 // no cube map here, so the sky is drawn as six quads instead and each one needs
68 // a texture of its own. Zero where a face never loaded.
69 std::array<unsigned int, 6> vkfaceids{};
70 int width, height, nrChannels;
71 void setupRenderData();
72 // Uploads one face through the renderer's plain 2D texture path. hdr converts
73 // float source pixels down to bytes first.
74 unsigned int uploadVulkanFace(int faceWidth, int faceHeight, void* pixels, bool hdr = false);
75 void drawVulkan();
76
77 unsigned int cubeVAO, cubeVBO;
78 unsigned int skyboxVAO, skyboxVBO;
79
80 gShader* skyboxshader;
81
82 gVbo vbo;
83 int skymapint, skymapslot;
84
85 //Equirectangular variables and objects
86 gShader* pbrShader;
87 gShader* equirectangularToCubemapShader;
88 gShader* irradianceShader;
89 gShader* prefilterShader;
90 gShader* brdfShader;
91
92 unsigned int captureFBO;
93 unsigned int captureRBO;
94 unsigned int irradianceMap;
95 unsigned int prefilterMap;
96 unsigned int brdfLUTTexture;
97 unsigned int quadVAO;
98 unsigned int quadVBO;
99
100 void renderCube();
101 void renderQuad();
102
103 bool ishdr, ispbr;
104};
105
106#endif /* GRAPHICS_GSKYBOX_H_ */
Definition gImage.h:34
Definition gShader.h:19
void draw()
unsigned int load(const std::vector< std::string > &fullPaths)
unsigned int loadTextures(const std::vector< std::string > &texturePaths)
virtual ~gSkybox()
unsigned int loadEquirectangular(const std::string &fullPath)
void loadFromData(std::array< int, 6 > widths, std::array< int, 6 > heights, std::array< void *, 6 > rawdata, std::array< bool, 6 > ishdr)
void loadSkybox(gImage *images)
void generatePbrMaps()
unsigned int getTextureId() const
void bindPbrMaps()
unsigned int loadTextureEquirectangular(const std::string &texturePath)
void loadDataSkybox(std::string *data, int width, int height)
Definition gVbo.h:30