mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
- '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
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#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);
|
|
}
|