diff options
| author | quou <quou@disroot.org> | 2025-02-22 17:01:35 +1100 | 
|---|---|---|
| committer | quou <quou@disroot.org> | 2025-02-22 17:01:53 +1100 | 
| commit | 04db6b0ccd81d988cfe3a1d09e4eb00eeea77273 (patch) | |
| tree | 5163857dca5070ecea802452c1e4e22806e4fbab /camera.cpp | |
| parent | 944ca7aede48f358329cc9e6cdac479648f30c17 (diff) | |
basic shadows
Diffstat (limited to 'camera.cpp')
| -rw-r--r-- | camera.cpp | 24 | 
1 files changed, 24 insertions, 0 deletions
| @@ -9,6 +9,30 @@ void Camera::init(float vfov, const v3f& f, const v3f& p) {  	asp = 1.0f;  } +void Camera::init_shadow( +	const v3f& dir, +	const v3f& mic, +	const v3f& mac +) { +	v3f up(0.0f, 1.0f, 0.0f); +	AABB aabb = { mic, mac }; +	init(0.0f, dir, v3f(0.0f)); +	view = m4f::lookat( +		dir, +		v3f(0.0f), +		up +	); +	aabb = m4f::transform(view, aabb); +	proj = m4f::orth( +		aabb.min.x, +		aabb.max.x, +		aabb.max.y, +		aabb.min.y, +		aabb.min.z, +		aabb.max.z +	); +} +  void Camera::update() {  	v3f up(0.0f, 1.0f, 0.0f);  	view = m4f::lookat(position, position + forward, up); |