Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added volumetric fog effect. #41213

Merged
merged 1 commit into from
Aug 13, 2020
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: 2 additions & 3 deletions core/math/camera_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Vector2 CameraMatrix::get_viewport_half_extents() const {
return Vector2(res.x, res.y);
}

void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
Vector2 CameraMatrix::get_far_plane_half_extents() const {
const real_t *matrix = (const real_t *)this->matrix;
///////--- Far Plane ---///////
Plane far_plane = Plane(matrix[3] - matrix[2],
Expand All @@ -303,8 +303,7 @@ void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
Vector3 res;
far_plane.intersect_3(right_plane, top_plane, &res);

r_width = res.x;
r_height = res.y;
return Vector2(res.x, res.y);
}

bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
Expand Down
2 changes: 1 addition & 1 deletion core/math/camera_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct CameraMatrix {

bool get_endpoints(const Transform &p_transform, Vector3 *p_8points) const;
Vector2 get_viewport_half_extents() const;
void get_far_plane_size(real_t &r_width, real_t &r_height) const;
Vector2 get_far_plane_half_extents() const;

void invert();
CameraMatrix inverse() const;
Expand Down
4 changes: 4 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ void EditorNode::_notification(int p_what) {
RS::get_singleton()->environment_set_sdfgi_ray_count(ray_count);
RS::GIProbeQuality gi_probe_quality = RS::GIProbeQuality(int(GLOBAL_GET("rendering/quality/gi_probes/quality")));
RS::get_singleton()->gi_probe_set_quality(gi_probe_quality);
RS::get_singleton()->environment_set_volumetric_fog_volume_size(GLOBAL_GET("rendering/volumetric_fog/volume_size"), GLOBAL_GET("rendering/volumetric_fog/volume_depth"));
RS::get_singleton()->environment_set_volumetric_fog_filter_active(bool(GLOBAL_GET("rendering/volumetric_fog/use_filter")));
RS::get_singleton()->environment_set_volumetric_fog_directional_shadow_shrink_size(GLOBAL_GET("rendering/volumetric_fog/directional_shadow_shrink"));
RS::get_singleton()->environment_set_volumetric_fog_positional_shadow_shrink_size(GLOBAL_GET("rendering/volumetric_fog/positional_shadow_shrink"));
}

ResourceImporterTexture::get_singleton()->update_imports();
Expand Down
1 change: 1 addition & 0 deletions glsl_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self):

self.vertex_included_files = []
self.fragment_included_files = []
self.compute_included_files = []

self.reading = ""
self.line_offset = 0
Expand Down
3 changes: 3 additions & 0 deletions scene/3d/light_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ void Light3D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_normal_bias", PROPERTY_HINT_RANGE, "0,10,0.001"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_transmittance_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_TRANSMITTANCE_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_fog_fade", PROPERTY_HINT_RANGE, "0.01,10,0.01"), "set_param", "get_param", PARAM_SHADOW_VOLUMETRIC_FOG_FADE);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "shadow_blur", PROPERTY_HINT_RANGE, "0.1,8,0.01"), "set_param", "get_param", PARAM_SHADOW_BLUR);
ADD_GROUP("Editor", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
Expand All @@ -292,6 +293,7 @@ void Light3D::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS);
BIND_ENUM_CONSTANT(PARAM_SHADOW_PANCAKE_SIZE);
BIND_ENUM_CONSTANT(PARAM_SHADOW_BLUR);
BIND_ENUM_CONSTANT(PARAM_SHADOW_VOLUMETRIC_FOG_FADE);
BIND_ENUM_CONSTANT(PARAM_TRANSMITTANCE_BIAS);
BIND_ENUM_CONSTANT(PARAM_MAX);

Expand Down Expand Up @@ -345,6 +347,7 @@ Light3D::Light3D(RenderingServer::LightType p_type) {
set_param(PARAM_SHADOW_BIAS, 0.02);
set_param(PARAM_SHADOW_NORMAL_BIAS, 1.0);
set_param(PARAM_TRANSMITTANCE_BIAS, 0.05);
set_param(PARAM_SHADOW_VOLUMETRIC_FOG_FADE, 1.0);
set_param(PARAM_SHADOW_FADE_START, 1);
set_disable_scale(true);
}
Expand Down
1 change: 1 addition & 0 deletions scene/3d/light_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Light3D : public VisualInstance3D {
PARAM_SHADOW_BIAS = RS::LIGHT_PARAM_SHADOW_BIAS,
PARAM_SHADOW_PANCAKE_SIZE = RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE,
PARAM_SHADOW_BLUR = RS::LIGHT_PARAM_SHADOW_BLUR,
PARAM_SHADOW_VOLUMETRIC_FOG_FADE = RS::LIGHT_PARAM_SHADOW_VOLUMETRIC_FOG_FADE,
PARAM_TRANSMITTANCE_BIAS = RS::LIGHT_PARAM_TRANSMITTANCE_BIAS,
PARAM_MAX = RS::LIGHT_PARAM_MAX
};
Expand Down
104 changes: 102 additions & 2 deletions scene/resources/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,74 @@ void Environment::_update_fog_height() {
fog_height_curve);
}

// Volumetric Fog

void Environment::_update_volumetric_fog() {
RS::get_singleton()->environment_set_volumetric_fog(environment, volumetric_fog_enabled, volumetric_fog_density, volumetric_fog_light, volumetric_fog_light_energy, volumetric_fog_length, volumetric_fog_detail_spread, volumetric_fog_gi_inject, RS::EnvVolumetricFogShadowFilter(volumetric_fog_shadow_filter));
}

void Environment::set_volumetric_fog_enabled(bool p_enable) {
volumetric_fog_enabled = p_enable;
_update_volumetric_fog();
}

bool Environment::is_volumetric_fog_enabled() const {
return volumetric_fog_enabled;
}
void Environment::set_volumetric_fog_density(float p_density) {
p_density = CLAMP(p_density, 0.0000001, 1.0);
volumetric_fog_density = p_density;
_update_volumetric_fog();
}
float Environment::get_volumetric_fog_density() const {
return volumetric_fog_density;
}
void Environment::set_volumetric_fog_light(Color p_color) {
volumetric_fog_light = p_color;
_update_volumetric_fog();
}
Color Environment::get_volumetric_fog_light() const {
return volumetric_fog_light;
}
void Environment::set_volumetric_fog_light_energy(float p_begin) {
volumetric_fog_light_energy = p_begin;
_update_volumetric_fog();
}
float Environment::get_volumetric_fog_light_energy() const {
return volumetric_fog_light_energy;
}
void Environment::set_volumetric_fog_length(float p_length) {
volumetric_fog_length = p_length;
_update_volumetric_fog();
}
float Environment::get_volumetric_fog_length() const {
return volumetric_fog_length;
}
void Environment::set_volumetric_fog_detail_spread(float p_detail_spread) {
volumetric_fog_detail_spread = p_detail_spread;
_update_volumetric_fog();
}
float Environment::get_volumetric_fog_detail_spread() const {
return volumetric_fog_detail_spread;
}

void Environment::set_volumetric_fog_gi_inject(float p_gi_inject) {
volumetric_fog_gi_inject = p_gi_inject;
_update_volumetric_fog();
}
float Environment::get_volumetric_fog_gi_inject() const {
return volumetric_fog_gi_inject;
}

void Environment::set_volumetric_fog_shadow_filter(VolumetricFogShadowFilter p_filter) {
volumetric_fog_shadow_filter = p_filter;
_update_volumetric_fog();
}

Environment::VolumetricFogShadowFilter Environment::get_volumetric_fog_shadow_filter() const {
return volumetric_fog_shadow_filter;
}

// Adjustment

void Environment::set_adjustment_enabled(bool p_enabled) {
Expand Down Expand Up @@ -1251,7 +1319,7 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_fog_height_curve", "curve"), &Environment::set_fog_height_curve);
ClassDB::bind_method(D_METHOD("get_fog_height_curve"), &Environment::get_fog_height_curve);

ADD_GROUP("Fog", "fog_");
ADD_GROUP("Fixed Fog", "fog_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_enabled"), "set_fog_enabled", "is_fog_enabled");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_color"), "set_fog_color", "get_fog_color");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_sun_color"), "set_fog_sun_color", "get_fog_sun_color");
Expand All @@ -1269,6 +1337,33 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height_max", PROPERTY_HINT_RANGE, "-4000,4000,0.1,or_lesser,or_greater"), "set_fog_height_max", "get_fog_height_max");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height_curve", PROPERTY_HINT_EXP_EASING), "set_fog_height_curve", "get_fog_height_curve");

ClassDB::bind_method(D_METHOD("set_volumetric_fog_enabled", "enabled"), &Environment::set_volumetric_fog_enabled);
ClassDB::bind_method(D_METHOD("is_volumetric_fog_enabled"), &Environment::is_volumetric_fog_enabled);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_light", "color"), &Environment::set_volumetric_fog_light);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_light"), &Environment::get_volumetric_fog_light);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_density", "density"), &Environment::set_volumetric_fog_density);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_density"), &Environment::get_volumetric_fog_density);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_light_energy", "begin"), &Environment::set_volumetric_fog_light_energy);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_light_energy"), &Environment::get_volumetric_fog_light_energy);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_length", "length"), &Environment::set_volumetric_fog_length);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_length"), &Environment::get_volumetric_fog_length);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_detail_spread", "detail_spread"), &Environment::set_volumetric_fog_detail_spread);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_detail_spread"), &Environment::get_volumetric_fog_detail_spread);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_gi_inject", "gi_inject"), &Environment::set_volumetric_fog_gi_inject);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_gi_inject"), &Environment::get_volumetric_fog_gi_inject);
ClassDB::bind_method(D_METHOD("set_volumetric_fog_shadow_filter", "shadow_filter"), &Environment::set_volumetric_fog_shadow_filter);
ClassDB::bind_method(D_METHOD("get_volumetric_fog_shadow_filter"), &Environment::get_volumetric_fog_shadow_filter);

ADD_GROUP("Volumetric Fog", "volumetric_fog_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "volumetric_fog_enabled"), "set_volumetric_fog_enabled", "is_volumetric_fog_enabled");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_density", PROPERTY_HINT_RANGE, "0,1,0.0001,or_greater"), "set_volumetric_fog_density", "get_volumetric_fog_density");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "volumetric_fog_light", PROPERTY_HINT_COLOR_NO_ALPHA), "set_volumetric_fog_light", "get_volumetric_fog_light");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_light_energy", PROPERTY_HINT_RANGE, "0,1024,0.01,or_greater"), "set_volumetric_fog_light_energy", "get_volumetric_fog_light_energy");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_gi_inject", PROPERTY_HINT_EXP_RANGE, "0.00,16,0.01"), "set_volumetric_fog_gi_inject", "get_volumetric_fog_gi_inject");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_length", PROPERTY_HINT_RANGE, "0,1024,0.01,or_greater"), "set_volumetric_fog_length", "get_volumetric_fog_length");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_detail_spread", PROPERTY_HINT_EXP_EASING, "0.01,16,0.01"), "set_volumetric_fog_detail_spread", "get_volumetric_fog_detail_spread");
ADD_PROPERTY(PropertyInfo(Variant::INT, "volumetric_fog_shadow_filter", PROPERTY_HINT_ENUM, "Disabled,Low,Medium,High"), "set_volumetric_fog_shadow_filter", "get_volumetric_fog_shadow_filter");

// Adjustment

ClassDB::bind_method(D_METHOD("set_adjustment_enabled", "enabled"), &Environment::set_adjustment_enabled);
Expand Down Expand Up @@ -1331,6 +1426,11 @@ void Environment::_bind_methods() {
BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_DISABLED);
BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_75_PERCENT);
BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_50_PERCENT);

BIND_ENUM_CONSTANT(VOLUMETRIC_FOG_SHADOW_FILTER_DISABLED);
BIND_ENUM_CONSTANT(VOLUMETRIC_FOG_SHADOW_FILTER_LOW);
BIND_ENUM_CONSTANT(VOLUMETRIC_FOG_SHADOW_FILTER_MEDIUM);
BIND_ENUM_CONSTANT(VOLUMETRIC_FOG_SHADOW_FILTER_HIGH);
}

Environment::Environment() {
Expand All @@ -1347,7 +1447,7 @@ Environment::Environment() {
_update_fog_depth();
_update_fog_height();
_update_adjustment();

_update_volumetric_fog();
_change_notify();
}

Expand Down
37 changes: 37 additions & 0 deletions scene/resources/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ class Environment : public Resource {
GLOW_BLEND_MODE_MIX,
};

enum VolumetricFogShadowFilter {
VOLUMETRIC_FOG_SHADOW_FILTER_DISABLED,
VOLUMETRIC_FOG_SHADOW_FILTER_LOW,
VOLUMETRIC_FOG_SHADOW_FILTER_MEDIUM,
VOLUMETRIC_FOG_SHADOW_FILTER_HIGH,
};

private:
RID environment;

Expand Down Expand Up @@ -196,6 +203,17 @@ class Environment : public Resource {
float fog_height_curve = 1.0;
void _update_fog_height();

// Volumetric Fog
bool volumetric_fog_enabled = false;
float volumetric_fog_density = 0.01;
Color volumetric_fog_light = Color(0.0, 0.0, 0.0);
float volumetric_fog_light_energy = 1.0;
float volumetric_fog_length = 64.0;
float volumetric_fog_detail_spread = 2.0;
VolumetricFogShadowFilter volumetric_fog_shadow_filter = VOLUMETRIC_FOG_SHADOW_FILTER_LOW;
float volumetric_fog_gi_inject = 0.0;
void _update_volumetric_fog();

// Adjustment
bool adjustment_enabled = false;
float adjustment_brightness = 1.0;
Expand Down Expand Up @@ -375,6 +393,24 @@ class Environment : public Resource {
void set_fog_height_curve(float p_distance);
float get_fog_height_curve() const;

// Volumetric Fog
void set_volumetric_fog_enabled(bool p_enable);
bool is_volumetric_fog_enabled() const;
void set_volumetric_fog_density(float p_density);
float get_volumetric_fog_density() const;
void set_volumetric_fog_light(Color p_color);
Color get_volumetric_fog_light() const;
void set_volumetric_fog_light_energy(float p_begin);
float get_volumetric_fog_light_energy() const;
void set_volumetric_fog_length(float p_length);
float get_volumetric_fog_length() const;
void set_volumetric_fog_detail_spread(float p_detail_spread);
float get_volumetric_fog_detail_spread() const;
void set_volumetric_fog_shadow_filter(VolumetricFogShadowFilter p_filter);
VolumetricFogShadowFilter get_volumetric_fog_shadow_filter() const;
void set_volumetric_fog_gi_inject(float p_gi_inject);
float get_volumetric_fog_gi_inject() const;

// Adjustment
void set_adjustment_enabled(bool p_enabled);
bool is_adjustment_enabled() const;
Expand All @@ -399,5 +435,6 @@ VARIANT_ENUM_CAST(Environment::SSAOBlur)
VARIANT_ENUM_CAST(Environment::SDFGICascades)
VARIANT_ENUM_CAST(Environment::SDFGIYScale)
VARIANT_ENUM_CAST(Environment::GlowBlendMode)
VARIANT_ENUM_CAST(Environment::VolumetricFogShadowFilter)

#endif // ENVIRONMENT_H
7 changes: 7 additions & 0 deletions servers/rendering/rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class RasterizerScene {
virtual void environment_glow_set_use_bicubic_upscale(bool p_enable) = 0;
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0;

virtual void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_lenght, float p_detail_spread, float p_gi_inject, RS::EnvVolumetricFogShadowFilter p_shadow_filter) = 0;

virtual void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) = 0;
virtual void environment_set_volumetric_fog_filter_active(bool p_enable) = 0;
virtual void environment_set_volumetric_fog_directional_shadow_shrink_size(int p_shrink_size) = 0;
virtual void environment_set_volumetric_fog_positional_shadow_shrink_size(int p_shrink_size) = 0;

virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) = 0;
virtual void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) = 0;

Expand Down
59 changes: 59 additions & 0 deletions servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,50 @@ void RasterizerEffectsRD::resolve_gi(RID p_source_depth, RID p_source_normal_rou
RD::get_singleton()->compute_list_end();
}

void RasterizerEffectsRD::reduce_shadow(RID p_source_shadow, RID p_dest_shadow, const Size2i &p_source_size, const Rect2i &p_source_rect, int p_shrink_limit, RD::ComputeListID compute_list) {
uint32_t push_constant[8] = { (uint32_t)p_source_size.x, (uint32_t)p_source_size.y, (uint32_t)p_source_rect.position.x, (uint32_t)p_source_rect.position.y, (uint32_t)p_shrink_limit, 0, 0, 0 };

RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, shadow_reduce.pipelines[SHADOW_REDUCE_REDUCE]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_source_shadow, p_dest_shadow), 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(uint32_t) * 8);

RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_source_rect.size.width, p_source_rect.size.height, 1, 8, 8, 1);
}
void RasterizerEffectsRD::filter_shadow(RID p_shadow, RID p_backing_shadow, const Size2i &p_source_size, const Rect2i &p_source_rect, RenderingServer::EnvVolumetricFogShadowFilter p_filter, RD::ComputeListID compute_list, bool p_vertical, bool p_horizontal) {
uint32_t push_constant[8] = { (uint32_t)p_source_size.x, (uint32_t)p_source_size.y, (uint32_t)p_source_rect.position.x, (uint32_t)p_source_rect.position.y, 0, 0, 0, 0 };

switch (p_filter) {
case RS::ENV_VOLUMETRIC_FOG_SHADOW_FILTER_DISABLED:
case RS::ENV_VOLUMETRIC_FOG_SHADOW_FILTER_LOW: {
push_constant[5] = 0;
} break;
case RS::ENV_VOLUMETRIC_FOG_SHADOW_FILTER_MEDIUM: {
push_constant[5] = 9;
} break;
case RS::ENV_VOLUMETRIC_FOG_SHADOW_FILTER_HIGH: {
push_constant[5] = 18;
} break;
}

RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, shadow_reduce.pipelines[SHADOW_REDUCE_FILTER]);
if (p_vertical) {
push_constant[6] = 1;
push_constant[7] = 0;
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_shadow, p_backing_shadow), 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(uint32_t) * 8);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_source_rect.size.width, p_source_rect.size.height, 1, 8, 8, 1);
}
if (p_vertical && p_horizontal) {
RD::get_singleton()->compute_list_add_barrier(compute_list);
}
if (p_horizontal) {
push_constant[6] = 0;
push_constant[7] = 1;
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_backing_shadow, p_shadow), 0);
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(uint32_t) * 8);
RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_source_rect.size.width, p_source_rect.size.height, 1, 8, 8, 1);
}
}
RasterizerEffectsRD::RasterizerEffectsRD() {
{ // Initialize copy
Vector<String> copy_modes;
Expand Down Expand Up @@ -1560,6 +1604,20 @@ RasterizerEffectsRD::RasterizerEffectsRD() {
}
}

{
Vector<String> shadow_reduce_modes;
shadow_reduce_modes.push_back("\n#define MODE_REDUCE\n");
shadow_reduce_modes.push_back("\n#define MODE_FILTER\n");

shadow_reduce.shader.initialize(shadow_reduce_modes);

shadow_reduce.shader_version = shadow_reduce.shader.version_create();

for (int i = 0; i < SHADOW_REDUCE_MAX; i++) {
shadow_reduce.pipelines[i] = RD::get_singleton()->compute_pipeline_create(shadow_reduce.shader.version_get_shader(shadow_reduce.shader_version, i));
}
}

RD::SamplerState sampler;
sampler.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler.min_filter = RD::SAMPLER_FILTER_LINEAR;
Expand Down Expand Up @@ -1624,4 +1682,5 @@ RasterizerEffectsRD::~RasterizerEffectsRD() {
ssr_scale.shader.version_free(ssr_scale.shader_version);
sss.shader.version_free(sss.shader_version);
tonemap.shader.version_free(tonemap.shader_version);
shadow_reduce.shader.version_free(shadow_reduce.shader_version);
}
Loading