LoginSignup
6
7

More than 5 years have passed since last update.

Stage3D の ATF について

Last updated at Posted at 2013-02-15

昨日ちょっと試してみたんだけどよく分からなかったので誰か知ってたら教えてください。

疑問

png2atf -c -i texture.png -o texture.atf を実行した際にできる ATF ファイルはどうやって使うのか?

やったこと

png2atf -c -i texture.png -o texture.atf で ATF ファイルを作る。
URLLoader でバイナリファイルとして読み込む。

var data: ByteArray = urlLoader.data;
data.position = 7;
var w: int = 1 << data.readByte();
var h: int = 1 << data.readByte();
var texture: Texture = context3D.createTexture(w, h, Context3DTextureFormat.COMPRESSED, false);
texture.uploadCompressedTextureFromByteArray(data, 0);

エラーは出ないけど表示されない。
-c オプションをつけなかった場合は Context3DTextureFormat.COMPRESSED
Context3DTextureFormat.BGRA
に変更して表示できた。
FlashPlayer 11.5、11.6 で試した。

調べてみると

どうやら -c オプションをつけると ATF ファイルタイプ(バイトインデックス:6)が、3 になっているっぽい。
※ atftools にある ATF のファイルフォーマットのドキュメントには 0,1,2 までしかかいていない。

atfinfo で 見てみると ATF File Type
-c をつけたときは RAW Compressed (DXT1+ETC1+PVRTV4bpp)
-c をつけなかったときは PRGB 888
と表示されていた。
その他の違いは AS3 TextureFormatContext3DTextureFormat.COMPRESSEDContext3DTextureFormat.BGRA の違いくらい。

表示させるには

フラグメントシェーダーの AGAL の一部を書き換える。

tex ft3, v2, fs0<2d,linear>

tex ft3, v2, fs0<2d,linear,dxt1>

※ サンプラビットの 9番目に 1 を立てる。
これで表示はされた。

この使い方であってるの?

知ってる人がいたらおせーてください。

もしかしたら

まだ対応してなくてもう少ししたら Context3DTextureFormatRAW_COMPRESSED 見たいなのが追加されるのかなぁ?
ちなみに rowCompressed とかを色々入力してみたがエラーがでてダメだった。

追記

Starling - QuadBatch
ここを見るとこれでよかったみたいだ。
ちなみに Compressed Alpha の場合は dxt5 を指定する。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7