Author Topic: Depth buffer texture  (Read 20100 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Depth buffer texture
« Reply #120 on: July 21, 2012, 04:02:16 pm »
Makes no sense to me. The crashing part references the texture coordinates of the current object. I don't see any chance how this should happen on some different object... ???

Me too, I'm looking at the code for three hours and without any result... What exactly do the code in GLRenderer class on 2319 line? For what is the array operation?

I used for ex. this method to create the object
Code: [Select]
addTriangle(new SimpleVector(), 0, 0, new SimpleVector(width, 0, 0), 1, 0, new SimpleVector(0, 0, length), 0, 1);
Have you tried without calling strip()?

I wasn't calling strip() method...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #121 on: July 21, 2012, 04:08:53 pm »
It's this:

Code: [Select]
int tt = obj.multiTex[texInd][number];

It gets the internal texture id for the polygon number at stage texInd. For stripped objects, this array can be [<something>][1], which made me think that you were using a stripped object and jPCT-AE somehow forgot about this and tried to access a higher polygon number...but if you don't strip...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Depth buffer texture
« Reply #122 on: July 21, 2012, 04:57:59 pm »
I checked whole code and strip() is nowhere. I set IRenderHook for all objects in both worlds for writing names of objects. Last displayed object has one texture layer.

This is complete log from rendering. All objects within "water 2" use one texture layer. Object named "water 2" has three texture layers.
Code: [Select]
07-21 16:50:28.884: I/jPCT-AE(4027): NEW FRAME
07-21 16:50:28.889: I/jPCT-AE(4027): Creating render buffer in depth mode!
07-21 16:50:28.919: I/jPCT-AE(4027): Render buffer created: 1
07-21 16:50:28.924: I/jPCT-AE(4027): Cylinder00_jPCT-2
07-21 16:50:28.924: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.924: I/jPCT-AE(4027): VBO created for object 'Cylinder00_jPCT-2'
07-21 16:50:28.924: I/jPCT-AE(4027): room02_jPCT19
07-21 16:50:28.924: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.924: I/jPCT-AE(4027): VBO created for object 'room02_jPCT19'
07-21 16:50:28.929: I/jPCT-AE(4027): pipe01_jPCT9
07-21 16:50:28.929: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.929: I/jPCT-AE(4027): VBO created for object 'pipe01_jPCT9'
07-21 16:50:28.929: I/jPCT-AE(4027): room01_jPCT8
07-21 16:50:28.929: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.929: I/jPCT-AE(4027): VBO created for object 'room01_jPCT8'
07-21 16:50:28.929: I/jPCT-AE(4027): Unbinding buffers (1)!
07-21 16:50:28.929: I/jPCT-AE(4027): Using vm based buffer copies!
07-21 16:50:28.929: I/jPCT-AE(4027): Checking for triangle strip...
07-21 16:50:28.929: I/jPCT-AE(4027): Not a triangle strip at position 1!
07-21 16:50:28.929: I/jPCT-AE(4027): Remapping 4 vertex indices!
07-21 16:50:28.929: I/jPCT-AE(4027): Creating vertex cache (96 bytes)!
07-21 16:50:28.929: I/jPCT-AE(4027): Vertex indices will be accessed directly!
07-21 16:50:28.934: I/jPCT-AE(4027): Subobject of object 202/__overlay plane 0__ compiled to indexed fixed point data using 6/6 vertices in 1ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Processing and uploading vertices of subobject of object 202/__overlay plane 0__ took 1ms
07-21 16:50:28.934: I/jPCT-AE(4027): Object 202/__overlay plane 0__ compiled to 1 subobjects in 1ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Checking for triangle strip...
07-21 16:50:28.934: I/jPCT-AE(4027): Not a triangle strip at position 1!
07-21 16:50:28.934: I/jPCT-AE(4027): Remapping 4 vertex indices!
07-21 16:50:28.934: I/jPCT-AE(4027): Creating vertex cache (96 bytes)!
07-21 16:50:28.934: I/jPCT-AE(4027): Vertex indices will be accessed directly!
07-21 16:50:28.934: I/jPCT-AE(4027): Subobject of object 205/__overlay plane 1__ compiled to indexed fixed point data using 6/6 vertices in 1ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Processing and uploading vertices of subobject of object 205/__overlay plane 1__ took 1ms
07-21 16:50:28.934: I/jPCT-AE(4027): Object 205/__overlay plane 1__ compiled to 1 subobjects in 1ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Checking for triangle strip...
07-21 16:50:28.934: I/jPCT-AE(4027): Not a triangle strip at position 1!
07-21 16:50:28.934: I/jPCT-AE(4027): Subobject of object 255/water 2 compiled to indexed fixed point data using 6/4 vertices in 0ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Processing and uploading vertices of subobject of object 255/water 2 took 1ms
07-21 16:50:28.934: I/jPCT-AE(4027): Object 255/water 2 compiled to 1 subobjects in 1ms!
07-21 16:50:28.934: I/jPCT-AE(4027): Processing and uploading vertices of subobject of object 205/__overlay plane 1__ took 0ms
07-21 16:50:28.934: I/jPCT-AE(4027): Compiling shader program!
07-21 16:50:28.939: I/jPCT-AE(4027): Handles of 27: 0/0
07-21 16:50:28.939: I/jPCT-AE(4027): __overlay plane 1__
07-21 16:50:28.939: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.939: I/jPCT-AE(4027): VBO created for object '__overlay plane 1__'
07-21 16:50:28.939: I/jPCT-AE(4027): Compiling shader program!
07-21 16:50:28.944: I/jPCT-AE(4027): Handles of 30: 0/0
07-21 16:50:28.944: I/jPCT-AE(4027): water 2 <!!!!!! object with three texture layers !!!!!!
07-21 16:50:28.944: I/jPCT-AE(4027): Creating buffers...
07-21 16:50:28.944: I/jPCT-AE(4027): VBO created for object 'water 2'
07-21 16:50:28.944: I/jPCT-AE(4027): RENDERING IS DONE
07-21 16:50:28.944: I/jPCT-AE(4027): BLIT GUI
07-21 16:50:28.949: I/jPCT-AE(4027): [ 1342882228953 ] - WARNING: Texture's size is 128/64, but textures should be square for OpenGL ES2.0! This may result in a black texture!
07-21 16:50:28.949: I/jPCT-AE(4027): Allocating native memory for 128*64 texture(false/false/false/false/): 32768 bytes!
07-21 16:50:28.949: I/jPCT-AE(4027): New texture's id is: 36
07-21 16:50:28.949: I/jPCT-AE(4027): New texture uploaded: com.threed.jpct.Texture@41c55568 in thread Thread[GLThread 7517,5,main]
07-21 16:50:28.949: I/jPCT-AE(4027): FRAME IS DISPLAYED
07-21 16:50:28.949: I/jPCT-AE(4027): Polygons checked: 154
07-21 16:50:28.949: I/jPCT-AE(4027): NEW FRAME
07-21 16:50:28.954: I/jPCT-AE(4027): Binding buffers (1/1)!
07-21 16:50:28.954: I/jPCT-AE(4027): Cylinder00_jPCT-2
07-21 16:50:28.959: I/jPCT-AE(4027): room02_jPCT19
07-21 16:50:28.959: I/jPCT-AE(4027): pipe01_jPCT9
07-21 16:50:28.959: I/jPCT-AE(4027): Drawing thread terminated!
07-21 16:50:28.964: I/jPCT-AE(4027): [ 1342882228968 ] - ERROR: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
07-21 16:50:28.964: I/jPCT-AE(4027): at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2319)
07-21 16:50:28.964: I/jPCT-AE(4027): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2226)
07-21 16:50:28.964: I/jPCT-AE(4027): at com.threed.jpct.World.draw(World.java:1319)
07-21 16:50:28.964: I/jPCT-AE(4027): at com.threed.jpct.World.draw(World.java:1081)
07-21 16:50:28.964: I/jPCT-AE(4027): at cz.chladek.mygame.post_effects.PostEffectsHelper.renderScene(PostEffectsHelper.java:150)
07-21 16:50:28.964: I/jPCT-AE(4027): at cz.chladek.mygame.AppActivity$MyRenderer.onDrawFrame(AppActivity.java:566)
07-21 16:50:28.964: I/jPCT-AE(4027): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
07-21 16:50:28.964: I/jPCT-AE(4027): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #123 on: July 21, 2012, 05:36:49 pm »
I've updated the beta-jar with a version that catches the exception and prints out some debug info. Please run it and post the debug output.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Depth buffer texture
« Reply #124 on: July 21, 2012, 05:47:04 pm »
Is it what you want? What does it mean? This object has one texture layer.
Code: [Select]
07-21 17:42:30.104: I/jPCT-AE(4981): [ 1342885350109 ] - WARNING: Debug: 3/2/4 - 1/0 - room01_jPCT8/220 - com.threed.jpct.World@418a79c8

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #125 on: July 21, 2012, 06:00:11 pm »
That output means:

Currently, 3 texture stages are active (that seems reasonable, because you have rendered an object with 3 stages before). 4 is max (as reported by the driver) and the object uses 2...the rest doesn't help here. The code expects each object that use multi-texturing to have the maximum number of stages (4 in this case) even if they aren't used. This doesn't seem to be the case here...and i've no idea why, but i'll try to fix it anyway.
« Last Edit: July 21, 2012, 06:03:54 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #126 on: July 21, 2012, 06:06:27 pm »
I've updated the beta jar. Please check it out to see if that helps.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Depth buffer texture
« Reply #127 on: July 21, 2012, 06:15:03 pm »
Yes, now it is fine ;) ... How is it possible, that you didn't get this error before? (if you use 4 layers for terrain and probably one for everything else)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #128 on: July 21, 2012, 07:21:44 pm »
How is it possible, that you didn't get this error before? (if you use 4 layers for terrain and probably one for everything else)
It can only happen if you create objects using different settings for Config.maxTextureLayers. If you set it before creating any other object, it won't show up.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Depth buffer texture
« Reply #129 on: October 09, 2012, 06:29:45 pm »
I have problem with render targets performance. I have two main textures into which I render and swapping among them and one additional for depth. For ex. I want to render scene with image distortions and DOF. I render depth into "depth" texture, scene into "texture1", after is rendered image distortion into "texture2" by using "depth" and "texture1", after is rendered DOF into "texture1" by using "depth" and "texture2". If is rendered scene with DOF only - 60fps, scene with image distortion only - 60 fps, scene with DOF and distortion (all distortion objects are out off viewing frustum) - 47fps! So only one additional blitting rendered into texture takes 13 fps...

And second question. I render depth without particles, after same scene in normal way. Javadoc says, here is done all transforms, so it is same for both rendering. Is possible to modify FrameBuffer.renderScene(...), to I could skip second renderScene(...) method?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Depth buffer texture
« Reply #130 on: October 09, 2012, 08:31:38 pm »
The issue that caused jPCT-AE to slow down when using multiple render targets is long gone...i don't see any reason inside the engine for this. IMHO, your "calculations" are misleading...60fps is the device cap anyway, so if you, for example, can render each pass in 10ms, each will be able to output 100fps, i.e. 60fps with the cap. Both combined will take 20ms, i.e. you'll get 50fps as a result. I don't see the actual issue here... ???

About the second question: Please elaborate a bit more on this...i don't get what "skip second renderScene()" means in this context!?