godotengine/godot

PI and TAU arent considered valid numeric expressions in hint_range in non-spatial shaders

Open

#119.835 aberto em 28 de mai. de 2026

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)C++ (25.320 forks)batch import
buggood first issuetopic:shaders

Métricas do repositório

Stars
 (110.708 stars)
Métricas de merge de PR
 (Mesclagem média 52d 19h) (239 fundiu PRs em 30d)

Description

Tested versions

Godot 4.6 stable

System information

Godot v4.6.stable - Windows 11 (build 26200) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.9186) - Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (16 threads) - 63.74 GiB memory

Issue description

For some reason variables like PI and TAU aren't considered valid numeric expressions when used as values for hint range

//***- mutable error behavior with shader_type -***
//This line errors with "Expected a valid numeric expression after ','
//on shader types canvas item, fog, particles and sky, but NOT spatial
uniform float using_constant : hint_range(0.0,(2.0*PI)) = 0.0;
uniform float using_constant_tau : hint_range(0.0, TAU) = 0.0;

//this line works just fine on all shader types
uniform float not_using_constant : hint_range(0.0,2.0*1.0) = 0.0;
//and obviously this works fine on all shader types
uniform float simple : hint_range(0.0,1.0) = 0.0;

There is also a special case in the spatial shader

//the spatial shader type doesnt error when you use constants in the hint range directly like so:
uniform float using_constant : hint_range(0.0,(2.0*PI)) = 0.0;
//however if the constant is inside of another constant directly, it errors
const float CONSTANT_PI = PI;
uniform float using_custom_constant:hint_range(0.0, CONSTANT_PI);

//this is also inconsistent because this small change fixes the issue:
const float CONSTANT_PI_WORKAROUND = PI * 1.0;
uniform float using_custom_constant:hint_range(0.0, CONSTANT_PI_WORKAROUND);

this same code, workaround and non workaround errors in non- spatial shader_types

and for posterity these dont error in any shader type:

//none of this errors in any shader type
const float REPEATING = 0.1111;
const float ONE = 1.0;
const float ADDED = ONE + REPEATING;
uniform float repeating_to_added:hint_range(REPEATING,ADDED);
uniform float multiplied_ranges:hint_range(ONE*REPEATING,ADDED*ONE);

Steps to reproduce

Go into shader editor, for each shader type paste a code snippet and see if it errors

Minimal reproduction project (MRP)

N/A

Guia do colaborador