Android and wrap modes

Hi All,



I’m doing a proof of concept for a cross platform (windows/android/applet/etc) 3d game and I successfully have a simple object spinning in space with a couple of light sources. I created the scene in blender, exported to Ogre3d and then converted to j3o objects.



It runs fine both in windows and in an applet. I set up my phone (Galaxy S2) with adb etc and the built APK was pushed into it and the game appeared in applications. However when I started to run it I got:



Unknown wrap mode: BorderClamp: … UnsupportedOperationException



OGLESShaderRenderer.convertWrapMode





Looking at that file I can see:



[java] private int convertWrapMode(Texture.WrapMode mode) {

switch (mode) {

/*

case BorderClamp:

return gl.GL_CLAMP_TO_BORDER;

case Clamp:

return gl.GL_CLAMP;

/

case EdgeClamp:

return GLES20.GL_CLAMP_TO_EDGE;

case Repeat:

return GLES20.GL_REPEAT;

/


case MirroredRepeat:

return gl.GL_MIRRORED_REPEAT;

*/

default:

throw new UnsupportedOperationException("Unknown wrap mode: " + mode);

}

}[/java]



So it seems that only EdgeClamp and Repeat are supported.



Now I realise I could do texture.setWrapMode or similar but I’d need to go through all my loaded textures and do that when really it should be set in the original metadata.



What I haven’t been able to find anywhere (having tried both googling and using the search on the JME site) is a description of exactly what the wrap modes mean, how they map to each other (in particular what I modify in Blender to cause the wrap mode to be set to EdgeClamp when it comes out in the final code having gone through Ogre, to j3o and then finally to JME) and whether this is a temporary or permanent limitation of the android system.



Thanks in advance,

Zarch

1 Like

Just thought I should add in case it makes any difference: The Blender object actually has 3 materials applied with two of those having different textures…so the exported j3o has 3 geometries within a node and a different material applied to each geometry.

You can find an explanation of those modes on page 169 of the OpenGL2 specification:

http://www.opengl.org/documentation/specs/version2.0/glspec20.pdf



Now that I think about it, we can probably just convert those modes to EdgeClamp since there’s no borders in OpenGL ES 2

Ok, thanks for the reference. I’ve read through the relevant section but I think I need to read more of the context to get full understanding. To make sure I’m going in the right direction this is my “plain english” understanding:



REPEAT - tiles the texture

CLAMP - pixels outside the texture ignore the texture? (use the outermost pixel repeatedly? use nothing?)

CLAMP_TO_EDGE - didnt quite follow the description without more context but I think once it reaches the edge of the texture it draws transparent (ie nothing) for the texture layer?

CLAMP_TO_BORDER - vague on the difference between border and edge but I think it is talking about the behaviour of pixels when it reaches the edge of the texture again.



In other news I changed the setting in Blender from “Clip” to “Extend” and the error changed from complaining about “BorderClamp” to complaining about “Clamp”. I then changed it to “Repeat” which worked.



The only other options in blender are “Clip Cube” (and “Checkerboard” (which is a variant on repeat). “Clip Cube” also seemed to work so I guess that is mapping to EdgeClamp. Blender describes Clip Cube as “Clip to cubic shaped area around the image and set exterior pixels to transparent”. Does that sound like EdgeClip?



Thanks,

Zarch

OpenGL has a feature called texture border, which allows you to put a border around the texture so that any texcoords outside of the texture get the texture border color. “Clamp to edge” prevents the border from being visible when the coordinates are between 0.0 and 1.0, while “Clamp to border” will display the border around the texture in that case. “Clamp” is somewhat of a legacy mode which doesn’t really work with the texture border feature. In OpenGL ES the texture border feature was removed entirely, and so many of those clamp modes are no longer available.



Since jME3 doesn’t even support texture border, I am somewhat considering deprecating those modes so that we can have better support for OpenGL ES 2.

The idea would see to make sense (from my very limited knowledge)…or at least to default back to the closest match rather than throwing an exception.



Thanks for the help. I’m sure I’ll be back with more questions once I get further on but I have to say I’m very impressed with the JME SDK and particularly the multi-platform deployment. It’s something I’ve had to do a few times and found it painful so having the IDE do it for me is awesome!



Thanks,

Zarch

It is fixed in SVN. The border clamp and clamp modes now become edge clamp

2 Likes