mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
add block material shaders
- 'shader' property of block materials: shaders/materials/<name>.glslv, .glslf with material_vertex / material_fragment hooks and #param uniforms - material shaders code is included into main, translucent and shadows programs through generated headers, no extra draw calls - chunk vertex normal.w byte replaced with 'flags': bit 7 - emission flag, bits 0-6 - material shader index (vertex format size is not changed) - doc/*/block-materials.md
This commit is contained in:
parent
f90750c066
commit
81489a13cf
33 changed files with 761 additions and 53 deletions
39
src/graphics/render/MaterialShaders.hpp
Normal file
39
src/graphics/render/MaterialShaders.hpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "data/dv_fwd.hpp"
|
||||
|
||||
class Content;
|
||||
class Shader;
|
||||
class ResPaths;
|
||||
class GLSLExtension;
|
||||
|
||||
/// @brief Material shaders (shaders/materials/<name>.glslv, .glslf) are
|
||||
/// included into the world shaders (main, translucent, shadows, entity)
|
||||
namespace material_shaders {
|
||||
inline constexpr const char* VERTEX_HEADER = "__materials_vertex__";
|
||||
inline constexpr const char* FRAGMENT_HEADER = "__materials_fragment__";
|
||||
|
||||
/// @brief Generate the world shaders headers from the material shaders.
|
||||
/// Must be called before the world shaders (re)compilation.
|
||||
/// @param content loaded content (nullable)
|
||||
void build_headers(
|
||||
GLSLExtension& preprocessor,
|
||||
const ResPaths& paths,
|
||||
const Content* content
|
||||
);
|
||||
|
||||
/// @brief Upload the material shaders params to the shader
|
||||
/// if changed since the previous call for this shader program
|
||||
void setup_shader(Shader& shader);
|
||||
|
||||
/// @brief Set the material shader params values ('param' directives)
|
||||
/// @param material material name (pack:name)
|
||||
/// @throws std::runtime_error if material or param does not exist
|
||||
void set_params(const std::string& material, const dv::value& params);
|
||||
|
||||
/// @brief Get the material shader params current values
|
||||
/// @return table of param name -> value or null if material has no shader
|
||||
dv::value get_params(const std::string& material);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue