ShaderEditor icon indicating copy to clipboard operation
ShaderEditor copied to clipboard

Strange value of gl_FragCoord.y on Honor 7X

Open casheera opened this issue 8 years ago • 19 comments

on Honor 7X (screen resolution 2160x1080): first frame works correctly, after gl_FragCoord.y==0.5 on each pixel, so "gl_FragColor = vec4(vec3(gl_FragCoord.y==.5), 1.0);" gives white screen

casheera avatar Dec 29 '17 12:12 casheera

Well, I can't explain why gl_FragColor = vec4(vec3(gl_FragCoord.y==.5), 1.0); gives a white screen (mine's black as I would expect) but gl_FragCoord.y holds the screen coordinate. In your case it ranges from 0 to 2159 in portrait mode. So gl_FragCoord.y==.5 should always be false what should be converted to 0.0 (black) - note there's an implicit type conversion from boolean to float. Is that really what you want?

Because gl_FragCoord is set by OpenGL and not by the app, it's unlikely that the app does anything wrong here. If there was a problem with gl_FragCoord, I'd expect it to show up in any app that draws with OpenGL.

markusfisch avatar Dec 29 '17 12:12 markusfisch

its fully synthetic gl_FragColor = vec4(vec3(gl_FragCoord.y==.5), 1.0); to show y is equal 0.5, and its only in portrait orientation, in landscape works ok. Here "Circles" example screenshots attached

photo5345946545406715983 photo5345946545406715984

casheera avatar Dec 29 '17 12:12 casheera

have tested opengl benchmarks - works fine in portrait and landscape modes

photo5345946545406715993 photo5345946545406715992

casheera avatar Dec 29 '17 13:12 casheera

Ah, I see. Very strange indeed. Never encountered anything like it.

Maybe the problem is with resolution rather than gl_FragCoord.y ... I just can't imagine why gl_FragCoord.y would ever be .5? Especially because it's set by OpenGL. Maybe gl_FragCoord.y == .5 is true because of a rounding error? I assume all shaders don't work in portrait mode then?

Does it change when you decrease the resolution setting in the tool bar besides the title? Say from 1/1 to 1/8?

markusfisch avatar Dec 29 '17 13:12 markusfisch

no example with ==. 5 doesnt use resolution at all. and it reproduce only in 1/1 mode in portrait

casheera avatar Dec 29 '17 13:12 casheera

So 1/2, 1/4 and 1/8 work in portrait mode? That's interesting ...

markusfisch avatar Dec 29 '17 13:12 markusfisch

yes. exactly. and "circles" wont work correctly only in portrait and 1 to 1. note that here is a strange screen aspect 1:2

casheera avatar Dec 29 '17 14:12 casheera

screenshot_20171229-202616 Im have no any skills in java or android development, but here are some considerations (may be it helps to find the way where to dig) :

  1. Its Android 7.0 here.
  2. It has "Full Screen Display Settings". if some app is turned on it runs on native screen resolution, if turned off - runs on 1920x1080 with black bar on bottom (some kind of legacy mode for apps that have no right fullscreen provider)
  3. But your app there is not in this list at all, and another opengl apps that works correct is in it and works both in full and croped modes.
  4. But despite this your app runs in fullscreen mode by default, and seems it use some workaround, and system "thinks" that app in default cropped mode and causes somewhere wrong calculation.

casheera avatar Dec 29 '17 18:12 casheera

Because of #73 I've made the app choose a GLES 3.0 context (if it's available). This is still experimental and in beta only. But if you like, you can try it to see if it has any effect on this problem as well:

https://play.google.com/apps/testing/de.markusfisch.android.shadereditor

markusfisch avatar Jan 09 '18 19:01 markusfisch

Have update to beta, but all the same. OGL ES 3.2 is avaliable photo5384145267277801568

And with such code:

#version 300 es

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

out vec4 fc;

void main() {
 fc = vec4(1.0);
}

I'm having L0001 Shader languages do not match (with #version 320 es - the same)

casheera avatar Jan 11 '18 10:01 casheera

After last update #version 300 es shaders compiles well but gl_FragCoord.y==0.5 bug still stays. So code below in portrait and 1/1 mode gives white screen:

#version 300 es

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

out vec4 fc;

void main() {
	fc = vec4(gl_FragCoord.y==0.5);
}

casheera avatar Jan 12 '18 06:01 casheera

Hm, anyway, was worth a try. I'm still trying to figure out what exactly may cause this. Would you mind running a special debug build so I could get a little more info about what's going on?

markusfisch avatar Jan 12 '18 20:01 markusfisch

Actually gl_FragCoord contains half pixel values by default. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragCoord.xhtml So in this case it should only paint the bottom pixel line to white and the rest to black.

fekga avatar Jan 12 '18 21:01 fekga

Would you mind running a special debug build so I could get a little more info about what's going on?

Sure, Markus, let's try.

casheera avatar Feb 05 '18 09:02 casheera

Hello, I've been having the exact same issue on my phone, and I notice we both have Huawei devices (mine is a P10 Lite). It is confusing that this seems to happen only with Huawei devices, but only in a very specific set of circumstances.

mbwk avatar Aug 17 '18 09:08 mbwk

Bug gone after upgrading to Android 8.

casheera avatar Aug 22 '18 18:08 casheera

Thanks a lot for reporting! Interesting, wouldn't have thought so 🤔

markusfisch avatar Aug 22 '18 19:08 markusfisch

I can also confirm this bug has vanished for me since upgrading to 8.

mbwk avatar Aug 31 '18 21:08 mbwk

Actually graphics hardwares and drivers have lots of bugs. but they are unknown. In my phone after playing with "Game of Life" sample, and leaving the app. Some points had remained on the screen for near one hour. ( even after restarting the phone they was visible)

Methylol avatar Feb 27 '22 13:02 Methylol