when you call setPixel32 of bitmapdata
setPixel32(x,y,argb);
the real data stored is a a/255*r a/255*g a/255*b
so you can set rgb data by this setPixel32(x,y,0xff_r_g_b),
and setPixel(x,y,rgb)==setPixel32(x,y,0xff_r_g_b)
but if i want this setPixel32(x,y,0x000f0f0f) , and use it as a texture ;
the shader will get the value 0 not 0x000f0f0f
Is there a way to store any uint value into BitmapData?
Can you post the ActionScript code that you're using to set up the image as well as the Pixelbender code that you're trying to use to read it. The alpha channel should be passed through correctly, although you need to take into account that the uint values in Flash will be converted to float values in PixelBender.
Bob
=========for bitmapdata it self================
The alpha channel can used to store no zero value. setPixel32 then getPixel32 will match
If the alpha channel is 0 , it will set all the rgb balue to 0. getPixel32()==0
=========when it upload to gpu over stage3d=========================
it will send the value after mutiply
bd.setPixel32(0, 0, 0xARGB);
the real value fetch by shader is this: A A/255*R A/255*G A/255*B
for example : i want a value argb value such as (0.5,1,1,1) in the shader
then i do this bd.setPixel32(0, 0, 0x7fffffff);
the real value fetch by shader is this: (0.5 0.5 0.5 0.5)
========================================================
There are there kinds value
val1=the parameter of setPixel32
val2=the return value of getPixel32
val3=the texture value read by shader
if(alpha!=0) val1==val2
if(alpha==0) val1!=val2 and val2==0
val3=(val1.a , val1.a/255*val1.r, val1.a/255*val1.r, val1.a/255*val1.r)/255
Am i clear?
=============================================================
package
{
import flash.display.BitmapData;
import flash.display.Sprite;
public class BitmapDataTest extends Sprite
{
public function BitmapDataTest()
{
var bd:BitmapData = new BitmapData(128, 128);
bd.setPixel32(0, 0, 0xffffffff);
var storeValue:uint = bd.getPixel32(0, 0);
trace(storeValue);//ok and also ok for shader
bd.setPixel32(0, 0, 0x1ffffff);
storeValue = bd.getPixel32(0, 0);
trace(storeValue);//ok for bitmapdata but not ok for shader
bd.setPixel32(0, 0, 0x0ffffff);
storeValue = bd.getPixel32(0, 0);
trace(storeValue);// not 0xffffff but 0
}
}
}
I think I understand what's happening, and I don't think there's a way of fixing it. As you've noticed, the alpha value affects the rgb values so it's not possible to set four entirely independent values and have them passed through. That's a legacy of Pixel Bender's roots in image processing. I'm sorry, but Ithink you're going to have to find a different way of encoding the data to pass to PB.
Bob
North America
Europe, Middle East and Africa
Asia Pacific