1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Refactored shadowmapping.

- Made shadow bias size independent, so it will remain when changing light or camera size.
- Implemented normal offset bias, which greatly enhances quality.
- Added transmission to subsurface scattering
- Reimplemented shadow filter modes

Closes #17260
This commit is contained in:
Juan Linietsky
2020-04-07 22:51:52 -03:00
parent b2f79cac9a
commit 4ffc0d6b3f
34 changed files with 1032 additions and 291 deletions

View File

@@ -170,17 +170,15 @@ public:
_add_item(aabb, ITEM_TYPE_OMNI_LIGHT, light_count);
} break;
case LIGHT_TYPE_SPOT: {
Vector3 v(0, 0, -1);
v.rotated(Vector3(0, 1, 0), Math::deg2rad(ld.spot_aperture)); //rotate in x-z
v.normalize();
v *= ld.radius;
v.y = v.x;
float r = ld.radius;
real_t len = Math::tan(Math::deg2rad(ld.spot_aperture)) * r;
aabb.position = xform.origin;
aabb.expand_to(xform.xform(v));
aabb.expand_to(xform.xform(Vector3(-v.x, v.y, v.z)));
aabb.expand_to(xform.xform(Vector3(-v.x, -v.y, v.z)));
aabb.expand_to(xform.xform(Vector3(v.x, -v.y, v.z)));
aabb.expand_to(xform.xform(Vector3(len, len, -r)));
aabb.expand_to(xform.xform(Vector3(-len, len, -r)));
aabb.expand_to(xform.xform(Vector3(-len, -len, -r)));
aabb.expand_to(xform.xform(Vector3(len, -len, -r)));
_add_item(aabb, ITEM_TYPE_SPOT_LIGHT, light_count);
} break;
}