Add properties for rao in the light job.

This commit is contained in:
Relintai 2022-02-24 19:23:25 +01:00
parent 9c0b10ef76
commit ee4c184d64
2 changed files with 66 additions and 2 deletions

View File

@ -24,12 +24,40 @@ SOFTWARE.
#include "../../defines.h"
#include "../../library/terrain_2d_surface.h"
#include "../../library/terrain_2d_library.h"
#include "../../library/terrain_2d_surface.h"
#include "../../meshers/terrain_2d_mesher.h"
#include "../default/terrain_2d_chunk_default.h"
int Terrain2DLightJob::get_rao_octaves() {
return _rao_octaves;
}
void Terrain2DLightJob::set_rao_octaves(const int val) {
_rao_octaves = val;
}
int Terrain2DLightJob::get_rao_period() {
return _rao_period;
}
void Terrain2DLightJob::set_rao_period(const int val) {
_rao_period = val;
}
float Terrain2DLightJob::get_rao_persistence() {
return _rao_persistence;
}
void Terrain2DLightJob::set_rao_persistence(const float val) {
_rao_persistence = val;
}
float Terrain2DLightJob::get_rao_scale_factor() {
return _rao_scale_factor;
}
void Terrain2DLightJob::set_rao_scale_factor(const float val) {
_rao_scale_factor = val;
}
void Terrain2DLightJob::phase_light() {
Ref<Terrain2DChunkDefault> chunk = _chunk;
@ -54,7 +82,7 @@ void Terrain2DLightJob::phase_light() {
}
if (gr && should_do()) {
generate_random_ao(chunk->get_voxel_world()->get_current_seed());
generate_random_ao(chunk->get_voxel_world()->get_current_seed(), _rao_octaves, _rao_period, _rao_persistence, _rao_scale_factor);
if (should_return())
return;
@ -84,10 +112,29 @@ void Terrain2DLightJob::_execute_phase() {
}
Terrain2DLightJob::Terrain2DLightJob() {
_rao_octaves = 4;
_rao_period = 30;
_rao_persistence = 0.3;
_rao_scale_factor = 0.6;
}
Terrain2DLightJob::~Terrain2DLightJob() {
}
void Terrain2DLightJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rao_octaves"), &Terrain2DLightJob::get_rao_octaves);
ClassDB::bind_method(D_METHOD("set_rao_octaves", "value"), &Terrain2DLightJob::set_rao_octaves);
ADD_PROPERTY(PropertyInfo(Variant::INT, "rao_octaves"), "set_rao_octaves", "get_rao_octaves");
ClassDB::bind_method(D_METHOD("get_rao_period"), &Terrain2DLightJob::get_rao_period);
ClassDB::bind_method(D_METHOD("set_rao_period", "value"), &Terrain2DLightJob::set_rao_period);
ADD_PROPERTY(PropertyInfo(Variant::INT, "rao_period"), "set_rao_period", "get_rao_period");
ClassDB::bind_method(D_METHOD("get_rao_persistence"), &Terrain2DLightJob::get_rao_persistence);
ClassDB::bind_method(D_METHOD("set_rao_persistence", "value"), &Terrain2DLightJob::set_rao_persistence);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rao_persistence"), "set_rao_persistence", "get_rao_persistence");
ClassDB::bind_method(D_METHOD("get_rao_scale_factor"), &Terrain2DLightJob::get_rao_scale_factor);
ClassDB::bind_method(D_METHOD("set_rao_scale_factor", "value"), &Terrain2DLightJob::set_rao_scale_factor);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rao_scale_factor"), "set_rao_scale_factor", "get_rao_scale_factor");
}

View File

@ -31,6 +31,18 @@ class Terrain2DLightJob : public Terrain2DJob {
GDCLASS(Terrain2DLightJob, Terrain2DJob);
public:
int get_rao_octaves();
void set_rao_octaves(const int val);
int get_rao_period();
void set_rao_period(const int val);
float get_rao_persistence();
void set_rao_persistence(const float val);
float get_rao_scale_factor();
void set_rao_scale_factor(const float val);
void phase_light();
void _execute_phase();
@ -40,6 +52,11 @@ public:
protected:
static void _bind_methods();
int _rao_octaves;
int _rao_period;
float _rao_persistence;
float _rao_scale_factor;
};
#endif