Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,373

Madness? THIS - IS - MOBILE!!!


Josh

3,561 views

 Share

I apologize preemptively for the title.

 

So I picked up a Samsung Galaxy Tab today, for testing...yeah, that's it, "testing"...rolleyes.gif

blogentry-1-0-01791500-1326707120_thumb.jpg

 

I installed the USB driver for Windows, restarted my computer, and was able to start debugging Leadwerks3D on it with no trouble at all. However, the rendering showed black objects that ought not be black.blink.png

blogentry-1-0-90237300-1326707126_thumb.jpg

 

At this point in the game, having such a basic issue is very scary to me. I tracked the problem down to the lighting uniforms being passed to the shader, but something didn't make sense.

 

In GL Shading Languages (GLSL), you can have arrays of uniforms, like this:

vec3 mediump lightdirection[4];

A uniform array like this should be accessible from the main program by setting individual elements in the array, or by setting the entire array at once with a pointer to eight floats. See for yourself:

http://www.khronos.o...spec_2.0.25.pdf

 

Page 35:

The first element of a uniform array is identified using the name of the uniform array appended with "[0]". Except if the last part of the string name indicates a uniform array, then the location of the first element of that array can be retrieved by either using the name of the uniform array, or the name of the uniform array appended with "[0]".

It did not appear that the light color and direction was being sent correctly, and more detailed debugging confirmed this.

 

After a few hours of testing, I finally determined that uniform array names on iOS have end with '[0]' (I didn't test any other element indexes, at least on the iOS simulator. My provisioning profile just expired, and that's a whole other story...), and just setting the uniform array at once with the name will not work. On the Samsung Galaxy Tab, the situation is reversed. My HTC Evo is the only device that follows the OpenGLES specification and allows either.

 

Samsung Galaxy Tab: "lightdirection"

iOS: "lightdirection[0]"

Evo: "lightdirection" or "lightdirection[0]" (as it should)

 

The solution? I'll just avoid using uniform arrays on any mobile devices. It's not hard to avoid now that I know what to look for, but it's hell figuring out which parts of the GL spec the driver authors ignored.

 

Fortunately, you don't have to worry about any of that, so you can just make your games and be happy. biggrin.png

blogentry-1-0-95646600-1326707132_thumb.jpg

 Share

5 Comments


Recommended Comments

How hard is it to enable shadowmapping on mobile? Just copy the original PC shaders and change lightdirection[0] to lightdirection?

Link to comment

I don't think OpenGLES has depth textures in the spec. Some implementations may support it, but the mobile feature support is way ahead of their performance. The iPad 2 is the fastest thing out there, and there's no way it could do full shadow mapping.

 

Maybe the next generation of mobile devices:

http://toucharcade.c...-to-ios-devices

Link to comment

Shadow mapping already works on my Galaxy S2, as I've tested with some self-written demos. I just want to be able to optionally enable it, although most other phones are too slow for it. The Galaxy S2 is an high-end gaming phone.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...