Author Topic: sharing textures accross multiple object3d's  (Read 4355 times)

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
sharing textures accross multiple object3d's
« 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);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #1 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?

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #2 on: June 30, 2016, 08:22:12 pm »
yeah should be two. Set it in the manifest and  set in the config on startup.
« Last Edit: June 30, 2016, 08:55:05 pm by lawless_c »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #3 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?

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #4 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?
« Last Edit: June 30, 2016, 10:05:55 pm by lawless_c »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #5 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.

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #6 on: July 01, 2016, 02:47:36 am »
oh darn

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #7 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... ;)

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #8 on: July 01, 2016, 04:46:02 pm »
Will try that, going to have to work it out with a pen and paper.

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #9 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #10 on: July 06, 2016, 12:17:40 pm »
No, I actually meant to replace it on the object, not in the TextureManager.

Offline lawless_c

  • int
  • **
  • Posts: 96
    • View Profile
Re: sharing textures accross multiple object3d's
« Reply #11 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: sharing textures accross multiple object3d's
« Reply #12 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?