ability to adjust propagation in gi probe
This commit is contained in:
parent
6f2e16306a
commit
5cc63dee0f
9 changed files with 101 additions and 15 deletions
|
|
@ -432,6 +432,9 @@ public:
|
|||
virtual void gi_probe_set_energy(RID p_probe,float p_range)=0;
|
||||
virtual float gi_probe_get_energy(RID p_probe) const=0;
|
||||
|
||||
virtual void gi_probe_set_propagation(RID p_probe,float p_range)=0;
|
||||
virtual float gi_probe_get_propagation(RID p_probe) const=0;
|
||||
|
||||
virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0;
|
||||
virtual bool gi_probe_is_interior(RID p_probe) const=0;
|
||||
|
||||
|
|
|
|||
|
|
@ -825,6 +825,9 @@ public:
|
|||
BIND2(gi_probe_set_energy,RID,float)
|
||||
BIND1RC(float,gi_probe_get_energy,RID)
|
||||
|
||||
BIND2(gi_probe_set_propagation,RID,float)
|
||||
BIND1RC(float,gi_probe_get_propagation,RID)
|
||||
|
||||
BIND2(gi_probe_set_interior,RID,bool)
|
||||
BIND1RC(bool,gi_probe_is_interior,RID)
|
||||
|
||||
|
|
|
|||
|
|
@ -2448,6 +2448,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
|
|||
probe->dynamic.bake_dynamic_range=VSG::storage->gi_probe_get_dynamic_range(p_instance->base);
|
||||
|
||||
probe->dynamic.mipmaps_3d.clear();
|
||||
probe->dynamic.propagate=VSG::storage->gi_probe_get_propagation(p_instance->base);
|
||||
|
||||
probe->dynamic.grid_size[0]=header->width;
|
||||
probe->dynamic.grid_size[1]=header->height;
|
||||
|
|
@ -2942,14 +2943,12 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
|
|||
}
|
||||
|
||||
|
||||
void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data) {
|
||||
void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data,float p_propagate) {
|
||||
|
||||
//average light to upper level
|
||||
p_local_data[p_idx].energy[0]=0;
|
||||
p_local_data[p_idx].energy[1]=0;
|
||||
p_local_data[p_idx].energy[2]=0;
|
||||
|
||||
int divisor=0;
|
||||
float divisor=0;
|
||||
float sum[3]={0.0,0.0,0.0};
|
||||
|
||||
for(int i=0;i<8;i++) {
|
||||
|
||||
|
|
@ -2959,20 +2958,25 @@ void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const G
|
|||
continue;
|
||||
|
||||
if (p_level+1 < (int)p_header->cell_subdiv-1) {
|
||||
_bake_gi_downscale_light(child,p_level+1,p_cells,p_header,p_local_data);
|
||||
_bake_gi_downscale_light(child,p_level+1,p_cells,p_header,p_local_data,p_propagate);
|
||||
}
|
||||
|
||||
p_local_data[p_idx].energy[0]+=p_local_data[child].energy[0];
|
||||
p_local_data[p_idx].energy[1]+=p_local_data[child].energy[1];
|
||||
p_local_data[p_idx].energy[2]+=p_local_data[child].energy[2];
|
||||
divisor++;
|
||||
sum[0]+=p_local_data[child].energy[0];
|
||||
sum[1]+=p_local_data[child].energy[1];
|
||||
sum[2]+=p_local_data[child].energy[2];
|
||||
divisor+=1.0;
|
||||
|
||||
}
|
||||
|
||||
divisor=Math::lerp(8.0,divisor,p_propagate);
|
||||
sum[0]/=divisor;
|
||||
sum[1]/=divisor;
|
||||
sum[2]/=divisor;
|
||||
|
||||
//divide by eight for average
|
||||
p_local_data[p_idx].energy[0]/=divisor;
|
||||
p_local_data[p_idx].energy[1]/=divisor;
|
||||
p_local_data[p_idx].energy[2]/=divisor;
|
||||
p_local_data[p_idx].energy[0]=Math::fast_ftoi(sum[0]);
|
||||
p_local_data[p_idx].energy[1]=Math::fast_ftoi(sum[1]);
|
||||
p_local_data[p_idx].energy[2]=Math::fast_ftoi(sum[2]);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -3024,7 +3028,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
|
|||
SWAP(probe_data->dynamic.light_cache_changes,probe_data->dynamic.light_cache);
|
||||
|
||||
//downscale to lower res levels
|
||||
_bake_gi_downscale_light(0,0,cells,header,local_data);
|
||||
_bake_gi_downscale_light(0,0,cells,header,local_data,probe_data->dynamic.propagate);
|
||||
|
||||
//plot result to 3D texture!
|
||||
|
||||
|
|
@ -3337,6 +3341,14 @@ void VisualServerScene::render_probes() {
|
|||
force_lighting=true;
|
||||
}
|
||||
|
||||
float propagate = VSG::storage->gi_probe_get_propagation(instance_probe->base);
|
||||
|
||||
if (probe->dynamic.propagate!=propagate) {
|
||||
probe->dynamic.propagate=propagate;
|
||||
force_lighting=true;
|
||||
}
|
||||
|
||||
|
||||
if (probe->invalid==false && probe->dynamic.enabled) {
|
||||
|
||||
switch(probe->dynamic.updating_stage) {
|
||||
|
|
|
|||
|
|
@ -445,6 +445,7 @@ public:
|
|||
Vector< PoolVector<CompBlockS3TC> > mipmaps_s3tc; //for s3tc
|
||||
|
||||
int updating_stage;
|
||||
float propagate;
|
||||
|
||||
int grid_size[3];
|
||||
|
||||
|
|
@ -570,7 +571,7 @@ public:
|
|||
void _gi_probe_fill_local_data(int p_idx,int p_level,int p_x,int p_y,int p_z,const GIProbeDataCell* p_cell,const GIProbeDataHeader *p_header,InstanceGIProbeData::LocalData *p_local_data,Vector<uint32_t> *prev_cell);
|
||||
|
||||
_FORCE_INLINE_ uint32_t _gi_bake_find_cell(const GIProbeDataCell *cells,int x,int y, int z,int p_cell_subdiv);
|
||||
void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data);
|
||||
void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, float p_propagate);
|
||||
void _bake_gi_probe_light(const GIProbeDataHeader *header,const GIProbeDataCell *cells,InstanceGIProbeData::LocalData *local_data,const uint32_t *leaves,int p_leaf_count, const InstanceGIProbeData::LightCache& light_cache,int p_sign);
|
||||
void _bake_gi_probe(Instance *p_probe);
|
||||
bool _check_gi_probe(Instance *p_gi_probe);
|
||||
|
|
|
|||
|
|
@ -474,6 +474,9 @@ public:
|
|||
virtual void gi_probe_set_energy(RID p_probe,float p_range)=0;
|
||||
virtual float gi_probe_get_energy(RID p_probe) const=0;
|
||||
|
||||
virtual void gi_probe_set_propagation(RID p_probe,float p_range)=0;
|
||||
virtual float gi_probe_get_propagation(RID p_probe) const=0;
|
||||
|
||||
virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0;
|
||||
virtual bool gi_probe_is_interior(RID p_probe) const=0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue