반응형

 

버텍스 쉐이더 애니

 

 

 

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
반응형

아웃라인 쉐이더

 

 

Shader "Custom/Outline" 
{
	Properties 
	{
		_Color("Main color", Color)=(0.5,0.5,0.5,1)
		_OutlineColor("OutlineColor",Color)=(0,0,0,1)
		_Outline("Outline Width",Range(0.0,0.03) ) =0.009
	}
// Blend SrcAlpha OneMinusSrcAlpha     // Alpha blending
// Blend One One                       // Additive
// Blend OneMinusDstColor One          // Soft Additive
// Blend DstColor Zero                 // Multiplicative
// Blend DstColor SrcColor             // 2x Multiplicative

  SubShader 
  {

  Tags { "RenderType"="Opaque" }
                           

	pass
	{
          Name "OUTLINE"
          CGPROGRAM
          #pragma vertex vert
          #pragma fragment frag
          #include "UnityCG.cginc"

	    uniform float _Outline;
	    uniform float4 _OutlineColor;

        struct vI
        {
          float4 mPosition : POSITION;
          float3 mNormal : NORMAL;
        };

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

        vO vert(vI i)
        {
          vO o;
          //오브젝트 공간에서 계산
          o.mPosition.xyz=i.mPosition.xyz + i.mNormal*_Outline;
          o.mPosition.w=i.mPosition.w;
          o.mPosition=mul(UNITY_MATRIX_MVP,o.mPosition);
          //투영공간에서 계산 ------------------------------------------------ iso 뷰모드에서는 라인이 안보임, perspect 뷰에서는  거리에 따라 라인두께의 변화가 심함.
          // o.mPosition=mul(UNITY_MATRIX_MVP, i.mPosition);
          // float3 norm=mul((float3x3)UNITY_MATRIX_IT_MV,i.mNormal);
          // norm.x *= UNITY_MATRIX_P[0][0];    //행렬의 y위치
          // norm.y *= UNITY_MATRIX_P[1][1]; //행렬의 y위치
          // float2 offest=TransformViewToProjection(norm.xy);     //위의 행렬위치 대신 쓸수있는것 
          // o.mPosition.xy +=offest*o.mPosition.z*_Outline; 
          o.mcolor=_OutlineColor;
            return o;
        }

        float4 frag(vO i) : COLOR
        {
            return i.mcolor;
        }

        ENDCG
        Cull front
        ZWrite off
    }

    pass
    {
          Name "BASE"
          CGPROGRAM
          #pragma vertex vert
          #pragma fragment frag
          // #include "UnityCG.cginc"
          float4 _Color;
          struct vI
        {
          float4 mPosition : POSITION;
          //float3 mNormal : NORMAL;
        };

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

        vO vert(vI i)
        {
          vO o;
          o.mPosition=mul(UNITY_MATRIX_MVP, i.mPosition);
          o.mcolor=_Color;
          return o;
        }

        float4 frag(vO i) : COLOR
        {
            return i.mcolor;
        }
        ENDCG
        Cull Back
        ZWrite on
    } 
  }

}

반응형

'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 - vertex anim  (0) 2020.05.07
UNITY - Lobby  (0) 2020.05.07
반응형

로비화면

-    물결 쉐이더.

-    애니메이션(로비중앙 오브제, 깃발제외).

-    지형 외곡.

로비 물결용 메쉬

 

 

 

 

반응형

'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 - vertex anim  (0) 2020.05.07
UNITY - Outline  (0) 2020.05.07

+ Recent posts