Visual Computing Library  devel
Loading...
Searching...
No Matches
drawable_environment_uniforms.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2026 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_ENVIRONMENT_UNIFORMS_H
24#define VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_ENVIRONMENT_UNIFORMS_H
25
26#include <vclib/bgfx/uniform.h>
27#include <vclib/render/settings/pbr_viewer_settings.h>
28
29namespace vcl {
30
39{
40 static inline std::array<float, 4> sData = {
41 0.0, // roughness
42 0.0, // cube side
43 0.0,
44 0.0};
45
46 static inline Uniform sDataUniform;
47
48public:
50
51 static void setRoughness(float roughness) { sData[0] = roughness; }
52
53 static void setCubeSideResolution(float cubeSide) { sData[1] = cubeSide; }
54
55 static void bind()
56 {
57 if (!sDataUniform.isValid())
58 sDataUniform =
59 Uniform("u_environmentSettingsPack", bgfx::UniformType::Vec4);
60 sDataUniform.bind(sData.data());
61 }
62};
63
64} // namespace vcl
65
66#endif // VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_ENVIRONMENT_UNIFORMS_H
The DrawableEnvironmentUniforms class is responsible for managing the shader uniforms related to a dr...
Definition drawable_environment_uniforms.h:39
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:41
The Uniform class wraps a bgfx::UniformHandle and provides a simple interface to set the uniform data...
Definition uniform.h:43
void bind(const void *data) const
Sets the uniform data for the current shader program.
Definition uniform.h:165
bool isValid() const
Checks if the Uniform is valid (i.e., if it has a valid bgfx::UniformHandle).
Definition uniform.h:129