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
20 lines
469 B
GLSL
20 lines
469 B
GLSL
#ifndef COMMONS_GLSL_
|
|
#define COMMONS_GLSL_
|
|
|
|
#include <constants>
|
|
|
|
vec3 apply_planet_curvature(vec3 modelPos, vec3 pos3d) {
|
|
modelPos.y -= pow(length(pos3d.xz) * CURVATURE_FACTOR, 3.0f);
|
|
return modelPos;
|
|
}
|
|
|
|
// chunk vertex flags (normal.w): bit 7 - emission flag, bits 0-6 - material
|
|
float unpack_emission(float w) {
|
|
return float(int(w * 255.0 + 0.5) >> 7);
|
|
}
|
|
|
|
int unpack_material(float w) {
|
|
return int(w * 255.0 + 0.5) & 127;
|
|
}
|
|
|
|
#endif // COMMONS_GLSL_
|