www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: lawless_c on June 30, 2016, 05:45:49 pm

Title: sharing textures accross multiple object3d's
Post by: lawless_c on June 30, 2016, 05:45:49 pm
Are there any delays or locks in sending a framebuffer image to texture?

I'm trying to reuse the same texture across two object3d's , the texture is shared to both via Two texture info's

When i run this however , textureA isn't applied to objectB as it should be. Is it possible there is delay in the first render that locks  the texture? I found that if i reversed the order
i ran into the same issue but with the other object3d.


    fb.setRenderTarget(TextureA);
    objectA.setVisibility(true);
    fb.clear();
    displayWorld.renderScene(fb);
    displayWorld.draw(fb);
    fb.display();
    objectA.setVisibility(false);

    fb.setRenderTarget(TextureB);
    objectB.setVisibility(true);
    fb.clear();
    displayWorld.renderScene(fb);
    displayWorld.draw(fb);
    fb.display();
    objectB.setVisibility(false);
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on June 30, 2016, 07:53:19 pm
No, there's no delay. Which OpenGL ES version are you using? 1.x or 2.0?
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on June 30, 2016, 08:22:12 pm
yeah should be two. Set it in the manifest and  set in the config on startup.
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on June 30, 2016, 09:32:03 pm
I don't think that I fully understand what you are trying to do here. What do you mean by 'shared' in this context? You are setting texA as a render target, render objA into it, then you set texB and render objB into it. I don't see anything shared here... And what exactly is the outcome and in which way does it differ from what you actually want to get?
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on June 30, 2016, 09:58:55 pm
The result of rendering objA to to TextureA is then used by objectB rendering to textureB


        texinfo   =  new TextureInfo(TextureManager.getInstance().getTextureID("TextureA"));

        texinfo.add(TextureManager.getInstance().getTextureID("TextureB"), TextureInfo.MODE_ADD);

        objectB .setTexture(texinfo);



I'm picking up TextureA with a shader in objectB

TextureA is also used by object A, maybe that's the issue?
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on June 30, 2016, 11:28:19 pm
TextureA is also used by object A, maybe that's the issue?
Yes, most likely. You are not supposed to render into a texture that is used in the rendered scene as well.
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on July 01, 2016, 02:47:36 am
oh darn
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on July 01, 2016, 09:12:22 am
oh darn
You might get aroudn this by introducing a third texture and swap textures on the object (that's a pretty cheap operation). Try to imagine what the outcome is supposed to be if you use your render target in the same scene...it could be everything depending on how the hardware/driver deals with it... ;)
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on July 01, 2016, 04:46:02 pm
Will try that, going to have to work it out with a pen and paper.
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on July 06, 2016, 10:56:18 am
Should texture replace be enough to do this?

If I'm using a textureinfo as a texture do i have to redo those to? As they seem to rely on a retrieved texture id.
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on July 06, 2016, 12:17:40 pm
No, I actually meant to replace it on the object, not in the TextureManager.
Title: Re: sharing textures accross multiple object3d's
Post by: lawless_c on July 07, 2016, 06:36:05 pm
Hmm no look yet. I used settexture to switch the object texture something that is not being rendered to but it was ineffective.

It's always which ever process is done 2nd that ends up not working and remaining unprocessed.
Title: Re: sharing textures accross multiple object3d's
Post by: EgonOlsen on July 07, 2016, 07:18:25 pm
I'm not sure what you are doing exactly. Can you create a simple test case for me that shows your problem?