Binding Texture to Framebuffer Conundrum

Hello,
I have a LOD system that uses heightmaps generated in a shader. It works fine but I noticed, when profiling the program, that binding a texture to the framebuffer every time a height map is needed was eating up a lot of time. To solve this issue I bind the texture, let’s call it hm1, to the framebuffer at startup. Yet by doing this every time hm1 is written into again all other “hm1 textures” are changed to match the newly written into texture. If that didn’t make sense let me know. I was wondering if anyone had any ideas regarding how to solve this problem. Here is some code if it helps:

At startup:

[java]
HM1 = new Texture2D(itexSize, itexSize, Format.RGBA32F);
fbo1 = new FrameBuffer(itexSize, itexSize, 1);
fbo1.setColorTexture(HM1);
vp1.setOutputFrameBuffer(fbo1); //this is a viewport
[/java]

when a new height map is requested:

[java]

           vp1.attachScene(heightmap_quad);
	if(vp1.isEnabled()){
	heightmap_quad.updateGeometricState();
	}	
return HM1;

[/java]

Any and all help is appreciated. If I was unclear about anything please notify me.

Oh here is an image that shows the problem:

Notice how all the green quads have the same height map…

@okelly4408 said: Yet by doing this every time hm1 is written into again all other "hm1 textures" are changed to match the newly written into texture.
I guess your confusion is here. There is no other hm1 texture, there is only one. the material uses the reference to the texture. If several materials reference the same texture variable if you change the texture data all the materials will be impacted.

You need a different texture variable for each quad.

1 Like
@nehon said: I guess your confusion is here. There is no other hm1 texture, there is only one. the material uses the reference to the texture. If several materials reference the same texture variable if you change the texture data all the materials will be impacted.

You need a different texture variable for each quad.

Ah, all right. I’ll just have to sick up the performance hit.