Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Decrease shader TIME rollover to 30 seconds on mobile platforms #59991

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 7, 2022

3.x version of #59990.

This avoids precision issues that became obvious when exporting a project to a mobile platform.

Shader animations will have to loop over 30 seconds to avoid visual discrepancies when TIME is reset back to 0.

@Calinou Calinou requested review from a team as code owners April 7, 2022 16:48
@Calinou Calinou added this to the 3.5 milestone Apr 7, 2022
@Calinou Calinou changed the title Decrease shader TIME rollover to 30 seconds on mobile platforms Decrease shader TIME rollover to 30 seconds on mobile platforms (3.x) Apr 7, 2022
@Calinou Calinou force-pushed the shader-time-rollover-secs-mobile-lower-default-3.x branch from 6078e04 to 5f4d74f Compare April 7, 2022 18:34
@clayjohn
Copy link
Member

I don't think we should merge this in 3.x. It will be a visually breaking change and will be confusing and non-intuitive for users.

@Calinou
Copy link
Member Author

Calinou commented Apr 10, 2022

I don't think we should merge this in 3.x. It will be a visually breaking change and will be confusing and non-intuitive for users.

On the other hand, a lot of shaders that use TIME are broken on mobile right now because of this. The only case where this change would actually worsen things is for users who manually enabled high float precision in the project settings. Some of those users might not need to enable high float precision anymore if they can use a lower TIME rollover value.

Here's an example of such an issue: #43505

While I agree that preserving compatibility between minor releases is important, I'm not sure if it's a goal worth pursuing when the existing behavior is basically unusable out of the box.

This is of course something that should be prominent in the release notes.

Edit: An alternative is to use the same approach as godotengine/godot-proposals#4834. This would avoid breaking compatibility with existing projects (although they'd be left with the rendering bugs on mobile).

@lawnjelly
Copy link
Member

I noticed that Unity also has similar problems with time. If I remember right they try to solve it by storing some different divisors of time in uniforms (in a vec4), as well as some common sin values of time (in another vec4).

Imo though the only foolproof way to solve this mobile, say for water shaders, is for the client code to calculate a repeatable range (e.g a specific sin frequency) then e.g. send it as e.g. 0.0 to 1.0 in a custom uniform. Or multiple of these if there are multiple versions needed in a shader.

Sending time in a uniform and then doing these calculations in the shader seems like it will always introduce some kind of error on low precision hardware. Basically for low end mobile, TIME is probably best avoided I suspect.

This avoids precision issues that became obvious when exporting
a project to a mobile platform.

Shader animations will have to loop over 30 seconds to avoid visual
discrepancies when `TIME` is reset back to 0.
@BastiaanOlij
Copy link
Contributor

Thinking about this, I think the setting should be added and merged, but maybe its default should match the current default for desktop.

That way we do not break existing games, but we do allow people to change the default on mobile who are experiencing issues on mobile.

@Calinou
Copy link
Member Author

Calinou commented Oct 27, 2022

Thinking about this, I think the setting should be added and merged, but maybe its default should match the current default for desktop.

That way we do not break existing games, but we do allow people to change the default on mobile who are experiencing issues on mobile.

This can already be done manually by the user.

If you don't want to break existing projects, godotengine/godot-proposals#4834 is an approach that will allow fixing the issue in new projects at least.

@Calinou Calinou changed the title Decrease shader TIME rollover to 30 seconds on mobile platforms (3.x) [3.x] Decrease shader TIME rollover to 30 seconds on mobile platforms Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants