mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-17 16:17: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.
39 lines
773 B
C++
39 lines
773 B
C++
#pragma once
|
|
|
|
#define GLFW_INCLUDE_NONE
|
|
#include <GLFW/glfw3.h>
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
|
|
namespace Cubed {
|
|
|
|
class Player;
|
|
|
|
class Camera {
|
|
private:
|
|
bool m_firse_mouse = true;
|
|
Player* m_player;
|
|
float m_last_mouse_x, m_last_mouse_y;
|
|
glm::vec3 m_camera_pos;
|
|
bool m_under_water = false;
|
|
|
|
public:
|
|
Camera();
|
|
|
|
void update_move_camera();
|
|
|
|
void camera_init(Player* player);
|
|
void hot_reload();
|
|
void reset_camera();
|
|
void update_cursor_position_camera(double xpos, double ypos);
|
|
|
|
const glm::mat4 get_camera_lookat() const;
|
|
const glm::vec3& get_camera_pos() const;
|
|
|
|
bool is_under_water() const;
|
|
glm::vec3 get_camera_front() const;
|
|
};
|
|
|
|
} // namespace Cubed
|