Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Raswr

#1
Support / Re: Context change
June 06, 2013, 12:20:33 AM
Quote from: EgonOlsen on June 05, 2013, 10:35:46 PM
There's actually nothing you have to do manage a context change if you don't want to. The engine should handle it by itself unless you don't remove any textures or meshes. Are you doing anything like that in onPause/onStop/...?

Ok thanks Egon, for some reason I was clearing the texture manager on OnStop() and I got confused while reading some posts about the glcontext that I didn't understand :o, I should have double-checked my code first , problem solved!


#2
Support / Context change
June 05, 2013, 09:31:42 PM
So I'm getting a crash on my app after pressing home and going back into it,

06-05 21:23:37.915: E/AndroidRuntime(28038): FATAL EXCEPTION: GLThread 43544
06-05 21:23:37.915: E/AndroidRuntime(28038): java.lang.NullPointerException
06-05 21:23:37.915: E/AndroidRuntime(28038): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2157)
06-05 21:23:37.915: E/AndroidRuntime(28038): at com.threed.jpct.World.draw(World.java:1344)
06-05 21:23:37.915: E/AndroidRuntime(28038): at com.threed.jpct.World.draw(World.java:1085)


I've been searching but haven't found what I have to do exactly to manage gl context changes. Is the solution to load all the models from the files (serialized) again? and same goes for the textures? I thought the engine would manage re-upload of vbos and textures to the gpu, but now I don't really know, the info is a bit confusing to me.



Thank you.

#3
Quote from: EgonOlsen on March 30, 2013, 08:57:21 PM
Rendering order shouldn't matter on any mobile device except Tegra, because they are all deferred renderers anyway (....except for Tegra).

Interesting I didn't know that, I come from programming desktop OpenGL so that's a good thing to know. Then, sending  the sky to render as the last object with depth test enabled wouldn't give any benefit on a phone (except the Tegra devices)?

I'll try some experiments anyway if I get time :) (both my devices are adrenos)

Thank you for the info.
#4
I'm not a fan of rendering the sky as a first object, I prefer leaving it to the last object. That it because if you draw the sky first without z test, you draw ALL the fragments of the sky, and probably many of them are going to be overwritten by other geometry, making some fragment rendering useless (and expensive if your sky uses some kind of shader).

I usually draw the sky the last with a vertex shader that does this to push the sky back into the far clipping plane, so it seems as it was in the infinity:

vec4 p=modelViewProjectionMatrix * position; //vert to eye space
gl_Position = vec4(p.x, p.y, p.w, p.w);           // replace z by w, this pushes skydome vertex back to the far plane


This way, the sky is pushed back in the far plane (no size issues) and you are rendering it in the last position with z test enabled, so probably many of the sky's fragments are ocluded by other things in your scene and it will be cheaper to render.

Hope I helped.
#5
Thanks Egon, I think I finally found good values for my mesh, by trial and error as you said, it's really really fast.

Thanks again :)

#6
Hello again  :)

I've been playing with collision detection octrees lately, they are quite interesting structures. This is going to be more of a learning thread, not a technical question. I have a big terrain (2500 triangles) and asigned a 10 depth octree to it (collision mode only). I was amazed at how fast it tests collision using sphere collision on my character. When I get close to that terrain, fps only fall from 57/58 to around 54 or 56 with such a big structure, especially on a phone!. It would be nice to know how this works a bit more (maybe not a completely jpct-ae related question, if it doesn't belong here, i'm sorry, just delete it).

I've been reading about octrees and they recursively subdivide a bigger space in the shape of 8 cubes/bounding boxes. But how can the collision detection system calculate this so fast? I mean, a 10depth octree can get really complex and testing against 8 nodes at every tree level should damage performance by a lot. I guess there are some optimizations but still, I can't believe that these sphere vs triangle collisions are calculating so fast on such a big mesh. Also, given a certain mesh, is there a method to know the optimal depth/max polys for the octree?  I would appreciate any insight on this topic, I'm really curious at how this works :o
#7
Quote from: EgonOlsen on February 06, 2013, 06:51:03 PM
Don't use drawable to store your textures. Use either raw or the assets directory. Images in drawable can get scaled at load time by Android, which is what happens here.

Wow! how didn't I know that? It never happened to me on my other phone, now I'm sure this one is upscaling the images as it has higher resolution, makes sense. Time for me to fix that, thanks :) (and sorry, this  was quite unrelated to jpct-ae)
#8
Support / Texture size crash on Android 4.2.1 (Nexus4)
February 06, 2013, 02:18:03 PM
Hi!

I recently switched to a Nexus 4 phone with Android 4.2.1 and i'm getting some weird crashes while loading textures. All my textures are square of 2 size, but I'm getting errors like these when executing Texture aux=new Texture(res.getDrawable(id),alpha); and after that activity stops

256x256 size texture:

02-06 14:05:26.487: I/jPCT-AE(17562): Loading Texture...
02-06 14:05:26.487: I/jPCT-AE(17562): [ 1360155926496 ] - ERROR: Unsupported Texture width: 341
02-06 14:05:26.487: I/jPCT-AE(17562): [ 1360155926500 ] - ERROR: java.lang.RuntimeException: [ 1360155926496 ] - ERROR: Unsupported Texture width: 341
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Logger.log(Logger.java:189)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.loadTexture(Texture.java:798)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.<init>(Texture.java:198)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.<init>(Texture.java:234)


128x128 texture:

02-06 14:09:46.624: I/jPCT-AE(18345): [ 1360156186637 ] - ERROR: Unsupported Texture width: 171
02-06 14:09:46.624: I/jPCT-AE(18345): [ 1360156186639 ] - ERROR: java.lang.RuntimeException: [ 1360156186637 ] - ERROR: Unsupported Texture width: 171
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Logger.log(Logger.java:189)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.loadTexture(Texture.java:798)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.<init>(Texture.java:198)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.<init>(Texture.java:234)


Some more info that appears on my logcat

02-06 14:15:53.186: I/jPCT-AE(18762): GL20 render pipeline initialized!
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL vendor:     Qualcomm
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL renderer:   Adreno (TM) 320
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL version:    OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL renderer initialized (using 2 texture stages)



Last time I tested my app on my Samsung Galaxy S plus it worked fine, now a relative has that phone so i can't test it again in it until tonight! Any ideas?

Thanks :)
#9
As far as I know, jpct-ae uses compiled objects only. For what I read on the wiki it sounds as a relationship between compiling and using VBO's, as it's something that makes rendering of high poly stuff faster and i guess strip is removing from memory the original vertex data you read from the model file, but you would also need that data for animation purposes.

I might be completely wrong here so just wait for an official answer  ;)
#10
Support / Re: Changing an Object3D model
January 18, 2013, 05:44:37 PM
Quote from: EgonOlsen on January 17, 2013, 07:37:26 AM
You don't have to make the Object3D implement the collision listener. You can simply make it its own class.

It should be save to add/remove objects based on the events because they should be triggered after iterating over the world's objects when checking for a collision. However, i'm not convinced that this is needed. Do you really need new texture coordinates for this? Couldn't you get away with just setting a new texture? In that case, you could reuse the Object3D. Another option might be make the broken object a child of the normal one and just toggle visibilities of both depending on their states...i'm not sure if that works well, but it might be worth a try.

Thanks Egon, unless I'm missing something, replacing the texture wouldn't work because both models (original and replacement) are different. The replacement is a broken version of the original, so it has less vertices but it uses the same texture (and the same texture coordinates for the vertices that "survived the crash"). This broken model is just the original one modified in Blender (some vertices got removed, others just got translated or rotated, uv mapping didn't change, but i think removing those verts makes the object completely different internally).

I'm going to give the child idea a try, I think it would probably work well and I guess it wouldn't be a big overhead, as i'll be cloning the pre-loaded model for them to use the same mesh.

Edit: Child idea is working like a charm, thanks!
#11
Support / Replacing an Object3D model
January 16, 2013, 07:53:22 PM
Here I come with a new question!  :P

I have a class that extends Object3D and implements a collision listener. I want to do the following: when the player crashes against this object3D, it must replace the 3D model it's showing, to represent a broken object. I only want the model+texture coordinates to change, I want to keep the texture file it's using, position, rotation, shader, etc. (as it's the same 3D model but broken down)

This object3D extension implements the listener collision(CollisionEvent arg0). Is it possible to change the model of this Object3D from that method? setMesh doesn't seem to do the trick and I read on another post that it doesn't pass texture coordinates so my only option would be to create a new Object3D cloning the one in my model pool, remove the old one from the World and insert the new one, but this collision listener function is inside the Object3D I would have to remove so i'm a bit confused on how to do this.

If there's no other way I'll have to manually set a boolean on this object and make an external class (world) check it and replace this object. But I prefer to ask here before doing those things! :)

Any help would be appreciated  ;)

#12
Support / Re: Help with setUniform
January 09, 2013, 03:40:34 PM
Quote from: Thomas. on January 09, 2013, 03:26:47 PM
Texture coordinates are from 0 to 1, maybe you want something like this?


public class myShaderManager{
public static float timer = 0;
static GLSLShader myShader;

    public static void update()
    {
        timer += 0.01f;
        if (timer > 1)
           timer = 0;
        myShader.setUniform("timer", timer);
    }
}



That was it! Sometimes I feel stupid :D, in the other version I had that timer multiplied by 0.01 before passing it and that's why it worked, and I completely ignored that in this version so i was just adding 1 to the texcoord leaving it in the same position  :-[ Thanks a lot!
#13
Support / Help with setUniform
January 09, 2013, 03:03:36 PM
Hi!

I'm trying to make a fragment shader that displaces 2 textures (normal maps) on one of its coordinates using a uniform timer. I have a small static class that manages this with an update method called on each frame that increases the timer. The shader is linked to an object3D and works well except that the textures don't get displaced, as if the uniform timer didn't get updated.

This is a simplified version of what my java class does to the shader:

public class myShaderManager{
public static int timer=0;
static GLSLShader myShader;

    public static void update()
    {
        timer=timer+1;
        myShader.setUniform("timer", (float)timer);
    }
}


Am I doing the set uniform part wrong?. For some reason I'm using the exact same shader on another project (openGLES2 only, shaders only differ in naming) and it works well so i'm getting a bit confused and just decided to ask here as I've learned a lot of things in these forums  :)  I can also provide some shader code if needed.