<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>파티클 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%ed%8c%8c%ed%8b%b0%ed%81%b4/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Wed, 30 Nov 2022 21:54:00 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>파티클 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>6 &#8211; 04 ~ 06 UV와 Time, 불 이펙트, 이미지 UV 제어 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader-uv-control-time-image/2755/</link>
					<comments>https://lycos7560.com/unity/unity_shader-uv-control-time-image/2755/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 30 Nov 2022 21:52:35 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[_Time]]></category>
		<category><![CDATA[Fire]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[UV]]></category>
		<category><![CDATA[이펙트]]></category>
		<category><![CDATA[파티클]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2755</guid>

					<description><![CDATA[<p>Unity Shager 에서 UV와 Time, image를 이용한 UV제어에 대한 간단한 정리와 코드입니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader-uv-control-time-image/2755/">6 &#8211; 04 ~ 06 UV와 Time, 불 이펙트, 이미지 UV 제어 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">6 &#8211; 04 UV와 Time</h2>



<div style="height:26px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">이번에는 UV가 자동으로 흘러가게 만들 것입니다.</p>



<p class="has-medium-font-size wp-block-paragraph">UV에 숫자를 더하면 이미지가 이동하는 것을 알고 있습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">Unity에 내장된 변수인 _Time을 이용하여 시간에 따라 이미지가 흘러가는 것처럼 보이게 만들 것입니다.</p>



<div style="height:89px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph"><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-UnityShaderVariables.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/kr/2021.3/Manual/SL-UnityShaderVariables.html</a> &lt;- 한글</p>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-UnityShaderVariables.html" target="_blank" rel="noreferrer noopener"><img fetchpriority="high" decoding="async" width="961" height="235" src="https://lycos7560.com/wp-content/uploads/image-351.png" alt="" class="wp-image-2757" srcset="https://lycos7560.com/wp-content/uploads/image-351.png 961w, https://lycos7560.com/wp-content/uploads/image-351-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-351-768x188.png 768w" sizes="(max-width: 961px) 100vw, 961px" /></a></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph"><a href="https://docs.unity3d.com/460/Documentation/Manual/SL-BuiltinValues.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/460/Documentation/Manual/SL-BuiltinValues.html</a>  &lt;- 영문</p>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<div style="height:44px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1519" height="836" src="https://lycos7560.com/wp-content/uploads/image-354.png" alt="" class="wp-image-2760" srcset="https://lycos7560.com/wp-content/uploads/image-354.png 1519w, https://lycos7560.com/wp-content/uploads/image-354-300x165.png 300w, https://lycos7560.com/wp-content/uploads/image-354-768x423.png 768w" sizes="(max-width: 1519px) 100vw, 1519px" /></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table is-style-regular has-medium-font-size"><table><tbody><tr><td>이름</td><td>타입</td><td>값</td></tr><tr><td>_Time</td><td>float4</td><td>씬이 열린 다음부터의 시간<br><br>(x, y, z, w)는 (t / 20, t, t * 2, t * 3) 에 대응합니다.<br><br>_Time.x는 1/20 속도&nbsp;<br><br>_Time.y는 원래의 시간<br><br>_Time.z는 2배의 속도 시간<br><br>_Time.w는 3배의 속도 시간</td></tr><tr><td>_SinTime</td><td>float4</td><td>sin 그래프의 시간입니다.<br><br>(x, y, z, w)는 (t / 8, t / 4, t / 2, t) 에 대응합니다.</td></tr><tr><td>_CosTime</td><td>float4</td><td>cos 그래프의 시간입니다.<br><br>(x, y, z, w)는 (t / 8, t / 4, t / 2, t) 에 대응합니다.</td></tr><tr><td>Unity_DeltaTime</td><td>float4</td><td>Delta Time은 지금의 프레임과 이전 시간의 프레임의 시간차이를 나타냅니다.<br><br>컴퓨터의 성능에 따라 프레임을 조작해 줄 댸 주로 사용합니다.<br><br>(x, y, z, w)는 (dt, 1/dt, smoothDt, 1/smoothDt)와 대응합니다.</td></tr></tbody></table></figure>



<div style="height:124px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">간단하게 UV에 시간을 더해봅니다.</p>



<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="707" height="363" src="https://lycos7560.com/wp-content/uploads/image-355.png" alt="" class="wp-image-2761" srcset="https://lycos7560.com/wp-content/uploads/image-355.png 707w, https://lycos7560.com/wp-content/uploads/image-355-300x154.png 300w" sizes="(max-width: 707px) 100vw, 707px" /></figure>



<div style="height:64px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="636" style="aspect-ratio: 1088 / 636;" width="1088" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_28_24_396.mp4"></video></figure>



<div style="height:88px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">이미지가 좌측 아래로 흘러가는 이유는 U/V 즉 X/Y에 동시에 _Time.y 를 더해주었기 때문입니다.</p>



<p class="has-medium-font-size wp-block-paragraph">이를 이용하여 다양한 효과를 줄 수 있습니다.</p>



<div style="height:157px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">X방향으로만 흘러가게 할 때</p>



<p class="has-medium-font-size wp-block-paragraph">(+ / &#8211; 의 조절로 방향도 전환 및 순자를 곱하여 속도 변경도 가능합니다.)</p>



<div style="height:34px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="636" style="aspect-ratio: 1088 / 636;" width="1088" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_33_26_306.mp4"></video></figure>



<div style="height:26px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="956" height="210" src="https://lycos7560.com/wp-content/uploads/image-358.png" alt="" class="wp-image-2767" srcset="https://lycos7560.com/wp-content/uploads/image-358.png 956w, https://lycos7560.com/wp-content/uploads/image-358-300x66.png 300w, https://lycos7560.com/wp-content/uploads/image-358-768x169.png 768w" sizes="(max-width: 956px) 100vw, 956px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">Y방향으로만 흘러가게 할 때</p>



<div style="height:26px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="636" style="aspect-ratio: 1088 / 636;" width="1088" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_29_48_573.mp4"></video></figure>



<div style="height:28px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="951" height="223" src="https://lycos7560.com/wp-content/uploads/image-357.png" alt="" class="wp-image-2765" srcset="https://lycos7560.com/wp-content/uploads/image-357.png 951w, https://lycos7560.com/wp-content/uploads/image-357-300x70.png 300w, https://lycos7560.com/wp-content/uploads/image-357-768x180.png 768w" sizes="(max-width: 951px) 100vw, 951px" /></figure>



<div style="height:23px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/UVTest"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {

            fixed4 c = tex2D (_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y + _Time.y));
            o.Emission = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading">6 &#8211; 05 UV를 이용한 불 이펙트 만들기</h2>



<div style="height:32px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="888" height="310" src="https://lycos7560.com/wp-content/uploads/image-359.png" alt="" class="wp-image-2768" srcset="https://lycos7560.com/wp-content/uploads/image-359.png 888w, https://lycos7560.com/wp-content/uploads/image-359-300x105.png 300w, https://lycos7560.com/wp-content/uploads/image-359-768x268.png 768w" sizes="(max-width: 888px) 100vw, 888px" /></figure>



<div style="height:41px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">알파 채널을 가지고 있는 이미지를 준비하고 텍스쳐 하나만 받는 쉐이더를 만듭니다.</p>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/fire3"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:46px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">불이라기에는 투명하지도 않고 움직이지도 않으며 빛의 영향까지 받습니다.</p>



<div style="height:41px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1029" height="478" src="https://lycos7560.com/wp-content/uploads/image-360.png" alt="" class="wp-image-2769" srcset="https://lycos7560.com/wp-content/uploads/image-360.png 1029w, https://lycos7560.com/wp-content/uploads/image-360-300x139.png 300w, https://lycos7560.com/wp-content/uploads/image-360-768x357.png 768w" sizes="(max-width: 1029px) 100vw, 1029px" /></figure>



<div style="height:35px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">우선 빛의 영향을 받지 않게 하기 위해서 o.Albedo를 o.Emission으로 변경합니다.</p>



<p class="has-medium-font-size wp-block-paragraph">이 불의 이미지는 알파 값을 가지고 있는데도 불구하고 투명해지지 않고 있습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">알파채널은 그냥 쉽게 작동하지 않고 활성화시키려면 더 근본적인 부분을 건드려야 합니다.</p>



<p class="has-medium-font-size wp-block-paragraph">알파는 실제 게임에서 일반 오브젝트와 매우 다르게 처리되며, 상당히 무거운 연산중에 하나입니다.&nbsp;</p>



<p class="has-medium-font-size wp-block-paragraph">우선 임시로 작동하도록 만듭니다.</p>



<div style="height:49px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1077" height="541" src="https://lycos7560.com/wp-content/uploads/image-361.png" alt="" class="wp-image-2770" srcset="https://lycos7560.com/wp-content/uploads/image-361.png 1077w, https://lycos7560.com/wp-content/uploads/image-361-300x151.png 300w, https://lycos7560.com/wp-content/uploads/image-361-768x386.png 768w" sizes="(max-width: 1077px) 100vw, 1077px" /></figure>



<div style="height:26px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/fire3"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard alpha:fade
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Emission = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">이제 불처럼 보이는 이미지를 만드는 데까지는 성공했습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">하지만 움직이지 않으니 그냥 정지된 불 이미지 같습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">일단 만들어 놓은 쉐이더에 새로운 이미지(알파 값을 가진)를 추가로 받을 수 있게 만들고 출력해 보겠습니다.</p>



<div style="height:41px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1085" height="946" src="https://lycos7560.com/wp-content/uploads/image-362.png" alt="" class="wp-image-2771" srcset="https://lycos7560.com/wp-content/uploads/image-362.png 1085w, https://lycos7560.com/wp-content/uploads/image-362-300x262.png 300w, https://lycos7560.com/wp-content/uploads/image-362-768x670.png 768w" sizes="(max-width: 1085px) 100vw, 1085px" /></figure>



<div style="height:36px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1086" height="876" src="https://lycos7560.com/wp-content/uploads/image-363.png" alt="" class="wp-image-2772" srcset="https://lycos7560.com/wp-content/uploads/image-363.png 1086w, https://lycos7560.com/wp-content/uploads/image-363-300x242.png 300w, https://lycos7560.com/wp-content/uploads/image-363-768x619.png 768w" sizes="(max-width: 1086px) 100vw, 1086px" /></figure>



<div style="height:35px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">추가로 이 이미지를 _Time.y를 이용하여 위쪽으로 흘러가게 만들겠습니다.</p>



<div style="height:34px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="720" style="aspect-ratio: 1232 / 720;" width="1232" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_38_15_621.mp4"></video></figure>



<div style="height:44px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1076" height="288" src="https://lycos7560.com/wp-content/uploads/image-364.png" alt="" class="wp-image-2774" srcset="https://lycos7560.com/wp-content/uploads/image-364.png 1076w, https://lycos7560.com/wp-content/uploads/image-364-300x80.png 300w, https://lycos7560.com/wp-content/uploads/image-364-768x206.png 768w" sizes="(max-width: 1076px) 100vw, 1076px" /></figure>



<div style="height:33px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">이제 완성된 두 개의 이미지를 합쳐서 완성해 보겠습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">간단히&nbsp; c 와 d의 색상값. 알파 값을 곱해줍니다.</p>



<div style="height:34px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1086" height="237" src="https://lycos7560.com/wp-content/uploads/image-365.png" alt="" class="wp-image-2775" srcset="https://lycos7560.com/wp-content/uploads/image-365.png 1086w, https://lycos7560.com/wp-content/uploads/image-365-300x65.png 300w, https://lycos7560.com/wp-content/uploads/image-365-768x168.png 768w" sizes="(max-width: 1086px) 100vw, 1086px" /></figure>



<div style="height:44px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="1168" style="aspect-ratio: 1072 / 1168;" width="1072" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_40_28_734.mp4"></video></figure>



<div style="height:53px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/fire3"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2 ("Albedo2 (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard alpha:fade
        #pragma target 3.0

        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));
            o.Emission = c.rgb * d.rgb;
            o.Alpha = c.a * d.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:55px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph">이런 방법으로 흐르는 물이나 폭포 플라스마 이펙트 등 다양한 표현이 가능합니다.</p>



<p class="wp-block-paragraph">하지만 이 방법은 매우 무거운 Standard 라이팅이 돌아가고 있고,</p>



<p class="wp-block-paragraph">뒤의 이미지와 겹쳐도 밝아지지 않는 불완전한 이펙트라고 할 수 있습니다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">6 &#8211; 06 이미지를 이용한 UV 제어</h2>



<p class="has-medium-font-size wp-block-paragraph"><br>이미지를 2장 받을 수 있으며 반투명이 동작하도록 만들어 줍니다.</p>



<p class="has-medium-font-size wp-block-paragraph">확실한 이미지를 알 수 있게 체크 무늬로 변경해줍니다.</p>



<p class="has-medium-font-size wp-block-paragraph">추가적으로 두번째 이미지를 데이터로 사용하기 위하여 위치를 바꾸어 주고 값을 더 해줍니다.</p>



<div style="height:45px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/fire3"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2 ("Albedo2 (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard alpha:fade
        #pragma target 3.0

        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, IN.uv_MainTex2);
            o.Emission = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:35px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1097" height="430" src="https://lycos7560.com/wp-content/uploads/image-366.png" alt="" class="wp-image-2777" srcset="https://lycos7560.com/wp-content/uploads/image-366.png 1097w, https://lycos7560.com/wp-content/uploads/image-366-300x118.png 300w, https://lycos7560.com/wp-content/uploads/image-366-768x301.png 768w" sizes="(max-width: 1097px) 100vw, 1097px" /></figure>



<div style="height:41px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">c 의 uv에 d.r을 더해 주었습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">d에 검은색을 넣어 주었으므로 d는 float(0, 0, 0, 1)입니다. 그리고 d.r은 0이 되어서 아무 일도 일어나지 않습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">하지만 텍스쳐를 변경한다면?</p>



<div style="height:54px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1086" height="651" src="https://lycos7560.com/wp-content/uploads/image-367.png" alt="" class="wp-image-2778" srcset="https://lycos7560.com/wp-content/uploads/image-367.png 1086w, https://lycos7560.com/wp-content/uploads/image-367-300x180.png 300w, https://lycos7560.com/wp-content/uploads/image-367-768x460.png 768w" sizes="(max-width: 1086px) 100vw, 1086px" /></figure>



<div style="height:56px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">d의 텍스쳐가 회색이라면 d.r은 0.5이므로 텍스쳐 전체 이미지의 절반 정도 이동할 것이고,</p>



<p class="has-medium-font-size wp-block-paragraph">d의 텍스쳐가 흰색이라면 d.r은 1 이므로 텍스쳐 전체 이미지만큼 이동하여 원래 이미지와 같아질 것입니다.</p>



<p class="has-medium-font-size wp-block-paragraph">그렇다면 단색이 아닌 다른 이미지를 넣으면?</p>



<div style="height:43px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="871" height="753" src="https://lycos7560.com/wp-content/uploads/image-368.png" alt="" class="wp-image-2779" srcset="https://lycos7560.com/wp-content/uploads/image-368.png 871w, https://lycos7560.com/wp-content/uploads/image-368-300x259.png 300w, https://lycos7560.com/wp-content/uploads/image-368-768x664.png 768w" sizes="(max-width: 871px) 100vw, 871px" /></figure>



<div style="height:45px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">이미지 밝기에 따라서 다르게 이동하였습니다.</p>



<p class="has-medium-font-size wp-block-paragraph">이번에는 이미지를 흐르게 해보겠습니다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Custom/fire3"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _MainTex2 ("Albedo2 (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard alpha:fade
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _MainTex2;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_MainTex2;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 d = tex2D(_MainTex2, float2(IN.uv_MainTex2.x, IN.uv_MainTex2.y - _Time.y));
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex + d.r);
            o.Emission = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="796" style="aspect-ratio: 1232 / 796;" width="1232" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_45_28_524.mp4"></video></figure>



<div style="height:33px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">그리고 불이미지로 변경합니다.</p>



<div style="height:38px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-video"><video height="796" style="aspect-ratio: 1232 / 796;" width="1232" controls src="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_45_45_504.mp4"></video></figure>



<div style="height:37px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="588" height="88" src="https://lycos7560.com/wp-content/uploads/image-369.png" alt="" class="wp-image-2782" srcset="https://lycos7560.com/wp-content/uploads/image-369.png 588w, https://lycos7560.com/wp-content/uploads/image-369-300x45.png 300w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<div style="height:33px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size wp-block-paragraph">위의 코드는 standard 쉐이더 즉, 현재 물리 기반의 라이팅이 작동되고 있다는 뜻 입니다.</p>



<p class="has-medium-font-size wp-block-paragraph">이것은 상당히 무거운 공식이며, 실제로 이 쉐이더에서는 이 물리기반 라이팅 공식이 전혀 사용되지 않음에도 불구하고</p>



<p class="has-medium-font-size wp-block-paragraph">이 공식이 구동되고 있다는 것을 의미합니다. (자원의 낭비)</p>



<p class="has-medium-font-size wp-block-paragraph">이 부분은 나중에 라이팅 연산을 배우고 난 후, 라이팅을 전혀 처리하지 않는 코드로 고치면</p>



<p class="has-medium-font-size wp-block-paragraph">실제로 부담없이 사용 할 수 있습니다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader-uv-control-time-image/2755/">6 &#8211; 04 ~ 06 UV와 Time, 불 이펙트, 이미지 UV 제어 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader-uv-control-time-image/2755/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_28_24_396.mp4" length="214639" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_33_26_306.mp4" length="172760" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_29_48_573.mp4" length="172078" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_38_15_621.mp4" length="363138" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_40_28_734.mp4" length="647436" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_45_28_524.mp4" length="1301764" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_06_45_45_504.mp4" length="450285" type="video/mp4" />

			</item>
	</channel>
</rss>
