Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions servers/rendering/renderer_rd/cluster_builder_rd.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ class ClusterBuilderRD {
render_element_count++;
}

_FORCE_INLINE_ uint32_t get_cluster_count_by_type(ElementType p_element_type) const {
DEV_ASSERT(p_element_type < ELEMENT_TYPE_MAX);
return cluster_count_by_type[p_element_type];
}

void bake_cluster();
void debug(ElementType p_element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,10 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
}
_pre_opaque_render(p_render_data, using_ssao, using_ssil, using_ssr, using_sdfgi || using_voxelgi, normal_roughness_views, rb_data.is_valid() && rb_data->has_voxelgi() ? rb_data->get_voxelgi() : RID());

if (current_cluster_builder) {
base_specialization.cluster_has_area_light = current_cluster_builder->get_cluster_count_by_type(ClusterBuilderRD::ELEMENT_TYPE_AREA_LIGHT) != 0;
}

RENDER_TIMESTAMP("Render Opaque Pass");

RD::get_singleton()->draw_command_begin_label("Render Opaque Pass");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class SceneShaderForwardClustered {
uint32_t multimesh_has_color : 1;
uint32_t multimesh_has_custom_data : 1;
uint32_t fog_use_legacy_blending : 1;
uint32_t cluster_has_area_light : 1;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2817,7 +2817,7 @@ void fragment_shader(in SceneData scene_data) {
}
}

{ // area lights
if (sc_cluster_has_area_light()) { // area lights

uint cluster_area_offset = cluster_offset + implementation_data.cluster_type_size * 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ bool sc_fog_use_legacy_blending() {
return ((sc_packed_1() >> 4) & 1U) != 0;
}

bool sc_cluster_has_area_light() {
return ((sc_packed_1() >> 5) & 1U) != 0;
}

float sc_luminance_multiplier() {
// Not used in clustered renderer but we share some code with the mobile renderer that requires this.
return 1.0;
Expand Down
Loading