summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2023-02-16 14:29:17 -0800
committerclayjohn <claynjohn@gmail.com>2023-02-16 14:29:17 -0800
commit76093d6a036bd017cff9a9baa4e6789a06af4418 (patch)
treeca03d1c7600a3235b41861e71f80454c857e90f3 /scene/3d
parent29f670b7ab28d6393b0a61d6860decc69c2dc1ec (diff)
Only include emission when enabled in material during VoxelGI bake
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/voxelizer.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index d169999de4..42b0748698 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -346,25 +346,29 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
} else {
mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive
}
+ if (mat->get_feature(BaseMaterial3D::FEATURE_EMISSION)) {
+ Ref<Texture2D> emission_tex = mat->get_texture(BaseMaterial3D::TEXTURE_EMISSION);
- Ref<Texture2D> emission_tex = mat->get_texture(BaseMaterial3D::TEXTURE_EMISSION);
-
- Color emission_col = mat->get_emission();
- float emission_energy = mat->get_emission_energy_multiplier() * exposure_normalization;
- if (GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
- emission_energy *= mat->get_emission_intensity();
- }
+ Color emission_col = mat->get_emission();
+ float emission_energy = mat->get_emission_energy_multiplier() * exposure_normalization;
+ if (GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
+ emission_energy *= mat->get_emission_intensity();
+ }
- Ref<Image> img_emission;
+ Ref<Image> img_emission;
- if (emission_tex.is_valid()) {
- img_emission = emission_tex->get_image();
- }
+ if (emission_tex.is_valid()) {
+ img_emission = emission_tex->get_image();
+ }
- if (mat->get_emission_operator() == BaseMaterial3D::EMISSION_OP_ADD) {
- mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy);
+ if (mat->get_emission_operator() == BaseMaterial3D::EMISSION_OP_ADD) {
+ mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy);
+ } else {
+ mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0));
+ }
} else {
- mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0));
+ Ref<Image> empty;
+ mc.emission = _get_bake_texture(empty, Color(0, 0, 0), Color(0, 0, 0));
}
} else {