Problem with big BitmapTexture (using AlphaMaskMethod)

Software: Away3D 4.x

Mr. T, Newbie
Posted: 19 June 2012 12:26 PM   Total Posts: 1

Hi everyone,

I’m working on a project. In this project there’s a panorama sphere with a big TextureMaterial (the bitmap has a format of 2048x1024 pixel) on it.

So far so good.

Now I have to use the AlphaMaskMethod to mask a “hole” (lets say a trinagle shape) into my panorama sphere an that mask has to be animated.

Therefore I create a normal sprite, draw my triangle, create a bitmapdata an draw my sprite into the bitmapdata which I can use for my AlphaMaskMethod. Unfortunately that (drawing an 2048x1024 bitmapdata every frame) causes a lot of performance problems, because all the bitmapdata stuff happens on the CPU. Does anybody has an idea how I can solve this problem? Is there a way to do that operations on the GPU instead (maybe width starling)? Or maybe there’s another way to create my animated AlphaMask?

Thx

   

Richard Olsson, Administrator
Posted: 20 June 2012 06:38 PM   Total Posts: 1192   [ # 1 ]

What you’re trying to do could be very easily done if you were able to transform the UV coordinates for the mask texture. However, UV coordinates are transformed on a per-sub-mesh level, so it would affect the panorama texture as well. It’s a pretty simple hack to get it working, but it does require some knowledge of AGAL. If you don’t have the knowledge to implement such a hack yourself you can consider hiring one of the core Away3D developers for just a couple of hours to sort it out, which might make sense if your project is a commercial one.

Basically, what you need to do is to create a set of UV transformation properties (potentially just offset) on AlphaMaskMethod, and apply that transformation between the texture sampling and the alpha multiplication in the shader code.

Alternatively, you can modify BasicDiffuseMethod so that the diffuse texture sampling uses the secondary UV set. Then, transforming the UVs will only affect the AlphaMaskMethod (using the primary UV set.)

Or, a similar option would be to modify DefaultRenderPass to apply UV transformation to the secondary UV set, and use the secondary UV set with the AlphaMaskMethod (using the already existing property on that method.)  Transforming the UVs would again only affect the AlphaMaskMethod in this case.

In both of the latter cases you’ll need to copy the primary UVs to the secondary UV buffer as well.

Basically, the bottom line is that there is no good way of doing this in Away3D today without modifying it or creating your own shading method as explained above. In some future version we might add separate UV transformation properties for the secondary UV buffer on SubMesh.

   

Avatar
theMightyAtom, Sr. Member
Posted: 21 June 2012 09:26 AM   Total Posts: 669   [ # 2 ]

When you say animated, do you mean a triangle shape moving over the panorama, revealing something beyond it?
I’m not entirely sure what the scenario is, but am wondering whether punching a whole in the geometry of the sphere might be an efficient GPU based alternative?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X