I have some very old android apps using OpenGL ES 1.x that I need to update in Google Play in order to make them work on newer devices. After doing the needed updates of deprecated code etc, I found that where I'm using fog, textures with transparency now no longer works. The transparent parts are showing slightly. If I turn off fog everything works fine though.
This was all working fine when I deployed the apps and has been tested through the years without issues. But apparently something has changed now.
Is there anyone that still has knowledge about OpenGL ES 1.x who can help with this? Here's the part of my code applying the fog and then drawing all the quads:
gl.glFogf(GL10.GL_FOG_MODE, GL10.GL_LINEAR);
gl.glHint(GL10.GL_FOG_HINT, GL10.GL_NICEST);
gl.glFogf(GL10.GL_FOG_START, startZ);
gl.glFogf(GL10.GL_FOG_END, endZ);
gl.glFogfv(GL10.GL_FOG_COLOR, fColor, 0);
gl.glEnable(GL10.GL_FOG);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
super.drawSprites(gl);
gl.glDisable(GL10.GL_FOG);
And here's an example of how it renders when fog is on, as you see the transparent parts of the quads are showing:
Looks like you are missing GL_ALPHA_TEST to cull the transparent fragments so you are picking up fog color on the transparent parts of each sprite.
This seems to be a device specific problem. My test phone was a Samsung Galaxy s22 ultra, and when testing on other devices (including the s21 ultra) no other phone shows the same error. So I will mark this as the answer. Thanks to #solidpixel for helping out with the debugging.
Related
I have developped a small openGLES2.0 app which is compatible from android version 8 to 17.
It basically renders a sphere model with simple texturing in an empty scene. I also keep track of device sensors like accelerometer. All is working fine and cool on a wide variety of android phones (GS2, GS3, GN2, Nexus...).
My simple problem is that i can't get it working on tablets (GT2 running on 4.1.1 for example). The app is installed correctly, it doesn't crash at all, i just see a black screen instead of my sphere model. The part of the application that doesn't use openGL is running perfectly.
I can't believe that OpenGLES 2.0 is not working on GT2, neither sensors, neither internet connection that i used also. Is there something to check/enable to get it working ? Maybe something related to the larger size of screen on tablets ? I could maybe post a bit of code but i think the problem is elsewhere...
Thanks for your time !
When you use GLES 2.0 on devices you must be careful with indices. On many devices you cannot use int index. Every device supports unsigned short index. For render you must use:
GLushort indicies[] = { 0, 1, 2, 0, 2, 3 };
...
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indicies);
I have an OpenGL ES 2 code base that runs on iOS, Android, and on PC via the PowerVR emulation libraries.
When I run this code on an LG Optimus G LGE971, I see black artifacts on my model:
http://imageshack.us/photo/my-images/594/renderartifacts.png/
My first reaction was that the near clipping plane might be the issue, but because these artifacts appear on only select devices, I do not believe that is the issue. Any other ideas on what might be causing this?
Also, this isn't captured well in the above image, but the artifacts are not static -- they move around as the model rotates, etc.
I think maybe Lighting Calculation in shader code was wrong by mistake.
That looks like only using Ambient light without diffuse & specular.
also I want you to check whether you converted the texture from BGRA to RGBA.
The issue has been fixed. I fixed the issue by using
glTexImage2D()
with NULL for the buffer when I set up my mipmap levels, and then using
glTexSubImage2D()
when uploading the texture data into each level.
We are a team of developers working on a terrain visualization software over a virtual 3D globe. The project is aimed at mobile devices running android, mainly tablets and mobile phones. We have tested this in several devices and, while mobile phones seem to run the application fine (we haven't detected any issues on any of them), some tablets seem to have problems when drawing the textures in the screen.
For clarity purposes, im attaching a video that displays the problem, since its a little difficult to explain with words. This example shows a sphere divided in 200 sectors, each one with a different texture.
Texture problem video
As you can see, sometimes it looks like it is trying to draw two different textures in the same sector at the same time.
We have tested this in these devices:
Samsung Galaxy S SLC (ok)
HTC Desire (ok)
Nook Ebook Reader (ok)
Samsung Galaxy Tab 10.1 (doesnt work propperly)
Sony Tablet S (doesnt work either)
Samsung Galaxy Tab 7.0 (ok)
Im posting the critical code that may be involved in this. First the fragment shader that is used to draw the textures:
varying mediump vec2 TextureCoordOut;
uniform sampler2D Sampler;
....
gl_FragColor = texture2D (Sampler, TextureCoordOut);
Next, im posting the key instructions that are executed in OpenGL, since the code is spared in several big functions:
GLES20.glGenTextures(num, idTextures, 1); //declare 200 textures
...
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, idTextures[texture]); //texture binding
...
GLES20.glVertexAttribPointer(Attributes.Position, size, GLES20.GL_FLOAT, false, stride, fb);
...
GLES20.glVertexAttribPointer(Attributes.TextureCoord, size, GLES20.GL_FLOAT, false, stride, fb);
...
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, first, count);
Im sorry not to be able to provide more details, but after several weeks of debugging, we have no clue at all of what could be causing this. Im turning to you hoping for any leads, since we are completely lost right now. Thanks in advance.
I think I might know what causes you difficulties. The only devices where it doesn't work for you are Tegra 2 devices. I recently started working with a Tegra 2 device and noticed certain differences. Compared to other devices Nvidia seems to have introduced certain kinds of rounding errors where some things can behave differently from other GPUs. I had to go to extreme lengths and use workarounds to get it working the way I want with my complex shaders.
And what I could see on your video looks sort of like the z-buffer might not have enough resolution and that causes some kind of z-fighting: http://en.wikipedia.org/wiki/Z-fighting. I am not sure because I don't really see from your code/description if you are drawing triangles that are very close together and can cause this kind of behaviour in the z-buffer.
But maybe you can try to scale the vertices (x,y,z) somewhat up or down and see what happens to the flickering. If it changes it probably has something to do with that, if not, the problem might have another reason, but then a little more code would be nice.
It would also be interesting to try to narrow it down by not painting the whole sphere but just one or two triangles where the problem occurs and see if it still happens.
PS: A longer video would have been better, short clips suck on vimeo.
I have an OpenGL Live wallpaper that works fine on all phones except those with the PowerVR SGX series. This includes almost all Samsung phones and the Motorola Droid series. The wallpaper is nothing but a black screen on the PowerVR GPU phones. I have been racking my brain for a week trying to figure this problem out but have had no luck.
One difference between the different GPUs is their texture compression. Some of the things I have done in that regards is I have changed my texture image to a square of 256x256. Changed it from 8 bit to a 16 bit rgba and even tried indexed.
I have a list of all the extensions that are available with the PowerVR and the ones that are available with the Adreno. It seems that there are quite a few differences in available extensions but I do not know what functions go with what extensions (though I can somewhat guess). Here is a list of the functions that I use:
glLightfv
glMaterialfv
glDepthFunc
glEnableClientState
glViewport
glMatrixMode
glLoadIdentity
gluPerspective
glclearcolor
glclear
glTranslatef
glRotatef
glVertexPointer
glTexCoordPointer
glColor4f
glNormal3f
glDrawArrays
glTexParamterx
I am using Robert Green's GlWallPaperService and have tried this solution at Trying to draw textured triangles on device fails, but the emulator works. Why? . Does anybody have any idea why the PowerVR chips are giving me such a hard time and what I could do about it?
Removing EGL10.EGL_RED_SIZE, EGL10.EGL_GREEN_SIZE, and EGL10.EGL_BLUE_SIZE but leaving EGL10.EGL_DEPTH_SIZE, EGL10.EGL_NONE in the eglChooseConfig worked. I assume that the PowerVR chip processes RGB in a way that makes defining them a problem.
This probably won't help you, but I noticed:
One difference between the different GPUs is their texture compression. Some of the things I have done in that regards is I have changed my texture image to a square of 256x256. Changed it from 8 bit to a 16 bit rgba and even tried indexed.
To my knowledge, no current hardware supports indexed textures. Also, to use texture compression, you need to target a compressed texture format that is specifically supported by the device (which usually entails running a compressor on the host/development platform). SGX supports PVRTC and ETC but whether those are enabled depends on the platform
From my own experience with this GPU, it will offer GLES configurations, that once applied will not work (i.e. the GLES context will not be created). The workaround is to look at the GLSurfaceView code, roll out your own and try out each offered configuration, whether it works for creating a context.
So, I'm writing a game engine.
I have a little example (see http://qrcode.kaywa.com/img.php?s=8&d=http://rokonandroid.com/rd.apk), that seems to work fine on every device except Droid / Milestone.
It displays a blue screen (due to glClearColor being set to blue), and nothing more.
I have tried with/without textures, and with/without VBOs. Yet still all blue screens on Droid.
What is unique about Droid and how it handles OpenGL, and why is it doing this?
Are you using OpenGL ES 2.x perchance? The droid can't support it. Alas there is precious little we can do but guess without seeing some source code!