マテリアルとライティングパラメーターは、ビルトイン頂点ライティングを制御するために使われます。頂点ライティングは、各頂点ごとに計算されている標準的な Direct3D/OpenGL のライティングモデルです。Lighting on はそれを点灯します。ライティングは Material ブロック、 ColorMaterial 、SeparateSpecular コマンドの影響を受けます。
頂点カラーリングと&ライティングは、レンダリングされたジオメトリのために計算された最初の効果です。これは、頂点レベルで動作し、テクスチャが適用される前に使用される基本の色を計算します。
トップレベルのコマンドは、固定機能ライティングを使うかどうか、および、いくつかの設定オプションを使用するかどうかを制御します。メインのセットアップは Material Block 、以下に詳細を詳述します。
Color color
オブジェクトのソリッドカラーを設定します。色は括弧内の 4 つの RGBA 値、または角カッコの中の色のプロパティ名のいずれかです。
Material {Material Block}
マテリアルブロックは、物体の材料特性を定義するために使用されます。
Lighting On | Off
マテリアルブロックで定義された設定で、任意の効果を持つようにするには、Lighting ON コマンドを使用してライティングを有効にする必要があります。ライティングがオフになっている場合は、色が Color コマンドから直接取得されます。
SeparateSpecular On | Off
このコマンドは、スペキュラーライティングがシェーダーパスの最後に追加されるので、スペキュラーライティングはテクスチャリングの影響を受けません。Lighting ON が使用されている場合にのみ効果があります。
ColorMaterial AmbientAndDiffuse | Emission
マテリアルにて設定された色の代わりに頂点ごとの色を使用します。 AmbientAndDiffuse は、マテリアルの Ambient および Diffuse 値を置き換えます。 Emission はマテリアルの Emission 値を置き換えます。
これは、マテリアルが光にどのように反応するかの設定が含まれます。これらの特性のいずれかを省略することができます。その場合には、それらは黒にデフォルト設定されます (つまり、何の効果もありません)。
Diffuse color: 広がった色構成要素。これはオブジェクトの基本色です。
Ambient color: アンビエント色要素。アンビエントライトがオブジェクトに当たる際の色で、Lighting ウィンドウ で設定されます。
Specular color: オブジェクトのスペキュラーハイライトの色です。
Shininess number: 0 と 1 の間のハイライトのシャープネス値。0 で拡散照明のようなたくさんの巨大なハイライトを得、1 で小さな斑点を得ます。
Emission color: ライトが当たっていないオブジェクトの色。
オブジェクトを照らすライトのフルカラーは、次のとおりです。
Ambient * Lighting ウィンドウの Ambient Intensity 設定 + (Light Color * Diffuse + Light Color * Specular) + Emission
式のライトの部分 (かっこ内) は、オブジェクトに当たるすべてのライトに対して繰り返されます。
大抵の場合、Diffuse と Ambient は同じ色にしておきたいでしょう( Unity の組み込みシェーダーはすべて、そうなります)。
常に純粋な赤でオブジェクトをレンダリングします。
Shader "Solid Red" {
SubShader {
Pass { Color (1,0,0,0) }
}
}
カラーオブジェクトを白、頂点ライティングを使用する基本的なシェーダー。
Shader "VertexLit White" {
SubShader {
Pass {
Material {
Diffuse (1,1,1,1)
Ambient (1,1,1,1)
}
Lighting On
}
}
}
マテリアルインスペクターに表示プロパティとしてマテリアルの色を追加した拡張バージョン。
Shader "VertexLit Simple" {
Properties {
_Color ("Main Color", COLOR) = (1,1,1,1)
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
}
Lighting On
}
}
}
そして最後に、本格的な頂点ライトシェーダー (ShaderLab: 古いテクスチャの結合 リファレンスページを参照してください)。
Shader "VertexLit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Emission ("Emmisive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.