From b1ca82c43a09e95b0072ef9cd67a0cdb4d416507 Mon Sep 17 00:00:00 2001 From: JFonS Date: Mon, 11 Jan 2021 20:20:22 +0100 Subject: [PATCH] CPU lightmapper fixes. - Fix Embree runtime when using MinGW (patch by @RandomShaper). - Fix baking of lightmaps on GridMaps. - Fix some GLSL errors. - Fix overflow in the number of shader variants (GLES2). --- doc/classes/ProjectSettings.xml | 2 +- drivers/gles2/rasterizer_scene_gles2.cpp | 6 +- drivers/gles2/rasterizer_storage_gles2.cpp | 2 + drivers/gles2/shader_compiler_gles2.h | 2 +- drivers/gles2/shaders/scene.glsl | 15 ++- drivers/gles3/rasterizer_storage_gles3.cpp | 2 + drivers/gles3/shaders/scene.glsl | 14 +-- modules/denoise/denoise_wrapper.cpp | 4 +- modules/denoise/denoise_wrapper.h | 4 +- modules/denoise/lightmap_denoiser.cpp | 4 +- modules/denoise/lightmap_denoiser.h | 4 +- modules/denoise/register_types.cpp | 4 +- modules/denoise/register_types.h | 4 +- modules/lightmapper_cpu/lightmapper_cpu.cpp | 4 +- modules/lightmapper_cpu/lightmapper_cpu.h | 4 +- modules/lightmapper_cpu/register_types.cpp | 4 +- modules/lightmapper_cpu/register_types.h | 4 +- modules/raycast/lightmap_raycaster.cpp | 4 +- modules/raycast/lightmap_raycaster.h | 4 +- modules/raycast/register_types.cpp | 4 +- modules/raycast/register_types.h | 4 +- scene/3d/baked_lightmap.cpp | 19 ++++ scene/3d/lightmapper.cpp | 4 +- scene/3d/lightmapper.h | 4 +- servers/visual_server.cpp | 3 - thirdparty/embree/common/sys/intrinsics.h | 14 +++ thirdparty/embree/common/sys/mutex.h | 16 +++ thirdparty/embree/common/sys/sysinfo.cpp | 2 +- .../common/tasking/taskschedulerinternal.cpp | 8 ++ thirdparty/embree/pathces/godot-changes.patch | 105 +++++++++++++++++- 30 files changed, 217 insertions(+), 57 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 1992cef09bc3..2ef5b17d5606 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1182,7 +1182,7 @@ Lower-end override for [member rendering/quality/intended_usage/framebuffer_allocation] on mobile devices, due to performance concerns or driver support. - Enable usage of bicubic sampling in baked lightmaps. This results in smoother looking lighting at the expense of more bandwidth usage. + Enable usage of bicubic sampling in baked lightmaps. This results in smoother looking lighting at the expense of more bandwidth usage. On GLES2, changes to this setting will only be applied upon restarting the application. Lower-end override for [member rendering/quality/lightmapping/use_bicubic_sampling] on mobile devices, in order to reduce bandwidth usage. diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index d0e4c5a51c67..ff27f113338d 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -4050,14 +4050,16 @@ void RasterizerSceneGLES2::initialize() { } } + if (storage->config.use_lightmap_filter_bicubic) { + state.scene_shader.add_custom_define("#define USE_LIGHTMAP_FILTER_BICUBIC\n"); + } + shadow_filter_mode = SHADOW_FILTER_NEAREST; glFrontFace(GL_CW); } void RasterizerSceneGLES2::iteration() { - storage->config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling"); - state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_FILTER_BICUBIC, storage->config.use_lightmap_filter_bicubic); shadow_filter_mode = ShadowFilterMode(int(GLOBAL_GET("rendering/quality/shadows/filter_mode"))); } diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 4a17f3274d4b..03ff9b560102 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -6299,6 +6299,8 @@ void RasterizerStorageGLES2::initialize() { config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading"); config.use_fast_texture_filter = GLOBAL_GET("rendering/quality/filters/use_nearest_mipmap_filter"); + GLOBAL_DEF_RST("rendering/quality/lightmapping/use_bicubic_sampling", true); + GLOBAL_DEF_RST("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false); config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling"); } diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h index f302001da593..c4877d23b0e0 100644 --- a/drivers/gles2/shader_compiler_gles2.h +++ b/drivers/gles2/shader_compiler_gles2.h @@ -98,4 +98,4 @@ class ShaderCompilerGLES2 { ShaderCompilerGLES2(); }; -#endif // SHADERCOMPILERGLES3_H +#endif // SHADERCOMPILERGLES2_H diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index d1f59c0a2a8d..9b2521c2c142 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -890,7 +890,7 @@ void reflection_process(samplerCube reflection_map, uniform mediump sampler2D lightmap; //texunit:-4 uniform mediump float lightmap_energy; -#ifdef USE_LIGHTMAP_FILTER_BICUBIC +#if defined(USE_LIGHTMAP_FILTER_BICUBIC) uniform mediump vec2 lightmap_texture_size; // w0, w1, w2, and w3 are the four cubic B-spline basis functions @@ -951,11 +951,6 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) { return (g0(fuv.y) * (g0x * texture2D(tex, p0) + g1x * texture2D(tex, p1))) + (g1(fuv.y) * (g0x * texture2D(tex, p2) + g1x * texture2D(tex, p3))); } -#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D_bicubic(m_tex, m_uv) - -#else //!USE_LIGHTMAP_FILTER_BICUBIC -#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D(m_tex, m_uv) - #endif //USE_LIGHTMAP_FILTER_BICUBIC #endif @@ -1728,8 +1723,12 @@ FRAGMENT_SHADER_CODE } #ifdef USE_LIGHTMAP - //ambient light will come entirely from lightmap is lightmap is used - ambient_light = LIGHTMAP_TEXTURE_SAMPLE(lightmap, uv2_interp).rgb * lightmap_energy; +//ambient light will come entirely from lightmap is lightmap is used +#if defined(USE_LIGHTMAP_FILTER_BICUBIC) + ambient_light = texture2D_bicubic(lightmap, uv2_interp).rgb * lightmap_energy; +#else + ambient_light = texture2D(lightmap, uv2_interp).rgb * lightmap_energy; +#endif #endif #ifdef USE_LIGHTMAP_CAPTURE diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 13e7ce333ed9..6984e3f2e82c 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -8555,6 +8555,8 @@ void RasterizerStorageGLES3::initialize() { String renderer = (const char *)glGetString(GL_RENDERER); + GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling", true); + GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false); config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling"); config.use_depth_prepass = bool(GLOBAL_GET("rendering/quality/depth_prepass/enable")); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index ba430b520d7e..78071ea51b04 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1488,7 +1488,7 @@ float h1(float a) { return 1.0 + w3(a) / (w2(a) + w3(a)); } -vec4 texture2D_bicubic(sampler2D tex, vec2 uv) { +vec4 texture_bicubic(sampler2D tex, vec2 uv) { vec2 texel_size = vec2(1.0) / lightmap_texture_size; uv = uv * lightmap_texture_size + vec2(0.5); @@ -1508,11 +1508,11 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) { vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size; vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size; - return (g0(fuv.y) * (g0x * texture2D(tex, p0) + g1x * texture2D(tex, p1))) + - (g1(fuv.y) * (g0x * texture2D(tex, p2) + g1x * texture2D(tex, p3))); + return (g0(fuv.y) * (g0x * texture(tex, p0) + g1x * texture(tex, p1))) + + (g1(fuv.y) * (g0x * texture(tex, p2) + g1x * texture(tex, p3))); } -vec4 texture_bicubic(sampler2DArray tex, vec3 uv) { +vec4 textureArray_bicubic(sampler2DArray tex, vec3 uv) { vec2 texel_size = vec2(1.0) / lightmap_texture_size; uv.xy = uv.xy * lightmap_texture_size + vec2(0.5); @@ -1536,11 +1536,11 @@ vec4 texture_bicubic(sampler2DArray tex, vec3 uv) { (g1(fuv.y) * (g0x * texture(tex, vec3(p2, uv.z)) + g1x * texture(tex, vec3(p3, uv.z)))); } -#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D_bicubic(m_tex, m_uv) -#define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) texture_bicubic(m_tex, m_uv) +#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture_bicubic(m_tex, m_uv) +#define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) textureArray_bicubic(m_tex, m_uv) #else //!USE_LIGHTMAP_FILTER_BICUBIC -#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture2D(m_tex, m_uv) +#define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv) #define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv) #endif //USE_LIGHTMAP_FILTER_BICUBIC diff --git a/modules/denoise/denoise_wrapper.cpp b/modules/denoise/denoise_wrapper.cpp index cc0d52d46f0a..0ef33e7ba522 100644 --- a/modules/denoise/denoise_wrapper.cpp +++ b/modules/denoise/denoise_wrapper.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/denoise/denoise_wrapper.h b/modules/denoise/denoise_wrapper.h index 2107df09c174..25e342bc93f1 100644 --- a/modules/denoise/denoise_wrapper.h +++ b/modules/denoise/denoise_wrapper.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/denoise/lightmap_denoiser.cpp b/modules/denoise/lightmap_denoiser.cpp index 6978f2a8470a..6023ebf05a2d 100644 --- a/modules/denoise/lightmap_denoiser.cpp +++ b/modules/denoise/lightmap_denoiser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/denoise/lightmap_denoiser.h b/modules/denoise/lightmap_denoiser.h index e7f5c23637b8..21d5ca3f328d 100644 --- a/modules/denoise/lightmap_denoiser.h +++ b/modules/denoise/lightmap_denoiser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/denoise/register_types.cpp b/modules/denoise/register_types.cpp index c9c90c3408d9..5fe835a365ec 100644 --- a/modules/denoise/register_types.cpp +++ b/modules/denoise/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/denoise/register_types.h b/modules/denoise/register_types.h index f0f1f44bfec2..516a91b134a5 100644 --- a/modules/denoise/register_types.h +++ b/modules/denoise/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/lightmapper_cpu/lightmapper_cpu.cpp b/modules/lightmapper_cpu/lightmapper_cpu.cpp index a49652162373..3cbdc7dc9efa 100644 --- a/modules/lightmapper_cpu/lightmapper_cpu.cpp +++ b/modules/lightmapper_cpu/lightmapper_cpu.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/lightmapper_cpu/lightmapper_cpu.h b/modules/lightmapper_cpu/lightmapper_cpu.h index f090ccdc2fe2..eb9a3a33ea09 100644 --- a/modules/lightmapper_cpu/lightmapper_cpu.h +++ b/modules/lightmapper_cpu/lightmapper_cpu.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/lightmapper_cpu/register_types.cpp b/modules/lightmapper_cpu/register_types.cpp index bd56763e85aa..f5861311b928 100644 --- a/modules/lightmapper_cpu/register_types.cpp +++ b/modules/lightmapper_cpu/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/lightmapper_cpu/register_types.h b/modules/lightmapper_cpu/register_types.h index 11594184c6b4..3033e838bee2 100644 --- a/modules/lightmapper_cpu/register_types.h +++ b/modules/lightmapper_cpu/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/raycast/lightmap_raycaster.cpp b/modules/raycast/lightmap_raycaster.cpp index ef0eaa3694c5..2a0a216f7694 100644 --- a/modules/raycast/lightmap_raycaster.cpp +++ b/modules/raycast/lightmap_raycaster.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/raycast/lightmap_raycaster.h b/modules/raycast/lightmap_raycaster.h index e04286f40c68..b116cf6466bc 100644 --- a/modules/raycast/lightmap_raycaster.h +++ b/modules/raycast/lightmap_raycaster.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/raycast/register_types.cpp b/modules/raycast/register_types.cpp index 8af3c467ab24..b6799ce62969 100644 --- a/modules/raycast/register_types.cpp +++ b/modules/raycast/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/raycast/register_types.h b/modules/raycast/register_types.h index 341359b23708..789604a4917d 100644 --- a/modules/raycast/register_types.h +++ b/modules/raycast/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index ecd0f5a85e7a..425857dde42e 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -370,6 +370,13 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector Array bmeshes = p_at_node->call("get_bake_meshes"); if (bmeshes.size() && (bmeshes.size() & 1) == 0) { Transform xf = get_global_transform().affine_inverse() * s->get_global_transform(); + Ref all_override; + + GeometryInstance *gi = Object::cast_to(p_at_node); + if (gi) { + all_override = mi->get_material_override(); + } + for (int i = 0; i < bmeshes.size(); i += 2) { Ref mesh = bmeshes[i]; if (!mesh.is_valid()) { @@ -385,6 +392,18 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector mf.lightmap_scale = 1; mf.mesh = mesh; + if (gi) { + mf.cast_shadows = mi->get_cast_shadows_setting() != GeometryInstance::SHADOW_CASTING_SETTING_OFF; + mf.generate_lightmap = mi->get_generate_lightmap(); + } else { + mf.cast_shadows = true; + mf.generate_lightmap = true; + } + + for (int j = 0; j < mesh->get_surface_count(); j++) { + mf.overrides.push_back(all_override); + } + meshes.push_back(mf); } } diff --git a/scene/3d/lightmapper.cpp b/scene/3d/lightmapper.cpp index 839186299b93..9e5078ba95e0 100644 --- a/scene/3d/lightmapper.cpp +++ b/scene/3d/lightmapper.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/scene/3d/lightmapper.h b/scene/3d/lightmapper.h index ccb08e4630d8..720f95a86460 100644 --- a/scene/3d/lightmapper.h +++ b/scene/3d/lightmapper.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index d5fcb3f230f0..7d6dda10bf02 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2446,9 +2446,6 @@ VisualServer::VisualServer() { GLOBAL_DEF(sz_balance_render_tree, 0.0f); ProjectSettings::get_singleton()->set_custom_property_info(sz_balance_render_tree, PropertyInfo(Variant::REAL, sz_balance_render_tree, PROPERTY_HINT_RANGE, "0.0,1.0,0.01")); - GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling", true); - GLOBAL_DEF("rendering/quality/lightmapping/use_bicubic_sampling.mobile", false); - GLOBAL_DEF("rendering/quality/2d/use_software_skinning", true); GLOBAL_DEF("rendering/quality/2d/ninepatch_mode", 0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/quality/2d/ninepatch_mode", PROPERTY_HINT_ENUM, "Default,Scaling")); diff --git a/thirdparty/embree/common/sys/intrinsics.h b/thirdparty/embree/common/sys/intrinsics.h index 6948e4a74212..58f5c3bb4e65 100644 --- a/thirdparty/embree/common/sys/intrinsics.h +++ b/thirdparty/embree/common/sys/intrinsics.h @@ -11,6 +11,12 @@ #include +// -- GODOT start -- +#if defined(__WIN32__) && defined(__MINGW32__) +#include +#endif +// -- GODOT end -- + #if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER) #if !defined(_tzcnt_u32) #define _tzcnt_u32 __tzcnt_u32 @@ -419,8 +425,16 @@ namespace embree __forceinline void pause_cpu(const size_t N = 8) { +// -- GODOT start -- for (size_t i=0; i + ++// -- GODOT start -- ++#if defined(__WIN32__) && defined(__MINGW32__) ++#include ++#endif ++// -- GODOT end -- ++ + #if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER) + #if !defined(_tzcnt_u32) + #define _tzcnt_u32 __tzcnt_u32 +@@ -30,8 +36,14 @@ #endif #if defined(__WIN32__) @@ -32,6 +45,23 @@ index 3f0619cac..6948e4a74 100644 #endif /* normally defined in pmmintrin.h, but we always need this */ +@@ -413,8 +425,16 @@ namespace embree + + __forceinline void pause_cpu(const size_t N = 8) + { ++// -- GODOT start -- + for (size_t i=0; i