Author Topic: Object3D's transparency issue  (Read 7164 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #45 on: April 24, 2015, 11:15:00 am »
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.

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #46 on: April 25, 2015, 03:41:07 pm »
So...
This is the problem causer? (the only time I use .flush();):
Code: [Select]
@Override
public void onPause() {
hasRendererLoaded = false;
gLView.onPause();
super.onPause();
TextureManager.getInstance().flush();
this.finish();
}

But even then...:
Code: [Select]
@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:
Code: [Select]
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
Code: [Select]
mainWorld.draw(frameBuffer);
Device information:
LG-P920 (cosmo_TMO-XXX)
Android 2.3.3 - 2.3.7

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #47 on: April 25, 2015, 11:55:49 pm »
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?

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #48 on: April 26, 2015, 01:10:57 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #49 on: April 27, 2015, 05:02:11 pm »
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...

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #50 on: May 03, 2015, 06:43:20 pm »
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.

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #51 on: May 03, 2015, 06:44:18 pm »
An Android 4.3 reference image (see previous post)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #52 on: May 03, 2015, 10:24:49 pm »
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.
« Last Edit: May 30, 2015, 04:12:19 pm by EgonOlsen »

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #53 on: May 30, 2015, 01:42:40 pm »
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:
Code: [Select]
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:
Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #54 on: May 30, 2015, 04:15:16 pm »
Where is this code located? In the render thread or in some listener method?

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #55 on: May 30, 2015, 04:21:08 pm »
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.
« Last Edit: May 30, 2015, 04:35:24 pm by AeroShark333 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Object3D's transparency issue
« Reply #56 on: May 30, 2015, 05:05:47 pm »
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.

Offline AeroShark333

  • long
  • ***
  • Posts: 149
    • View Profile
Re: Object3D's transparency issue
« Reply #57 on: May 30, 2015, 09:57:57 pm »
Thanks for the help! It works like a charm and it doesn't lag at all really :)