sharing textures accross multiple object3d's

Started by lawless_c, June 30, 2016, 05:45:49 PM

Previous topic - Next topic

lawless_c

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);

EgonOlsen

No, there's no delay. Which OpenGL ES version are you using? 1.x or 2.0?

lawless_c

#2
yeah should be two. Set it in the manifest and  set in the config on startup.

EgonOlsen

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?

lawless_c

#4
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?

EgonOlsen

Quote from: lawless_c on June 30, 2016, 09:58:55 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.


EgonOlsen

Quote from: lawless_c on July 01, 2016, 02:47:36 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... ;)

lawless_c

Will try that, going to have to work it out with a pen and paper.

lawless_c

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.

EgonOlsen

No, I actually meant to replace it on the object, not in the TextureManager.

lawless_c

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.

EgonOlsen

I'm not sure what you are doing exactly. Can you create a simple test case for me that shows your problem?