본문 바로가기

Material, BluePrint/Material

UNITY - vertex anim

 

버텍스 쉐이더 애니

 

 

 

Shader "Custom/VertexAni"
{
  Properties
  {
   _mColor("Main color", Color)=(0.5,0.5,0.5,1)
   _Strong ("strong",range(0.05,10.0) ) = 2.0
   _Speed ("speed",range(1,10.0) ) = 1.0
   _Wave ("wave",range(0.002,0.02) ) = 0.002
  }

  SubShader 
  {
     Tags { "RenderType"="Opaque" }

      Pass
      {
         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
         #include "UnityCG.cginc"

         float _Strong;
         float _Speed;
         float _Wave;
         float4 _mColor;

        struct vI
        {
         float4 mPosition : POSITION;
         float4 mColor : COLOR;
        };


        struct vO
        {
         float4 mPosition : POSITION;
         float4 mColor : COLOR;
        };



       vO vert(vI i)
       {
        vO o;
        o.mPosition=mul(_Object2World,i.mPosition);
        //sin(@)= -1~ 1
        // ( sin( (@*Y포지션의 높이값으로 Wave조절)*Speed) *Strong )
        // Strong의 값으로 전체의 높낮이를 조정
        // @의 값으로 전체 파이의 길이를 조정
        //다시 한번 전체 @의 값을 Speed로 조정.
        o.mPosition.x+=( sin( (_Time[3] + (o.mPosition.y * _Wave) ) *_Speed)* i.mColor.x )*_Strong;
        o.mPosition.y+=( cos( (_Time[3] + (o.mPosition.x * _Wave) ) *_Speed)* i.mColor.x )*_Strong;
        o.mPosition.z+=( cos( (_Time[2] + (o.mPosition.x * _Wave) ) *_Speed)* i.mColor.x )*_Strong;
        o.mPosition=mul(UNITY_MATRIX_VP,o.mPosition);
        o.mColor=i.mColor;
        return o;
       }
       
       
      float4 frag(vO o) : COLOR
      {
       return o.mColor*_mColor;
      }
     ENDCG
   }
 }
} 

 

'Material, BluePrint > Material' 카테고리의 다른 글

UNITY- [Triple s]  (0) 2020.05.07
UNITY- [Triple s-ProtoType]  (0) 2020.05.07
UNITY - Matcap  (0) 2020.05.07
UNITY - Outline  (0) 2020.05.07
UNITY - Lobby  (0) 2020.05.07