- 2022.03.28 Monday
- スポンサーサイト
-
一定期間更新がないため広告を表示しています
- | スポンサードリンク | - | | - | - | pookmark |
- 2015.07.08 Wednesday
- メタセコイア4.4で4枚の板ポリにマテリアルを張って合成したFBXをUnity5.0.2にインポートした際に表示上の重なり順が逆転してしまう件に関して
-
メタセコイア4.4で4枚の板ポリにマテリアルを張って合成したFBXをUnity5.0.2にインポートした際に表示上の重なり順が逆転してしまう件に関して
困っています。
FBX Review ではうまく表示されているようです。
Unity5.0.2f
では
左が合成したもの 表示順がおかしいです。
右が合成してないものです。表示順が正常です。
合成して使わないとバッチ数が減らなくて付加がかかってしまうため合成しようとしています。
今回はMetasequoia4.4で合成しましたがうまくいきませんでした。
小林 信行 先生いわく
「
トランスペアレンシー系シェーダーとZソートでのエラーの典型例ですね。
この現象を起こさないためには、オブジェクトを合成しないか、以下のページを参考に独自のシェーダーを描く必要があります。
http://tips.hecomi.com/entry/2014/03/07/005743
http://unityshader.hatenablog.com/entry/2013/12/30/040056
正直言いましてトランスペアレンシー系のシェーダーの重ね描きは、3D系のエンジンでは元々重い処理ですので、バッチ数は気にせずに、扱いやすい方法でやったほうがいいと思います。」
ということで
シェーダーを
デフォルトの中のUnit/Transparent Cutoutのシェーダーに変更したらうまく表示されました!!!
Unit/Transparent Cutoutだとちょっとジャギーがきたない
こんなのがありました!
http://docs.unity3d.com/Manual/SL-AlphaTest.html
Vegetation.shader
sorce.
Shader "Vegetation" { Properties { _Color ("Main Color", Color) = (.5, .5, .5, .5) _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5 } SubShader { // Set up basic lighting Material { Diffuse [_Color] Ambient [_Color] } Lighting On // Render both front and back facing polygons. Cull Off // first pass: // render any pixels that are more than [_Cutoff] opaque Pass { AlphaTest Greater [_Cutoff] SetTexture [_MainTex] { combine texture * primary, texture } } // Second pass: // render in the semitransparent details. Pass { // Dont write to the depth buffer ZWrite off // Don't write pixels we have already written. ZTest Less // Only render pixels less or equal to the value AlphaTest LEqual [_Cutoff] // Set up alpha blending Blend SrcAlpha OneMinusSrcAlpha SetTexture [_MainTex] { combine texture * primary, texture } } } }
Note
おしまい
上だと2回書いてしまうので
やっぱりUnlit/Transparent Cutoutに戻しました。
デフォルトのシェーダーのソースはこちら。
http://japan.unity3d.com/unity/download/archive
Unlit-AlphaTest.shader
sorce.
// Unlit alpha-cutout shader. // - no lighting // - no lightmap support // - no per-material color Shader "Unlit/Transparent Cutout" { Properties { _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } SubShader { Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} LOD 100 Lighting Off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; UNITY_FOG_COORDS(1) }; sampler2D _MainTex; float4 _MainTex_ST; fixed _Cutoff; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); UNITY_TRANSFER_FOG(o,o.vertex); return o; } fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.texcoord); clip(col.a - _Cutoff); UNITY_APPLY_FOG(i.fogCoord, col); return col; } ENDCG } } }
Note
Directional light とかライトををつけていたが 重かったので 消した
暗かったので発光させた。
Shader "Unlit/Transparent VegetationGradation" {
Properties {
_Color ("Main Color", Color) = (.5, .5, .5, .5)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_Cutoff ("Base Alpha cutoff", Range (0,.9)) = .7
}
SubShader {
// Set up basic lighting
Material {
Diffuse [_Color]
Ambient [_Color]
Emission[_Color]
}
Lighting On
// Render both front and back facing polygons.
Cull Off
// first pass:
// render any pixels that are more than [_Cutoff] opaque
Pass {
AlphaTest Greater [_Cutoff]
SetTexture [_MainTex] {
combine texture * primary, texture
}
}
// Second pass:
// render in the semitransparent details.
Pass {
// Dont write to the depth buffer
ZWrite off
// Don't write pixels we have already written.
ZTest Less
// Only render pixels less or equal to the value
AlphaTest LEqual [_Cutoff]
// Set up alpha blending
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] {
combine texture * primary, texture
}
}
}
}
。。
さらにライトの設定を完全に消したら
Shader "Unlit/Transparent VegetationGradation" {
Properties {
_Color ("Main Color", Color) = (.5, .5, .5, .5)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_Cutoff ("Base Alpha cutoff", Range (0,.9)) = .7
}
SubShader {
// Set up basic lighting
//Material {
// Diffuse [_Color]
// Ambient [_Color]
// Emission[_Color]
//}
Lighting Off
//Lighting Off
// Render both front and back facing polygons.
Cull Off
// first pass:
// render any pixels that are more than [_Cutoff] opaque
Pass {
AlphaTest Greater [_Cutoff]
SetTexture [_MainTex] {
//combine texture * primary, texture
combine texture, texture
}
}
// Second pass:
// render in the semitransparent details.
Pass {
// Dont write to the depth buffer
ZWrite off
// Don't write pixels we have already written.
ZTest Less
// Only render pixels less or equal to the value
AlphaTest LEqual [_Cutoff]
// Set up alpha blending
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] {
//combine texture * primary, texture
combine texture, texture
}
}
}
}
....... - | whaison | Metasequoia | 15:30 | comments(0) | - | pookmark |
- 2015.05.20 Wednesday
- Metasequoia4.4.3 から Maya2015へのOBJエクスポートの設定
-
Metasequoia4.4.3 から Maya2015へのOBJエクスポートの設定
UVマッピング
V方向を反転にチェックをいれる
- | whaison | Metasequoia | 12:53 | comments(0) | - | pookmark |