Core: Use Math namespace for constants

This commit is contained in:
Thaddeus Crews 2025-04-10 11:21:05 -05:00
parent 06c71fbf40
commit 94282d88f9
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
181 changed files with 812 additions and 818 deletions

View file

@ -81,7 +81,7 @@ SSEffects::SSEffects() {
int b = spmap[subPass];
float ca, sa;
float angle0 = (float(a) + float(b) / float(sub_pass_count)) * Math_PI * 0.5f;
float angle0 = (float(a) + float(b) / float(sub_pass_count)) * Math::PI * 0.5f;
ca = Math::cos(angle0);
sa = Math::sin(angle0);
@ -706,7 +706,7 @@ void SSEffects::screen_space_indirect_lighting(Ref<RenderSceneBuffersRD> p_rende
}
}
radius_near_limit /= tan_half_fov_y;
ssil.gather_push_constant.intensity = p_settings.intensity * Math_PI;
ssil.gather_push_constant.intensity = p_settings.intensity * Math::PI;
ssil.gather_push_constant.fade_out_mul = -1.0 / (ssil_fadeout_to - ssil_fadeout_from);
ssil.gather_push_constant.fade_out_add = ssil_fadeout_from / (ssil_fadeout_to - ssil_fadeout_from) + 1.0;
ssil.gather_push_constant.inv_radius_near_limit = 1.0f / radius_near_limit;
@ -788,7 +788,7 @@ void SSEffects::screen_space_indirect_lighting(Ref<RenderSceneBuffersRD> p_rende
RD::get_singleton()->draw_command_begin_label("Generate Importance Map");
ssil.importance_map_push_constant.half_screen_pixel_size[0] = 1.0 / p_ssil_buffers.buffer_width;
ssil.importance_map_push_constant.half_screen_pixel_size[1] = 1.0 / p_ssil_buffers.buffer_height;
ssil.importance_map_push_constant.intensity = p_settings.intensity * Math_PI;
ssil.importance_map_push_constant.intensity = p_settings.intensity * Math::PI;
//base pass
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssil.pipelines[SSIL_GATHER_BASE]);

View file

@ -205,9 +205,9 @@ void Fog::init_fog_shader(uint32_t p_max_directional_lights, int p_roughness_lay
ShaderCompiler::DefaultIdentifierActions actions;
actions.renames["TIME"] = "scene_params.time";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["WORLD_POSITION"] = "world.xyz";
actions.renames["OBJECT_POSITION"] = "params.position";
actions.renames["UVW"] = "uvw";

View file

@ -1674,7 +1674,7 @@ void GI::SDFGI::debug_probes(RID p_framebuffer, const uint32_t p_view_count, con
push_constant.band_power = 4;
push_constant.sections_in_band = ((band_points / 2) - 1);
push_constant.band_mask = band_points - 2;
push_constant.section_arc = Math_TAU / float(push_constant.sections_in_band);
push_constant.section_arc = Math::TAU / float(push_constant.sections_in_band);
push_constant.y_mult = y_mult;
uint32_t total_points = push_constant.sections_in_band * band_points;
@ -1977,11 +1977,11 @@ void GI::SDFGI::pre_process_gi(const Transform3D &p_transform, RenderDataRD *p_r
// Convert from Luminous Power to Luminous Intensity
if (lights[idx].type == RS::LIGHT_OMNI) {
lights[idx].energy *= 1.0 / (Math_PI * 4.0);
lights[idx].energy *= 1.0 / (Math::PI * 4.0);
} else if (lights[idx].type == RS::LIGHT_SPOT) {
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
// We make this assumption to keep them easy to control.
lights[idx].energy *= 1.0 / Math_PI;
lights[idx].energy *= 1.0 / Math::PI;
}
}
@ -2440,11 +2440,11 @@ void GI::SDFGI::render_static_lights(RenderDataRD *p_render_data, Ref<RenderScen
// Convert from Luminous Power to Luminous Intensity
if (lights[idx].type == RS::LIGHT_OMNI) {
lights[idx].energy *= 1.0 / (Math_PI * 4.0);
lights[idx].energy *= 1.0 / (Math::PI * 4.0);
} else if (lights[idx].type == RS::LIGHT_SPOT) {
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
// We make this assumption to keep them easy to control.
lights[idx].energy *= 1.0 / Math_PI;
lights[idx].energy *= 1.0 / Math::PI;
}
}
@ -2906,11 +2906,11 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
// Convert from Luminous Power to Luminous Intensity
if (l.type == RS::LIGHT_OMNI) {
l.energy *= 1.0 / (Math_PI * 4.0);
l.energy *= 1.0 / (Math::PI * 4.0);
} else if (l.type == RS::LIGHT_SPOT) {
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
// We make this assumption to keep them easy to control.
l.energy *= 1.0 / Math_PI;
l.energy *= 1.0 / Math::PI;
}
}

View file

@ -783,9 +783,9 @@ void SkyRD::init() {
actions.renames["SCREEN_UV"] = "uv";
actions.renames["FRAGCOORD"] = "gl_FragCoord";
actions.renames["TIME"] = "params.time";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["HALF_RES_COLOR"] = "half_res_color";
actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
actions.renames["RADIANCE"] = "radiance";

View file

@ -618,9 +618,9 @@ void SceneShaderForwardClustered::init(const String p_defines) {
actions.renames["TIME"] = "global_time";
actions.renames["EXPOSURE"] = "(1.0 / scene_data_block.data.emissive_exposure_normalization)";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
actions.renames["CLIP_SPACE_FAR"] = "SHADER_SPACE_FAR";
actions.renames["VIEWPORT_SIZE"] = "read_viewport_size";

View file

@ -552,9 +552,9 @@ void SceneShaderForwardMobile::init(const String p_defines) {
actions.renames["TIME"] = "scene_data_block.data.time";
actions.renames["EXPOSURE"] = "(1.0 / scene_data_block.data.emissive_exposure_normalization)";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
actions.renames["CLIP_SPACE_FAR"] = "SHADER_SPACE_FAR";
actions.renames["VIEWPORT_SIZE"] = "read_viewport_size";

View file

@ -1773,9 +1773,9 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
actions.renames["CANVAS_MATRIX"] = "canvas_data.canvas_transform";
actions.renames["SCREEN_MATRIX"] = "canvas_data.screen_transform";
actions.renames["TIME"] = "canvas_data.time";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["AT_LIGHT_PASS"] = "false";
actions.renames["INSTANCE_CUSTOM"] = "instance_custom";

View file

@ -643,7 +643,7 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
if (RendererSceneRenderRD::get_singleton()->is_using_physical_light_units()) {
light_data.energy *= light->param[RS::LIGHT_PARAM_INTENSITY];
} else {
light_data.energy *= Math_PI;
light_data.energy *= Math::PI;
}
if (p_render_data->camera_attributes.is_valid()) {
@ -866,14 +866,14 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
// Convert from Luminous Power to Luminous Intensity
if (type == RS::LIGHT_OMNI) {
energy *= 1.0 / (Math_PI * 4.0);
energy *= 1.0 / (Math::PI * 4.0);
} else {
// Spot Lights are not physically accurate, Luminous Intensity should change in relation to the cone angle.
// We make this assumption to keep them easy to control.
energy *= 1.0 / Math_PI;
energy *= 1.0 / Math::PI;
}
} else {
energy *= Math_PI;
energy *= Math::PI;
}
if (p_render_data->camera_attributes.is_valid()) {

View file

@ -80,9 +80,9 @@ ParticlesStorage::ParticlesStorage() {
}
actions.renames["TRANSFORM"] = "PARTICLE.xform";
actions.renames["TIME"] = "frame_history.data[0].time";
actions.renames["PI"] = _MKSTR(Math_PI);
actions.renames["TAU"] = _MKSTR(Math_TAU);
actions.renames["E"] = _MKSTR(Math_E);
actions.renames["PI"] = _MKSTR(Math::PI);
actions.renames["TAU"] = _MKSTR(Math::TAU);
actions.renames["E"] = _MKSTR(Math::E);
actions.renames["LIFETIME"] = "params.lifetime";
actions.renames["DELTA"] = "local_delta";
actions.renames["NUMBER"] = "particle_number";