Object3D's transparency issue

Started by AeroShark333, December 06, 2014, 12:07:56 PM

Previous topic - Next topic

EgonOlsen

That can happen only if the object to be rendered references a texture that doesn't exist (anymore). That not possible IMHO unless one calls flush() on the TextureManager in some other than the rendering thread. I could catch that exception, but that won't help much because something is in an undefined state here anyway.

AeroShark333

So...
This is the problem causer? (the only time I use .flush();):
@Override
public void onPause() {
hasRendererLoaded = false;
gLView.onPause();
super.onPause();
TextureManager.getInstance().flush();
this.finish();
}


But even then...:
@Override
public void onDrawFrame(GL10 gl) {
if (!hasRendererLoaded) {
return;

                // irrelevant code

                       }

}


Textures won't really be used if it 'return;'s.

Also... I have a new stacktrace from an user:
java.lang.RuntimeException: [ 1429958366470 ] - ERROR: Failed to load and compile fragment shaders!
at com.threed.jpct.Logger.log(Logger.java:206)
at com.threed.jpct.GLSLShader.loadProgram(GLSLShader.java:1077)
at com.threed.jpct.GLSLShader.preInit(GLSLShader.java:285)
at com.threed.jpct.GL20.setShader(GL20.java:362)
at com.threed.jpct.GLRenderer.setShader(GLRenderer.java:553)
at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:189)
at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2308)
at com.threed.jpct.World.draw(World.java:1417)
at com.threed.jpct.World.draw(World.java:1100)
at com.aeroshark333.skinviewer.SkinActivity$ViewerRenderer.onDrawFrame(SkinActivity.java:1659)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)


Line #1659
mainWorld.draw(frameBuffer);

Device information:
LG-P920 (cosmo_TMO-XXX)
Android 2.3.3 - 2.3.7

EgonOlsen

That flush is most likely the problem. Your flag doesn't ensure anything if both methods are called in different threads. If you want to avoid this, use proper synchronization instead....or simply don't flush the textures. Why are you doing this in onPause anyway?

AeroShark333

Hmm, you're right... I don't really have a reason for the flushing in onPause... So I guess I'll remove that line.

And what about the stacktrace?

EgonOlsen

Nothing new about the Stacktraces of that kind. I highly doubt that it's a real issue with the shader itself. It might be a driver problem (also unlikely at that stage) or maybe some problem with an unintialized GL context because of the app shutting down or whatever...

AeroShark333

I have a small issue and I do not know why I have this problem.
The head on Android 2.2 does look filtered, while it is not filtered on Android 4.3.
(Android 2.2 uses OpenGL 1.0 (SDK emulator) and Android 4.3 uses OpenGL 2.0 (Genymotion emulator))
The weird thing is: the rest of the body is not filtered on Android 2.2 (or looks not filtered), which is why I think this issue does not make sense.
And when I apply a body texture to the head object (in code), then it is not filtered.
So I cannot blame the object for filtering the textures.
I do not know why the head textures are filtered on Android 2.2 but not on Android 4.3.

AeroShark333

An Android 4.3 reference image (see previous post)

EgonOlsen

#52
As long as this is the result of the emulator only, i wouldn't give it a second thought. The emulator still does strange things when it comes to OpenGL.

AeroShark333

Hmm, I have been getting a nullpointerexception and I have no idea how to fix it.
Basically I am trying to alter the meshdata while running the application.
Code:
Mesh mesh = rA.getMesh();
mesh.setVertexController(new GenericVertexController(){

private static final long serialVersionUID = 1311476511641434156L;

@Override
public void apply() {
SimpleVector[] s = getSourceMesh();
//System.out.println("length:"+ s.length);
SimpleVector[] d = getDestinationMesh();
for (int i = 0; i < 26;i++){
d[i].z =  s[i].z - (lastX - firstX)*0.001f * (i/2) * (i/2);
d[i+26].z =  s[i+26].z -(lastX - firstX)* 0.001f * (i/2) * (i/2);
d[i].x = s[i].x;
d[i].y = s[i].y;
}
}

}, true);
mesh.applyVertexController();
mesh.removeVertexController();


Stacktrace:
05-30 13:36:21.741: W/dalvikvm(5893): threadid=17: thread exiting with uncaught exception (group=0xa61f2908)
05-30 13:36:21.745: E/AndroidRuntime(5893): FATAL EXCEPTION: GLThread 392
05-30 13:36:21.745: E/AndroidRuntime(5893): java.lang.NullPointerException
05-30 13:36:21.745: E/AndroidRuntime(5893): at com.threed.jpct.GenericVertexController.init(GenericVertexController.java:88)
05-30 13:36:21.745: E/AndroidRuntime(5893): at com.threed.jpct.Mesh.setVertexController(Mesh.java:164)
05-30 13:36:21.745: E/AndroidRuntime(5893): at com.aeroshark333.skinviewer.SkinActivity$18.run(SkinActivity.java:1251)
05-30 13:36:21.745: E/AndroidRuntime(5893): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
05-30 13:36:21.745: E/AndroidRuntime(5893): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


The code is run in a queued GL-thread.

EgonOlsen

Where is this code located? In the render thread or in some listener method?

AeroShark333

#55
I tried both: both lead to the same stacktrace/crash.
The only place it does work is when it is initializing the renderer. (before adding it to the world)

EDIT: If I remove Object3D.strip() then it won't crash, however the new meshdata is not completely applied.
It is applied (since I can see another Object3D, which is tied to a the Object3D's mesh's SimpleVector, does move)
But the new shape/texturedeforming is not visible. Only the initialized meshdata form is applied, not the changes that I want to apply in the renderer/listener.

EgonOlsen

I see...that's because objects get compiled and uploaded to the GPU at build time. If you want to modify the geometry afterwards, the object has to be compiled in dynamic mode. You can do this by either make an explicit call to compile(true) after calling build() or let the engine to this automagically...for which you have to assign the vertex controller before calling build. Then apply your controller, then call touch() on the object.
In any way, this will trigger a re-upload of the mesh to the GPU. If you are doing this constantly, it might cause a performance penalty.

AeroShark333

Thanks for the help! It works like a charm and it doesn't lag at all really :)