진행과정

  1. 알파 채널이 있는 불 이미지들(fireTest : 불 모양 / 4_2 : 불 기둥 모양)을 준비해 프로젝트에 넣는다.
    fireTest.tga
    4.00MB
    4_2.tga
    0.25MB
  2. 3D > Quad 제작
  3. 새 Standard Surface Shader 제작 및 수정
    1. //
      // >> 흘러가는 형태의 불
      //
      Shader "Custom/Fire"
      {
          Properties
          {
              _MainTex("Albedo (RGB)", 2D) = "white" {} // :: 불 모양
              _MainTex2("Albedo (RGB)", 2D) = "white" {} // :: 흘러가는 불 기둥
          }
          SubShader
          {
              Tags { "RenderType"="Transparent" "Queue"="Transparent" } // :: 투명도 적용
              LOD 200
      
              CGPROGRAM
              #pragma surface surf Standard alpha:fade // :: 투명도 적용
      
              sampler2D _MainTex;
              sampler2D _MainTex2;
      
              struct Input
              {
                  float2 uv_MainTex;
                  float2 uv_MainTex2;
              };
      
              void surf (Input IN, inout SurfaceOutputStandard o)
              {
                  fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
                  fixed4 d = tex2D (_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y)); // :: -y 위로 흘러가도록
                  // :: Emission : Light 영향을 적게
                  // :: c 텍스쳐와 d 텍스쳐를 곱해서 둘이 겹쳐져 흘러가는 것
                  o.Emission = c.rgb * d.rgb; 
                  o.Alpha = c.a * d.a; // :: 투명도
              }
              ENDCG
          }
          FallBack "Diffuse"
      }
  4. 새 Material 제작 후 Custom / Fire 쉐이더 적용
  5. 각 불 모양의 이미지를 해당 Material에 넣는다.
    1. 첫번째 Albedo : 불 모양
    2. 두번째 Albedo : 불 기둥
  6. 완성

블로그 이미지

RIsN

,