Addition of FogVolumes, FogShaders, FogMaterial, and overhaul of VolumetricFog

Co-authored-by: Brian Semrau <brian.semrau@gmail.com>
This commit is contained in:
clayjohn 2021-10-03 04:28:55 -07:00
parent 9307808987
commit 1b2cd9f251
51 changed files with 2979 additions and 777 deletions

View file

@ -32,6 +32,7 @@
#include "editor/editor_scale.h"
#include "scene/gui/subviewport_container.h"
#include "scene/resources/fog_material.h"
#include "scene/resources/particles_material.h"
#include "scene/resources/sky_material.h"
@ -477,3 +478,40 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &
smat->set_name(mat->get_name());
return smat;
}
String FogMaterialConversionPlugin::converts_to() const {
return "ShaderMaterial";
}
bool FogMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<FogMaterial> mat = p_resource;
return mat.is_valid();
}
Ref<Resource> FogMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<FogMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
Ref<ShaderMaterial> smat;
smat.instantiate();
Ref<Shader> shader;
shader.instantiate();
String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (const PropertyInfo &E : params) {
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
smat->set_shader_param(E.name, value);
}
smat->set_render_priority(mat->get_render_priority());
return smat;
}