パスワードを忘れた? アカウント作成
10098982 journal
日記

Ab.の日記: blender2ogre に alpha_rejection 設定を追加

日記 by Ab.
blender2ogre の Ogre .scene exporter ですが、alpha_rejection 設定が無く、デフォルトの always_pass で完全に透明な pixel でも z 打っちゃって少し悲しかったので勝手に追加。
普通は material script は exporter で作らせずに手打ちで作る事を想定してるのかもしまれませんね。
と思っていたけど、調べたら本家でも昔は対応していたのに途中から機能が削除されてしまっているようで謎です。

ちなみに Ogre 用の設定は ogre dotScene exporter を組み込んでもそのままでは弄れません。
最上段のメニュー(info bar っていうのかな?)に出てくる Ogre ってチェックボックスにチェックを付けると弄れるようになります。
scene_blend の設定とか無いなぁと思っていたら exporter のソースを見たらあったのでどういう事かと思ったらそういう仕組みでした。
しかも blender RNA の仕組みによってセーブされるデータ自体も拡張され、 .blend ファイルに設定がちゃんと保存されていてびっくり。 blender すごいな!

Index: io_export_ogreDotScene.py
===================================================================
--- io_export_ogreDotScene.py    (revision 108)
+++ io_export_ogreDotScene.py    (working copy)
@@ -648,6 +648,15 @@
     description='blending operation of material to scene',
     default='one zero')

+bpy.types.Material.ogrehidden_alpha_rejection = EnumProperty(
+    items=_ogre_depth_func,
+    name='alpha rejection function',
+    description='Neither pixel, nor z, nor stencil is written If alpha rejection checking is failed. This comparison is normally greater than 0.',
+    default='greater')
+bpy.types.Material.ogrehidden_alpha_rejection_comparand = IntProperty(
+    name='alpha rejection comparand (normally 0 or 128)',
+    default=0)
+
## FAQ

_faq_ = '''
@@ -996,7 +1005,7 @@
def get_image_textures( mat ):
     r = []
     for s in mat.texture_slots:
-        if s and s.texture.type == 'IMAGE':
+        if s and s.texture and s.texture.type == 'IMAGE':
             r.append( s )
     return r

@@ -6706,6 +6715,13 @@
                 M += indent(3, 'emissive vertexcolour' )
             else:
                 M += indent(3, 'emissive %s %s %s %s' %(color.r*f, color.g*f, color.b*f, alpha) )
+
+            if mat.ogrehidden_alpha_rejection:
+                if mat.ogrehidden_alpha_rejection.startswith('always_'):
+                    M += indent(3, 'alpha_rejection %s' %(mat.ogrehidden_alpha_rejection))
+                else:
+                    M += indent(3, 'alpha_rejection %s %s' %(
+                        mat.ogrehidden_alpha_rejection, mat.ogrehidden_alpha_rejection_comparand))
             M += '\n' # pretty printing

         if mat.offset_z:
@@ -7335,6 +7351,13 @@
             row.prop(mat, "alpha")
         else:
             row.prop(mat, "use_transparency", text='Transparent')
+
+    alpha_rej_box = layout.box()
+    alpha_rej_hdr = alpha_rej_box.row()
+    alpha_rej_hdr.prop(mat, 'ogrehidden_alpha_rejection', text='Alpha Rejection')
+    alpha_rej_comp = alpha_rej_box.row()
+    alpha_rej_comp.prop(mat, 'ogrehidden_alpha_rejection_comparand', text='Comparand')
+
     if not parent:
         return # only allow on pass1 and higher

この議論は、Ab. (3793)によって ログインユーザだけとして作成されたが、今となっては 新たにコメントを付けることはできません。
typodupeerror

Stableって古いって意味だっけ? -- Debian初級

読み込み中...