diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 7c75e852f9a3..206f6ffafa2f 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -1035,6 +1035,9 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance"; actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; + actions[VS::SHADER_CANVAS_ITEM].renames["PI"] = _MKSTR(Math_PI); + actions[VS::SHADER_CANVAS_ITEM].renames["TAU"] = _MKSTR(Math_TAU); + actions[VS::SHADER_CANVAS_ITEM].renames["E"] = _MKSTR(Math_E); actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; @@ -1117,6 +1120,9 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { //builtins actions[VS::SHADER_SPATIAL].renames["TIME"] = "time"; + actions[VS::SHADER_SPATIAL].renames["PI"] = _MKSTR(Math_PI); + actions[VS::SHADER_SPATIAL].renames["TAU"] = _MKSTR(Math_TAU); + actions[VS::SHADER_SPATIAL].renames["E"] = _MKSTR(Math_E); actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 7966fe00856d..c28bae5efb0e 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -1112,6 +1112,10 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; + actions[VS::SHADER_CANVAS_ITEM].renames["PI"] = _MKSTR(Math_PI); + actions[VS::SHADER_CANVAS_ITEM].renames["TAU"] = _MKSTR(Math_TAU); + actions[VS::SHADER_CANVAS_ITEM].renames["E"] = _MKSTR(Math_E); + actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; @@ -1175,6 +1179,10 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { //builtins actions[VS::SHADER_SPATIAL].renames["TIME"] = "time"; + actions[VS::SHADER_SPATIAL].renames["PI"] = _MKSTR(Math_PI); + actions[VS::SHADER_SPATIAL].renames["TAU"] = _MKSTR(Math_TAU); + actions[VS::SHADER_SPATIAL].renames["E"] = _MKSTR(Math_E); + actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; @@ -1282,7 +1290,12 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_PARTICLES].renames["RESTART"] = "restart"; actions[VS::SHADER_PARTICLES].renames["CUSTOM"] = "out_custom"; actions[VS::SHADER_PARTICLES].renames["TRANSFORM"] = "xform"; + actions[VS::SHADER_PARTICLES].renames["TIME"] = "time"; + actions[VS::SHADER_PARTICLES].renames["PI"] = _MKSTR(Math_PI); + actions[VS::SHADER_PARTICLES].renames["TAU"] = _MKSTR(Math_TAU); + actions[VS::SHADER_PARTICLES].renames["E"] = _MKSTR(Math_E); + actions[VS::SHADER_PARTICLES].renames["LIFETIME"] = "lifetime"; actions[VS::SHADER_PARTICLES].renames["DELTA"] = "local_delta"; actions[VS::SHADER_PARTICLES].renames["NUMBER"] = "particle_number"; diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index ae7008f5b8e5..409d2d179915 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -299,8 +299,7 @@ void ParticlesMaterial::_update_shader() { code += " float scale_rand = rand_from_seed(alt_seed);\n"; code += " float hue_rot_rand = rand_from_seed(alt_seed);\n"; code += " float anim_offset_rand = rand_from_seed(alt_seed);\n"; - code += " float pi = 3.14159;\n"; - code += " float degree_to_rad = pi / 180.0;\n"; + code += " float degree_to_rad = PI / 180.0;\n"; code += "\n"; if (emission_shape == EMISSION_SHAPE_POINTS || emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) { diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index ce09b84a7daf..c24205da43ae 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -54,6 +54,9 @@ ShaderTypes::ShaderTypes() { /*************** SPATIAL ***********************/ shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; @@ -200,6 +203,9 @@ ShaderTypes::ShaderTypes() { /************ CANVAS ITEM **************************/ shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; @@ -265,6 +271,10 @@ ShaderTypes::ShaderTypes() { /************ PARTICLES **************************/ shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT;