summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/baked_light_instance.cpp8
-rw-r--r--scene/3d/gi_probe.cpp60
-rw-r--r--scene/3d/gi_probe.h11
-rw-r--r--scene/3d/light.cpp3
-rw-r--r--scene/3d/light.h1
5 files changed, 71 insertions, 12 deletions
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index 514c73a488..b67b75d48f 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -389,8 +389,8 @@ void BakedLight::_plot_face(int p_idx, int p_level, const Vector3 *p_vtx, const
Vector2 uv = get_uv(intersection,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
albedo_accum.r+=p_material.albedo[ofs].r;
@@ -415,8 +415,8 @@ void BakedLight::_plot_face(int p_idx, int p_level, const Vector3 *p_vtx, const
Vector2 uv = get_uv(inters,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 8035ce1cc7..4c33590568 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -64,6 +64,18 @@ float GIProbeData::get_energy() const{
}
+void GIProbeData::set_propagation(float p_range) {
+
+ VS::get_singleton()->gi_probe_set_propagation(probe,p_range);
+}
+
+float GIProbeData::get_propagation() const{
+
+ return VS::get_singleton()->gi_probe_get_propagation(probe);
+
+}
+
+
void GIProbeData::set_interior(bool p_enable) {
VS::get_singleton()->gi_probe_set_interior(probe,p_enable);
@@ -121,6 +133,9 @@ void GIProbeData::_bind_methods() {
ClassDB::bind_method(_MD("set_energy","energy"),&GIProbeData::set_energy);
ClassDB::bind_method(_MD("get_energy"),&GIProbeData::get_energy);
+ ClassDB::bind_method(_MD("set_propagation","propagation"),&GIProbeData::set_propagation);
+ ClassDB::bind_method(_MD("get_propagation"),&GIProbeData::get_propagation);
+
ClassDB::bind_method(_MD("set_interior","interior"),&GIProbeData::set_interior);
ClassDB::bind_method(_MD("is_interior"),&GIProbeData::is_interior);
@@ -134,6 +149,7 @@ void GIProbeData::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_data"),_SCS("get_dynamic_data"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
ADD_PROPERTY(PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"propagation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_propagation"),_SCS("get_propagation"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"interior",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_interior"),_SCS("is_interior"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"compress",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_compress"),_SCS("is_compressed"));
@@ -214,6 +230,18 @@ float GIProbe::get_energy() const {
return energy;
}
+void GIProbe::set_propagation(float p_propagation) {
+
+ propagation=p_propagation;
+ if (probe_data.is_valid()) {
+ probe_data->set_propagation(propagation);
+ }
+}
+float GIProbe::get_propagation() const {
+
+ return propagation;
+}
+
void GIProbe::set_interior(bool p_enable) {
interior=p_enable;
@@ -510,8 +538,8 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
Vector2 uv = get_uv(intersection,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
albedo_accum.r+=p_material.albedo[ofs].r;
@@ -539,8 +567,8 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
Vector2 uv = get_uv(inters,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
@@ -906,7 +934,7 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
}
-void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker) {
+void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material) {
for(int i=0;i<p_mesh->get_surface_count();i++) {
@@ -914,7 +942,16 @@ void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_b
if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
continue; //only triangles
- Baker::MaterialCache material = _get_material_cache(p_mesh->surface_get_material(i),p_baker);
+ Ref<Material> src_material;
+
+ if (p_override_material.is_valid()) {
+ src_material=p_override_material;
+ } else if (i<p_materials.size() && p_materials[i].is_valid()) {
+ src_material=p_materials[i];
+ } else {
+ src_material=p_mesh->surface_get_material(i);
+ }
+ Baker::MaterialCache material = _get_material_cache(src_material,p_baker);
Array a = p_mesh->surface_get_arrays(i);
@@ -1009,6 +1046,10 @@ void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){
Baker::PlotMesh pm;
pm.local_xform=xf;
pm.mesh=mesh;
+ for(int i=0;i<mesh->get_surface_count();i++) {
+ pm.instance_materials.push_back(mi->get_surface_material(i));
+ }
+ pm.override_material=mi->get_material_override();
p_baker->mesh_list.push_back(pm);
}
@@ -1083,7 +1124,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug){
print_line("plotting mesh "+itos(pmc++)+"/"+itos(baker.mesh_list.size()));
- _plot_mesh(E->get().local_xform,E->get().mesh,&baker);
+ _plot_mesh(E->get().local_xform,E->get().mesh,&baker,E->get().instance_materials,E->get().override_material);
}
_fixup_plot(0,0,0,0,0,&baker);
@@ -1358,6 +1399,9 @@ void GIProbe::_bind_methods() {
ClassDB::bind_method(_MD("set_energy","max"),&GIProbe::set_energy);
ClassDB::bind_method(_MD("get_energy"),&GIProbe::get_energy);
+ ClassDB::bind_method(_MD("set_propagation","max"),&GIProbe::set_propagation);
+ ClassDB::bind_method(_MD("get_propagation"),&GIProbe::get_propagation);
+
ClassDB::bind_method(_MD("set_interior","enable"),&GIProbe::set_interior);
ClassDB::bind_method(_MD("is_interior"),&GIProbe::is_interior);
@@ -1372,6 +1416,7 @@ void GIProbe::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"),_SCS("set_extents"),_SCS("get_extents"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_RANGE,"1,16,1"),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"propagation",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_propagation"),_SCS("get_propagation"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior"),_SCS("set_interior"),_SCS("is_interior"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"compress"),_SCS("set_compress"),_SCS("is_compressed"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"data",PROPERTY_HINT_RESOURCE_TYPE,"GIProbeData"),_SCS("set_probe_data"),_SCS("get_probe_data"));
@@ -1389,6 +1434,7 @@ GIProbe::GIProbe() {
subdiv=SUBDIV_128;
dynamic_range=4;
energy=1.0;
+ propagation=1.0;
extents=Vector3(10,10,10);
color_scan_cell_width=4;
bake_texture_size=128;
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index e416b28791..f03a558908 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -32,6 +32,9 @@ public:
void set_dynamic_range(int p_range);
int get_dynamic_range() const;
+ void set_propagation(float p_range);
+ float get_propagation() const;
+
void set_energy(float p_range);
float get_energy() const;
@@ -114,6 +117,8 @@ private:
int axis_cell_size[3];
struct PlotMesh {
+ Ref<Material> override_material;
+ Vector<Ref<Material> > instance_materials;
Ref<Mesh> mesh;
Transform local_xform;
};
@@ -132,6 +137,7 @@ private:
Vector3 extents;
int dynamic_range;
float energy;
+ float propagation;
bool interior;
bool compress;
@@ -141,7 +147,7 @@ private:
Vector<Color> _get_bake_texture(Image &p_image,const Color& p_color);
Baker::MaterialCache _get_material_cache(Ref<Material> p_material,Baker *p_baker);
void _plot_face(int p_idx, int p_level, int p_x,int p_y,int p_z,const Vector3 *p_vtx, const Vector2* p_uv, const Baker::MaterialCache& p_material, const Rect3 &p_aabb,Baker *p_baker);
- void _plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker);
+ void _plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker,const Vector<Ref<Material> >& p_materials,const Ref<Material>& p_override_material);
void _find_meshes(Node *p_at_node,Baker *p_baker);
void _fixup_plot(int p_idx, int p_level,int p_x,int p_y, int p_z,Baker *p_baker);
@@ -170,6 +176,9 @@ public:
void set_energy(float p_energy);
float get_energy() const;
+ void set_propagation(float p_propagation);
+ float get_propagation() const;
+
void set_interior(bool p_enable);
bool is_interior() const;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 0c6c113dd2..799c00d266 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -253,6 +253,7 @@ void Light::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow_enabled"), _SCS("set_shadow"), _SCS("has_shadow"));
ADD_PROPERTY( PropertyInfo( Variant::COLOR, "shadow_color",PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_shadow_color"), _SCS("get_shadow_color"));
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_bias",PROPERTY_HINT_RANGE,"-16,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_BIAS);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_contact",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_CONTACT_SHADOW_SIZE);
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_max_distance",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_MAX_DISTANCE);
ADD_GROUP("Editor","");
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
@@ -264,6 +265,7 @@ void Light::_bind_methods() {
BIND_CONSTANT( PARAM_ATTENUATION );
BIND_CONSTANT( PARAM_SPOT_ANGLE );
BIND_CONSTANT( PARAM_SPOT_ATTENUATION );
+ BIND_CONSTANT( PARAM_CONTACT_SHADOW_SIZE );
BIND_CONSTANT( PARAM_SHADOW_MAX_DISTANCE );
BIND_CONSTANT( PARAM_SHADOW_SPLIT_1_OFFSET );
BIND_CONSTANT( PARAM_SHADOW_SPLIT_2_OFFSET );
@@ -297,6 +299,7 @@ Light::Light(VisualServer::LightType p_type) {
set_param(PARAM_ATTENUATION,1);
set_param(PARAM_SPOT_ANGLE,45);
set_param(PARAM_SPOT_ATTENUATION,1);
+ set_param(PARAM_CONTACT_SHADOW_SIZE,0);
set_param(PARAM_SHADOW_MAX_DISTANCE,0);
set_param(PARAM_SHADOW_SPLIT_1_OFFSET,0.1);
set_param(PARAM_SHADOW_SPLIT_2_OFFSET,0.2);
diff --git a/scene/3d/light.h b/scene/3d/light.h
index d27b9fed12..4cf0156d5c 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -55,6 +55,7 @@ public:
PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION,
PARAM_SPOT_ANGLE = VS::LIGHT_PARAM_SPOT_ANGLE,
PARAM_SPOT_ATTENUATION = VS::LIGHT_PARAM_SPOT_ATTENUATION,
+ PARAM_CONTACT_SHADOW_SIZE= VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE,
PARAM_SHADOW_MAX_DISTANCE = VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE,
PARAM_SHADOW_SPLIT_1_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
PARAM_SHADOW_SPLIT_2_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,