godotengine / godotengine/godot

Shading language hint_range for uniform variables doesn't round to step

Open
#113,249 2 comments 0 reactions 0 assignees View on GitHub
bug topic:editor topic:shaders
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in: v4.5.stable.official [876b29033]
I think this is unlikely to be a recent regression.

### System information

Windows 11 - Godot v4.5.stable.official [876b29033] - Vulkan (Forward+)

### Issue description

Following uniform definition:
`uniform float spread : hint_range(-1.0, 1.0, 0.1) = 0.0;`
Modifying the value in the inspector causes the parameter to be not rounded to 0.0 anymore but is set to something like 0.0000000149012 and it is not possible to set to exactly 0.0 anymore.
With `uniform float spread : hint_range(0.0, 1.0, 0.1) = 0.0;` it sets the value to 0.0 as expected.

### Steps to reproduce

- Define a uniform variable in a shader: `uniform float spread : hint_range(-1.0, 1.0, 0.1) = 0.0;`
- Assign shader to any material and change the Shader Parameters in the Inspector to any value and then back to 0.0 (or any other value)

### Minimal reproduction project (MRP)

[mrp.zip](https://github.com/user-attachments/files/23810350/mrp.zip)

Contributor guide

Open the contributing guide

Research direction

Start by opening the attached MRP and reproducing the issue with the shader uniform in the Inspector. Trace how the Inspector edits `hint_range` values for the shader parameter, then verify that returning to 0.0 or another step value produces the exact stepped value rather than a small floating-point remainder.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.