Best approach for quickly updating a texture’s bitmapdata

Software: Away3D 4.x

Avatar
Baush, Sr. Member
Posted: 21 October 2012 09:35 PM   Total Posts: 135

I’m planning on making a 2D UV drawing tool that quickly updates the texture on a 3D model next to it.

Other than re-uploading the texture on the GPU like this, is there a more efficient way?

bitmapTexture.invalidateContent();
(
material as TextureMaterial).texture bitmapTexture

Any other attempts simply did not update the texture.

Thanks!

   

NAZ, Newbie
Posted: 05 April 2013 02:04 PM   Total Posts: 9   [ # 1 ]

Hey Baush!

Did you manage to fix this issue, i really need to do the same… updating the bitmapdata of a BitmapTexture from a plane on the fly… it’s not working for me any way i try.

Hope you figured it out!.

Naz

   

Avatar
Baush, Sr. Member
Posted: 05 April 2013 02:33 PM   Total Posts: 135   [ # 2 ]

Hello Naz,

The most efficient way I found was to draw on a bitmapData that is used as a bitmap texture and then invalidate the texture so it gets re-uploaded on the GPU.

1. init texture and material

texture = new BitmapData(256, 256);
material = new TextureMaterial(new BitmapTexture(texture));

2. for each draw, modify the texture bitmapData and invalidate the texture

texture.copyPixel…
material.texture.invalidateContent();

If anyone got an even more efficient way, let us know!

   

Avatar
alihm, Jr. Member
Posted: 06 April 2013 03:33 PM   Total Posts: 49   [ # 3 ]

There is a simple efficient way but it works only if you want to switch between very limited number of textures.

Have a plane for each of your textures in the scene. All invisible except one. Then when you need to switch, just copy transforms and turn visibilities on and off.

So basically textures will stay in the GPU and it makes switching between textures very efficient.

   

Avatar
Baush, Sr. Member
Posted: 06 April 2013 04:41 PM   Total Posts: 135   [ # 4 ]

Agreed, assuming the textures will only be alternated and not user-edited. I also suggest you look into the animated texture material if you only have a preset of textures to alternate.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X