Skip to content

Commit

Permalink
Restore the Y Scale as a cascade layout setting.
Browse files Browse the repository at this point in the history
Fixed Volumetric Fog
  • Loading branch information
reduz committed Jul 11, 2024
1 parent be83510 commit 404787a
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 225 deletions.
4 changes: 3 additions & 1 deletion scene/resources/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ void Environment::_bind_methods() {
ADD_GROUP("DynamicGI", "dynamic_gi_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dynamic_gi_enabled"), "set_dynamic_gi_enabled", "is_dynamic_gi_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "dynamic_gi_cascades", PROPERTY_HINT_RANGE, "1,8,1"), "set_dynamic_gi_cascades", "get_dynamic_gi_cascades");
ADD_PROPERTY(PropertyInfo(Variant::INT, "dynamic_gi_cascade_format", PROPERTY_HINT_ENUM, "16x8x16,16x16x16"), "set_dynamic_gi_cascade_format", "get_dynamic_gi_cascade_format");
ADD_PROPERTY(PropertyInfo(Variant::INT, "dynamic_gi_cascade_format", PROPERTY_HINT_ENUM, "16x8x16,16x16x16,16x16x16 75% Height,16x16x16 50% Height"), "set_dynamic_gi_cascade_format", "get_dynamic_gi_cascade_format");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dynamic_gi_min_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_dynamic_gi_min_cell_size", "get_dynamic_gi_min_cell_size");
// Don't store the values of `dynamic_gi_cascade0_distance` and `dynamic_gi_max_distance`
// as they're derived from `dynamic_gi_min_cell_size`.
Expand Down Expand Up @@ -1657,6 +1657,8 @@ void Environment::_bind_methods() {

BIND_ENUM_CONSTANT(DYNAMIC_GI_CASCADE_FORMAT_16x8x16);
BIND_ENUM_CONSTANT(DYNAMIC_GI_CASCADE_FORMAT_16x16x16);
BIND_ENUM_CONSTANT(DYNAMIC_GI_CASCADE_FORMAT_16x16x16_75_PERCENT_HEIGHT);
BIND_ENUM_CONSTANT(DYNAMIC_GI_CASCADE_FORMAT_16x16x16_50_PERCENT_HEIGHT);
BIND_ENUM_CONSTANT(DYNAMIC_GI_CASCADE_FORMAT_MAX);
}

Expand Down
2 changes: 2 additions & 0 deletions scene/resources/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class Environment : public Resource {
enum DynamicGICascadeFormat {
DYNAMIC_GI_CASCADE_FORMAT_16x8x16,
DYNAMIC_GI_CASCADE_FORMAT_16x16x16,
DYNAMIC_GI_CASCADE_FORMAT_16x16x16_75_PERCENT_HEIGHT,
DYNAMIC_GI_CASCADE_FORMAT_16x16x16_50_PERCENT_HEIGHT,
DYNAMIC_GI_CASCADE_FORMAT_MAX,
};

Expand Down
29 changes: 17 additions & 12 deletions servers/rendering/renderer_rd/environment/gi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,20 @@ void GI::HDDAGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_r
switch (cascade_format) {
case RS::ENV_HDDAGI_CASCADE_FORMAT_16x16x16: {
cascade_size.y = CASCADE_SIZE;
y_mult = 1.0;
} break;
case RS::ENV_HDDAGI_CASCADE_FORMAT_16x8x16: {
cascade_size.y = CASCADE_SIZE / 2;
case RS::ENV_HDDAGI_CASCADE_FORMAT_16x16x16_50_PERCENT_HEIGHT: {
cascade_size.y = CASCADE_SIZE;
y_mult = 2.0;
} break;
default: {
case RS::ENV_HDDAGI_CASCADE_FORMAT_16x16x16_75_PERCENT_HEIGHT: {
cascade_size.y = CASCADE_SIZE;
y_mult = 1.5;
} break;
case RS::ENV_HDDAGI_CASCADE_FORMAT_16x8x16:
default: {
cascade_size.y = CASCADE_SIZE / 2;
y_mult = 1.0;
} break;
}

Expand All @@ -374,9 +382,6 @@ void GI::HDDAGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_r
occlusion_bias = RendererSceneRenderRD::get_singleton()->environment_get_hddagi_occlusion_bias(p_env);
normal_bias = RendererSceneRenderRD::get_singleton()->environment_get_hddagi_normal_bias(p_env);
frames_to_converge = p_requested_history_size;
//y_scale_mode = RendererSceneRenderRD::get_singleton()->environment_get_hddagi_y_scale(p_env);
//static const float y_scale[3] = { 2.0, 1.5, 1.0 };
//y_mult = y_scale[y_scale_mode];
version = gi->hddagi_current_version;
cascades.resize(num_cascades);

Expand Down Expand Up @@ -546,9 +551,9 @@ void GI::HDDAGI::create(RID p_env, const Vector3 &p_world_position, uint32_t p_r
RD::TextureFormat tf_ambient = tf_lightprobes;
tf_ambient.width = (PROBE_DIVISOR.x + 1);
tf_ambient.height = (PROBE_DIVISOR.y + 1) * (PROBE_DIVISOR.z + 1);

lightprobe_ambient_data = create_clear_texture(tf_ambient, String("HDDAGI Lighprobe Ambient"));
lightprobe_ambient_tex = RD::get_singleton()->texture_create_shared(tv, lightprobe_ambient_data);
tf_ambient.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
tf_ambient.shareable_formats.clear();
lightprobe_ambient_tex = create_clear_texture(tf_ambient, String("HDDAGI Ambient Light Texture"));

RD::TextureFormat tf_neighbours;
tf_neighbours.texture_type = RD::TEXTURE_TYPE_2D_ARRAY;
Expand Down Expand Up @@ -819,7 +824,7 @@ void GI::HDDAGI::render_region(Ref<RenderSceneBuffersRD> p_render_buffers, int p
0,
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 1, lightprobe_specular_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 2, lightprobe_diffuse_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 3, lightprobe_ambient_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 3, lightprobe_ambient_tex),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 4, lightprobe_hit_cache_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 5, lightprobe_moving_average_history),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 6, lightprobe_moving_average),
Expand Down Expand Up @@ -1041,7 +1046,7 @@ GI::HDDAGI::~HDDAGI() {

RD::get_singleton()->free(lightprobe_specular_data);
RD::get_singleton()->free(lightprobe_diffuse_data);
RD::get_singleton()->free(lightprobe_ambient_data);
RD::get_singleton()->free(lightprobe_ambient_tex);
RD::get_singleton()->free(lightprobe_diffuse_filter_data);
RD::get_singleton()->free(lightprobe_hit_cache_data);
RD::get_singleton()->free(lightprobe_hit_cache_version_data);
Expand Down Expand Up @@ -1360,7 +1365,7 @@ void GI::HDDAGI::update_probes(RID p_env, SkyRD::Sky *p_sky, uint32_t p_view_cou
RD::Uniform(RD::UNIFORM_TYPE_SAMPLER, 4, RendererRD::MaterialStorage::get_singleton()->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 5, lightprobe_specular_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 6, lightprobe_diffuse_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 7, lightprobe_ambient_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 7, lightprobe_ambient_tex),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 8, lightprobe_hit_cache_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 9, lightprobe_hit_cache_version_data),
RD::Uniform(RD::UNIFORM_TYPE_IMAGE, 10, region_version_data),
Expand Down
1 change: 0 additions & 1 deletion servers/rendering/renderer_rd/environment/gi.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ class GI : public RendererGI {
RID lightprobe_specular_data;
RID lightprobe_diffuse_data;
RID lightprobe_diffuse_tex;
RID lightprobe_ambient_data;
RID lightprobe_ambient_tex;
RID lightprobe_diffuse_filter_data;
RID lightprobe_diffuse_filter_tex;
Expand Down
6 changes: 2 additions & 4 deletions servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ void RendererSceneRenderRD::_debug_hddagi_probes(Ref<RenderSceneBuffersRD> p_ren
Ref<RendererRD::GI::HDDAGI> hddagi = p_render_buffers->get_custom_data(RB_SCOPE_HDDAGI);

hddagi->debug_probes(p_framebuffer, p_view_count, p_camera_with_transforms);

}

////////////////////////////////
Expand Down Expand Up @@ -794,7 +793,7 @@ bool RendererSceneRenderRD::_debug_draw_can_use_effects(RS::ViewportDebugDraw p_
case RS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER:
case RS::VIEWPORT_DEBUG_DRAW_SSAO:
case RS::VIEWPORT_DEBUG_DRAW_SSIL:
case RS::VIEWPORT_DEBUG_DRAW_SDFGI:
case RS::VIEWPORT_DEBUG_DRAW_HDDAGI:
case RS::VIEWPORT_DEBUG_DRAW_GI_BUFFER:
case RS::VIEWPORT_DEBUG_DRAW_OCCLUDERS:
can_use_effects = true;
Expand All @@ -805,7 +804,7 @@ bool RendererSceneRenderRD::_debug_draw_can_use_effects(RS::ViewportDebugDraw p_
case RS::VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION:
case RS::VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE:
case RS::VIEWPORT_DEBUG_DRAW_PSSM_SPLITS:
case RS::VIEWPORT_DEBUG_DRAW_SDFGI_PROBES:
case RS::VIEWPORT_DEBUG_DRAW_HDDAGI_PROBES:
case RS::VIEWPORT_DEBUG_DRAW_DISABLE_LOD:
can_use_effects = true;
break;
Expand Down Expand Up @@ -1107,7 +1106,6 @@ void RendererSceneRenderRD::_post_prepass_render(RenderDataRD *p_render_data, bo
}

void RendererSceneRenderRD::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_compositor, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderHDDAGIData *p_render_hddagi_regions, int p_render_hddagi_region_count, const RenderHDDAGIUpdateData *p_hddagi_update_data, RenderingMethod::RenderInfo *r_render_info) {

RendererRD::LightStorage *light_storage = RendererRD::LightStorage::get_singleton();
RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();

Expand Down
Loading

0 comments on commit 404787a

Please sign in to comment.