Skip to content

Commit f91db3d

Browse files
authored
Merge pull request #91399 from QbieShay/qbe/fix-pmul-name
Revert premul alpha to spell without the T
2 parents 92e726d + e410643 commit f91db3d

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

doc/classes/BaseMaterial3D.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@
610610
The color of the object is multiplied by the background.
611611
</constant>
612612
<constant name="BLEND_MODE_PREMULT_ALPHA" value="4" enum="BlendMode">
613-
The color of the object is added to the background and the alpha channel is used to mask out the background. This is effectively a hybrid of the blend mix and add modes, useful for FX like fire where you want the flame to add but the smoke to mix. By default, this works with unshaded materials using premultiplied textures. For shaded materials, use the PREMUL_ALPHA_FACTOR built-in so that lighting can be modulated as well.
613+
The color of the object is added to the background and the alpha channel is used to mask out the background. This is effectively a hybrid of the blend mix and add modes, useful for effects like fire where you want the flame to add but the smoke to mix. By default, this works with unshaded materials using premultiplied textures. For shaded materials, use the [code]PREMUL_ALPHA_FACTOR[/code] built-in so that lighting can be modulated as well.
614614
</constant>
615615
<constant name="ALPHA_ANTIALIASING_OFF" value="0" enum="AlphaAntiAliasing">
616616
Disables Alpha AntiAliasing for the material.

drivers/gles3/shaders/scene.glsl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1442,9 +1442,9 @@ void main() {
14421442
float clearcoat_roughness = 0.0;
14431443
float anisotropy = 0.0;
14441444
vec2 anisotropy_flow = vec2(1.0, 0.0);
1445-
#ifdef PREMULT_ALPHA_USED
1446-
float premult_alpha = 1.0;
1447-
#endif
1445+
#ifdef PREMUL_ALPHA_USED
1446+
float premul_alpha = 1.0;
1447+
#endif PREMUL_ALPHA_USED
14481448
#ifndef FOG_DISABLED
14491449
vec4 fog = vec4(0.0);
14501450
#endif // !FOG_DISABLED
@@ -2149,7 +2149,7 @@ void main() {
21492149
#endif // !RENDER_MATERIAL
21502150
#endif // !MODE_RENDER_DEPTH
21512151

2152-
#ifdef PREMULT_ALPHA_USED
2153-
frag_color.rgb *= premult_alpha;
2154-
#endif
2152+
#ifdef PREMUL_ALPHA_USED
2153+
frag_color.rgb *= premul_alpha;
2154+
#endif PREMUL_ALPHA_USED
21552155
}

drivers/gles3/storage/material_storage.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ MaterialStorage::MaterialStorage() {
12431243
actions.renames["NORMAL_MAP_DEPTH"] = "normal_map_depth";
12441244
actions.renames["ALBEDO"] = "albedo";
12451245
actions.renames["ALPHA"] = "alpha";
1246-
actions.renames["PREMULT_ALPHA_FACTOR"] = "premult_alpha";
1246+
actions.renames["PREMUL_ALPHA_FACTOR"] = "premul_alpha";
12471247
actions.renames["METALLIC"] = "metallic";
12481248
actions.renames["SPECULAR"] = "specular";
12491249
actions.renames["ROUGHNESS"] = "roughness";
@@ -2906,7 +2906,7 @@ void SceneShaderData::set_code(const String &p_code) {
29062906
actions.render_mode_values["blend_mix"] = Pair<int *, int>(&blend_modei, BLEND_MODE_MIX);
29072907
actions.render_mode_values["blend_sub"] = Pair<int *, int>(&blend_modei, BLEND_MODE_SUB);
29082908
actions.render_mode_values["blend_mul"] = Pair<int *, int>(&blend_modei, BLEND_MODE_MUL);
2909-
actions.render_mode_values["blend_premult_alpha"] = Pair<int *, int>(&blend_modei, BLEND_MODE_PREMULT_ALPHA);
2909+
actions.render_mode_values["blend_premul_alpha"] = Pair<int *, int>(&blend_modei, BLEND_MODE_PREMULT_ALPHA);
29102910

29112911
actions.render_mode_values["alpha_to_coverage"] = Pair<int *, int>(&alpha_antialiasing_modei, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE);
29122912
actions.render_mode_values["alpha_to_coverage_and_one"] = Pair<int *, int>(&alpha_antialiasing_modei, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE);

servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {
9090
actions.render_mode_values["blend_mix"] = Pair<int *, int>(&blend_mode, BLEND_MODE_MIX);
9191
actions.render_mode_values["blend_sub"] = Pair<int *, int>(&blend_mode, BLEND_MODE_SUB);
9292
actions.render_mode_values["blend_mul"] = Pair<int *, int>(&blend_mode, BLEND_MODE_MUL);
93-
actions.render_mode_values["blend_premult_alpha"] = Pair<int *, int>(&blend_mode, BLEND_MODE_PREMULT_ALPHA);
93+
actions.render_mode_values["blend_premul_alpha"] = Pair<int *, int>(&blend_mode, BLEND_MODE_PREMULT_ALPHA);
9494

9595
actions.render_mode_values["alpha_to_coverage"] = Pair<int *, int>(&alpha_antialiasing_mode, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE);
9696
actions.render_mode_values["alpha_to_coverage_and_one"] = Pair<int *, int>(&alpha_antialiasing_mode, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE);
@@ -604,7 +604,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
604604
actions.renames["NORMAL_MAP_DEPTH"] = "normal_map_depth";
605605
actions.renames["ALBEDO"] = "albedo";
606606
actions.renames["ALPHA"] = "alpha";
607-
actions.renames["PREMULT_ALPHA_FACTOR"] = "premult_alpha";
607+
actions.renames["PREMUL_ALPHA_FACTOR"] = "premul_alpha";
608608
actions.renames["METALLIC"] = "metallic";
609609
actions.renames["SPECULAR"] = "specular";
610610
actions.renames["ROUGHNESS"] = "roughness";
@@ -684,7 +684,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
684684
actions.usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
685685
actions.usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
686686
actions.usage_defines["LIGHT_VERTEX"] = "#define LIGHT_VERTEX_USED\n";
687-
actions.usage_defines["PREMULT_ALPHA_FACTOR"] = "#define PREMULT_ALPHA_USED\n";
687+
actions.usage_defines["PREMUL_ALPHA_FACTOR"] = "#define PREMUL_ALPHA_USED\n";
688688

689689
actions.usage_defines["ALPHA_SCISSOR_THRESHOLD"] = "#define ALPHA_SCISSOR_USED\n";
690690
actions.usage_defines["ALPHA_HASH_SCALE"] = "#define ALPHA_HASH_USED\n";

servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {
9191
actions.render_mode_values["blend_mix"] = Pair<int *, int>(&blend_mode, BLEND_MODE_MIX);
9292
actions.render_mode_values["blend_sub"] = Pair<int *, int>(&blend_mode, BLEND_MODE_SUB);
9393
actions.render_mode_values["blend_mul"] = Pair<int *, int>(&blend_mode, BLEND_MODE_MUL);
94-
actions.render_mode_values["blend_premult_alpha"] = Pair<int *, int>(&blend_mode, BLEND_MODE_PREMULT_ALPHA);
94+
actions.render_mode_values["blend_premul_alpha"] = Pair<int *, int>(&blend_mode, BLEND_MODE_PREMULT_ALPHA);
9595

9696
actions.render_mode_values["alpha_to_coverage"] = Pair<int *, int>(&alpha_antialiasing_mode, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE);
9797
actions.render_mode_values["alpha_to_coverage_and_one"] = Pair<int *, int>(&alpha_antialiasing_mode, ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE);
@@ -508,7 +508,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
508508
actions.renames["NORMAL_MAP_DEPTH"] = "normal_map_depth";
509509
actions.renames["ALBEDO"] = "albedo";
510510
actions.renames["ALPHA"] = "alpha";
511-
actions.renames["PREMULT_ALPHA_FACTOR"] = "premult_alpha";
511+
actions.renames["PREMUL_ALPHA_FACTOR"] = "premul_alpha";
512512
actions.renames["METALLIC"] = "metallic";
513513
actions.renames["SPECULAR"] = "specular";
514514
actions.renames["ROUGHNESS"] = "roughness";
@@ -593,7 +593,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
593593
actions.usage_defines["ALPHA_HASH_SCALE"] = "#define ALPHA_HASH_USED\n";
594594
actions.usage_defines["ALPHA_ANTIALIASING_EDGE"] = "#define ALPHA_ANTIALIASING_EDGE_USED\n";
595595
actions.usage_defines["ALPHA_TEXTURE_COORDINATE"] = "@ALPHA_ANTIALIASING_EDGE";
596-
actions.usage_defines["PREMULT_ALPHA_FACTOR"] = "#define PREMULT_ALPHA_USED";
596+
actions.usage_defines["PREMUL_ALPHA_FACTOR"] = "#define PREMUL_ALPHA_USED";
597597

598598
actions.usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
599599
actions.usage_defines["SSS_TRANSMITTANCE_DEPTH"] = "#define ENABLE_TRANSMITTANCE\n";

servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl

+6-6
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,9 @@ vec3 encode24(vec3 v) {
914914
void fragment_shader(in SceneData scene_data) {
915915
uint instance_index = instance_index_interp;
916916

917-
#ifdef PREMULT_ALPHA_USED
918-
float premult_alpha = 1.0;
919-
#endif // PREMULT_ALPHA_USED
917+
#ifdef PREMUL_ALPHA_USED
918+
float premul_alpha = 1.0;
919+
#endif // PREMUL_ALPHA_USED
920920
//lay out everything, whatever is unused is optimized away anyway
921921
vec3 vertex = vertex_interp;
922922
#ifdef USE_MULTIVIEW
@@ -2462,9 +2462,9 @@ void fragment_shader(in SceneData scene_data) {
24622462
motion_vector = prev_position_uv - position_uv;
24632463
#endif
24642464

2465-
#if defined(PREMULT_ALPHA_USED) && !defined(MODE_RENDER_DEPTH)
2466-
frag_color.rgb *= premult_alpha;
2467-
#endif //PREMULT_ALPHA_USED
2465+
#if defined(PREMUL_ALPHA_USED) && !defined(MODE_RENDER_DEPTH)
2466+
frag_color.rgb *= premul_alpha;
2467+
#endif //PREMUL_ALPHA_USED
24682468
}
24692469

24702470
void main() {

servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl

+4-4
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,8 @@ void main() {
749749
float clearcoat_roughness = 0.0;
750750
float anisotropy = 0.0;
751751
vec2 anisotropy_flow = vec2(1.0, 0.0);
752-
#ifdef PREMULT_ALPHA_USED
753-
float premult_alpha = 1.0;
752+
#ifdef PREMUL_ALPHA_USED
753+
float premul_alpha = 1.0;
754754
#endif
755755
#ifndef FOG_DISABLED
756756
vec4 fog = vec4(0.0);
@@ -1849,8 +1849,8 @@ void main() {
18491849
// On mobile we use a UNORM buffer with 10bpp which results in a range from 0.0 - 1.0 resulting in HDR breaking
18501850
// We divide by sc_luminance_multiplier to support a range from 0.0 - 2.0 both increasing precision on bright and darker images
18511851
frag_color.rgb = frag_color.rgb / sc_luminance_multiplier;
1852-
#ifdef PREMULT_ALPHA_USED
1853-
frag_color.rgb *= premult_alpha;
1852+
#ifdef PREMUL_ALPHA_USED
1853+
frag_color.rgb *= premul_alpha;
18541854
#endif
18551855

18561856
#endif //MODE_MULTIPLE_RENDER_TARGETS

servers/rendering/shader_types.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ ShaderTypes::ShaderTypes() {
124124
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
125125
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
126126
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
127-
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PREMULT_ALPHA_FACTOR"] = ShaderLanguage::TYPE_FLOAT;
127+
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PREMUL_ALPHA_FACTOR"] = ShaderLanguage::TYPE_FLOAT;
128128
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
129129
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT;
130130
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT;
@@ -209,7 +209,7 @@ ShaderTypes::ShaderTypes() {
209209

210210
// spatial render modes
211211
{
212-
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("blend"), "mix", "add", "sub", "mul", "premult_alpha" });
212+
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("blend"), "mix", "add", "sub", "mul", "premul_alpha" });
213213
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_draw"), "opaque", "always", "never" });
214214
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_prepass_alpha") });
215215
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_test_disabled") });

0 commit comments

Comments
 (0)