ユーザ用ツール

サイト用ツール

wiki:unity:tips:080

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
最新リビジョン 両方とも次のリビジョン
wiki:unity:tips:080 [2014/11/13 09:25]
127.0.0.1 外部編集
wiki:unity:tips:080 [2015/04/16 23:21]
step
ライン 9: ライン 9:
 Unityに標準搭載のシェーダは、マテリアルの設置画面から選択できます。 Unityに標準搭載のシェーダは、マテリアルの設置画面から選択できます。
  
-ログラムからシェーダを変化させるには以下の様にします。+スクリからシェーダを入れ替えるには以下の様にします。
 <code csharp> <code csharp>
 gameObject.renderer.material.shader = Shader.Find( "​Self-Illumin/​Diffuse"​ ); gameObject.renderer.material.shader = Shader.Find( "​Self-Illumin/​Diffuse"​ );
ライン 20: ライン 20:
 しかし端末に転送するとShader.Findで返ってくる値はnullです。なぜ? しかし端末に転送するとShader.Findで返ってくる値はnullです。なぜ?
  
-これは、内臓シェーダが全てパッケージに含まれる訳ではないためです。Unityでは、ビルド時に必要なファイルをかき集めてパッケージを作成しますが、スクリプトで文字列指定されているファイルまでは流石に見ません。なので、"​Self-Illumin/​Diffuse"​シェーダは使われていないものとしてパッケージが作成されたわけです。それで、これを解決するにはどうすれば良いのか?それは冒頭にも述べた様にシェーダはマテリアルを通して実装されています。従って、シェーダ毎にマテリアルを分けてあげれば良いのです。+これは、内臓シェーダが全てパッケージに含まれる訳ではないためです。Unityでは、ビルド時に必要なファイルをかき集めてパッケージを作成しますが、スクリプトで文字列指定されているファイルまでは流石に見ません。なので、"​Self-Illumin/​Diffuse"​シェーダは使われていないものとしてパッケージが作成されたわけです。それで、これを解決するにはどうすれば良いのか?それは冒頭にも述べた様にシェーダはマテリアルを通して実装されています。従って、シェーダ用のマテリアルデータ用意してあげれば良いのです。
  
 {{:​wiki:​unity:​tips:​unity_shader_sel_2.png?​200|}} {{:​wiki:​unity:​tips:​unity_shader_sel_2.png?​200|}}
ライン 38: ライン 38:
 必要なタイミングで入れ替えます。これできちんと反映される様になりました。 必要なタイミングで入れ替えます。これできちんと反映される様になりました。
  
-ちなみに、現時点(2014/​07/​18)でUnity内臓のシェーダはこれだけあります。 + 
-<code+==== 設定からパッケージ取り込むシェーダーを設定できる ==== 
- "​Bumped Diffuse"​ +エディターで設定を行えば、シェーダーファイルをResources以下に用意する必要無いみたいです。 
- "​Bumped Specular"​ + 
- "​Decal"​ +[Edit Project Settings > Graphics]を選択します。 
- "​Diffuse"​ +{{:​wiki:​unity:​tips:​unity_always_shader.png|}} 
- "​Diffuse Detail"​ + 
- "​Parallax Diffuse"​ +ここにシェーダーファイルを設定しておけば、ビルド時に取り込まれます。 
- "​Parallax Specular"​ + 
- "​Specular"​ +[[http://blog.livedoor.jp/nanashisoft/archives/52686561.html|Unity:​ビルド時にシェーダーを必ず含める方法 : Nanashi-soft]]
- "​VertexLit"​ +
-  +
- "​FX/Flare"​ +
-  +
- "​GUI/Text Shader"​ +
-  +
- "​Mobile/Bumped Diffuse"​ +
- "​Mobile/Bumped Specular"​ +
- "​Mobile/Bumped Specular (1 Directional Light)"​ +
- "​Mobile/​Diffuse"​ +
- "​Mobile/​Particles/​Additive"​ +
- "​Mobile/​Particles/​Alpha Blended"​ +
- "​Mobile/​Particles/​Multiply"​ +
- "​Mobile/​Particles/​VertexLit Blended"​ +
- "​Mobile/​Skybox"​ +
- "​Mobile/​Unlit (Supports Lightmap +
- "​Mobile/​VertexLit (Only Directional Lights)"​ +
-  +
- "​Nature/​Terrain/​Bumped Specular"​ +
- "​Nature/​Terrain/​Diffuse"​ +
- "​Nature/​Tree Creator Bark"​ +
- "​Nature/​Tree Creator Leaves"​ +
- "​Nature/​Tree Creator Leaves Fast"​ +
- "​Nature/​Tree Soft Occlusion Bark"​ +
- "​Nature/​Tree Soft Occlusion Leaves"​ +
-  +
- "​Particles/​Additive"​ +
- "​Particles/​Additive (Soft)"​ +
- "​Particles/​Alpha Blended"​ +
- "​Particles/​Alpha Blended Premultiply"​ +
- "​Particles/​Multiply"​ +
- "​Particles/​Multiply (Double)"​ +
- "​Particles/​VertexLit Blended"​ +
- "​Particles/​~Additive-Multiply"​ +
-  +
- "​Reflective/​Bumped Diffuse"​ +
- "​Reflective/​Bumped Specular"​ +
- "​Reflective/​Bumped Unlit"​ +
- "​Reflective/​Bumped VertexLit"​ +
- "​Reflective/​Diffuse"​ +
- "​Reflective/​Parallax Diffuse"​ +
- "​Reflective/​Parallax Specular"​ +
- "​Reflective/​Specular"​ +
- "​Reflective/​VertexLit"​ +
-  +
- "​RenderFX/​Skybox"​ +
- "​RenderFX/​Skybox Cubed"​ +
-  +
- "​Self-Illumin/​Bumped Diffuse"​ +
- "​Self-Illumin/​Bumped Specular"​ +
- "​Self-Illumin/​Diffuse"​ +
- "​Self-Illumin/​Parallax Diffuse"​ +
- "​Self-Illumin/​Parallax Specular"​ +
- "​Self-Illumin/​Specular"​ +
- "​Self-Illumin/​VertexLit"​ +
-  +
- "​Sprites/​Default"​ +
- "​Sprites/​Diffuse"​ +
-  +
- "​Transparent/​Bumped Diffuse"​ +
- "​Transparent/​Bumped Specular"​ +
- "​Transparent/​Cutout/​Bumped Diffuse"​ +
- "​Transparent/​Cutout/​Bumped Specular"​ +
- "​Transparent/​Cutout/​Diffuse"​ +
- "​Transparent/​Cutout/​Soft Edge Unlit"​ +
- "​Transparent/​Cutout/​Specular"​ +
- "​Transparent/​Cutout/​VertexLit"​ +
- "​Transparent/​Diffuse"​ +
- "​Transparent/​Parallax Diffuse"​ +
- "​Transparent/​Parallax Specular"​ +
- "​Transparent/​Specular"​ +
- "​Transparent/​VertexLit"​ +
-  +
- "​Unlit/​Texture"​ +
- "​Unlit/​Transparent"​ +
- "​Unlit/​Transparent Cutout"​ +
-</​code>​+
Permalink wiki/unity/tips/080.txt · 最終更新: 2019/08/15 15:03 by step

oeffentlich