18#ifndef HEADER_SP_BASE_HPP
19#define HEADER_SP_BASE_HPP
21#include "graphics/gl_headers.hpp"
22#include "utils/constants.hpp"
23#include "utils/no_copy.hpp"
39 namespace scene {
class ICameraSceneNode;
class IMesh; }
40 namespace video {
class SColor; }
49enum DrawCallType:
unsigned int
60inline std::ostream& operator<<(std::ostream& os,
const DrawCallType& dct)
65 return os <<
"normal";
67 return os <<
"transparent";
69 return os <<
"shadow cam 1";
71 return os <<
"shadow cam 2";
73 return os <<
"shadow cam 3";
75 return os <<
"shadow cam 4";
81enum SamplerType:
unsigned int;
82enum RenderPass:
unsigned int;
83class SPDynamicDrawCall;
89extern GLuint sp_mat_ubo[MAX_PLAYER_COUNT][3];
90extern GLuint sp_fog_ubo;
91extern std::array<GLuint, 1> sp_prefilled_tex;
92extern std::atomic<uint32_t> sp_max_texture_size;
93extern unsigned sp_solid_poly_count;
94extern unsigned sp_shadow_poly_count;
95extern int sp_cur_shadow_cascade;
96extern bool sp_culling;
97extern bool sp_debug_view;
98extern bool sp_apitrace;
99extern unsigned sp_cur_player;
100extern unsigned sp_cur_buf_id[MAX_PLAYER_COUNT];
101extern irr::core::vector3df sp_wind_dir;
107GLuint getSampler(SamplerType);
109SPShader* getNormalVisualizer();
111SPShader* getGlowShader();
113void prepareDrawCalls();
115void draw(RenderPass, DrawCallType dct = DCT_NORMAL);
119void drawSPDebugView();
121void addObject(SPMeshNode*);
127void handleDynamicDrawCall();
129void addDynamicDrawCall(std::shared_ptr<SPDynamicDrawCall>);
131void updateModelMatrix();
135void resetEmptyFogColor();
137void drawBoundingBoxes();
141SPMesh* convertEVTStandard(irr::scene::IMesh* mesh,
142 const irr::video::SColor* color = NULL);
144void uploadSPM(irr::scene::IMesh* mesh);
147inline void setMaxTextureSize() {}
149void setMaxTextureSize();
152inline void unsetMaxTextureSize() { sp_max_texture_size.store(2048); }
154inline uint8_t srgbToLinear(
float color_srgb)
157 if (color_srgb <= 0.04045f)
159 ret = (int)(255.0f * (color_srgb / 12.92f));
163 ret = (int)(255.0f * (powf((color_srgb + 0.055f) / 1.055f, 2.4f)));
165 return uint8_t(irr::core::clamp(ret, 0, 255));
168inline uint8_t srgb255ToLinear(
unsigned color_srgb_255)
170 static unsigned srgb_linear_map[256] =
172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
174 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4,
175 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7,
176 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11,
177 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
178 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22,
179 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29,
180 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38,
181 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47,
182 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58,
183 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71,
184 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84,
185 85, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99,
186 101, 102, 103, 105, 106, 107, 109, 110, 112, 113, 114, 116,
187 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134,
188 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153,
189 155, 157, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175,
190 176, 178, 180, 182, 184, 186, 188, 190, 192, 193, 195, 197,
191 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220, 222,
192 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248,
195 return uint8_t(srgb_linear_map[color_srgb_255]);
199inline uint8_t linearToSrgb(
float color_linear)
201 if (color_linear <= 0.0031308f)
203 color_linear = color_linear * 12.92f;
207 color_linear = 1.055f * powf(color_linear, 1.0f / 2.4f) - 0.055f;
209 return uint8_t(irr::core::clamp(
int(color_linear * 255.0f), 0, 255));
Definition: shader_based_renderer.hpp:49