Unityな日々(Unity Geek)

Unityで可視化アプリを開発するための試行錯誤の覚書

ShaderLab:Propertiesの種類

Properties{}ブロックの中に記述するPropertyは次の種類がある。

  1. Float Range (Range):スライダで範囲指定
  2. Color(Color):RGBAの4次元配列。各値は0~1
  3. Texuture2D(2D):テクスチャ
  4. Rectangle(Rect):
  5. Cubemap(Cube):Cubemap
  6. Float(Float):不動小数点数
  7. Vector(Vector):ベクトル配列

サンプル

Properties {
    // properties for water shader
    _WaveScale ("Wave scale", Range (0.02,0.15)) = 0.07 // sliders
    _ReflDistort ("Reflection distort", Range (0,1.5)) = 0.5
    _RefrDistort ("Refraction distort", Range (0,1.5)) = 0.4
    _RefrColor ("Refraction color", Color) = (.34, .85, .92, 1) // color
    _ReflectionTex ("Environment Reflection", 2D) = "" {} // textures
    _RefractionTex ("Environment Refraction", 2D) = "" {}
    _Fresnel ("Fresnel (A) ", 2D) = "" {}
    _BumpMap ("Bumpmap (RGB) ", 2D) = "" {}
}

プロパティ名("表示名",種類) = デフォルト値

という構造はすべて同じ。

デフォルト値の指定方法はPropertyの種類によって異なる。 - Range/Float 数値 - Color/Vector 4次元配列 - 2D/Rect/Cube 空文字""、または、ビルトイン・テクスチャ名(“white”, “black”, “gray” or “bump")

テクスチャ系(2D/Rect/Cube)の {}内にはオプションを指定できる。

  • TexGen: texgenmode=テクスチャ座標を自動生成モード。ObjectLinear, EyeLinear, SphereMap, CubeReflect, CubeNormalのいずれかを指定。

  • LightmapMode:指定した場合はlightmapパラメータの影響を受ける。Renderer.lightmapIndex