Giter Club home page Giter Club logo

Comments (8)

NeoSpark314 avatar NeoSpark314 commented on August 18, 2024

I tried the attached reproducer and the problem is clearly visible on the quest while it does not occur on desktop:

time_deterioration_screenshot

I used renderdoc to inspect the created shader and it seems to be a floating point precision problem:
In the final fragment shader there is at the top a

#if defined(USE_HIGHP_PRECISION)
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif

but USE_HIGHP_PRECISION is not defined. So the default precision for computations is mediump.

The computation from the shader graph later looks like this.

{
	vec3 m_n_out7p0;
	m_n_out7p0 = vec3(uv_interp, 0.0);
	float m_n_out2p0;
	m_n_out2p0 = time;
	float m_n_in5p1 = 0.3;
	float m_n_out5p0;
	m_n_out5p0 = (m_n_out2p0 * m_n_in5p1);
	float m_n_in4p2 = 0.0;
	vec3 m_n_out4p0;
	m_n_out4p0 = vec3(m_n_out5p0, m_n_out5p0, m_n_in4p2);
	vec3 m_n_out6p0;
	m_n_out6p0 = (m_n_out7p0 + m_n_out4p0);
	vec3 m_n_out3p0;
	float m_n_out3p1;
	vec4 m_tex_frg_3_read = texture2D(m_tex_frg_3, m_n_out6p0.xy);
	m_n_out3p0 = m_tex_frg_3_read.rgb;
	m_n_out3p1 = m_tex_frg_3_read.a;
	albedo = m_n_out3p0;
}

even though the time variable is defined as uniform highp float time; the actual computation is done in mediump!

Querying the precision on the oculus quest using glGetShaderPrecisionFormat gives

V GodotOVRMobile:     Fragment Shader Precision: LOW  [15, 15] 10
V GodotOVRMobile:     Fragment Shader Precision: MED  [15, 15] 10
V GodotOVRMobile:     Fragment Shader Precision: HIGH [127, 127] 23

so all computations are done with 10bit mantissa.

Looking into the godot code the only place where USE_HIGHP_PRECISION is defined for the shader seems to be in the JavaScript case:
https://github.com/godotengine/godot/blob/ac38f0782fbf781265ec34a43196e3ea157f3696/drivers/gles2/shader_gles2.cpp#L180

Forcing this define to be always present by disabling the #ifdef JAVASCRIPT_ENABLED fixed the issue.

I don't know what the proper solution to this problem is. Two ideas from my side are

  • Add an optional highp mode for shader graph computations
  • Have a global flag in the mobile settings to push the high precision mode for all shaders

from godot_oculus_mobile.

m4gr3d avatar m4gr3d commented on August 18, 2024

cc @akien-mga

from godot_oculus_mobile.

m4gr3d avatar m4gr3d commented on August 18, 2024

@fakedeltatime Can you open an issue on the main Godot engine issues page as well since as @NeoSpark314 mentions this may also affect other platforms.

from godot_oculus_mobile.

akien-mga avatar akien-mga commented on August 18, 2024

Related: godotengine/godot#32813

from godot_oculus_mobile.

akien-mga avatar akien-mga commented on August 18, 2024

Related: godotengine/godot#32813

I tested the reproduction project there on a Xiaomi Pocophone F1 and I can confirm that the same issue happens as described here, so it's the same bug.

@NeoSpark314 Would be worth adding your findings there.

from godot_oculus_mobile.

fakedeltatime avatar fakedeltatime commented on August 18, 2024

I'm surprised that I'm not getting these problems with my low tier Nokia 1 phone, but I guess that might be because it's running Android Go (a lighter version of Android) instead of regular Android?

from godot_oculus_mobile.

Firepal avatar Firepal commented on August 18, 2024

Since godotengine/godot#33646 was merged into master and included in 3.2.3, shouldn't this issue be closed?
That PR was probably the best that could've been done in any case ^^'

from godot_oculus_mobile.

m4gr3d avatar m4gr3d commented on August 18, 2024

Agree, thanks for the reminder @Firepal!

from godot_oculus_mobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.