以下の内容はhttps://nakamura001.hatenablog.com/entry/20120406/1333728063より取得しました。


(Cg)Vertexシェーダで cos の値を使ってポリゴンを移動


以下のページの兵士の顔を膨張させるサンプルコードを元に作成。

Unity - Surface Shader Examples
http://unity3d.com/support/documentation/Components/SL-SurfaceShaderExamples.html

Vertexシェーダの部分を以下の様に変更。

    void vert (inout appdata_full v) {
        v.vertex.x += _CosTime.w * 10;
    }

プログラムの全体はこちら。

Shader "test" {
  Properties {
    _MainTex ("Texture", 2D) = "white" {}
  }
  SubShader {
    Tags { "RenderType" = "Opaque" }
    CGPROGRAM
    #pragma surface surf Lambert vertex:vert
    struct Input {
        float2 uv_MainTex;
    };
    void vert (inout appdata_full v) {
        v.vertex.x += _CosTime.w * 10;
    }
    sampler2D _MainTex;
    void surf (Input IN, inout SurfaceOutput o) {
        o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
    }
    ENDCG
  } 
  Fallback "Diffuse"
}



以上の内容はhttps://nakamura001.hatenablog.com/entry/20120406/1333728063より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14