Only include emission when enabled in material during VoxelGI bake

This commit is contained in:
clayjohn 2023-02-16 14:29:17 -08:00
parent 29f670b7ab
commit 76093d6a03
1 changed files with 18 additions and 14 deletions

View File

@ -346,25 +346,29 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
} else { } else {
mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive 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(); Ref<Image> img_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; if (emission_tex.is_valid()) {
img_emission = emission_tex->get_image();
}
if (emission_tex.is_valid()) { if (mat->get_emission_operator() == BaseMaterial3D::EMISSION_OP_ADD) {
img_emission = emission_tex->get_image(); 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));
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 { } 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 { } else {