Black textures in android?

Hi, having always probs with textured models, anyway my ship (converted to .j3o) works in JME3:

,but in android the ship appears black.
Looks like I made something not correct in exporting/importing and android is not that error proof like JME3?
A video how to export models in blender correct, so it works in android, would be nice.
(texture tutorial looks hard, is it that complicated? -> https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:external:blender#uv_mapped_textures )
If someone wants to look at my model and check what I’ve done wrong, explain how to fix: please PM.
A code example, how I can attach a material to the ship.j3o, without overwriting the texture, would be nice, too.

(The code I use should be not the prob, like you see, I used the hoover tank-example and the tank as model works. in both enviroments :-x )

Can you check the logs and see if there’s anything there about the textures? At the very least it should give a warning that the texture can’t be used

Sometime compression does that
try to add that line in your MainActivity constructor

[java]
TextureUtil.ENABLE_COMPRESSION = false;
[/java]

1 Like

What is the MainActivity constructor?

I am running the HelloAnim tutorial and cannot find where to place this piece of code.

It just says “Package TextureUtil does not exist”

MainActivity is android specific code. If you want to make changes to android code it is recommended to install the NBAndroid plugin.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android#beta_instructions

Were you able to resolve your issue? I am having the same problem. Terrain textures appear fine at first, but unshaded and lighting textures are entirely black. The same application runs perfectly on Windows, but Android (4.2.2 on Nexus 7) shows black textures.

I did disable texture compression, but that didn’t change anything. I can see no errors in the log file concerning textures at all.

Resolved my issues at least. I changed the dimensions of the texture to a power of 2 (512x512) and the texture appears. Might be a noob mistake, but apparently some opengles implementations require texture sizes to be a power of 2 in certain cases. Don’t know if this helps anyone else.

1 Like

So, I kind of had reverse results; I had an image that was 512x32 and on PC it worked fine, on Android the texture was black.

When I upped the texture size to 512x512, not only did the Android texture remain black, but the PC texture became black as well.

There are absolutely no errors in the console about this.

Are you using RC2 or some nightly version?

<cite>@Momoko_Fan said:</cite> Are you using RC2 or some nightly version?

I’m using the SVN, so nightly. I pulled it probably two nights ago.

@JDBallard said: So, I kind of had reverse results; I had an image that was 512x32 and on PC it worked fine, on Android the texture was black.

When I upped the texture size to 512x512, not only did the Android texture remain black, but the PC texture became black as well.

There are absolutely no errors in the console about this.

This is going to sound dumb but if it’s also black on the PC now then are you sure the texture isn’t just black now? How are you sure?

<cite>@pspeed said:</cite> This is going to sound dumb but if it's also black on the PC now then are you sure the texture isn't just black now? How are you sure?

Because a) I made the texture, and b) nothing about the texture was changed (including any code) other than the canvas size being increased to 512 from 32.

@JDBallard said: Because a) I made the texture, and b) nothing about the texture was changed (including any code) other than the canvas size being increased to 512 from 32.

So, just assumptions then. You haven’t independently verified by loading it in an image viewer or something?

Not to be harsh or anything but when things are supposed to work but aren’t then you have to question every assumption that “supposed to work” is based on. If the exact same setup worked on the PC with one texture and now doesn’t with a different texture then it strongly points to “bad texture”. If it’s not “exactly the same setup” then that’s where you can start looking… but it only takes 5 seconds to turn assumptions into fact regarding the texture validity.

<cite>@pspeed said:</cite> So, just assumptions then. You haven't independently verified by loading it in an image viewer or something?

Not to be harsh or anything but when things are supposed to work but aren’t then you have to question every assumption that “supposed to work” is based on. If the exact same setup worked on the PC with one texture and now doesn’t with a different texture then it strongly points to “bad texture”. If it’s not “exactly the same setup” then that’s where you can start looking… but it only takes 5 seconds to turn assumptions into fact regarding the texture validity.

Trust me, I’m not a newbie at this :wink: I verified everything. Switching back to a 512x32 texture worked on PC, as expected. Haven’t gotten textures to work at all on Android.

…but I feel like if you’ve actually looked at the image independently in an image viewer that you’d have just said that. :wink:

Until then, it is always a possibility that the 512x512 texture is actually just all black. There is really no other reason that it should be all black in JME just because you swapped it out.

<cite>@pspeed said:</cite> ...but I feel like if you've actually looked at the image independently in an image viewer that you'd have just said that. ;)

Until then, it is always a possibility that the 512x512 texture is actually just all black. There is really no other reason that it should be all black in JME just because you swapped it out.

I don’t know how to infer that it’s by nature that I check images other than to say “I checked it”. I didn’t think I needed to say I checked the saved image if a) I’m a programmer and b) I’m facing a bug related to that texture. Seems pretty illogical not to check it. Should have been implied.

Regardless, is there any insight as to what the issue might be?

Do you use a normal map? If yes, did you generate the tangents for your mesh?

<cite>@normen said:</cite> Do you use a normal map? If yes, did you generate the tangents for your mesh?

No, no normal maps.

@JDBallard said: I don't know how to infer that it's by nature that I check images other than to say "I checked it". I didn't think I needed to say I checked the saved image if a) I'm a programmer and b) I'm facing a bug related to that texture. Seems pretty illogical not to check it. Should have been implied.

Regardless, is there any insight as to what the issue might be?

Ok… so you did load it in a viewer, ie: you “checked the image”. You never actually said that before so I couldn’t be sure. The closest thing I got was a list of things you did that were not checking the image and reasons why you wouldn’t have to check the image. Never once was it said “Yes, I checked it.” Just “I made it so I don’t need to check it” and “yes I’m sure”

And if I assumed everyone knew how to properly debug their stuff then I’d never have anything to offer here and the debugging world would be a great mystery.

There is a presupposition that has to happen for everyone who posts here. If you are asking for help then that means that you have exhausted all of your own debugging capabilities and now are looking for others. Since I’m not sitting there next to you then I don’t know what you’ve tried… I only know you’ve exceeded your own capacity for sorting it yourself. I have no idea what that capacity is until I ask.

Normen’s suggestion is a good one… though it doesn’t explain why it worked with the other image other than that “it can be random” the behavior you get for unspecified attributes.

Have you tried other size textures? 128x128, etc.?

Can you post the 512x512 image with a simple test case?