Implement new CPU lightmapper
Completely re-write the lightmap generation code: - Follow the general lightmapper code structure from 4.0. - Use proper path tracing to compute the global illumination. - Use atlassing to merge all lightmaps into a single texture (done by @RandomShaper) - Use OpenImageDenoiser to improve the generated lightmaps. - Take into account alpha transparency in material textures. - Allow baking environment lighting. - Add bicubic lightmap filtering. There is some minor compatibility breakage in some properties and methods in BakedLightmap, but lightmaps generated in previous engine versions should work fine out of the box. The scene importer has been changed to generate `.unwrap_cache` files next to the imported scene files. These files *SHOULD* be added to any version control system as they guarantee there won't be differences when re-importing the scene from other OSes or engine versions. This work started as a Google Summer of Code project; Was later funded by IMVU for a good amount of progress; Was then finished and polished by me on my free time. Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
This commit is contained in:
@ -502,6 +502,27 @@ public:
|
||||
return (cn.cross(an) > 0) == orientation;
|
||||
}
|
||||
|
||||
static Vector3 barycentric_coordinates_2d(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) {
|
||||
// http://www.blackpawn.com/texts/pointinpoly/
|
||||
Vector2 v0 = c - a;
|
||||
Vector2 v1 = b - a;
|
||||
Vector2 v2 = s - a;
|
||||
|
||||
// Compute dot products
|
||||
double dot00 = v0.dot(v0);
|
||||
double dot01 = v0.dot(v1);
|
||||
double dot02 = v0.dot(v2);
|
||||
double dot11 = v1.dot(v1);
|
||||
double dot12 = v1.dot(v2);
|
||||
|
||||
// Compute barycentric coordinates
|
||||
double invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
|
||||
double b2 = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
||||
double b1 = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
||||
double b0 = 1.0f - b2 - b1;
|
||||
return Vector3(b0, b1, b2);
|
||||
}
|
||||
|
||||
static Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 *p_segment) {
|
||||
|
||||
Vector2 p = p_point - p_segment[0];
|
||||
@ -1014,6 +1035,13 @@ public:
|
||||
|
||||
static void make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
|
||||
|
||||
struct PackRectsResult {
|
||||
int x;
|
||||
int y;
|
||||
bool packed;
|
||||
};
|
||||
static Vector<PackRectsResult> partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size);
|
||||
|
||||
static Vector<Vector3> compute_convex_mesh_points(const Plane *p_planes, int p_plane_count);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user