NDEVR
API Documentation
GLESMaterialManager.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: VulkanMaterialManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include "GLBuffer.h"
35#include "GLESShader.h"
36#include "GLESGraphicsDevice.h"
37#include "GLESImage.h"
38#include <NDEVR/Model.h>
39#include <NDEVR/Material.h>
40namespace NDEVR
41{
43 class QOpenGLTexture;
54 static_assert(sizeof(GLESVertexUniformObject) == 16, "Bad VertexUniformSize");
55#pragma pack(push, 1)
96#pragma pack(pop)
102 {
103 public:
107 GLESMaterialManager(const GLESMaterialManager& m_pipeline) = delete;
110
112 void cleanup();
115 bool hasGrid() const { return m_has_grid; }
124 const GLESVertexUniformObject& vertexUniform() const { return m_vert_uniform; }
129
140 bool hasOpacity() const { return m_has_opacity; }
143 bool ignoreDepth() const { return m_ignore_depth; }
146 bool writeToDepth() const { return m_write_to_depth; }
149 bool usesModelColor() const { return m_use_model_color; }
152 bool usesLayerColor() const { return m_use_layer_color; }
158 fltp04 depthBias() const { return m_depth_bias; }
161 bool hasImage() const;
163 void commit();
177 StringView getExtraPropertyChannel() const { return m_extra_channel; }
194 Time lastDependencyUpdate() const { return m_last_push_update_time; }
197 UUID material() const;
200 bool isTwoSided() const { return m_is_two_sided; }
203 bool isWireframe() const { return m_is_wireframe; }
206 bool overrideCamera() const { return m_override_camera; }
209 bool useNormalForTexture() const { return m_use_normal_for_texture; }
212 bool useLighting() const;
215 bool smoothNormals() const;
218 uint08 id() const;
223 protected:
241 protected:
242 Buffer<Material> m_materials;
244 DynamicPointer<OpenGLBuffer> m_vertex_uniform_buffer;
245 DynamicPointer<OpenGLBuffer> m_frag_uniform_buffer;
246 GLESVertexUniformObject m_vert_uniform;
247 FragUniformObject m_frag_uniform;
248 Time m_last_updated_time;
249
250 Time m_last_push_update_time;
251
252 String m_image_address[cast<uint04>(UVType::e_uv_size)];
254
255 String m_extra_channel;
256 Vector<3, Material::TileTextureMode> m_texture_tile_mode;
257
258 DynamicPointer<GLESShaderManager> m_shader_manager;
259 Material::ShadingModel m_shade_model;
260 fltp04 m_depth_bias;
261 QOpenGLTexture* m_texture = nullptr;
262
263 mutable bool m_needs_to_commit_frag_buffer = true;
264 mutable bool m_needs_to_commit_vert_buffer = true;
265 bool m_needs_pipeline_update = true;
266 bool m_has_opacity = false;
267 bool m_has_image = false;
268 bool m_uses_color_channel = false;
269 bool m_has_image_opacity = false;
270 bool m_is_two_sided = false;
271 bool m_override_camera = false;
272 bool m_smooth_normals = false;
273 bool m_is_wireframe = false;
274 bool m_has_grid = false;
275 bool m_use_normal_for_texture = false;
276 bool m_use_model_color = false;
277 bool m_use_layer_color = false;
278 bool m_ignore_depth = false;
279 bool m_write_to_depth = true;
280 uint04 m_layer_number;
281 Material::UVMode m_uv_mode;
282 uint08 m_id;
283 };
284}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
bool useLighting() const
Checks whether lighting is enabled for the material.
void setUniformVariables(GLESShader *shader)
Pushes uniform values to the given shader.
void updateShader(const Material &mat, const GraphicsUpdateArguments &args, DynamicPointer< GLESShaderManager > &shader_manager)
Updates the shader for the given material if needed.
GLESMaterialManager(const DynamicPointer< GLESGraphicsDevice > &device)
Constructs a GLESMaterialManager for the given device.
bool overrideCamera() const
Checks whether the material overrides the camera projection.
void cleanup()
Releases all GPU resources held by this manager.
GLESVertexUniformObject getVertexUniformObject(const Material &material) const
Builds a vertex uniform object from the given material.
bool isTwoSided() const
Checks whether the material is two-sided.
void clearMaterials()
Removes all materials from this manager.
FragUniformObject getFragUniformObject(const Material &material) const
Builds a fragment uniform object from the given material.
bool isWireframe() const
Checks whether the material renders as wireframe.
bool hasGrid() const
Checks whether any material uses grid rendering.
~GLESMaterialManager()
Destroys the material manager and releases GPU resources.
bool ignoreDepth() const
Checks whether depth testing should be ignored.
uint08 id() const
Returns a unique identifier for this material manager instance.
GLESShader * getShader(GLESShader::Definition &definition) const
Returns the shader matching the given definition, creating if needed.
StringView getColorByChannel(GraphicsUpdateArguments &args) const
Returns the name of the color-by channel for the current material.
void commit()
Commits pending uniform buffer changes to the GPU.
void updateImages(const Material &material, GraphicsUpdateArguments &args, DynamicPointer< GLESImageManager > &manager)
Updates GPU textures for the given material.
bool smoothNormals() const
Checks whether smooth normal interpolation is enabled.
static uint08 MaterialID(const Material &material)
Computes a unique identifier for the given material.
Time lastDependencyUpdate() const
Returns the last time material dependencies were pushed to GPU.
bool needsToUpdateShader(const Material &material)
Checks whether the material's shader needs recompilation.
void createPipeline(GraphicsUpdateArguments &args, DynamicPointer< GLESShaderManager > &shader_manager, DynamicPointer< GLESImageManager > &manager)
Creates or recreates the rendering pipeline for the current materials.
void checkImages()
Checks whether any image textures need re-uploading.
uint04 getLayerNumber(const Material &material) const
Returns the layer number for the given material.
bool needsToUpdateImage(const Material &material)
Checks whether the material's image textures need updating.
void addMaterial(const Material &material)
Adds a material to this manager's material list.
uint04 getNumberOfImages(const GraphicsUpdateArguments &args) const
Returns the number of active texture images.
bool usesModelColor() const
Checks whether model color overrides material color.
fltp04 fadeDistance() const
Returns the distance at which objects begin to fade.
UUID material() const
Returns the UUID of the primary material managed by this instance.
fltp04 depthBias() const
Returns the depth bias offset.
bool useNormalForTexture() const
Checks whether normals are used for texture coordinate generation.
StringView getExtraPropertyChannel() const
Returns the extra property channel name.
void updateUniformBuffer(GraphicsUpdateArguments &args)
Updates uniform buffers from the current material state.
const GLESVertexUniformObject & vertexUniform() const
Returns the current vertex uniform object.
bool hasOpacity() const
Checks whether any material has opacity.
bool writeToDepth() const
Checks whether depth writing is enabled.
bool hasImage() const
Checks whether any material has a texture image.
bool usesLayerColor() const
Checks whether layer color overrides material color.
A Shader for rendering default OpenGL logic to the graphics card.
Definition GLESShader.h:16
Options that are used for performing an update on a Graphics Engine call.
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
ShadingModel
Enumerates the available shading models for material rendering.
Definition Material.h:162
UVMode
Defines UV mapping modes that control how texture colors are determined for surfaces.
Definition Material.h:185
TextureCoordMode
Defines how texture coordinates are generated or interpreted for a material.
Definition Material.h:226
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ e_uv_size
The number of UV types. Used for sizing arrays.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Items to send to the OpenGL Fragmentation shader.
Vector< 6, uint04 > textures
Texture unit indices.
FragUniformObject(const Material &m_material)
Constructs a FragUniformObject from a Material.
Vector< 3, Vector< 4, fltp04 > > constant_channels
Constant color channels (ambient, diffuse, specular).
uint04 render_mode
The active rendering mode flags.
Matrix< fltp04 > float_values
Matrix of float value ranges for the fragment shader.
Vector< 4, sint04 > m_grid_lines
Grid line positions.
fltp04 max_distance
Maximum visible distance.
void setMode(Material::TextureCoordMode mat_mode)
Sets the texture coordinate mode.
Vector< 4, sint04 > m_grid_lines_desc
Grid line descriptors.
FragUniformObject()
Default constructor.
fltp04 fade_distance
Distance at which objects begin to fade.
FloatPosition
Indices into the float_values matrix for fragment shader value ranges.
@ e_min_value_frag_pos
Index of the minimum value row.
@ e_mid_value_frag_pos
Index of the midpoint value row.
@ e_max_value_frag_pos
Index of the maximum value row.
uint04 texture_coord_mode
Texture coordinate generation mode.
Buffer< Vector< 4, fltp04 > > palette_colors
Color palette for indexed color rendering.
fltp04 shininess
Specular shininess exponent.
fltp04 opacity
Overall material opacity.
Defines the set of features a shader must support, used to select or compile the correct variant.
Definition GLESShader.h:37
Stores items to send to the OpenGL Vertex Shader.
fltp04 reserved1
Reserved for future use.
fltp04 reserved0
Reserved for future use.
fltp04 reserved2
Reserved for future use.
fltp04 pixel_thickness
The pixel thickness for line and point rendering.