mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
Introduce shadow mapping using a dedicated depth framebuffer and shader. The block fragment shader now performs percentage-closer filtering (PCF) with Poisson disk sampling and random rotation for soft shadows. The vertex shader outputs light-space coordinates. A new depth shader pair handles rendering from the light's perspective, discarding transparent fragments. The renderer sets up the light projection based on the camera position and sun direction, and applies the shadow factor to diffuse lighting. Day/night cycle can now be toggled off in the world server thread.
12 lines
310 B
GLSL
12 lines
310 B
GLSL
#version 460
|
|
layout (location = 0) in vec3 pos;
|
|
layout (location = 1) in vec2 texCoord;
|
|
layout (location = 2) in float layer;
|
|
uniform mat4 lightSpaceMatrix;
|
|
out vec2 tc;
|
|
flat out int tex_layer;
|
|
void main() {
|
|
tc = texCoord;
|
|
tex_layer = int(layer);
|
|
gl_Position = lightSpaceMatrix * vec4(pos, 1.0);
|
|
} |