<?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/%EC%89%90%EC%9D%B4%EB%8D%94/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Fri, 06 Sep 2024 00:55:07 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</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>Write HLSL Shader in Unity (URP)</title>
		<link>https://lycos7560.com/unity/write-hlsl-shader-in-unity-urp_qwer/38216/</link>
					<comments>https://lycos7560.com/unity/write-hlsl-shader-in-unity-urp_qwer/38216/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 03 Sep 2024 23:59:39 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[ShaderLab]]></category>
		<category><![CDATA[URP]]></category>
		<category><![CDATA[그래픽]]></category>
		<category><![CDATA[쉐이더]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=38216</guid>

					<description><![CDATA[<p>HLSL in Unity https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html In Unity, you use the HLSL programming language to write shader programs.(Unity에서는 HLSL 프로그래밍 언어를 사용하여 셰이더를 작성합니다.) This section of the manual includes information on using HLSL in a Unity-specific way. (이 메뉴얼의 섹션은 HLSL을 Unity-specific 방식으로 사용하는 방법이 포함되어있습니다.* Unity-specific =&#62; Unity 엔진에서 HLSL을 사용하는 특수한 규칙이나 패턴을 의미,Unity는 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/unity/write-hlsl-shader-in-unity-urp_qwer/38216/">Write HLSL Shader in Unity (URP)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">HLSL in Unity</h2>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html</a></p>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-21e4a904      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							Content						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#hlsl-in-unity" class="uagb-toc-link__trigger">HLSL in Unity</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#adding-hlsl-code-to-your-shaderlab-codeshaderlab-code에-hlsl-코드-추가" class="uagb-toc-link__trigger">Adding HLSL code to your ShaderLab code(ShaderLab code에 HLSL 코드 추가)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#hlsl-syntax-hlsl-구문" class="uagb-toc-link__trigger">HLSL syntax (HLSL 구문)</a></li></ul></li><li class="uagb-toc__list"><a href="#preprocessor-directives-in-hlsl-hlsl의-전처리기-지시어" class="uagb-toc-link__trigger">Preprocessor directives in HLSL (HLSL의 전처리기 지시어)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#include-and-include-with-pragmas-directives-in-hlslhlsl의-include-및-include-with-pragmas-지시어" class="uagb-toc-link__trigger">include and include_with_pragmas directives in HLSL(HLSL의 include 및 include_with_pragmas 지시어)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#provide-information-to-the-shader-compiler-in-hlslhlsl의-shader-compiler에-정보-제공" class="uagb-toc-link__trigger">Provide information to the shader compiler in HLSL(HLSL의 shader compiler에 정보 제공)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#targeting-shader-models-and-gpu-features-in-hlslhlsl의-셰이더-모델-및-gpu-기능-타겟팅" class="uagb-toc-link__trigger">Targeting shader models and GPU features in HLSL(HLSL의 셰이더 모델 및 GPU 기능 타겟팅)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#targeting-graphics-apis-and-platforms-in-hlslhlsl에서-그래픽-api-및-플랫폼-타겟팅" class="uagb-toc-link__trigger">Targeting graphics APIs and platforms in HLSL(HLSL에서 그래픽 API 및 플랫폼 타겟팅)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#declaring-and-using-shader-keywords-in-hlslhlsl에서-쉐이더-키워드-선언-및-사용" class="uagb-toc-link__trigger">Declaring and using shader keywords in HLSL(HLSL에서 쉐이더 키워드 선언 및 사용)</a></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#shader-semantics-쉐이더-의미론" class="uagb-toc-link__trigger">Shader semantics (쉐이더 의미론)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#vertex-shader-input-semantics-정점-쉐이더-입력-의미론" class="uagb-toc-link__trigger">Vertex shader input semantics (정점 쉐이더 입력 의미론)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#fragment-shader-output-semantics-프래그먼트픽셀-쉐이더-출력-의미론" class="uagb-toc-link__trigger">Fragment shader output semantics (프래그먼트(픽셀) 쉐이더 출력 의미론)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#vertex-shader-outputs-and-fragment-shader-inputsvertex-shader-출력과-fragment-shader-입력" class="uagb-toc-link__trigger">Vertex shader outputs and fragment shader inputs(Vertex shader 출력과 fragment shader 입력)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#other-special-semantics-기타-특수-의미론" class="uagb-toc-link__trigger">Other special semantics (기타 특수 의미론)</a></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#accessing-shader-properties-in-cghlslcghlsl에서-셰이더-속성-접근" class="uagb-toc-link__trigger">Accessing shader properties in Cg/HLSL(Cg/HLSL에서 셰이더 속성 접근)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#how-property-values-are-provided-to-shaders-속성-값이-shader에-제공되는-방법" class="uagb-toc-link__trigger">How property values are provided to shaders (속성 값이 shader에 제공되는 방법)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#serialized-and-runtime-material-properties-직렬화된-머티리얼-속성과-런타임-머티리얼-속성" class="uagb-toc-link__trigger">Serialized and Runtime Material properties (직렬화된 머티리얼 속성과 런타임 머티리얼 속성)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#special-texture-properties-특수-텍스처-속성" class="uagb-toc-link__trigger">Special Texture properties (특수 텍스처 속성)</a></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#providing-vertex-data-to-vertex-programs-버텍스-프로그램에-버텍스-데이터-제공" class="uagb-toc-link__trigger">Providing vertex data to vertex programs (버텍스 프로그램에 버텍스 데이터 제공)</a><li class="uagb-toc__list"><a href="#built-in-shader-include-files" class="uagb-toc-link__trigger">Built-in shader include files</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#hlslsupportcginc" class="uagb-toc-link__trigger">HLSLSupport.cginc</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#unityshadervariablescginc" class="uagb-toc-link__trigger">UnityShaderVariables.cginc</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#unitycgcginc" class="uagb-toc-link__trigger">UnityCG.cginc</a></ul></ul></ul></ul></ul></ol>					</div>
									</div>
				</div>
			


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



<p>In Unity, you use the HLSL programming language to write shader programs.<br>(Unity에서는 HLSL 프로그래밍 언어를 사용하여 셰이더를 작성합니다.)</p>



<p>This section of the manual includes information on using HLSL in a Unity-specific way. <br>(이 메뉴얼의 섹션은 HLSL을 Unity-specific 방식으로 사용하는 방법이 포함되어있습니다.<br>* Unity-specific =&gt; Unity 엔진에서 HLSL을 사용하는 특수한 규칙이나 패턴을 의미,<br>Unity는 기본적인 HLSL 문법과 개념을 사용하지만, Shader를 작성할 때 ShaderLab 시스템과 통합하여 사용하는 방식을 채택하고 있음.<br>렌더링 파이프라인과 호환되도록 설계된 특정 구조와 방법)</p>



<p>For general information on writing HLSL, see <a href="https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl" target="_blank" rel="noreferrer noopener">Microsoft’s HLSL documentation</a>.<br>(HLSL 작성에 대한 일반적인 정보는 <a href="https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl">Microsoft의 HLSL 문서를 참조하세요.</a>)</p>



<p>Note: Unity originally used the Cg language, hence the name of some of Unity’s keywords (CGPROGRAM) and file extensions (.cginc). <br>(참고:  Unity는 원래 Cg 언어를 사용했기 때문에  Unity의 일부 키워드(CGPROGRAM)와 파일 확장자(.cginc)의 이름을 사용했습니다.)</p>



<p>Unity no longer uses Cg, but these names are still in use.<br>(유니티는 더 이상 Cg를 사용하지 않지만 이러한 이름은 여전히 사용되고 있습니다.)</p>



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



<h3 class="wp-block-heading">Adding HLSL code to your ShaderLab code<br>(ShaderLab code에 HLSL 코드 추가)</h3>



<p>You place your HLSL code inside code blocks in your&nbsp;ShaderLab code.<br>ShaderLab code 블록 안에 HLSL code를 넣습니다.</p>



<p>They usually look like this:<br>보통 아래와 같이 보입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">  Pass {
      // ... the usual pass state setup ...
      
      HLSLPROGRAM
      // compilation directives for this snippet, e.g.:
      #pragma vertex vert
      #pragma fragment frag
      
      // the shader program itself
      
      ENDHLSL

      // ... the rest of pass ...
  }</pre>



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



<p>For more information on shader code blocks, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-shaderlab-code-blocks.html">ShaderLab: adding shader programs</a>.<br>(shader code  blocks에 대한 자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-shaderlab-code-blocks.html">ShaderLab: shader 프로그램 추가</a>를 참조하세요.)</p>



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



<h3 class="wp-block-heading">HLSL syntax (HLSL 구문)</h3>



<p>HLSL has two syntaxes: a legacy DirectX 9-style syntax, and a more modern DirectX 10+ style syntax.<br>(HLSL에는 기존 DirectX 9 스타일 syntax와 최신 DirectX 10+ 스타일 syntax의 두 가지 syntax가 있습니다.)</p>



<p>The difference is mostly in how texture sampling functions work:<br>(차이점은 대부분 텍스처 샘플링 기능의 작동 방식에 있습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; The legacy syntax uses sampler2D, tex2D() and similar functions. This syntax works on all platforms.<br>(기존 구문은 sampler2D, tex2D() 및 유사한 기능을 사용합니다. 이 syntax는 모든 플랫폼에서 작동합니다.)</li>



<li>&#8211; The DX10+ syntax uses Texture2D, SamplerState and .Sample() functions.<br>(DX10+ 구문은 Texture2D, SamplerState 및 .Sample() 함수를 사용합니다.)<br>Some forms of this syntax do not work on OpenGL platforms, because textures and samplers are not different objects in OpenGL.<br>(textures와  samplers 는 OpenGL에서 서로 다른 개체가 아니기 때문에 이 syntax의 일부 형태는 OpenGL 플랫폼에서 작동하지 않습니다.)</li>
</ul>



<p>Unity provides shader libraries that contain preprocessor macros to help you manage these differences.<br>(Unity는 이러한 차이점을 관리하는 데 도움이 되는 전처리 매크로(preprocessor macros)가 포함된 shader libraries를 제공합니다.)</p>



<p>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinMacros.html" target="_blank" rel="noreferrer noopener">Built-in shader macros</a>.<br>자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinMacros.html" target="_blank" rel="noreferrer noopener">Built-in shader macros</a>를 참조하세요.</p>



<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 class="wp-block-uagb-container uagb-block-d72f70ee alignfull uagb-is-root-container">
<p></p>



<h2 class="wp-block-heading">Preprocessor directives in HLSL <br>(HLSL의 전처리기 지시어)</h2>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-preprocessor-directives.html">https://docs.unity3d.com/2023.2/Documentation/Manual/shader-preprocessor-directives.html</a></p>



<p>Internally, shader compilation has multiple stages.<br>(내부적으로 shader 컴파일에는 여러 단계가 있습니다.)</p>



<p>The first stage is <strong>preprocessing</strong>, where a program called the preprocessor prepares the code for compilation.<br>(첫 번째 단계는 <strong>전처리 단계</strong>로, 전처리라는 프로그램이 코드를 컴파일을 위해 준비합니다.)</p>



<p><strong>Preprocessor directives</strong> are instructions for the preprocessor.<br>(<strong>전처리기 지시어</strong>는 전처기기에 대한 지시 사항입니다.)</p>



<p>This section of the manual contains information on Unity-specific ways of working with HLSL preprocessor directives, and HLSL preprocessor directives that are unique to Unity. <br>(이 manual의 이 section에는 Unity-specific 방식으로 HLSL 전처리기 지시어를 사용하는 방법과 Unity에 고유한 HLSL 전처리기 지시어에 대한 정보가 포함되어 있습니다.)</p>



<p>It does not contain exhaustive documentation on all the preprocessor directives that HLSL supports, or general information on working with preprocessor directives in HLSL. <br>(HLSL이 지원하는 모든 전처리기 지시어에 대한 포괄적인 문서나 HLSL의 전처리기 지시어를 사용하는 방법에 대한 일반적인 정보는 포함되어 있지 않습니다.)</p>



<p>For that information, see the HLSL documentation: &nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-preprocessor" target="_blank" rel="noreferrer noopener">Preprocessor directives (HLSL)</a><br>(해당 정보는 HLSL 문서의 전처리기 지시어(Preprocessor directives) 섹션을 참조하세요. : &nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-preprocessor" target="_blank" rel="noreferrer noopener">Preprocessor directives (HLSL)</a>)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Page</strong></th><th class="has-text-align-left" data-align="left"><strong>Description</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-include-directives.html">include and include_with_pragmas directives in HLSL</a><br>(HLSL에서 include 및 include_with_pragmas 지시어)</td><td class="has-text-align-left" data-align="left">Working with<code>&nbsp;#include</code>&nbsp; and the Unity-specific&nbsp;<code>#include_with_pragmas</code>&nbsp;directives in HLSL in Unity.<br>(Unity에서 HLSL에서 <code>#include</code>와 Unity-specific <code>#include_with_pragmas</code> 지시어를 사용하는 방법에 대한 설명.)</td></tr><tr><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-PragmaDirectives.html">Provide information to the shader compiler in HLSL</a><br>(HLSL에서 셰이더 컴파일러에 정보 제공하기)</td><td class="has-text-align-left" data-align="left">Working with&nbsp;<code>#pragma</code>&nbsp;directives and the&nbsp;<code>#define_for_platform_compiler</code>&nbsp;directive in HLSL in Unity.<br>(Unity에서 HLSL에서 <code>#pragma</code> 지시어와 <code>#define_for_platform_compiler</code> 지시어를 사용하는 방법에 대한 설명.)</td></tr><tr><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html">Targeting shader models and GPU features in HLSL</a><br>(HLSL에서 셰이더 모델 및 GPU 기능 타겟팅하기)</td><td class="has-text-align-left" data-align="left">sing&nbsp;<code>#pragma</code>&nbsp;directives to indicate that your&nbsp;<strong>shader</strong> requires certain GPU features.<br>(셰이더가 특정 GPU 기능을 요구함을 나타내기 위해 <code>#pragma</code> 지시어를 사용하는 방법에 대한 설명.)</td></tr><tr><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html">Targeting graphics APIs and platforms in HLSL</a><br>(HLSL에서 그래픽스 API 및 플랫폼 타겟팅하기)</td><td class="has-text-align-left" data-align="left">Using&nbsp;<code>#pragma</code>&nbsp;directives to target specific graphics API and platforms.<br>(특정 그래픽스 API와 플랫폼을 타겟팅하기 위해 <code>#pragma</code> 지시어를 사용하는 방법에 대한 설명.)</td></tr><tr><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html">Declaring and using shader keywords in HLSL</a><br>HLSL에서 셰이더 키워드 선언 및 사용하기</td><td class="has-text-align-left" data-align="left">Using&nbsp;<code>#pragma</code>&nbsp;directives to declare shader keywords and&nbsp;<code>#if</code>&nbsp;directives to indicate that code depends on the state of shader keywords.<br>(셰이더 키워드를 선언하기 위해 <code>#pragma</code> 지시어를 사용하고, 셰이더 키워드의 상태에 따라 코드가 의존하는 것을 나타내기 위해 <code>#if</code> 지시어를 사용하는 방법에 대한 설명.)</td></tr></tbody></table></figure>



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



<h3 class="wp-block-heading">include and include_with_pragmas directives in HLSL<br>(HLSL의 <code>include</code> 및 <code>include_with_pragmas</code> 지시어)</h3>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-include-directives.html">https://docs.unity3d.com/2023.2/Documentation/Manual/shader-include-directives.html</a></p>



<p>In HLSL,&nbsp;<code>#include</code>&nbsp;directives are a type of&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-preprocessor-directives.html">preprocessor directive</a>.<br>(HLSL에서 <code>#include</code> 지시어는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-preprocessor-directives.html">전처리기 지시어</a>의 일종입니다.)</p>



<p>They instruct the compiler to include the contents of one HLSL file inside another.<br>(이들은 컴파일러에게 하나의 HLSL 파일의 내용을 다른 파일에 포함하도록 지시합니다.)</p>



<p>The file that they include is called an&nbsp;<strong>include file</strong>.<br>(이때 포함되는 파일을 <strong>include file</strong>이라고 합니다.)</p>



<p>In Unity, regular&nbsp;<code>#include</code>&nbsp;directives work the same as in standard HLSL.<br>(Unity에서 일반적인 <code>#include</code> 지시어는 표준 HLSL과 동일하게 작동합니다.)</p>



<p>For more information on regular&nbsp;<code>#include</code>&nbsp;directives, see the HLSL documentation:&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-include" target="_blank" rel="noreferrer noopener">include Directive</a>.<br>일반적인 <code>#include</code> 지시어에 대한 자세한 정보는 HLSL 문서의 <a href="https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-include"><code>include Directive</code>를 참조</a>하세요.</p>



<p>Unity also provides an additional, Unity-specific&nbsp;<code>#include_with_pragmas</code>&nbsp;directive.<br>(Unity는 추가적으로 Unity-specific <code>#include_with_pragmas</code> 지시어를 제공합니다.)</p>



<p>The&nbsp;<code>#include_with_pragmas</code>&nbsp;directive works the same as a regular&nbsp;<code>#include</code>&nbsp;directive, but it also allows you to use&nbsp;<code>#pragma</code>&nbsp;directives in the include file. <br>(<code>#include_with_pragmas</code> 지시어는 일반 <code>#include</code> 지시어와 동일하게 작동하지만, 포함 파일 내에서 <code>#pragma</code> 지시어를 사용할 수 있게 해줍니다.)</p>



<p>This means that the&nbsp;<code>#include_with_pragmas</code>&nbsp;directive allows you to share&nbsp;<code>#pragma</code>&nbsp;directives between multiple files.<br>(즉, <code>#include_with_pragmas</code> 지시어를 사용하면 <strong>여러 파일 간에 <code>#pragma</code> 지시어를 공유</strong>할 수 있습니다.)</p>



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



<h4 class="wp-block-heading">Using the include_with_pragmas directive<br>(<code>include_with_pragmas</code> 지시어 사용하기)</h4>



<p><strong>Note:</strong>&nbsp;To use&nbsp;<code>#include_with_pragmas</code>&nbsp;directives, you must enable the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-compilation.html#preprocessor">Caching Shader Preprocessor</a>.<br>(<strong>참고</strong>: <code>#include_with_pragmas</code> 지시어를 사용하려면 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-compilation.html#preprocessor">Caching Shader Preprocessor</a>를 활성화해야 합니다.)</p>



<p>This example demonstrates how to use the Unity-specific&nbsp;<code>#include_with_pragmas</code>&nbsp;directive to enable a common workflow improvement: the ability to toggle&nbsp;<strong>shader</strong> debugging on and off for multiple shaders, without needing to edit every shader source file every time.<br>(다음 예시는 Unity-specific <code>#include_with_pragmas</code> 지시어를 사용하여 셰이더 디버깅을 켜고 끌 수 있는 일반적인 작업 흐름 개선 방법을 보여줍니다.<br> 이를 통해 여러 셰이더의 디버깅을 설정할 때마다 매번 셰이더 소스 파일을 수정할 필요가 없습니다.)</p>



<p>The following line demonstrates the contents of the include file.<br>(다음 줄은 포함 파일의 내용을 보여줍니다.)</p>



<p>It contains a single pragma directive that enables shader debugging:<br>(이 파일에는 셰이더 디버깅을 활성화하는 단일 <code>#pragma</code> 지시어가 포함되어 있습니다:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// Comment out the following line to disable shader debugging
// (다음 줄의 주석 처리('#')를 제거하면 hader debugging이 비활성화됩니다)
#pragma enable_d3d11_debug_symbols</pre>



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



<p>In each shader that you want to debug, add an&nbsp;<code>#include_with_pragmas</code>&nbsp;directive that points to the include file.<br>(디버깅할 각 shader에 대해, 포함 파일을 가리키는 <code>#include_with_pragmas</code> 지시어를 추가하세요.)</p>



<p>Put the directive near the other&nbsp;<code>#pragma</code>&nbsp;directives, like this:<br>(이 지시어를 다른 <code>#pragma</code> 지시어들 근처에 배치합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// Example pragma directives
#pragma target 4.0 // Shader가 DirectX 11의 Shader 모델 4.0을 대상으로 한다는 것을 지정
#pragma vertex vert // vert라는 이름의 버텍스 Shader 함수를 사용하겠다고 선언
#pragma fragment frag // frag라는 이름의 프래그먼트 Shader 함수를 사용하겠다고 선언

// Replace path-to-include-file with the path to the include file 
// (지정된 경로의 포함 파일을 포함하며, 이 파일에 있는 #pragma 지시어도 함께 적용)
// (경로 "path-to-include-file"는 실제 포함 파일의 경로로 대체해야 합니다.)
#include_with_pragmas "path-to-include-file"

// The rest of the HLSL code goes here
------------------------------
#include_with_pragmas "path-to-include-file" 지시어를 사용하면, 
해당 경로에 있는 파일(path-to-include-file) 내부의 #pragma 지시어들을 여러 shader 파일에서 공유
여러 shader에서 공통으로 사용하는 #pragma 지시어를 한 곳에서 관리할 수 있게 됩니다.</pre>



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



<p>Now, when you want to toggle shader debugging on and off for all shaders that use the include file, you only need to change a single line in the include file. <br>(이제 포함 파일을 사용하는 모든 shader에 대해 shader debugging을 켜고 끄고 싶을 때, 포함 파일의 한 줄만 변경하면 됩니다.)</p>



<p>When Unity recompiles the shaders, it includes the amended line.<br>(Unity가 셰이더를 다시 컴파일할 때, 수정된 줄이 포함됩니다.)</p>



<p><strong>Note:</strong>&nbsp;If a shader file uses&nbsp;<code>#include</code>&nbsp;to import a file that contains an&nbsp;<code>#include_with_pragmas</code>&nbsp;directive, Unity ignores the&nbsp;<code>#pragma</code>&nbsp;directives in the file the&nbsp;<code>#include_with_pragmas</code>&nbsp;directive references.<br>(<strong>참고: </strong>shader 파일이 <code>#include_with_pragmas</code> 지시어를 포함하는 파일을 <code>#include</code>로 가져오는 경우, Unity는 <code>#include_with_pragmas</code> 지시어가 참조하는 파일의 <code>#pragma</code> 지시어를 무시합니다)</p>



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



<h3 class="wp-block-heading">Provide information to the shader compiler in HLSL<br>(HLSL의 shader compiler에 정보 제공)</h3>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-PragmaDirectives.html">https://docs.unity3d.com/2023.2/Documentation/Manual/SL-PragmaDirectives.html</a></p>



<p>In HLSL, you can use the following types of&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-preprocessor-directives.html">preprocessor directive</a>&nbsp;to provide information to the&nbsp;<strong>shader</strong> compiler:<br>(HLSL에서 셰이더 컴파일러에 정보를 제공하기 위해 다음과 같은 전처리 지시어를 사용할 수 있습니다 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<ul class="wp-block-list">
<li><code>#pragma</code></li>



<li><code>#define_for_platform_compiler</code></li>
</ul>



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



<h4 class="wp-block-heading">Pragma directives (Pragma 지시어)</h4>



<p><code>#pragma</code>&nbsp;directives provide additional information to the shader compiler that isn’t covered by other types of preprocessor directive.<br>(<code>#pragma</code> 지시어는 다른 종류의 전처리 지시어로는 다룰 수 없는 추가적인 정보를 Shader Compiler에 제공합니다.)</p>



<p>You can put&nbsp;<code>#pragma</code>&nbsp;directives anywhere in your HLSL code, but it is a common convention to put them at the start, like this:<br>(<code>#pragma</code> 지시어는 HLSL 코드의 어디에나 넣을 수 있지만, <strong>일반적으로 코드의 시작 부분에 배치하는 것이 관례</strong>입니다. 다음과 같이 사용할 수 있습니다:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma target 3.0 // Shader가 DirectX 9의 Shader 모델 3.0을 대상으로 한다는 것을 지정
#pragma exclude_renderers vulkan // 특정 렌더링 API에서 Shader를 제외 / Vulkan 렌더링 API를 사용할 때는 컴파일되거나 실행되지 않음
#pragma vertex vert // vert라는 이름의 버텍스 Shader 함수를 사용하겠다고 선언
#pragma fragment frag // frag라는 이름의 프래그먼트 Shader 함수를 사용하겠다고 선언

// The rest of your HLSL code goes here
// 나머지 HLSL 코드는 여기에 작성합니다</pre>



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



<h5 class="wp-block-heading">Limitations (제한 사항)</h5>



<p>There are some limitations around the use of&nbsp;<code>#pragma</code>&nbsp;directives:<br>(<code>#pragma</code> 지시어 사용에 몇 가지 제한 사항이 있습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; You can use&nbsp;<code>#pragma</code>directives inside conditional (<code>#if</code>) directives if the expression depends only on:<br>(<code>#pragma</code> 지시어는 조건부 지시어(<code>#if</code>) 내에서 사용할 수 있지만, 조건식은 다음에만 의존해야 합니다:)
<ul class="wp-block-list">
<li>Any custom&nbsp;<code>#define</code>&nbsp;directives in your own code<br>(사용자 정의 <code>#define</code> 지시어)</li>



<li>The following platform keywords :<br>(특정 플랫폼 키워드:)<br><code>SHADER_API_MOBILE</code>,&nbsp;<code>SHADER_API_DESKTOP</code>,&nbsp;<code>UNITY_NO_RGBM</code>,&nbsp;<code>UNITY_USE_NATIVE_HDR</code>,&nbsp;<code>UNITY_FRAMEBUFFER_FETCH_AVAILABLE</code>,&nbsp;<code>UNITY_NO_CUBEMAP_ARRAY</code></li>



<li>The&nbsp;<code>UNITY_VERSION</code>&nbsp;macro<br>(<code>UNITY_VERSION</code> 매크로)</li>
</ul>
</li>
</ul>



<ul class="wp-block-list">
<li>&#8211; You can only use Unity-specific&nbsp;<code>#pragma</code>&nbsp;directives in&nbsp;<code>.shader</code>&nbsp;files, and in files that you include with the&nbsp;<code>#include_with_pragmas</code>&nbsp;directive.<br>( Unity-specific <code>#pragma</code> 지시어는 <code>.shader</code> 파일과 <code>#include_with_pragmas</code> 지시어로 포함된 파일에서만 사용할 수 있습니다.)</li>



<li>Unity does not support them in files that you include with the&nbsp;<code>#include</code>&nbsp;directive; the compiler ignores them.<br>(<code>#include</code> 지시어로 포함된 파일에서는 지원되지 않으며, 컴파일러는 이를 무시합니다.)</li>



<li></li>



<li>&#8211; You can only use standard HLSL&nbsp;<code>#pragma</code>&nbsp;directives in files that you include with the&nbsp;<code>#include</code>&nbsp;directive. <br>(표준 HLSL <code>#pragma</code> 지시어는 <code>#include</code> 지시어로 포함된 파일에서만 사용할 수 있습니다.)<br>Unity does not support them in&nbsp;<code>.shader</code>&nbsp;files, or in files that you include with an&nbsp;<code>#include_with_pragmas</code>&nbsp;directive; the compiler ignores them.<br>(<code>.shader</code> 파일이나 <code>#include_with_pragmas</code> 지시어로 포함된 파일에서는 지원되지 않으며, 컴파일러는 이를 무시합니다.)</li>
</ul>



<p><strong>Note:</strong>&nbsp;If a shader file uses&nbsp;<code>#include</code>&nbsp;to import a file that contains an&nbsp;<code>#include_with_pragmas</code>&nbsp;directive, Unity ignores the&nbsp;<code>#pragma</code>&nbsp;directives in the file the&nbsp;<code>#include_with_pragmas</code>&nbsp;directive references.<br>(참고: 셰이더 파일이 <code>#include</code>를 사용하여 <code>#include_with_pragmas</code> 지시어가 포함된 파일을 가져오는 경우, <br>Unity는 <code>#include_with_pragmas</code> 지시어가 참조하는 파일의 <code>#pragma</code> 지시어를 무시합니다.<br>=&gt; <code>#include</code>로 가져온 shader 파일이 <code>#include_with_pragmas</code> 지시어를 포함하는 경우, <br>Unity는 <code>#include_with_pragmas</code> 지시어가 참조하는 파일의 <code>#pragma</code> 지시어를 무시)</p>



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



<h5 class="wp-block-heading">Standard pragma directives (표준 pragma 지시어)</h5>



<p>Unity supports all&nbsp;#pragma&nbsp;directives that are part of standard HLSL, as long as these directives are in regular include files.<br>(Unity는 표준 HLSL의 모든 <code>#pragma</code> 지시어를 지원합니다, 이 지시어들은 일반적인 포함 파일에서 사용될 수 있습니다.)</p>



<p>For more information on these directives, see the HLSL documentation:&nbsp;<a href="https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-pragma">pragma Directive.</a><br>(자세한 내용은 HLSL 문서의 <a href="https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-pragma" target="_blank" rel="noreferrer noopener"><code>pragma Directive</code>를 참조</a>하세요.)</p>



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



<h5 class="wp-block-heading">Surface Shaders (표면 셰이더)</h5>



<p>If you are writing a&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">Surface Shader</a>, use this directive to tell the compiler which function to use as the&nbsp;<strong>surface function</strong>, and pass data to that function.<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">Surface Shader</a>를 작성할 때는 다음과 같은 지시어를 사용하여 컴파일러에 <strong>surface function</strong>과 그에 필요한 데이터를 전달할 수 있습니다:)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Statement</strong></th><th class="has-text-align-left" data-align="left"><strong>Function</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>#pragma surface &lt;surface function&gt; &lt;lighting model&gt; &lt;optional parameters&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the surface shader, so that it works with the given lighting model. For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">Surface Shaders</a>.<br>(주어진 이름을 서피스 셰이더로 사용하여 주어진 조명 모델과 함께 작동하도록 함수를 컴파일합니다. 자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">Surface Shaders</a>를 참조하세요.)</td></tr></tbody></table></figure>



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



<h5 class="wp-block-heading">Shader stages (Shader 단계)</h5>



<p>If you are writing a regular graphics shader, use these directives to tell the compiler which functions to use for different shader stages.<br>(일반 graphics shader를 작성할 때는 다음 지시어를 사용하여 컴파일러에 다양한 shader 단계에 사용할 함수를 알려줍니다.)</p>



<p>The&nbsp;<code>#pragma vertex</code>&nbsp;and&nbsp;<code>#pragma fragment</code>&nbsp;directives are required, but other stages are optional.<br>(<code>#pragma vertex</code>와 <code>#pragma fragment</code> 지시어는 필수이며, 다른 단계는 선택적입니다.)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Statement</strong></th><th class="has-text-align-left" data-align="left"><strong>Function</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>#pragma vertex &lt;name&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the vertex shader. <br>(지정된 이름의 함수를 정점 셰이더로 컴파일합니다.)<br>Replace &lt;name&gt; with the function name. <br>(<code>&lt;name&gt;</code>을 함수 이름으로 교체하세요.)<br>This directive is required in regular graphics shaders.<br>(이 지시어는 일반 그래픽 셰이더에서 필수입니다.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma fragment &lt;name&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the fragment shader.<br>(지정된 이름의 함수를  fragment shader로 컴파일합니다.)<br>Replace &lt;name&gt; with the function name.<br>(<code>&lt;name&gt;</code>을 함수 이름으로 교체하세요.)<br>This directive is required in regular graphics shaders.<br>(이 지시어는 일반 graphics shaders에서 필수입니다.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma geometry &lt;name&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the geometry shader.<br>(지정된 이름의 함수를 기하학 셰이더로 컴파일합니다.)<br>Replace &lt;name&gt; with the function name. <br>(&lt;name&gt;을 함수 이름으로 교체하세요.)<br>This option automatically turns on&nbsp;<code>#pragma require geometry</code>; <br>(이 옵션은 자동으로 <code>#pragma require geometry</code>를 활성화합니다.)<br>for more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html">Targeting shader models and GPU features in HLSL</a>.<br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">HLSL의 셰이더 모델 및 GPU 기능을 참조하세요.</a>)<br><br><strong>Note</strong>: Metal does not support geometry shaders.<br>(<strong>참고</strong>: Metal[애플]은 기하학 셰이더를 지원하지 않습니다.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma hull &lt;name&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the DirectX 11 hull shader. <br>(지정된 이름의 함수를 DirectX 11 hull Shader로 컴파일합니다.)<br>Replace &lt;name&gt; with the function name. <br>(&lt;name&gt;을 함수 이름으로 교체하세요.)<br>This automatically adds&nbsp;<code>#pragma require tessellation</code>; <br>(이 옵션은 자동으로 #pragma require tessellation을 활성화합니다.)<br>for more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">Targeting shader models and GPU features in HLSL</a>.<br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html">HLSL의 셰이더 모델 및 GPU 기능</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">을</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html"> 참조하세요.</a>)<br><br>&#8211; hull Shader : shader 모델 5.0에서 도입된 기능으로, 복잡한 기하학적 세부사항을 동적으로 생성하는 데 사용<br>Hull Shader는 이 테셀레이션(<strong>일정한 형태의 도형들로 평면을 빈틈 없이 채우는 것</strong>.) <br>프로세스의 첫 번째 단계로, 입력된 기하학을 테셀레이션(세분화)할 수 있도록 정보를 제공</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma domain &lt;name&gt;</code></td><td class="has-text-align-left" data-align="left">Compile the function with the given name as the DirectX 11 domain shader. <br>(지정된 이름의 함수를 DirectX 11 Domain shader로 컴파일합니다.)<br>Replace &lt;name&gt; with the function name. <br>(&lt;name&gt;을 함수 이름으로 교체하세요.)<br>This option automatically turns on&nbsp;<code>#pragma require tessellation</code>; <br>(이 옵션은 자동으로 <code>#pragma require tessellation</code>을 활성화합니다.)<br>for more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">Targeting shader models and GPU features in HLSL</a>.<br>(자세한 내용은<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener"> HLSL의 셰이더 모델 및 GPU 기능을 참조하세요.</a>)</td></tr></tbody></table></figure>



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



<h5 class="wp-block-heading">Shader variants and keywords (Shader 변형 및 키워드)</h5>



<p>Use these directives to tell the shader compiler how to handle&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants-and-keywords.html" target="_blank" rel="noreferrer noopener">shader variants and keywords</a>.<br>(다음 지시어를 사용하여 shader  컴파일러에 shader  <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants-and-keywords.html" target="_blank" rel="noreferrer noopener">변형 및 키워드</a>를 처리하는 방법을 지시할 수 있습니다.)</p>



<p>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">Declaring and using shader keywords in HLSL</a>.<br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">HLSL의 셰이더 키워드 선언 및 사용을 참조</a>하세요.)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Directive</strong></th><th class="has-text-align-left" data-align="left"><strong>Description</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>#pragma multi_compile &lt;keywords&gt;</code></td><td class="has-text-align-left" data-align="left">Declares a collection of keywords. The compiler includes all of the keywords in the build.<br>(여러 개의 키워드를 선언합니다. 컴파일러는 모든 키워드를 포함하여 빌드를 생성합니다.)<br>You can use suffixes such as&nbsp;<code>_local</code>&nbsp;to set additional options.<br>(<code>_local</code>과 같은 접미사를 사용하여 추가 옵션을 설정할 수 있습니다.)<br>For more information and a list of supported suffixes, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">Declaring and using shader keywords in HLSL</a>.<br>(자세한 내용과 지원되는 접미사 목록은 HLSL의 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">shader 키워드 선언 및 사용을 참조</a>하세요.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma shader_feature &lt;keywords&gt;</code></td><td class="has-text-align-left" data-align="left">Declares a collection of keywords. The compiler excludes unused keywords from the build.<br>(여러 개의 키워드를 선언합니다. 컴파일러는 사용되지 않는 키워드를 빌드에서 제외합니다.)<br>You can use suffixes such as&nbsp;<code>_local</code>&nbsp;to set additional options.<br>(<code>_local</code>과 같은 접미사를 사용하여 추가 옵션을 설정할 수 있습니다.)<br>For more information and a list of supported suffixes, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">Declaring and using shader keywords in HLSL</a>.<br>(자세한 내용과 지원되는 접미사 목록은 HLSL의 shader <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">키워드 선언 및 사용을 참조</a>하세요.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma hardware_tier_variants &lt;values&gt;</code></td><td class="has-text-align-left" data-align="left"><strong>Built-in Render Pipeline</strong> only: Add keywords for&nbsp;<strong>graphics tiers</strong>&nbsp;when compiling for a given graphics API. <br>(<strong>Built-in Render Pipeline</strong>에서만 사용됩니다. 주어진 그래픽 API를 위해 <strong>graphics tiers</strong>에 대한 키워드를 추가합니다.)<br>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/graphics-tiers.html" target="_blank" rel="noreferrer noopener">Graphics tiers</a>.<br>그래픽 티어에 대한 자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/graphics-tiers.html" target="_blank" rel="noreferrer noopener">Graphics tiers를 참조</a>하세요.</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma skip_variants &lt;list of keywords&gt;</code></td><td class="has-text-align-left" data-align="left">Strip specified keywords.<br>(지정된 키워드를 생략하여 빌드에서 제거합니다.)</td></tr></tbody></table></figure>



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



<h5 class="wp-block-heading">Graphics APIs</h5>



<p>Use these directives to tell Unity to include or exclude code for a given graphics API.<br>(다음 지시어를 사용하여 Unity에 특정 그래픽 API에 대한 코드를 포함하거나 제외하도록 지시할 수 있습니다.)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Statement</strong></th><th class="has-text-align-left" data-align="left"><strong>Function</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>#pragma only_renderers &lt;value&gt;</code></td><td class="has-text-align-left" data-align="left">Compile this shader program only for given graphics APIs. <br>(이 셰이더 프로그램을 지정된 그래픽 API에 대해서만 컴파일합니다.)<br>Replace &lt;values&gt; with a space-delimited list of valid values.<br>(<code>&lt;value&gt;</code>를 유효한 값들의 공백으로 구분된 목록으로 교체하세요.)<br>For more information and a list of valid values, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener">Targeting graphics APIs and platforms in HLSL</a>.<br>(자세한 내용과 유효한 값 목록은<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener"> HLSL의 그래픽 API 및 플랫폼 타겟팅을 참조</a>하세요.)</td></tr><tr><td class="has-text-align-left" data-align="left"><code>#pragma exclude_renderers &lt;value&gt;</code></td><td class="has-text-align-left" data-align="left">Do not compile this shader program for given graphics APIs. <br>(이 셰이더 프로그램을 지정된 그래픽 API에 대해 컴파일하지 않습니다.)<br>Replace &lt;value&gt; with a space-delimited list of valid values. <br>(<code>&lt;value&gt;</code>를 유효한 값들의 공백으로 구분된 목록으로 교체하세요.)<br>For more information and a list of valid values, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener">Targeting graphics APIs and platforms in HLSL</a>.<br>(자세한 내용과 유효한 값 목록은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener">HLSL의 그래픽 API 및 플랫폼 타겟팅을 참조</a>하세요.)</td></tr></tbody></table></figure>



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



<h5 class="wp-block-heading">Other pragma directives (기타 <code>#pragma</code> 지시어)</h5>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th><strong>Statement</strong></th><th><strong>Function</strong></th></tr></thead><tbody><tr><td><code>#pragma instancing_options &lt;options&gt;</code></td><td>Enable GPU instancing in this shader, with given options. <br>(주어진 옵션을 사용하여 이 셰이더에서 GPU 인스턴싱을 활성화합니다.)<br>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/GPUInstancing.html" target="_blank" rel="noreferrer noopener">GPU instancing</a><br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/GPUInstancing.html" target="_blank" rel="noreferrer noopener">GPU instancing</a>을 참조하세요.)</td></tr><tr><td><code>#pragma once</code></td><td>Put this directive in a file to ensure that the compiler includes the file only once in a shader program.<br>(이 지시어를 파일에 추가하면 컴파일러가 해당 파일을 셰이더 프로그램에서 한 번만 포함하도록 보장합니다.)<br><strong>Note:</strong>&nbsp;Unity only supports this directive when the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-compilation.html#preprocessor" target="_blank" rel="noreferrer noopener">Caching Shader Preprocessor</a>&nbsp;is enabled.<br>(<strong>참고</strong>: Unity는 이 지시어를 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-compilation.html#preprocessor" target="_blank" rel="noreferrer noopener">Caching Shader Preprocessor</a>가 활성화된 경우에만 지원합니다.)</td></tr><tr><td><code>#pragma enable_d3d11_debug_symbols</code></td><td>Generates shader debug symbols for supported graphics APIs, and disables optimizations for all graphics APIs. <br>(지원되는 그래픽 API에 대해 셰이더 디버그 심볼을 생성하고, <strong>모든 그래픽 API에 대해 최적화를 비활성화</strong>합니다.)<br>Use this for debugging shader code in an external tool.<br>(외부 도구에서 셰이더 코드를 <strong>디버깅</strong>할 때 사용합니다.)<br>Unity generates debug symbols for Vulkan, DirectX 11 and 12, and supported console platforms.<br>(Unity는 Vulkan, DirectX 11 및 12 및 지원되는 console  platforms에 대한 debug symbols을 생성합니다.)<br><strong>Warning:</strong>&nbsp;Using this results in an increased file size and reduced shader performance. <br>(이 지시어를 사용하면 파일 크기가 증가하고 셰이더 성능이 저하될 수 있습니다.)<br>When you have finished debugging your shaders and you are ready to make a final build of your application, remove this line from your shader source code and recompile the shaders.<br>(shader 디버깅을 완료하고 application을 최종 빌드할 준비가 되면 shader 소스 코드에서 이 줄을 제거하고 shader를 다시 컴파일합니다.)</td></tr><tr><td><code>#pragma skip_optimizations &lt;value&gt;</code></td><td>Forces optimizations off for given graphics APIs. <br>(주어진 그래픽 API에 대해 최적화를 강제로 비활성화합니다.)<br>Replace &lt;values&gt; with a space-delimited list of valid values. <br>(<code>&lt;value&gt;</code>를 유효한 값들의 공백으로 구분된 목록으로 교체하세요.)<br>For a list of valid values, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener">Targeting graphics APIs and platforms in HLSL</a><br>(유효한 값 목록은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompilationAPIs.html" target="_blank" rel="noreferrer noopener">HLSL의 그래픽 API 및 플랫폼 타겟팅을 참조</a>하세요.)</td></tr><tr><td><code>#pragma hlslcc_bytecode_disassembly</code></td><td>Embed disassembled HLSLcc bytecode into a translated shader.<br>(번역된 셰이더에 disassembled HLSLcc 바이트코드를 포함합니다.)</td></tr><tr><td><code>#pragma disable_fastmath</code></td><td>Enable precise IEEE 754 rules involving NaN handling. <br>(NaN 처리와 관련된 IEEE 754 규칙을 정확히 따릅니다.)<br>This currently only affects the Metal platform.<br>(현재 Metal 플랫폼에서만 영향을 미칩니다.)</td></tr><tr><td><code>#pragma editor_sync_compilation</code></td><td>Force synchronous compilation. This affects the Unity Editor only. <br>(동기식 컴파일을 강제합니다. 이는 Unity Editor에만 영향을 미칩니다.)<br>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/AsynchronousShaderCompilation.html" target="_blank" rel="noreferrer noopener">Asynchronous Shader compilation</a>.<br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/AsynchronousShaderCompilation.html" target="_blank" rel="noreferrer noopener">Asynchronous(비동기) Shader</a> 컴파일을 참조하세요.)</td></tr><tr><td><code>#pragma enable_cbuffer</code></td><td>Emit&nbsp;<code>cbuffer(name)</code>&nbsp;when using&nbsp;<code>CBUFFER_START(name)</code>&nbsp;and&nbsp;<code>CBUFFER_END</code>&nbsp;macros from HLSLSupport even if the current platform does not support constant buffers.<br>(현재 플랫폼이 상수 버퍼를 지원하지 않더라도 <code>CBUFFER_START(name)</code> 및 <code>CBUFFER_END</code> 매크로를 사용할 때 <code>cbuffer(name)</code>을 생성합니다.)<br></td></tr></tbody></table></figure>



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



<h5 class="wp-block-heading">Use a define_for_platform_compiler directive<br>(<code>#define_for_platform_compiler</code> 지시어 사용하기)</h5>



<p>Use a&nbsp;<code>#define_for_platform_compiler</code>&nbsp;directive in your shader code to send a&nbsp;<code>#define</code>&nbsp;directive to the shader compiler.<br>(shader 코드에서 <code>#define_for_platform_compiler</code> 지시어를 사용하여 shader 컴파일러에 <code>#define</code> 지시어를 전달할 수 있습니다.)</p>



<p>For example,&nbsp;<code>#define_for_platform_compiler EXAMPLE_SYMBOL</code>&nbsp;sends a&nbsp;<code>#define EXAMPLE_SYMBOL</code>&nbsp;directive to the shader compiler that defines a symbol called&nbsp;<code>EXAMPLE_SYMBOL</code>. <br>(예를 들어, <code>#define_for_platform_compiler EXAMPLE_SYMBOL</code>은 <code>#define EXAMPLE_SYMBOL</code> 지시어를 shader 컴파일러에 전달하여 <code>EXAMPLE_SYMBOL</code>이라는 심볼을 정의합니다.)</p>



<p>Refer to external shader compiler documentation, for example&nbsp;<a href="https://learn.microsoft.com/en-us/windows/win32/direct3dtools/fxc" target="_blank" rel="noreferrer noopener">Microsoft’s documentation on the FXC compiler</a>, for more information about symbols that shader compilers use.<br>(이와 관련된 자세한 내용은 외부 셰이더 컴파일러 문서, <a href="https://learn.microsoft.com/en-us/windows/win32/direct3dtools/fxc" target="_blank" rel="noreferrer noopener">예를 들어 Microsoft의 FXC 컴파일러 문서를 참조하세요.</a>)</p>



<p>The Unity preprocessor doesn’t use symbols you define with&nbsp;<code>#define_for_platform_compiler</code>, so you can’t use the symbols in your own shader code. <br>(Unity 전처리기는 <code>#define_for_platform_compiler</code>로 정의한 심볼을 사용하지 않습니다. 따라서, 이러한 심볼을 shader 코드에서 직접 사용할 수 없습니다.)</p>



<p>For example, in the above example, if you add shader code inside an&nbsp;<code>#if (EXAMPLE_SYMBOL)</code>&nbsp;statement, the code won’t run.<br>(예를 들어, 위의 예제에서 <code>#if (EXAMPLE_SYMBOL)</code> 구문 안에 셰이더 코드를 추가하더라도 그 코드는 실행되지 않습니다.)</p>



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



<h3 class="wp-block-heading">Targeting shader models and GPU features in HLSL<br>(HLSL의 셰이더 모델 및 GPU 기능 타겟팅)</h3>



<p><a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/2022.3/Documentation/Manual/SL-ShaderCompileTargets.html</a></p>



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



<p>You can use&nbsp;<a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-PragmaDirectives.html"><code>#pragma</code>&nbsp;directives</a>&nbsp;to indicate that a&nbsp;<strong>shader</strong> requires certain GPU features.<br>(#pragma 지시어를 사용하여 Shader가 특정 GPU 기능을 필요로 한다는 것을 명시할 수 있습니다.)</p>



<p>At runtime, Unity uses this information to determine whether a shader program is compatible with the current hardware.<br>(Unity는 런타임 시 이 정보를 사용하여 Shader 프로그램이 현재 하드웨어와 호환되는지 여부를 판단합니다.)</p>



<p>You can specify individual GPU features with the&nbsp;<code>#pragma require</code>&nbsp;directive, or specify a&nbsp;<strong>shader model</strong>&nbsp;with the&nbsp;<code>#pragma target</code>&nbsp;directive.<br>(#pragma require 지시어로 개별 GPU 기능을 지정하거나, #pragma target 지시어로 Shader 모델을 지정할 수 있습니다.)</p>



<p> A shader model is a shorthand for a group of GPU features; internally, it is the same as a&nbsp;<code>#pragmarequire</code>&nbsp;directive with the same list of features.<br>(Shader 모델은 여러 GPU 기능을 하나로 묶은 단축어로, 내부적으로 동일한 기능 목록을 가진 #pragma require 지시어와 동일합니다.)</p>



<p>It is important to correctly describe the GPU features that your shader requires.<br>(Shader가 필요로 하는 GPU 기능을 정확히 기술하는 것이 중요합니다.)</p>



<p> If your shader uses features that are not included in the list of requirements, this can result in either compile time errors, or in devices failing to support shaders at runtime.<br>(Shader에서 사용한 기능이 요구 사항 목록에 포함되지 않은 경우, 컴파일 시 오류가 발생하거나 런타임 시 디바이스에서 Shader를 지원하지 못하는 상황이 발생할 수 있습니다.)</p>



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



<h4 class="wp-block-heading">Default behavior (기본 동작)</h4>



<p>By default, Unity compiles shaders with&nbsp;<code>#pragma require derivatives</code>, which corresponds to&nbsp;<code>#pragma target 2.5</code>.<br>(Unity는 기본적으로 #pragma require derivatives로 Shader를 컴파일하며, 이는 #pragma target 2.5에 해당합니다.)</p>



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



<h4 class="wp-block-heading">Special requirements for shader stages (shader 단계에 대한 특별 요구 사항)</h4>



<p>If your shader defines certain shader stages, Unity automatically adds items to the list of requirements.<br>(Shader가 특정 Shader 단계를 정의하는 경우, Unity는 자동으로 요구 사항 목록에 항목을 추가합니다.)</p>



<ul class="wp-block-list">
<li>&#8211; If a shader defines a geometry stage (with&nbsp;<code>#pragma geometry</code>), Unity automatically adds&nbsp;<code>geometry</code>&nbsp;to the list of requirements.<br>(#pragma geometry), Unity는 자동으로 요구 사항 목록에 geometry를 추가합니다.)</li>



<li>&#8211; If a shader defines a tessellation stage (with&nbsp;<code>#pragma hull</code>&nbsp;or&nbsp;<code>#pragma domain</code>), Unity automatically adds&nbsp;<code>tessellation</code>&nbsp;to the list of requirements.<br>(#pragma hull 또는 #pragma domain), Unity는 자동으로 요구 사항 목록에 tessellation을 추가합니다.)</li>
</ul>



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



<p>If the list of requirements (or the equivalent target value) does not already include these values, Unity displays a warning message when it compiles the shader, to indicate that it has added these requirements.<br>(요구 사항 목록에 이러한 값들이 이미 포함되어 있지 않다면, Unity는 Shader를 컴파일할 때 이러한 요구 사항이 추가되었음을 알리는 경고 메시지를 표시합니다.)</p>



<p>To avoid seeing this warning message, explicitly add the requirements or use an appropriate target value in your code.<br>(이 경고 메시지를 피하려면 코드에서 명시적으로 요구 사항을 추가하거나 적절한 target 값을 사용해야 합니다.)</p>



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



<h4 class="wp-block-heading">Specifying GPU features or a shader model (GPU 기능 또는 셰이더 모델 지정)</h4>



<p>To specify required features, use the&nbsp;<code>#pragma require</code>&nbsp;directive, followed by a list of space-delimited values. For example:<br>(필요한 기능을 지정하려면, #pragma require 지시어를 사용하고 공백으로 구분된 값들의 목록을 나열합니다. 예를 들어서:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma require integers mrt8

// integers: Shader에서 정수 연산을 지원하는 GPU를 요구
// 이는 정수 기반의 계산이나 비트 연산을 수행하는 Shader에서 필수

// mrt8: 최대 8개의 Multiple Render Targets (MRTs)을 지원하는 GPU를 요구
// mrt는 Shader가 한 번의 렌더 패스에서 여러 개의 렌더 타겟에 출력할 수 있도록 하는 기능</pre>



<p>You can also use the&nbsp;<code>#pragma require</code>&nbsp;directive followed by a colon and a list of space-delimited&nbsp;<a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">shader keywords</a>.<br>(#pragma require 지시어 뒤에 콜론과 공백으로 구분된 <a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">Shader 키워드</a> 목록을 추가할 수도 있습니다.)</p>



<p>This means that the requirement applies only to variants that are used when any of the given keywords are enabled. For example:<br>(이는 지정된 키워드가 활성화될 때 사용되는 변형에만 해당 요구 사항이 적용됨을 의미합니다. 예를 들어)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma require integers mrt8 : EXAMPLE_KEYWORD OTHER_EXAMPLE_KEYWORD</pre>



<p>You can use multiple&nbsp;<code>#pragma require</code>&nbsp;lines.<br>(#pragma require 지시어를 여러 줄 사용할 수 있습니다.)</p>



<p>In this example, the shader requires&nbsp;<code>integers</code>&nbsp;in all cases, and&nbsp;<code>mrt8</code>&nbsp;if EXAMPLE_KEYWORD is enabled.<br>(이 예제에서는 Shader가 모든 경우에 integers를 필요로 하며, EXAMPLE_KEYWORD가 활성화된 경우 mrt8도 필요로 합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma require integers
#pragma require integers mrt8 : EXAMPLE_KEYWORD</pre>



<p>To specify a shader model, use&nbsp;<code>#pragma target</code>&nbsp;directive. For example:<br>(Shader 모델을 지정하려면, #pragma target 지시어를 사용하십시오.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma target 4.0</pre>



<p>You can also use the&nbsp;<code>#pragma target</code>&nbsp;directive followed by a list of space-delimited&nbsp;<a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">shader keywords</a>.<br>(#pragma target 지시어 뒤에 공백으로 구분된 <a href="https://docs.unity3d.com/2022.3/Documentation/Manual/SL-MultipleProgramVariants.html" target="_blank" rel="noreferrer noopener">Shader 키워드</a> 목록을 추가할 수도 있습니다.)</p>



<p>This means that the requirement applies only to variants that are used when any of the given keywords are enabled. For example:<br>(이는 지정된 키워드가 활성화될 때 사용되는 변형에만 해당 요구 사항이 적용됨을 의미합니다. 를 들어서)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma target 4.0 EXAMPLE_KEYWORD OTHER_EXAMPLE_KEYWORD</pre>



<p><strong>Note:</strong>&nbsp;The syntax for specifying keywords for&nbsp;<code>#pragma require</code>&nbsp;and&nbsp;<code>#pragma target</code>&nbsp;is slightly different.<br>(<strong>참고</strong>: #pragma require와 #pragma target에 대한 키워드를 지정하는 문법은 약간 다릅니다.)</p>



<p>When you specify keywords for&nbsp;<code>#pragma require</code>, you use a colon.<br>(#pragma require에 키워드를 지정할 때는 콜론(:)을 사용합니다.)</p>



<p>When you specify keywords for&nbsp;<code>#pragma target</code>, you do not use a colon.<br>(#pragma target에 키워드를 지정할 때는 콜론을 사용하지 않습니다.)</p>



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



<h4 class="wp-block-heading">List of ‘#pragma target’ values (<code>#pragma target</code> 값 목록)</h4>



<p>Here is the list of shader models that Unity uses, and the combination of&nbsp;<code>#pragma require</code>&nbsp;values that each corresponds to.<br>(다음은 Unity에서 사용하는 Shader 모델 목록과 각각에 해당하는 <code>#pragma require</code> 값의 조합입니다.)</p>



<p><strong>Note:</strong>&nbsp;Unity’s shader models are similar to DirectX shader models and OpenGL version requirements, but they do not correspond exactly.<br>(<strong>참고:</strong> Unity의 Shader 모델은 DirectX Shader 모델 및 OpenGL 버전 요구 사항과 유사하지만, 정확히 일치하지는 않습니다.)</p>



<p>Read the descriptions carefully to ensure that you understand the differences.<br> (차이를 이해하려면 설명을 주의 깊게 읽으십시오.)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Value</strong></th><th class="has-text-align-left" data-align="left"><strong>Description</strong></th><th class="has-text-align-left" data-align="left"><strong>Support</strong></th><th class="has-text-align-left" data-align="left"><strong>Equivalent&nbsp;<code>#pragma require</code>&nbsp;values</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>2.0</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sm2" target="_blank" rel="noreferrer noopener">DirectX shader model 2.0</a>.<br>(DirectX Shader 모델 2.0과 동일합니다.)<br><br>Limited amount of arithmetic and texture instructions; <br>(제한된 산술 및 텍스처 명령어;)<br>8 interpolators; no vertex texture sampling; no derivatives in fragment shaders; no explicit LOD texture sampling.<br>(8개의 보간자; 버텍스 텍스처 샘플링 없음; 프래그먼트 Shader에서 미분 없음; 명시적인 LOD 텍스처 샘플링 없음.))</td><td class="has-text-align-left" data-align="left">Works on all platforms supported by Unity.<br>(Unity가 지원하는 모든 플랫폼에서 작동합니다.)</td><td class="has-text-align-left" data-align="left">N/A</td></tr><tr><td class="has-text-align-left" data-align="left"><code>2.5</code></td><td class="has-text-align-left" data-align="left">Almost the same as 3.0, but with only 8 interpolators, and no explicit LOD texture sampling.<br>(Shader 모델 3.0과 거의 동일하지만, 8개의 보간자만 사용하며 명시적인 LOD 텍스처 샘플링이 없습니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 9+<br>OpenGL 3.2+<br>OpenGL ES 2.0<br>Vulkan<br>Metal</td><td class="has-text-align-left" data-align="left"><code>derivatives</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>3.0</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sm3" target="_blank" rel="noreferrer noopener">DirectX shader model 3.0</a>.<br>(DirectX Shader 모델 3.0과 동일합니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 10 +<br>OpenGL 3.2+<br>OpenGL ES 3.0+<br>Vulkan<br>Metal<br><br>Might work on some OpenGL ES 2.0 devices, depending on driver extensions and features.<br>(드라이버 확장 및 기능에 따라 일부 OpenGL ES 2.0 디바이스에서 작동할 수 있습니다.)</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>2.5</code>, plus:<br>(2.5에 추가적으로:)<br><code>interpolators10 samplelod fragcoord</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>3.5</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://en.wikipedia.org/wiki/OpenGL_ES#OpenGL_ES_3.0" target="_blank" rel="noreferrer noopener">OpenGL ES 3.0</a>.<br>(OpenGL ES 3.0과 동일합니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 10+<br>OpenGL 3.2+<br>OpenGL ES 3+<br>Vulkan<br>Metal</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>3.0</code>, plus:<br>(3.0에 추가적으로:)<br><code>interpolators15 mrt4 integers 2darray instancing</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>4.0</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sm4" target="_blank" rel="noreferrer noopener">DirectX shader model 4.0</a>, but without the requirement to support 8 MRTs.<br>(DirectX Shader 모델 4.0과 동일하지만, 8 MRT 지원 요구 사항은 없습니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 10+<br>Desktop OpenGL 3.x<br>OpenGL ES 3.1<br>OpenGL 3.2+<br>OpenGL ES 3.1 + Android Extension Pack (AEP)<br>Vulkan<br>Metal (if no geometry stage is defined)<br>(Metal (geometry 단계가 정의되지 않은 경우))</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>3.5</code>, plus:<br>(3.5에 추가적으로:)<br><code>geometry</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>gl4.1</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://en.wikipedia.org/wiki/OpenGL#OpenGL_4.1" target="_blank" rel="noreferrer noopener">OpenGL 4.1</a><br>(OpenGL 4.1과 동일합니다.)</td><td class="has-text-align-left" data-align="left">Desktop OpenGL 4.1<br>(데스크톱 OpenGL 4.1)<br>Shader model 4.0 + tessellation to match macOS 10.9 capabilities.<br>(Shader 모델 4.0에 tessellation이 추가되어 macOS 10.9 기능과 일치합니다.)</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>4.0</code>, plus:<br>(4.0에 추가적으로:)<br><code>cubearray tesshw tessellation msaatex</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>4.5</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://en.wikipedia.org/wiki/OpenGL_ES#OpenGL_ES_3.1" target="_blank" rel="noreferrer noopener">OpenGL ES 3.1</a>.<br>(OpenGL ES 3.1과 동일합니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 11+<br>OpenGL 4.3+<br>OpenGL ES 3.1<br>Vulkan<br>Metal</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>3.5</code>, plus:<br>(3.5에 추가적으로:)<br><code>compute randomwrite msaatex</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>4.6</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://en.wikipedia.org/wiki/OpenGL#OpenGL_4.1" target="_blank" rel="noreferrer noopener">OpenGL 4.1</a>.<br>(OpenGL 4.1과 동일합니다.)<br>This is the highest OpenGL level supported on a Mac.<br>이것이 Mac에서 지원되는 최고 OpenGL 수준입니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 11+<br>OpenGL 4.1+<br>OpenGL ES 3.1 + AEP<br>Vulkan<br>Metal (if no geometry stage is defined, and no hull or domain stage is defined)<br>(Metal (geometry 단계나 hull 또는 domain 단계가 정의되지 않은 경우))</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>4.0</code>, plus:<br>(4.0에 추가적으로:)<br><code>cubearray tesshw tessellation msaatex</code></td></tr><tr><td class="has-text-align-left" data-align="left"><code>5.0</code></td><td class="has-text-align-left" data-align="left">Equivalent to&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/d3d11-graphics-reference-sm5" target="_blank" rel="noreferrer noopener">DirectX shader model 5.0</a>, but without the requirement to support 32 interpolators or cubemap arrays.<br>(DirectX Shader 모델 5.0과 동일하지만, 32개의 보간자나 cubemap 배열 지원 요구 사항은 없습니다.)</td><td class="has-text-align-left" data-align="left">DirectX 11 feature level 11+<br>Desktop OpenGL &gt;= 4.2<br>OpenGL 4.3+<br>OpenGL ES 3.1 + AEP<br>Vulkan<br>Metal (if no geometry stage is defined, and no hull or domain stage is defined)<br>(Metal (geometry 단계나 hull 또는 domain 단계가 정의되지 않은 경우))</td><td class="has-text-align-left" data-align="left">Everything in&nbsp;<code>4.0</code>, plus:<br>(4.0에 추가적으로:)<br><code>compute randomwrite msaatex tesshw tessellation</code></td></tr></tbody></table></figure>



<p>For information on shader model support for console platforms, see the platform-specific documentation.<br>(콘솔 플랫폼의 Shader 모델 지원에 대한 정보는 플랫폼별 문서를 참조하십시오.)</p>



<p><strong>Notes:</strong></p>



<ul class="wp-block-list">
<li>&#8211; In the DirectX definitions, shader model 4.0 includes&nbsp;<code>mrt8</code>, and shader model 5.0 includes&nbsp;<code>interpolators32</code>&nbsp;and&nbsp;<code>cubearray</code>.<br>(DirectX 정의에서 Shader 모델 4.0은 mrt8을 포함하고, Shader 모델 5.0은 interpolators32와 cubearray를 포함합니다.)</li>



<li>Unity does not include these, for broader compatibility. To require these features, use an explicit&nbsp;<code>#pragma require</code>&nbsp;directive.<br>(Unity는 더 넓은 호환성을 위해 이를 포함하지 않습니다. 이러한 기능이 필요할 경우, 명시적으로 <code>#pragma require</code> 지시어를 사용하십시오.)</li>



<li>&#8211; If you use a target that requires&nbsp;<code>geometry</code>&nbsp;but your shader does not define a geometry stage, Unity removes&nbsp;<code>geometry</code>&nbsp;from the list of requirements at compile time.<br>(geometry가 필요한 target을 사용하였으나 Shader가 geometry 단계를 정의하지 않은 경우, Unity는 컴파일 시 요구 사항 목록에서 geometry를 제거합니다.)</li>



<li>&#8211; If you use a target that requires&nbsp;<code>tessellation</code>&nbsp;but your shader does not define a hull or domain stage, Unity removes&nbsp;<code>tessellation</code>&nbsp;from the list of requirements at compile time.<br>(tessellation이 필요한 target을 사용하였으나 Shader가 hull 또는 domain 단계를 정의하지 않은 경우, Unity는 컴파일 시 tessellation을 요구 사항 목록에서 제거합니다.)</li>
</ul>



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



<h4 class="wp-block-heading">List of ‘#pragma require’ values (&#8216;#pragma required&#8217; 값 목록)</h4>



<p>Here are all the valid values for the&nbsp;<code>#pragma require</code>&nbsp;directive.<br>(다음은 <code>#pragma require</code> 지시어에 대한 모든 유효한 값들입니다.)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th><strong>Value</strong></th><th><strong>Description</strong></th></tr></thead><tbody><tr><td><code>interpolators10</code></td><td>At least 10 vertex-to-fragment interpolators (“varyings”) are available.<br>(최소 10개의 버텍스-프래그먼트 보간자(“varyings”)가 제공됩니다.)</td></tr><tr><td><code>interpolators15</code></td><td>At least 15 vertex-to-fragment interpolators (“varyings”) are available.<br>(최소 15개의 버텍스-프래그먼트 보간자(“varyings”)가 제공됩니다.)<br><strong>Note:</strong>&nbsp;Internally, this also automatically adds&nbsp;<code>integers</code>&nbsp;to the list of requirements.<br>(참고: 내부적으로, 이는 자동으로 <code>integers</code>를 요구 사항 목록에 추가합니다.)</td></tr><tr><td><code>interpolators32</code></td><td>At least 32 vertex-to-fragment interpolators (“varyings”) are available.<br>(최소 32개의 버텍스-프래그먼트 보간자(“varyings”)가 제공됩니다.)</td></tr><tr><td><code>integers</code></td><td>Integers are a supported data type, including bit/shift operations.<br>(정수는 비트/시프트 연산을 포함한 지원 데이터 타입입니다.)<br><strong>Note:</strong>&nbsp;Internally, this also automatically adds&nbsp;<code>interpolators15</code>&nbsp;to the list of requirements.<br>(참고: 내부적으로, 이는 자동으로 <code>interpolators15</code>를 요구 사항 목록에 추가합니다.)</td></tr><tr><td><code>mrt4</code></td><td>At least 4 render targets are supported.<br>(최소 4개의 렌더 타겟이 지원됩니다.)</td></tr><tr><td><code>mrt8</code></td><td>At least 8 render targets are supported.<br>(최소 8개의 렌더 타겟이 지원됩니다.)</td></tr><tr><td><code>derivatives</code></td><td><strong>Pixel</strong> shader derivative instructions (ddx/ddy) are supported. <br>(Pixel shader 미분 명령(ddx/ddy)이 지원됩니다.)</td></tr><tr><td><code>samplelod</code></td><td>Explicit texture&nbsp;<strong>LOD</strong> sampling (tex2Dlod / SampleLevel) is supported.<br>(명시적인 텍스처 LOD 샘플링(tex2Dlod / SampleLevel)이 지원됩니다.)</td></tr><tr><td><code>fragcoord</code></td><td>Pixel location (XY on screen, ZW depth in clip space) input in pixel shader is supported.<br>(Pixel shader에서 Pixel 위치(화면상의 XY, 클립 공간에서의 ZW 깊이) 입력이 지원됩니다.)</td></tr><tr><td><code>2darray</code></td><td>2D texture arrays are a supported data type.<br>(2D 텍스처 배열이 지원되는 데이터 타입입니다.)</td></tr><tr><td><code>cubearray</code></td><td><strong>Cubemap</strong> arrays are a supported data type.<br>(Cubemap 배열이 지원되는 데이터 타입입니다.)</td></tr><tr><td><code>instancing</code></td><td>SV_InstanceID input system value is supported.<br>(SV_InstanceID 입력 시스템 값이 지원됩니다.)</td></tr><tr><td><code>geometry</code></td><td>Geometry shader stages are supported.<br>(Geometry shader 단계가 지원됩니다.)</td></tr><tr><td><code>compute</code></td><td>Compute shaders, structured buffers, and atomic operations are supported.<br>(Compute shader, 구조화된 버퍼, 원자 연산이 지원됩니다.)</td></tr><tr><td><code>randomwrite</code>&nbsp;or&nbsp;<code>uav</code></td><td>“Random write” (UAV) textures are supported.<br>(&#8220;랜덤 쓰기&#8221;(UAV) 텍스처가 지원됩니다.)</td></tr><tr><td><code>tesshw</code></td><td>Hardware tessellation is supported, but not necessarily tessellation (hull/domain) shader stages. <br>(하드웨어 테셀레이션이 지원되지만, 테셀레이션(hull/domain) shader 단계는 필수적으로 지원되지는 않습니다. )<br>For example, Metal supports tessellation, but not hull or domain stages.<br>(예를 들어, Metal은 테셀레이션을 지원하지만 hull 또는 domain 단계를 지원하지 않습니다.)</td></tr><tr><td><code>tessellation</code></td><td>Tessellation (hull/domain) shader stages are supported.<br>(테셀레이션(hull/domain) shader 단계가 지원됩니다.)</td></tr><tr><td><code>msaatex</code></td><td>The ability to access multi-sampled textures (Texture2DMS in HLSL) is supported.<br>(멀티 샘플링된 텍스처(Texture2DMS in HLSL)에 접근할 수 있는 기능이 지원됩니다.)</td></tr><tr><td><code>sparsetex</code></td><td>Sparse textures with residency info (“Tier2” support in DirectX terms;&nbsp;<code>CheckAccessFullyMapped</code>&nbsp;HLSL function).<br>(레지던시 정보가 포함된 Sparse 텍스처(DirectX 용어로 “Tier2” 지원; HLSL 함수 <code>CheckAccessFullyMapped</code>).)</td></tr><tr><td><code>framebufferfetch</code>&nbsp;or&nbsp;<code>fbfetch</code></td><td>Framebuffer fetch (the ability to read input pixel color in the pixel shader) is supported.<br>(프레임버퍼 패치(pixel shader에서 입력 픽셀 색상을 읽을 수 있는 기능)가 지원됩니다.)</td></tr><tr><td><code>setrtarrayindexfromanyshader</code></td><td>Setting the render target array index from any shader stage (not just the geometry shader stage) is supported.<br>(Geometry shader 단계뿐만 아니라 모든 shader 단계에서 렌더 타겟 배열 인덱스를 설정할 수 있는 기능이 지원됩니다.)</td></tr><tr><td>inlineraytracing</td><td>Inline&nbsp;<strong>ray tracing</strong> is supported, so you can generate ray queries in the&nbsp;<strong>rasterization</strong> and compute stages of a shader. <br>(인라인 레이 트레이싱이 지원되어, 쉐이더의 래스터화 및 컴퓨팅 단계에서 레이 쿼리를 생성할 수 있습니다.)<br>Refer to&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/SystemInfo-supportsInlineRayTracing.html" target="_blank" rel="noreferrer noopener">SystemInfo.supportsInlineRayTracing</a>&nbsp;for more information.<br>(자세한 내용은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/SystemInfo-supportsInlineRayTracing.html" target="_blank" rel="noreferrer noopener">SystemInfo.supportsInlineRayTracing</a></code>을 참조하세요.)</td></tr></tbody></table></figure>



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



<h3 class="wp-block-heading">Targeting graphics APIs and platforms in HLSL<br>(HLSL에서 그래픽 API 및 플랫폼 타겟팅)</h3>



<p>Some&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-PragmaDirectives.html" target="_blank" rel="noreferrer noopener"><code>#pragma</code>&nbsp;directives</a>&nbsp;take parameters that allow you to target specific graphics APIs and platforms.<br>(일부 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-PragmaDirectives.html" target="_blank" rel="noreferrer noopener"><code>#pragma</code> 지시어</a>는 특정 그래픽 API 및 플랫폼을 타겟팅할 수 있는 매개변수를 받습니다.)</p>



<p>This page contains information on using those directives, and provides a list of valid parameter values.<br>(이 페이지는 이러한 지시어 사용에 대한 정보를 제공하며, 유효한 매개변수 값 목록을 제공합니다.)</p>



<h4 class="wp-block-heading">Including or excluding graphics APIs<br>(그래픽 API 포함 또는 제외)</h4>



<p>By default, Unity compiles all&nbsp;<strong>shader</strong> programs for each graphics API in the list for the current build target.<br>(기본적으로 Unity는 현재 빌드 타겟의 목록에 있는 각 그래픽 API에 대해 모든 <strong>shader</strong> 프로그램을 컴파일합니다.)</p>



<p>Sometimes, you might want to compile certain shader programs only for certain graphics APIs; for example, if you use features that are not supported on all platforms.<br>(때로는 특정 그래픽 API에만 Shader 프로그램을 컴파일하고 싶을 수 있습니다. 예를 들어, 모든 플랫폼에서 지원되지 않는 기능을 사용할 경우입니다.)</p>



<p>To compile a shader program only for given APIs, use the&nbsp;<code>#pragma only_renderers</code>&nbsp;directive. You can pass multiple values, space delimited.<br>(특정 API에 대해서만  shader 프로그램을 컴파일하려면 <code>#pragma only_renderers</code> 지시어를 사용하십시오. 여러 값을 공백으로 구분하여 전달할 수 있습니다.)</p>



<p>This example demonstrates how to compile shaders only for Metal and Vulkan:<br>(다음 예는 Metal 및 Vulkan에 대해서만 shader를 컴파일하는 방법을 보여줍니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma only_renderers metal vulkan</pre>



<p>To exclude shader code from compilation by given compilers, use the&nbsp;<code>#pragma exclude_renderers</code>&nbsp;directive.<br>(특정 컴파일러에서 쉐이더 코드를 컴파일하지 않으려면 <code>#pragma exclude_renderers</code> 지시어를 사용하십시오. )</p>



<p>You can pass multiple values, space delimited.<br>(여러 값을 공백으로 구분하여 전달할 수 있습니다.)</p>



<p>This example demonstrates how to exclude a shader from compilation for Metal and Vulkan:<br>(다음 예는 Metal 및 Vulkan에 대한 shader 컴파일을 제외하는 방법을 보여줍니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma exclude_renderers metal vulkan</pre>



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



<h4 class="wp-block-heading">Generating shader variants for graphics tiers for a given graphics API<br>(주어진 그래픽 API에 대한 그래픽 티어의 shdaer 변형 생성)</h4>



<p>In the Built-in&nbsp;<strong>Render Pipeline</strong>, Unity automatically generates&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants.html" target="_blank" rel="noreferrer noopener">shader variants</a> that correspond to&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/graphics-tiers.html" target="_blank" rel="noreferrer noopener">graphics tiers</a>&nbsp;under certain conditions.<br>(Built-in&nbsp;<strong>Render Pipeline</strong>에서 Unity는 특정 조건 하에 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/graphics-tiers.html" target="_blank" rel="noreferrer noopener">graphics tiers</a>에 해당하는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants.html" target="_blank" rel="noreferrer noopener">shader variants</a>을 자동으로 생성합니다.)</p>



<p>You can also force Unity to generate these variants, if required.<br>(필요시 Unity에 강제로 이러한 변형을 생성하게 할 수 있습니다.)</p>



<p>To do this, use the&nbsp;<code>#pragma hardware_tier_variants</code>&nbsp;preprocessor directive and specify the graphics APIs for which you want to generate tier shader variants.<br>(이를 위해 <code>#pragma hardware_tier_variants</code> 전처리 지시어를 사용하고 tier shader 변형을 생성하려는 그래픽 API를 지정하십시오.)</p>



<p>For example, this instructs Unity to compile tier shader variants for Metal:<br>(예를 들어, 이는 Unity가 Metal에 대한 tier shader 변형을 컴파일하도록 지시합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma hardware_tier_variants metal</pre>



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



<h4 class="wp-block-heading">List of valid parameter values (유효한 매개변수 값 목록)</h4>



<p>Supported values are:<br>(지원되는 값은 다음과 같습니다:)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th><strong>Value</strong></th><th><strong>Description</strong></th></tr></thead><tbody><tr><td><code>d3d11</code></td><td>DirectX 11 feature level 10 and above, DirectX 12</td></tr><tr><td><code>gles3</code></td><td>OpenGL ES 3.x,&nbsp;<strong>WebGL</strong> 2.0</td></tr><tr><td><code>ps4</code></td><td>PlayStation 4</td></tr><tr><td><code>xboxone</code></td><td>Xbox One and GameCore, DirectX 11 and DirectX 12</td></tr><tr><td><code>metal</code></td><td>iOS/Mac Metal</td></tr><tr><td><code>glcore</code></td><td>OpenGL 3.x, OpenGL 4.x</td></tr><tr><td><code>vulkan</code></td><td>Vulkan</td></tr><tr><td><code>switch</code></td><td>Nintendo Switch</td></tr><tr><td><code>ps5</code></td><td>PlayStation 5</td></tr></tbody></table></figure>



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



<h3 class="wp-block-heading">Declaring and using shader keywords in HLSL<br>(HLSL에서 쉐이더 키워드 선언 및 사용)</h3>



<p>You can declare&nbsp;<strong>shader</strong> keywords so shaders behave differently when you enable or disable the keywords.<br>(<strong>shader</strong>키워드를 선언하여 키워드를 활성화하거나 비활성화할 때 shader가 다르게 동작하도록 할 수 있습니다.)</p>



<p>You can declare shader keywords in regular graphics shaders including&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">surface shaders</a>, and&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html">comp</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html" target="_blank" rel="noreferrer noopener">u</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html">te shaders</a>.<br>(regular graphics shaders 및 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">surface shaders</a>, <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html">comp</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html" target="_blank" rel="noreferrer noopener">u</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html">te shaders</a>에서 shader 키워드를 선언할 수 있습니다.)</p>



<h4 class="wp-block-heading">Declare shader keywords using pragma<br>(pragma를 사용한 shader 키워드 선언)</h4>



<p>To declare shader keywords, use a&nbsp;<code>#pragma</code>&nbsp;directive in the HLSL code. For example:<br>(shader 키워드를 선언하려면 HLSL 코드에서 <code>#pragma</code> 지시어를 사용하십시오. 예를 들어:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma shader_feature REFLECTION_TYPE1 REFLECTION_TYPE2 REFLECTION_TYPE3</pre>



<p>You can use one of the following shader directives:<br>(다음 쉐이더 지시어 중 하나를 사용할 수 있습니다:)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><strong>Shader directive</strong></th><th class="has-text-align-left" data-align="left"><strong>Branching type</strong></th><th class="has-text-align-left" data-align="left"><strong>Shader variants Unity creates</strong></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left"><code>shader_feature</code></td><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-branching.html#static-branching" target="_blank" rel="noreferrer noopener">Static branching</a></td><td class="has-text-align-left" data-align="left">Variants for keyword combinations you enable at build time<br>빌드 시점에서 활성화한 키워드 조합에 대한 변형을 생성합니다.</td></tr><tr><td class="has-text-align-left" data-align="left"><code>multi_compile</code></td><td class="has-text-align-left" data-align="left">Static branching</td><td class="has-text-align-left" data-align="left">Variants for every possible combination of keywords<br>가능한 모든 키워드 조합에 대한 변형을 생성합니다.</td></tr><tr><td class="has-text-align-left" data-align="left"><code>dynamic_branch</code></td><td class="has-text-align-left" data-align="left"><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-branching.html#dynamic-branching" target="_blank" rel="noreferrer noopener">Dynamic branching</a></td><td class="has-text-align-left" data-align="left">No variants<br>변형을 생성하지 않습니다.</td></tr></tbody></table></figure>



<p>Read more about&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-conditionals.html" target="_blank" rel="noreferrer noopener">when to use which shader directive</a>.<br>(어떤 shader 지시어를 사용할지에 대한 추가 정보는 따로 참조하세요.)</p>



<p>See&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords.html#keyword-limits" target="_blank" rel="noreferrer noopener">shader keyword limits</a>.<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords.html#keyword-limits" target="_blank" rel="noreferrer noopener">shader 키워드 제한 사항</a>을 참조하세요.)</p>



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



<h4 class="wp-block-heading">How sets of keywords work (키워드 집합이 작동하는 방식)</h4>



<p>The keywords in a single&nbsp;<code>#pragma</code>&nbsp;statement are together called a ‘set’. <br>(단일 <code>#pragma</code> 문에 포함된 키워드는 ‘집합’이라고 합니다.)</p>



<p>You can enable or disable multiple keywords in a set at the same time.<br>( 한 번에 여러 키워드를 활성화하거나 비활성화할 수 있습니다.)</p>



<p>For example, to declare a set of three keywords:<br>(예를 들어, 세 개의 키워드 집합을 선언하려면:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma shader_feature REFLECTION_TYPE1 REFLECTION_TYPE2 REFLECTION_TYPE3</pre>



<p>You can declare multiple sets of keywords in a single shader. For example, to create 2 sets:<br>(단일 shader에서 여러 키워드 집합을 선언할 수 있습니다. 예를 들어, 두 개의 집합을 만들려면:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma shader_feature REFLECTION_TYPE1 REFLECTION_TYPE2 REFLECTION_TYPE3
#pragma shader_feature RED GREEN BLUE WHITE</pre>



<p>You can’t do the following:<br>(다음은 할 수 없습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; Include two keywords with the same name in one set.<br>(한 집합에 동일한 이름의 키워드를 포함할 수 없습니다.)</li>



<li>&#8211; Include duplicate keyword sets in one shader.<br>(하나의 shader에서 중복된 키워드 집합을 포함할 수 없습니다.)</li>



<li>&#8211; Declare a keyword as both&nbsp;<code>dynamic_branch</code>&nbsp;and&nbsp;<code>shader_feature</code>&nbsp;or&nbsp;<code>multi_compile</code>&nbsp;&#8211; Unity uses&nbsp;<code>dynamic_branch</code>&nbsp;if you do this.<br>(<code>dynamic_branch</code>와 <code>shader_feature</code> 또는 <code>multi_compile</code>을 동시에 선언할 수 없습니다. Unity는 이 경우 <code>dynamic_branch</code>를 사용합니다.)</li>
</ul>



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



<h4 class="wp-block-heading">Make shader behavior conditional (쉐이더 동작을 조건부로 설정)</h4>



<p>To mark parts of your shader code conditional based on whether you enable or disable a shader keyword, use&nbsp;<a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-if" target="_blank" rel="noreferrer noopener">an HLSL if statement</a>.<br>(shader 키워드의 활성화 여부에 따라 shader 코드의 일부를 조건부로 설정하려면 <a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-if" target="_blank" rel="noreferrer noopener">HLSL의 <code>if</code> 문</a>을 사용하십시오.)</p>



<p>For example:<br>(예를 들어:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma multi_compile QUALITY_LOW QUALITY_MED QUALITY_HIGH

if (QUALITY_LOW)
{
    // code for low quality setting
    // 저품질 설정에 대한 코드
}
</pre>



<p>You can enable and disable keywords&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords-material-inspector.html" target="_blank" rel="noreferrer noopener">using the Inspector</a>&nbsp;or&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords-scripts.html" target="_blank" rel="noreferrer noopener">C# scripting</a>.<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords-material-inspector.html" target="_blank" rel="noreferrer noopener">Inspector</a>나 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-keywords-scripts.html" target="_blank" rel="noreferrer noopener">C# 스크립팅</a>을 사용하여 키워드를 활성화하거나 비활성화할 수 있습니다.)</p>



<p>What Unity does with your shader code depends on which shader directive you use.<br>(Unity가 shader 코드에서 하는 작업은 사용하는 shader 지시어에 따라 다릅니다.)</p>



<p>If you use&nbsp;<code>dynamic_branch</code>, Unity creates a uniform Boolean variable for each keyword.<br>(만약 <code>dynamic_branch</code>를 사용하면, Unity는 각 키워드에 대해 uniform Boolean 변수를 생성합니다.)</p>



<p>When you enable a keyword, Unity sets the Boolean for that variable to&nbsp;<code>true</code>, and your GPU switches to using the code in the&nbsp;<code>if</code>&nbsp;statement for that keyword. <br>(키워드를 활성화하면 Unity는 해당 변수를 true로 설정하고 GPU가 해당 키워드의 <code>if</code> 문 코드를 사용하도록 전환합니다.)</p>



<p>This is dynamic branching.<br>(이것이 동적 분기입니다.)</p>



<p>If you use&nbsp;<code>shader_feature</code>&nbsp;or&nbsp;<code>multi_compile</code>, Unity creates separate&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants.html" target="_blank" rel="noreferrer noopener">shader varia</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants.html">nts</a> for each keyword state. <br>(<code>shader_feature</code>나 <code>multi_compile</code>을 사용하는 경우 Unity는 각 키워드 상태에 대해 별도의 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-variants.html">shader variants</a>을 생성합니다.)</p>



<p>Each variant contains the code from an&nbsp;<code>if</code>&nbsp;branch for that keyword. <br>(각 변형은 해당 키워드의 <code>if</code> 분기 코드를 포함합니다.)</p>



<p>When you enable a keyword, Unity sends the matching variant to your GPU. This is static branching.<br>(키워드를 활성화하면 Unity는 해당 variant을 GPU로 보냅니다. 이것이 정적 분기입니다.)</p>



<p>Read more about&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-conditionals.html" target="_blank" rel="noreferrer noopener">when to use which shader directive</a>.<br>(어떤 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/shader-conditionals.html" target="_blank" rel="noreferrer noopener">shader 지시어를 사용할지에</a> 대한 추가 정보는 따로 참조하세요.)</p>



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



<h4 class="wp-block-heading">Use other statements to make shader behavior conditional<br>(다른 명령문을 사용하여 Shader 동작을 조건부로 설정)</h4>



<p>You can also use the following HLSL statements to create conditional code:<br>(다음 HLSL 명령문을 사용하여 조건부 코드를 만들 수 있습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; <a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-if" target="_blank" rel="noreferrer noopener"><code>#if, #elif, #else and #endif</code></a>.
<ul class="wp-block-list">
<li>&#8211; <a href="https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-ifdef" target="_blank" rel="noreferrer noopener"><code>#ifdef and #ifndef</code></a>.</li>
</ul>
</li>
</ul>



<p>Using these instead of&nbsp;<code>if</code>&nbsp;makes it more difficult to change the&nbsp;<code>#pragma</code>&nbsp;keyword directive later.<br>(이 명령문들을 <code>if</code> 대신 사용하는 것은 나중에 <code>#pragma</code> 키워드 지시어를 변경하기 어렵게 만듭니다.)</p>



<p>For example, if you need to reduce the number of shader variants, it’s more difficult to change&nbsp;<code>multi_compile</code>&nbsp;to&nbsp;<code>shader_feature</code>.<br>(예를 들어, shader 변형의 수를 줄여야 할 경우 <code>multi_compile</code>을 <code>shader_feature</code>로 변경하기가 더 어려워집니다.)</p>



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



<h4 class="wp-block-heading">Make keywords local (키워드를 로컬로 만들기)</h4>



<p>Keywords are global by default.<br>(키워드는 기본적으로 전역입니다.)</p>



<p>Add&nbsp;<code>_local</code>&nbsp;to the shader directive to make the keywords local. <br>(키워드를 로컬로 만들려면 쉐이더 지시어에 <code>_local</code>을 추가하십시오.)</p>



<p>If you enable or disable a global keyword, you don’t affect the state of local keywords with the same name.<br>(전역 키워드를 활성화하거나 비활성화해도 동일한 이름을 가진 로컬 키워드의 상태에 영향을 미치지 않습니다.)</p>



<p>For example:<br>(예를 들어:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma shader_feature_local QUALITY_LOW QUALITY_MED QUALITY_HIGH</pre>



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



<h4 class="wp-block-heading">Restrict keywords to shader stages (키워드를 쉐이더 단계로 제한)</h4>



<p>When you declare a keyword, Unity assumes all stages of the shader contain conditional code for that keyword.<br>(키워드를 선언할 때 Unity는 쉐이더의 모든 단계에 대해 해당 키워드에 대한 조건부 코드가 포함된 것으로 간주합니다.)</p>



<p>You can add the following suffixes to indicate that only certain stages contain conditional code for a keyword. <br>(다음 접미사를 추가하여 특정 단계에만 조건부 코드가 포함되어 있음을 나타낼 수 있습니다.)</p>



<p>This helps Unity strip unneeded shader variants.<br>(이는 Unity가 불필요한 쉐이더 변형을 제거하는 데 도움이 됩니다.)</p>



<ul class="wp-block-list">
<li><code>_vertex</code></li>



<li><code>_fragment</code></li>



<li><code>_hull</code></li>



<li><code>_domain</code></li>



<li><code>_geometry</code></li>



<li><code>_raytracing</code></li>
</ul>



<p>For example, use&nbsp;<code>#pragma shader_feature_fragment RED GREEN BLUE</code>&nbsp;to indicate that you use the 3 keywords to create conditional code in the fragment stage only.<br>(예를 들어, <code>#pragma shader_feature_fragment RED GREEN BLUE</code>를 사용하여 세 가지 키워드를 사용해 fragment 단계에서만 조건부 코드를 생성함을 나타냅니다.)</p>



<p>You can’t add these suffixes to&nbsp;<code>#pragma dynamic_branch</code>&nbsp;because&nbsp;<code>dynamic_branch</code>&nbsp;doesn’t create variants.<br>(<code>dynamic_branch</code>는 변형을 생성하지 않기 때문에 이 접미사를 추가할 수 없습니다.)</p>



<p>These suffixes may behave differently or have no effect depending on the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.GraphicsDeviceType.html">graphics API</a>:<br>(이 접미사는 <a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.GraphicsDeviceType.html" target="_blank" rel="noreferrer noopener">그래픽 API</a>에 따라 다르게 작동하거나 아무런 효과가 없을 수 있습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; The suffixes have no effect on OpenGL, OpenGL ES or Vulkan.<br>(이 접미사는 OpenGL, OpenGL ES 또는 Vulkan에서는 효과가 없습니다.)</li>



<li>&#8211; The&nbsp;<code>_geometry</code>&nbsp;and&nbsp;<code>_raytracing</code>&nbsp;suffixes have no effect on Metal, and Metal treats&nbsp;<code>_vertex</code>,&nbsp;<code>_hull</code>&nbsp;and&nbsp;<code>_domain</code>&nbsp;as a single stage.<br>(<code>_geometry</code> 및 <code>_raytracing</code> 접미사는 Metal에서는 효과가 없으며, Metal은 <code>_vertex</code>, <code>_hull</code>, <code>_domain</code>을 하나의 단계로 처리합니다.)</li>
</ul>



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



<h4 class="wp-block-heading">Restrict keywords to shader models and GPU features<br>(키워드를 shader 모델과 GPU 기능으로 제한)</h4>



<p>You can add keywords to&nbsp;<code>#pragma require</code>&nbsp;and&nbsp;<code>#pragma target</code>&nbsp;directives, so conditional code only runs if the current hardware uses a particular shader model or GPU feature.<br>(<code>#pragma require</code> 및 <code>#pragma target</code> 지시어에 키워드를 추가하여 현재 하드웨어가 특정 쉐이더 모델 또는 GPU 기능을 사용하는 경우에만 조건부 코드가 실행되도록 할 수 있습니다.)</p>



<p>For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">Targeting shader models and GPU features in HLSL</a>.<br>(자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderCompileTargets.html" target="_blank" rel="noreferrer noopener">HLSL에서 쉐이더 모델 및 GPU 기능 타겟팅을 참조</a>하십시오.)</p>



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



<h4 class="wp-block-heading">Create a shader variant for disabled keywords<br>(비활성화된 키워드에 대한 shader 변형 생성)</h4>



<p>If you use&nbsp;<code>shader_feature</code>&nbsp;to create a single keyword, Unity automatically creates a second variant for when the feature is disabled. <br>(단일 키워드를 생성하기 위해 <code>shader_feature</code>를 사용하는 경우, Unity는 해당 기능이 비활성화될 때 두 번째 변형을 자동으로 생성합니다.)</p>



<p>This helps reduce the number of keywords you need to enable and disable. <br>(이는 활성화 및 비활성화해야 하는 키워드 수를 줄이는 데 도움이 됩니다.)</p>



<p>For example, the following code creates 2 variants:<br>(예를 들어, 다음 코드는 2개의 변형을 생성합니다:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma shader_feature EXAMPLE_ON</pre>



<p>If you use&nbsp;<code>multi_compile</code>, or you use&nbsp;<code>shader_feature</code>&nbsp;to create a set of two or more keywords, you can use&nbsp;<code>_</code>&nbsp;when you declare a keyword set. <br>(<code>multi_compile</code>을 사용하거나 <code>shader_feature</code>를 사용하여 두 개 이상의 키워드 집합을 생성하는 경우, 키워드 집합을 선언할 때 <code>_</code>를 사용할 수 있습니다.)</p>



<p>Unity creates a shader variant for situations when all keywords in that set are disabled.<br>(Unity는 해당 집합의 모든 키워드가 비활성화된 상황에 대한 shader변형을 생성합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma multi_compile _ EXAMPLE_ON
#pragma shader_feature _ RED GREEN BLUE WHITE</pre>



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



<h4 class="wp-block-heading">Use shortcuts to create keyword sets<br>(단축어를 사용하여 키워드 집합 생성)</h4>



<p>You can use Unity shader directive shortcuts to create sets of shader variants.<br>(Unity shader 지시어 단축어를 사용하여 shader 변형 집합을 생성할 수 있습니다.)</p>



<p>The following example explains how to add&nbsp;<code>SHADOWS_DEPTH</code>&nbsp;and&nbsp;<code>SHADOWS_CUBE</code>&nbsp;variants:<br>(다음 예는 <code>SHADOWS_DEPTH</code> 및 <code>SHADOWS_CUBE</code> 변형을 추가하는 방법을 설명합니다:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma multi_compile_shadowcaster</pre>



<p>You can remove keywords you don’t need using&nbsp;<code>skip_variants</code>. <br>(<code>skip_variants</code>를 사용하여 필요하지 않은 키워드를 제거할 수 있습니다.)</p>



<p>For example, use the following to remove&nbsp;<code>POINT</code>&nbsp;and&nbsp;<code>POINT_COOKIES</code>&nbsp;variants when Unity generates variants from&nbsp;<code>multi_compile_fwdadd</code>.<br>(예를 들어, Unity가 <code>multi_compile_fwdadd</code>에서 변형을 생성할 때 <code>POINT</code> 및 <code>POINT_COOKIES</code> 변형을 제거하려면 다음을 사용하십시오:)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#pragma multi_compile_fwdadd
#pragma skip_variants POINT POINT_COOKIE</pre>



<p>The following shortcuts relate to light, shadow and lightmapping in the Built-in&nbsp;<strong>Render Pipeline</strong> :<br>(다음 단축어는 내장 렌더 파이프라인의 조명, 그림자 및 라이트매핑과 관련이 있습니다:)</p>



<ul class="wp-block-list">
<li><code>- multi_compile_fwdbase</code>&nbsp;adds this set of keywords:<br>(multi_compile_fwdbase는 다음과 같은 키워드 집합을 추가합니다:)<br>DIRECTIONAL LIGHTMAP_ON DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON SHADOWS_SCREEN SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING LIGHTPROBE_SH. <br>These variants are needed by&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardBase.html" target="_blank" rel="noreferrer noopener">PassType.ForwardBase</a>.<br>이 변형들은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardBase.html" target="_blank" rel="noreferrer noopener">PassType.ForwardBase</a></code>에 필요합니다.</li>



<li><code>- multi_compile_fwdbasealpha</code>&nbsp;adds this set of keywords:<br>(<code>multi_compile_fwdadd</code>는 다음과 같은 키워드 집합을 추가합니다:)<br>DIRECTIONAL LIGHTMAP_ON DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING VERTEXLIGHT_ON LIGHTPROBE_SH. <br>These variants are needed by&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardBase.html">PassType.ForwardBase</a>.<br>이 변형들은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardBase.html" target="_blank" rel="noreferrer noopener">PassType.ForwardBase</a></code>에 필요합니다.</li>



<li>&#8211; <code>multi_compile_fwdadd</code>&nbsp;adds this set of keywords: <br>(multi_compile_fwdadd_fullshadows는 다음과 같은 키워드 집합을 추가합니다:)<br>POINT DIRECTIONAL SPOT POINT_COOKIE DIRECTIONAL_COOKIE. <br>These variants are needed by&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardAdd.html">PassType.ForwardAdd</a>.<br>(이 변형들은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ForwardBase.html" target="_blank" rel="noreferrer noopener">PassType.ForwardBase</a></code>에 필요합니다.)</li>



<li>&#8211; <code>multi_compile_fwdadd_fullshadows</code>&nbsp;adds this set of keywords:<br>(<code>multi_compile_lightpass</code>는 다음과 같은 키워드 집합을 추가합니다:)<br>POINT DIRECTIONAL SPOT POINT_COOKIE DIRECTIONAL_COOKIE SHADOWS_DEPTH SHADOWS_SCREEN SHADOWS_CUBE SHADOWS_SOFT SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING. <br>This is the same as&nbsp;<code>multi_compile_fwdadd</code>, but this adds the ability for the lights to have real-time shadows.<br>(이것은 <code>multi_compile_fwdadd</code>와 동일하지만, 실제 그림자를 위한 기능이 추가됩니다.)</li>



<li>&#8211; <code>multi_compile_lightpass</code>&nbsp;adds this set of keywords:<br>(<code>multi_compile_shadowcaster</code>는 다음과 같은 키워드 집합을 추가합니다:)<br>POINT DIRECTIONAL SPOT POINT_COOKIE DIRECTIONAL_COOKIE SHADOWS_DEPTH SHADOWS_SCREEN SHADOWS_CUBE SHADOWS_SOFT SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING. <br>This is effectively a catch-all shortcut for all functionality related to real-time light and shadows, other than&nbsp;<strong>Light Probes</strong>.<br>(이것은 실시간 빛과 그림자에 관련된 모든 기능을 포함하는 단축어로, 라이트 프로브를 제외한 모든 것에 해당됩니다.)</li>



<li>&#8211; <code>multi_compile_shadowcaster</code>&nbsp;adds this set of keywords: <br>SHADOWS_DEPTH SHADOWS_CUBE. <br>These variants are needed by&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ShadowCaster.html" target="_blank" rel="noreferrer noopener">PassType.ShadowCaster</a>.<br>(이 변형들은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.ShadowCaster.html" target="_blank" rel="noreferrer noopener">PassType.ShadowCaster</a></code>에 필요합니다.)</li>



<li>&#8211; <code>multi_compile_shadowcollector</code>&nbsp;adds this set of keywords: <br>SHADOWS_SPLIT_SPHERES SHADOWS_SINGLE_CASCADE. <br>It also compiles variants without any of these keywords. These variants are needed for screen-space shadows.<br>(또한 이러한 키워드 없이 변형들을 컴파일합니다. 이 변형들은 화면 공간 그림자에 필요합니다.)</li>



<li><code>- multi_compile_prepassfinal</code>&nbsp;adds this set of keywords: <br>LIGHTMAP_ON DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON UNITY_HDR_ON SHADOWS_SHADOWMASK LIGHTPROBE_SH. <br>It also compiles variants without any of these keywords. These variants are needed by&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.Deferred.html" target="_blank" rel="noreferrer noopener">PassType.Deferred</a>.<br>(또한 이러한 키워드 없이 변형들을 컴파일합니다. 이 변형들은 <code><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rendering.PassType.Deferred.html" target="_blank" rel="noreferrer noopener">PassType.Deferred</a></code>에 필요합니다.)</li>
</ul>



<p>The following shortcuts relate to other settings:<br>(<strong>다음 단축어들은 다른 설정과 관련됩니다</strong>: )</p>



<ul class="wp-block-list">
<li>&#8211; <code>multi_compile_particles</code>&nbsp;adds this keyword relating to the Built-in&nbsp;<strong>particle system</strong> : SOFTPARTICLES_ON. <br>(<code>multi_compile_particles</code>는 기본 제공 파티클 시스템과 관련된 SOFTPARTICLES_ON 키워드를 추가합니다.)<br>It also compiles variants without this keyword. For more information, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/Built-inParticleSystem.html" target="_blank" rel="noreferrer noopener">Built-in Particle System</a>.<br>(또한 이 키워드 없이 변형들을 컴파일합니다. 더 자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/Built-inParticleSystem.html" target="_blank" rel="noreferrer noopener">Built-in Particle System</a>을 참조하십시오.)</li>



<li>&#8211; <code>multi_compile_fog</code>&nbsp;adds this set of keywords relating to fog: FOG_LINEAR, FOG_EXP, FOG_EXP2. <br>(<code>multi_compile_fog</code>는 안개와 관련된 다음과 같은 키워드 집합을 추가합니다: FOG_LINEAR, FOG_EXP, FOG_EXP2.)<br>It also compiles variants without any of these keywords. You can control this behavior in the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-GraphicsSettings.html" target="_blank" rel="noreferrer noopener">Graphics settings</a>&nbsp;window.<br>(또한 이러한 키워드 없이 변형들을 컴파일합니다. 이 동작은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-GraphicsSettings.html" target="_blank" rel="noreferrer noopener">그래픽 설정</a>창에서 제어할 수 있습니다.)</li>



<li>&#8211; <code>multi_compile_instancing</code>&nbsp;adds keywords relating to instancing. <br>(<code>multi_compile_instancing</code>은 인스턴싱과 관련된 키워드를 추가합니다.)<br>If the shader uses procedural instancing, it adds this set of keywords: INSTANCING_ON PROCEDURAL_ON. <br>(shader가 procedural 인스턴싱을 사용하는 경우, INSTANCING_ON과 PROCEDURAL_ON 키워드 집합을 추가합니다.)<br>Otherwise, it adds this keyword: INSTANCING_ON. It also compiles variants without any of these keywords. <br>(그렇지 않으면 INSTANCING_ON 키워드만 추가됩니다. 또한 이러한 키워드 없이 변형들을 컴파일합니다.)<br>You can control this behavior in the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-GraphicsSettings.html" target="_blank" rel="noreferrer noopener">Graphics settings</a>&nbsp;window.<br>(이 동작은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-GraphicsSettings.html" target="_blank" rel="noreferrer noopener">그래픽 설정</a> 창에서 제어할 수 있습니다.)</li>
</ul>



<p></p>
</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)"/>



<h2 class="wp-block-heading">Shader semantics (쉐이더 의미론)</h2>



<p>When writing HLSL&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">shader programs</a>, input and output variables need to have their “intent” indicated via&nbsp;<strong>semantics</strong>. <br>(HLSL <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">shader programs</a>을 작성할 때, 입력 및 출력 변수는 그 <strong>“의도”</strong>를 의미론을 통해 나타내야 합니다)</p>



<p>This is a standard concept in HLSL shader language; see the&nbsp;<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb509647.aspx" target="_blank" rel="noreferrer noopener">Semantics documentation on MSDN</a>&nbsp;for more details.<br>(이는 HLSL 쉐이더 언어의 표준 개념으로, 자세한 내용은 <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb509647.aspx" target="_blank" rel="noreferrer noopener">MSDN의 의미론 문서</a>를 참조하십시오.)</p>



<h3 class="wp-block-heading">Vertex shader input semantics (정점 쉐이더 입력 의미론)</h3>



<p>The main vertex&nbsp;<strong>shader</strong>&nbsp;function (indicated by the&nbsp;<code>#pragma vertex</code>&nbsp;directive) needs to have semantics on all the input parameters.<br>(주요 정점 쉐이더 함수( <code>#pragma vertex</code> 지시어로 표시됨)에는 모든 입력 매개변수에 대한 의미론이 필요합니다.)</p>



<p>These correspond to individual&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Mesh.html" target="_blank" rel="noreferrer noopener">Mesh</a> data elements, like vertex position, normal mesh, and texture coordinates.<br>(이러한 의미론은 정점 위치, 정점 법선, 텍스처 좌표와 같은 개별 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Mesh.html" target="_blank" rel="noreferrer noopener">메시</a> 데이터 요소에 해당합니다.)</p>



<p>See&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-VertexProgramInputs.html" target="_blank" rel="noreferrer noopener">vertex program inputs</a>&nbsp;for more details.<br>(더 자세한 내용은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-VertexProgramInputs.html" target="_blank" rel="noreferrer noopener">정점 프로그램 입력</a>을 참조하십시오.)</p>



<p>Here’s an example of a simple&nbsp;<strong>vertex shader</strong> that takes vertex position and a texture coordinate as an input.<br>(다음은 정점 위치와 텍스처 좌표를 입력으로 받는 간단한 <strong>정점 shader</strong>의 예입니다.)</p>



<p> The&nbsp;<strong>pixel</strong> shader visualizes the texture coordinate as a color.<br>(<strong>픽셀 </strong>shader는 텍스처 좌표를 색상으로 시각화합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Unlit/Show UVs"
{
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            struct v2f {
                float2 uv : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            v2f vert (
                float4 vertex : POSITION, // vertex position input
                float2 uv : TEXCOORD0 // first texture coordinate input
                )
            {
                v2f o;
                o.pos = UnityObjectToClipPos(vertex);
                o.uv = uv;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                return fixed4(i.uv, 0, 0);
            }
            ENDCG
        }
    }
}</pre>



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



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="396" height="295" src="https://lycos7560.com/wp-content/uploads/2024/09/image.png" alt="" class="wp-image-38239" srcset="https://lycos7560.com/wp-content/uploads/2024/09/image.png 396w, https://lycos7560.com/wp-content/uploads/2024/09/image-300x223.png 300w" sizes="(max-width: 396px) 100vw, 396px" /></figure>



<p>Instead of spelling out all individual inputs one by one, it’s also possible to declare a structure of them, and indicate semantics on each individual member variable of the struct.<br>(개별 입력을 하나씩 나열하는 대신, 입력들을 구조체로 선언하고 구조체의 각 멤버 변수에 의미론을 지정할 수도 있습니다.)</p>



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



<h3 class="wp-block-heading">Fragment shader output semantics (프래그먼트(픽셀) 쉐이더 출력 의미론)</h3>



<p>Most often a fragment (pixel) shader outputs a color, and has an&nbsp;<code>SV_Target</code>&nbsp;semantic. The fragment shader in the example above does exactly that:<br>(대부분의 경우, 프래그먼트(픽셀) 쉐이더는 색상을 출력하며, <code>SV_Target</code> 의미론을 가집니다. 위의 예제에서 프래그먼트 쉐이더는 정확히 이 작업을 수행합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">struct fragOutput {
    fixed4 color : SV_Target;
};
fragOutput frag (v2f i)
{
    fragOutput o;
    o.color = fixed4(i.uv, 0, 0);
    return o;
}</pre>



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



<p>Returning structures from the fragment shader is mostly useful for shaders that don’t just return a single color. <br>(fragment shader에서 구조체를 반환하는 것은 단일 색상 외에 여러 값을 반환해야 하는 shader에 유용합니다.)</p>



<p>Additional semantics supported by the fragment shader outputs are as follows.<br>(fragment shader 출력에서 지원하는 추가 의미론은 다음과 같습니다.)</p>



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



<h4 class="wp-block-heading">SV_TargetN: Multiple render targets</h4>



<p><code>SV_Target1</code>,&nbsp;<code>SV_Target2</code>, etc.: These are additional colors written by the shader. <br>(<code>SV_Target1</code>, <code>SV_Target2</code> 등은 쉐이더가 추가로 작성하는 색상 값입니다.)</p>



<p>This is used when rendering into more than one render target at once (known as the Multiple Render Targets rendering technique, or MRT).&nbsp;<code>SV_Target0</code>&nbsp;is the same as&nbsp;<code>SV_Target</code>.<br>(이는 한 번에 여러 렌더 타겟에 렌더링할 때 사용됩니다(MRT, Multiple Render Targets 렌더링 기술). <code>SV_Target0</code>은 <code>SV_Target</code>과 동일합니다.)</p>



<h4 class="wp-block-heading">SV_Depth: Pixel shader depth output</h4>



<p>Usually the fragment shader doesn’t override the Z buffer value, and a default value is used from the regular triangle&nbsp;<strong>rasterization</strong><br><strong><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/Glossary.html#Rasterization"></a></strong>. <br>(일반적으로 프래그먼트 shader는 Z 버퍼 값을 덮어쓰지 않으며, 기본 값은 일반적인 삼각형 래스터화에서 사용됩니다.)</p>



<p>However, for some effects it’s useful to output custom Z buffer depth values per pixel.<br>(그러나 일부 효과에서는 픽셀별로 사용자 정의 Z 버퍼 깊이 값을 출력하는 것이 유용할 수 있습니다.)</p>



<p>Note that on many GPUs this turns off some&nbsp;<strong>depth buffer</strong> optimizations, so don’t override Z buffer value without a good reason.<br>많은 GPU에서 이 작업을 수행하면 <strong>depth buffer</strong> 최적화가 비활성화될 수 있으므로, 특별한 이유 없이 Z 버퍼 값을 덮어쓰지 않는 것이 좋습니다.</p>



<p>The cost incurred by&nbsp;<code>SV_Depth</code>&nbsp;varies depending on the GPU architecture, but overall it’s fairly similar to the cost of alpha testing (using the built-in&nbsp;<code>clip()</code>&nbsp;function in HLSL).<br>(<code>SV_Depth</code>로 인한 비용은 GPU 아키텍처에 따라 다르지만, 대체로 알파 테스트(내장된 <code>clip()</code> 함수 사용)와 비슷한 비용을 가집니다.)</p>



<p>Render shaders that modify depth after all regular opaque shaders (for example, by using the&nbsp;<code>AlphaTest</code>&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SubShaderTags.html" target="_blank" rel="noreferrer noopener">rendering queue</a>.<br>(모든 일반 불투명 쉐이더 후에 깊이를 수정하는 렌더 쉐이더(예: <code>AlphaTest</code> <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SubShaderTags.html" target="_blank" rel="noreferrer noopener">렌더링 큐</a>를 사용하는 경우)에서 사용됩니다.)</p>



<p>The depth output value needs to be a single&nbsp;<code>float</code>.<br>(깊이 출력 값은 단일 <code>float</code> 값이어야 합니다.)</p>



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



<h3 class="wp-block-heading">Vertex shader outputs and fragment shader inputs<br>(Vertex shader 출력과 fragment shader 입력)</h3>



<p>A vertex shader needs to output the final clip space position of a vertex, so that the GPU knows where on the screen to rasterize it, and at what depth. <br>(vertex shader는 꼭지점의 최종 클립 공간 위치를 출력해야 하며, 그래야 GPU가 화면 어디에 그리며 어느 깊이에서 rasterize해야 할지 알 수 있습니다.)</p>



<p>This output needs to have the&nbsp;<code>SV_POSITION</code>&nbsp;semantic, and be of a&nbsp;<code>float4</code>&nbsp;type.<br>(이 출력 값은 SV_POSITION 의미론을 가져야 하며, float4 타입이어야 합니다.)</p>



<p>Any other outputs (“interpolators” or “varyings”) produced by the vertex shader are whatever your particular shader needs.<br>(vertex shader 생성되는 다른 출력들(“보간자” 또는 “변화값”)은 shader에서 필요한 값들입니다. )</p>



<p>The values output from the vertex shader will be interpolated across the face of the rendered triangles, and the values at each pixel will be passed as inputs to the fragment shader.<br>(vertex shader에서 출력된 값들은 렌더링된 삼각형 면 전체에 걸쳐 보간되며, 각 픽셀의 값들은 fragment shader로 입력됩니다.)</p>



<p>Many modern GPUs don’t really care what semantics these variables have; however some old systems (most notably, shader model 2 GPUs) did have special rules about the semantics:<br>(대부분의 최신 GPU는 이 변수들이 어떤 의미론을 가지는지 신경 쓰지 않습니다. 그러나 일부 구형 시스템(특히 shader 모델 2 GPU)은 의미론에 대한 특별한 규칙이 있었습니다.)</p>



<ul class="wp-block-list">
<li>&#8211; <code>TEXCOORD0</code>,&nbsp;<code>TEXCOORD1</code>&nbsp;etc are used to indicate arbitrary high precision data such as texture coordinates and positions.<br>(TEXCOORD0, TEXCOORD1 등은 텍스처 좌표나 위치와 같은 임의의 고정밀 데이터를 나타내는 데 사용됩니다.)</li>



<li>&#8211; <code>COLOR0</code>&nbsp;and&nbsp;<code>COLOR1</code>&nbsp;semantics on vertex outputs and fragment inputs are for low-precision, 0–1 range data (like simple color values).<br>(vertex 출력과 fragment 입력에서 COLOR0과 COLOR1 의미론은 저정밀도, 0–1 범위의 데이터를 나타내며, 간단한 색상 값과 같은 데이터를 다룹니다.)</li>
</ul>



<p>For best cross platform support, label vertex outputs and fragment inputs as&nbsp;<code>TEXCOORDn</code>&nbsp;semantics.<br>(최적의 플랫폼 호환성을 위해 버텍스 출력과 프래그먼트 입력은 TEXCOORDn 의미론으로 지정하는 것이 좋습니다.)</p>



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



<h4 class="wp-block-heading">Interpolator count limits (보간자 개수 제한)</h4>



<p>There are limits to how many interpolator variables can be used in total to pass the information from the vertex into the fragment shader.<br>(vertex에서 fragment shader로 정보를 전달하는 데 사용할 수 있는 보간자 변수의 총 개수에는 제한이 있습니다.)</p>



<p> The limit depends on the platform and GPU, and the general guidelines are:<br>(이 제한은 플랫폼과 GPU에 따라 다르며, 일반적인 가이드는 다음과 같습니다.)</p>



<ul class="wp-block-list">
<li><strong>&#8211; Up to 8 interpolators</strong>: <br>(최대 8개의 보간자: )<br>Direct3D 11 9.x level (Windows Phone) . Since the interpolator count is limited, but each interpolator can be a 4-component vector, some shaders pack things together to stay within limits. For example, you can pass two texture coordinates in one&nbsp;<code>float4</code>&nbsp;variable (.xy for one coordinate, .zw for the second coordinate).<br>(Direct3D 11 9.x 수준 (Windows Phone). 보간자 개수가 제한되어 있지만, 각 보간자는 4개의 구성 요소로 이루어진 벡터일 수 있기 때문에, 일부 쉐이더는 제한 내에서 값을 패킹합니다. 예를 들어, 두 개의 텍스처 좌표를 하나의 float4 변수(.xy는 첫 번째 좌표, .zw는 두 번째 좌표)로 전달할 수 있습니다.)</li>



<li><strong>&#8211; Up to 10 interpolators</strong>: Shader model 3.0 (<code>#pragma target 3.0</code>).<br>(최대 10개의 보간자: 쉐이더 모델 3.0 (#pragma target 3.0).)</li>



<li><strong>&#8211; Up to 16 interpolators</strong>: OpenGL ES 3.0 (Android), Metal (iOS).<br>(최대 16개의 보간자: OpenGL ES 3.0 (Android), Metal (iOS).)</li>



<li><strong>&#8211; Up to 32 interpolators</strong>: Direct3D 10 shader model 4.0 (<code>#pragma target 4.0</code>).<br>(최대 32개의 보간자: Direct3D 10 쉐이더 모델 4.0 (#pragma target 4.0).)</li>
</ul>



<p>Regardless of your particular target hardware, it’s generally a good idea to use as few interpolators as possible for performance reasons.<br>(목표 하드웨어와 관계없이 성능을 위해 보간자를 가능한 적게 사용하는 것이 좋습니다.)</p>



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



<h3 class="wp-block-heading">Other special semantics (기타 특수 의미론)</h3>



<h4 class="wp-block-heading">Screen space pixel position: VPOS<br>(스크린 공간 픽셀 위치: VPOS)</h4>



<p>A fragment shader can receive position of the pixel being rendered as a special&nbsp;<code>VPOS</code>&nbsp;semantic. <br>(fragment 쉐이더는 렌더링 중인 픽셀의 위치를 VPOS라는 특별한 의미론으로 받을 수 있습니다.)</p>



<p>This feature only exists starting with shader model 3.0, so the shader needs to have the&nbsp;<code>#pragma target 3.0</code>&nbsp;compilation directive.<br>(이 기능은 shader 모델 3.0부터 존재하므로, shader 는 #pragma target 3.0 컴파일 지시어가 필요합니다.)</p>



<p>On different platforms the underlying type of the screen space position input varies, so for maximum portability use the&nbsp;<code>UNITY_VPOS_TYPE</code>&nbsp;type for it, which is&nbsp;<code>float4</code>&nbsp;on most platforms.<br>(다른 플랫폼에서는 스크린 공간 위치 입력의 기본 타입이 다를 수 있으므로, 최대 호환성을 위해 대부분의 플랫폼에서 float4 타입인 UNITY_VPOS_TYPE을 사용하는 것이 좋습니다.)</p>



<p>Additionally, using the pixel position semantic makes it hard to have both the clip space position (SV_POSITION) and VPOS in the same vertex-to-fragment structure. <br>(또한 픽셀 위치 의미론을 사용하면 클립 공간 위치(SV_POSITION)와 VPOS를 동일한 vertex-to-fragmen 구조에서 함께 사용하는 것이 어려워집니다.)</p>



<p>Therefore, the vertex shader should output the clip space position as a separate “out” variable. See the example shader below:<br>(따라서 vertex shader는 클립 공간 위치를 별도의 “출력” 변수로 출력해야 합니다. 아래의 예제 쉐이더를 참조하십시오.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Unlit/Screen Position"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.0

            // note: no SV_POSITION in this struct
            struct v2f {
                float2 uv : TEXCOORD0;
            };

            v2f vert (
                float4 vertex : POSITION, // vertex position input
                float2 uv : TEXCOORD0, // texture coordinate input
                out float4 outpos : SV_POSITION // clip space position output
                )
            {
                v2f o;
                o.uv = uv;
                outpos = UnityObjectToClipPos(vertex);
                return o;
            }

            sampler2D _MainTex;

            fixed4 frag (v2f i, UNITY_VPOS_TYPE screenPos : VPOS) : SV_Target
            {
                // screenPos.xy will contain pixel integer coordinates.
                // use them to implement a checkerboard pattern that skips rendering
                // 4x4 blocks of pixels

                // checker value will be negative for 4x4 blocks of pixels
                // in a checkerboard pattern
                screenPos.xy = floor(screenPos.xy * 0.25) * 0.5;
                float checker = -frac(screenPos.r + screenPos.g);

                // clip HLSL instruction stops rendering a pixel if value is negative
                clip(checker);

                // for pixels that were kept, read the texture and output it
                fixed4 c = tex2D (_MainTex, i.uv);
                return c;
            }
            ENDCG
        }
    }
}</pre>



<figure class="wp-block-image size-full"><img decoding="async" width="394" height="292" src="https://lycos7560.com/wp-content/uploads/2024/09/image-1.png" alt="" class="wp-image-38240" srcset="https://lycos7560.com/wp-content/uploads/2024/09/image-1.png 394w, https://lycos7560.com/wp-content/uploads/2024/09/image-1-300x222.png 300w" sizes="(max-width: 394px) 100vw, 394px" /></figure>



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



<h4 class="wp-block-heading">Face orientation: VFACE (면 방향: VFACE)</h4>



<p>A fragment shader can receive a variable that indicates whether the rendered surface is facing the&nbsp;<strong>camera</strong>, or facing away from the camera.<br>(fragment shader는 렌더링된 표면이 카메라를 향하고 있는지, 아니면 카메라에서 멀어지고 있는지를 나타내는 변수를 받을 수 있습니다.) </p>



<p>This is useful when rendering geometry that should be visible from both sides – often used on leaves and similar thin objects.<br>(이는 잎사귀와 같은 얇은 객체에서 양면이 모두 보이게 렌더링해야 할 때 유용합니다.)</p>



<p>The&nbsp;<code>VFACE</code>&nbsp;semantic input variable will contain a positive value for front-facing triangles, and a negative value for back-facing ones.<br>(VFACE 의미론 입력 변수는 앞면을 향하는 삼각형에는 양의 값을, 뒷면을 향하는 삼각형에는 음의 값을 포함합니다.)</p>



<p>This feature only exists from shader model 3.0 onwards, so the shader needs to have the&nbsp;<code>#pragma target 3.0</code>&nbsp;compilation directive.<br>(이 기능은 쉐이더 모델 3.0부터 존재하므로, 쉐이더는 #pragma target 3.0 컴파일 지시어가 필요합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Unlit/Face Orientation"
{
    Properties
    {
        _ColorFront ("Front Color", Color) = (1,0.7,0.7,1)
        _ColorBack ("Back Color", Color) = (0.7,1,0.7,1)
    }
    SubShader
    {
        Pass
        {
            Cull Off // turn off backface culling

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.0

            float4 vert (float4 vertex : POSITION) : SV_POSITION
            {
                return UnityObjectToClipPos(vertex);
            }

            fixed4 _ColorFront;
            fixed4 _ColorBack;

            fixed4 frag (fixed facing : VFACE) : SV_Target
            {
                // VFACE input positive for frontbaces,
                // negative for backfaces. Output one
                // of the two colors depending on that.
                return facing > 0 ? _ColorFront : _ColorBack;
            }
            ENDCG
        }
    }
}</pre>



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



<p>The shader above uses the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Cull.html">Cull</a>&nbsp;state to disable back-face culling (by default back-facing triangles aren’t rendered at all). <br>(위의 shader 는 Cull 상태를 사용하여 후면 컬링을 비활성화합니다. 기본적으로 후면 삼각형은 전혀 렌더링되지 않습니다.)</p>



<p>Here is the shader applied to a bunch of&nbsp;<strong>Quad</strong>&nbsp;meshes, rotated at different orientations:<br>(다양한 방향으로 회전된 여러 개의 쿼드 메시들에 적용된 쉐이더는 다음과 같습니다:)</p>



<figure class="wp-block-image size-full"><img decoding="async" width="393" height="293" src="https://lycos7560.com/wp-content/uploads/2024/09/image-2.png" alt="" class="wp-image-38241" srcset="https://lycos7560.com/wp-content/uploads/2024/09/image-2.png 393w, https://lycos7560.com/wp-content/uploads/2024/09/image-2-300x224.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></figure>



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



<h4 class="wp-block-heading">Vertex ID: SV_VertexID (Vertex ID: SV_VertexID)</h4>



<p>A vertex shader can receive a variable that has the “vertex number” as an unsigned integer. <br>(정점 쉐이더는 &#8216;정점 번호&#8217;를 부호 없는 정수로 받을 수 있습니다.)</p>



<p>This is mostly useful when you want to fetch additional per-vertex data from textures or&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html" target="_blank" rel="noreferrer noopener">ComputeBuffers</a>.<br>(이는 주로 텍스처나 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-ComputeShader.html" target="_blank" rel="noreferrer noopener">ComputeBuffers</a>에서 추가적인 per-vertex data를 가져올 때 유용합니다.)</p>



<p>This feature only exists from DX10 (shader model 4.0) and GLCore / OpenGL ES 3, so the shader needs to have the&nbsp;<code>#pragma target 3.5</code>&nbsp;compilation directive.<br>(이 기능은 DX10(쉐이더 모델 4.0)과 GLCore/OpenGL ES 3부터 존재하므로, 쉐이더는 #pragma target 3.5 컴파일 지시어를 포함해야 합니다.)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "Unlit/VertexID"
{
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.5

            struct v2f {
                fixed4 color : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            v2f vert (
                float4 vertex : POSITION, // vertex position input
                uint vid : SV_VertexID // vertex ID, needs to be uint
                )
            {
                v2f o;
                o.pos = UnityObjectToClipPos(vertex);
                // output funky colors based on vertex ID
                float f = (float)vid;
                o.color = half4(sin(f/10),sin(f/100),sin(f/1000),0) * 0.5 + 0.5;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                return i.color;
            }
            ENDCG
        }
    }
}</pre>



<figure class="wp-block-image size-full"><img decoding="async" width="397" height="295" src="https://lycos7560.com/wp-content/uploads/2024/09/image-3.png" alt="" class="wp-image-38242" srcset="https://lycos7560.com/wp-content/uploads/2024/09/image-3.png 397w, https://lycos7560.com/wp-content/uploads/2024/09/image-3-300x223.png 300w" sizes="(max-width: 397px) 100vw, 397px" /></figure>



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



<h2 class="wp-block-heading">Accessing shader properties in Cg/HLSL<br>(Cg/HLSL에서 셰이더 속성 접근)</h2>



<p>Shader declares Material properties in a&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>&nbsp;block. <br>(Shader는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>&nbsp;블록에서 머티리얼 속성을 선언합니다. )</p>



<p>If you want to access some of those properties in a&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">shader program</a>, you need to declare a Cg/HLSL variable with the same name and a matching type.|<br>(shader program에서 해당 속성 중 일부에 접근하려면, 동일한 이름과 일치하는 타입을 가진 Cg/HLSL 변수를 선언해야 합니다. )</p>



<p>For example these&nbsp;<strong>shader</strong> properties:<br>(예를 들어, 이러한 <strong>shader</strong> 속성들 : )</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">_MyColor ("Some Color", Color) = (1,1,1,1) 
_MyVector ("Some Vector", Vector) = (0,0,0,0) 
_MyFloat ("My float", Float) = 0.5 
_MyTexture ("Texture", 2D) = "white" {} 
_MyCubemap ("Cubemap", CUBE) = "" {} </pre>



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



<p>would be declared for access in Cg/HLSL code as:<br>(Cg/HLSL 코드에서 다음과 같이 선언됩니다: )</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">fixed4 _MyColor; // low precision type is usually enough for colors (색상에는 일반적으로 낮은 정밀도의 타입이 충분)
float4 _MyVector;
float _MyFloat; 
sampler2D _MyTexture;
samplerCUBE _MyCubemap;</pre>



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



<p>Cg/HLSL can also accept&nbsp;<strong>uniform</strong>&nbsp;keyword, but it is not necessary:<br>(Cg/HLSL에서는 uniform 키워드를 사용할 수 있지만, 반드시 필요한 것은 아닙니다: )</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">uniform float4 _MyColor;</pre>



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



<p>Property types in&nbsp;<strong>ShaderLab</strong> map to Cg/HLSL variable types this way:</p>



<ul class="wp-block-list">
<li>&#8211; Color and Vector properties map to&nbsp;<strong>float4</strong>,&nbsp;<strong>half4</strong>&nbsp;or&nbsp;<strong>fixed4</strong>&nbsp;variables.<br>(Color와 Vector 속성은 float4, half4 또는 fixed4 변수에 매핑됩니다. )</li>



<li>&#8211; Range and Float properties map to&nbsp;<strong>float</strong>,&nbsp;<strong>half</strong>&nbsp;or&nbsp;<strong>fixed</strong>&nbsp;variables.<br>(Range와 Float 속성은 float, half 또는 fixed 변수에 매핑됩니다.)</li>



<li>&#8211; Texture properties map to&nbsp;<strong>sampler2D</strong>&nbsp;variables for regular (2D) textures;&nbsp;<strong>Cubemaps</strong> map to&nbsp;<strong>samplerCUBE</strong>; and 3D textures map to&nbsp;<strong>sampler3D</strong>.<br>(텍스처 속성은 일반 (2D) textures의 경우 <strong>sampler2D</strong>&nbsp;변수에, <strong>Cubemaps</strong>의 경우 <strong>samplerCUBE</strong>, 3D 텍스처는 <strong>sampler3D</strong>에 매핑됩니다. )</li>
</ul>



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



<h3 class="wp-block-heading">How property values are provided to shaders (속성 값이 shader에 제공되는 방법)</h3>



<p>Shader property values are found and provided to shaders from these places:<br>(셰이더 속성 값은 다음과 같은 경로로 셰이더에 전달됩니다: )</p>



<ul class="wp-block-list">
<li>&#8211; Per-Renderer values set in&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/MaterialPropertyBlock.html" target="_blank" rel="noreferrer noopener">MaterialPropertyBlock</a>. This is typically “per-instance” data (e.g. customized tint color for a lot of objects that all share the same material).<br><a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/MaterialPropertyBlock.html" target="_blank" rel="noreferrer noopener">MaterialPropertyBlock</a>에 설정된 렌더러별 값. 이는 일반적으로 “인스턴스별” 데이터입니다 (예: 동일한 머티리얼을 공유하는 여러 객체에 대한 맞춤형 색상).</li>



<li>&#8211; Values set in the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Material.html">Material</a> that’s used on the rendered object.<br>(렌더링된 객체에 사용된 머티리얼에 설정된 값. )</li>



<li>&#8211; Global shader properties, set either by Unity rendering code itself (see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-UnityShaderVariables.html">built-in shader variables</a>), or from your own&nbsp;<strong>scripts</strong> (e.g.&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Shader.SetGlobalTexture.html" target="_blank" rel="noreferrer noopener">Shader.SetGlobalTexture</a>).<br>전역 셰이더 속성은 Unity의 렌더링 코드에서 설정되거나(내장 셰이더 변수 참조), 스크립트에서 직접 설정됩니다(예: <a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Shader.SetGlobalTexture.html" target="_blank" rel="noreferrer noopener">Shader.SetGlobalTexture</a>).</li>
</ul>



<p>The order of precedence is like above: per-instance data overrides everything; then Material data is used; and finally if shader property does not exist in these two places then global property value is used. <br>(우선순위는 위와 같습니다: 인스턴스별 데이터가 모든 것을 덮어쓰며, 그다음으로 머티리얼 데이터가 사용됩니다. 이 두 곳에 shader 속성이 없으면 전역 속성 값이 사용됩니다.)</p>



<p>Finally, if there’s no shader property value defined anywhere, then “default” (zero for floats, black for colors, empty white texture for textures) value will be provided.<br>(마지막으로, 어느 곳에도 shader 속성이 정의되어 있지 않으면 “기본값”(float의 경우 0, 색상의 경우 검정, 텍스처의 경우 빈 흰색 텍스처)이 제공됩니다. )</p>



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



<h3 class="wp-block-heading">Serialized and Runtime Material properties <br>(직렬화된 머티리얼 속성과 런타임 머티리얼 속성)</h3>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Material.html" target="_blank" rel="noreferrer noopener">Materials</a>&nbsp;can contain both serialized and runtime-set property values.<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Material.html" target="_blank" rel="noreferrer noopener">Materials</a>은 직렬화된 값과 런타임에서 설정된 속성 값을 모두 포함할 수 있습니다. )</p>



<p>Serialized data is all the properties defined in shader’s&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>&nbsp;block.<br>(직렬화된 데이터는 셰이더의 Properties 블록에 정의된 모든 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>입니다.)</p>



<p>Typically these are values that need to be stored in the material, and are tweakable by the user in Material&nbsp;<strong>Inspector</strong>.<br>(일반적으로 이러한 값들은 material에 저장되어야 하며, Material <strong>Inspector</strong>에서 사용자가 조정할 수 있습니다.)</p>



<p>A material can also have some properties that are used by the shader, but not declared in shader’s&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>&nbsp;block.<br>material 에는 shader에서 사용되지만 shader의 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a> 블록에 선언되지 않은 속성도 있을 수 있습니다.</p>



<p>Typically this is for properties that are set from script code at runtime, e.g. via&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Material.SetColor.html" target="_blank" rel="noreferrer noopener">Material.SetColor</a>.<br>(이러한 속성은 일반적으로 런타임에서 스크립트 코드로 설정됩니다(예: &nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Material.SetColor.html" target="_blank" rel="noreferrer noopener">Material.SetColor</a>를 통해).)</p>



<p>Note that matrices and arrays can only exist as non-serialized runtime properties (since there’s no way to define them in Properties block).<br>(행렬과 배열은 Properties 블록에서 정의할 수 없기 때문에 <strong>직렬화되지 않은 런타임 속성으로만 존재</strong>할 수 있다는 점에 유의해야 합니다.)</p>



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



<h3 class="wp-block-heading">Special Texture properties (특수 텍스처 속성)</h3>



<p>For each texture that is setup as a shader/material property, Unity also sets up some extra information in additional vector properties.<br>(shader/material 속성으로 설정된 각 텍스처에 대해 Unity는 추가 벡터 속성에 추가 정보를 설정합니다.)</p>



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



<h4 class="wp-block-heading">Texture tiling &amp; offset (텍스처 타일링 및 오프셋)</h4>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Material.html" target="_blank" rel="noreferrer noopener">Materials</a>&nbsp;often have Tiling and Offset fields for their texture properties.<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Material.html" target="_blank" rel="noreferrer noopener">Materials</a>은 종종 텍스처 속성에 대해 타일링 및 오프셋 필드를 가집니다.)</p>



<p>This information is passed into shaders in a float4&nbsp;<em>{TextureName}</em><code>_ST</code>&nbsp;property:<br>(이 정보는 float4 {TextureName}_ST 속성으로 shaders에 전달됩니다.)</p>



<ul class="wp-block-list">
<li>&#8211; <code>x</code>&nbsp;contains X tiling value (x는 X 타일링 값을 포함합니다)</li>



<li>&#8211; <code>y</code>&nbsp;contains Y tiling value (y는 Y 타일링 값을 포함합니다)</li>



<li>&#8211; <code>z</code>&nbsp;contains X offset value (z는 X 오프셋 값을 포함합니다)</li>



<li>&#8211; <code>w</code>&nbsp;contains Y offset value (w는 Y 오프셋 값을 포함합니다)</li>
</ul>



<p>For example, if a shader contains texture named&nbsp;<code>_MainTex</code>, the tiling information will be in a&nbsp;<code>_MainTex_ST</code>&nbsp;vector.<br>(예를 들어, shader에 _MainTex라는 텍스처가 있을 경우, 타일링 정보는 _MainTex_ST 벡터에 포함됩니다.)</p>



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



<h4 class="wp-block-heading">Texture size (텍스처 크기)</h4>



<p><em>{TextureName}</em><code>_TexelSize</code>&nbsp;&#8211; a float4 property contains texture size information:<br>({TextureName}_TexelSize &#8211; float4 속성은 텍스처 크기 정보를 포함합니다 : )</p>



<ul class="wp-block-list">
<li>&#8211; <code>x</code>&nbsp;contains 1.0/width (x는 1.0/너비 값을 포함합니다)</li>



<li>&#8211; <code>y</code>&nbsp;contains 1.0/height (y는 1.0/높이 값을 포함합니다)</li>



<li>&#8211; <code>z</code>&nbsp;contains width (z는 너비를 포함합니다)</li>



<li>&#8211; <code>w</code>&nbsp;contains height (w는 높이를 포함합니다)</li>
</ul>



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



<h4 class="wp-block-heading">Texture HDR parameters (Texture HDR 매개변수)</h4>



<p><em>{TextureName}</em><code>_HDR</code>&nbsp;&#8211; a float4 property with information on how to decode a potentially&nbsp;<strong>HDR</strong> (e.g. RGBM-encoded) texture depending on the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/LinearLighting.html">color space</a>&nbsp;used.<br>({TextureName}_HDR &#8211; 사용된 색 공간에 따라 HDR (예: RGBM 인코딩된) 텍스처를 디코딩하는 방법에 대한 정보를 포함하는 float4 속성입니다.)</p>



<p>See&nbsp;<code>DecodeHDR</code>&nbsp;function in&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html" target="_blank" rel="noreferrer noopener">UnityCG.cginc</a>&nbsp;shader include file.<br>(자세한 내용은<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html" target="_blank" rel="noreferrer noopener">UnityCG.cginc</a>&nbsp;shader 포함 파일의 DecodeHDR 함수를 참조하세요.)</p>



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



<h4 class="wp-block-heading">Color spaces and color/vector shader data (색 공간 및 색상/벡터 shader 데이터)</h4>



<p>When using&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/LinearLighting.html" target="_blank" rel="noreferrer noopener">Linear color space</a>, all material color properties are supplied as sRGB colors, but are converted into linear values when passed into shaders.<br>(&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/LinearLighting.html" target="_blank" rel="noreferrer noopener">Linear color space</a>을 사용할 때, 모든 Material 색상 속성은 sRGB 색상으로 제공되며, shader로 전달될 때 선형 값으로 변환됩니다.)</p>



<p>For example, if your&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html">Properties</a>&nbsp;shader block contains a&nbsp;<code>Color</code>&nbsp;property called “<em>MyColor“, then the corresponding ”</em>MyColor” HLSL variable will get the linear color value.<br>(예를 들어, Properties 셰이더 블록에 “MyColor”라는 Color 속성이 있으면, 해당 “MyColor” HLSL 변수는 선형 색상 값을 받게 됩니다.)</p>



<p>For properties that are marked as&nbsp;<code>Float</code>&nbsp;or&nbsp;<code>Vector</code>&nbsp;type, no color space conversions are done by default; it is assumed that they contain non-color data.<br>(Float 또는 Vector 타입으로 표시된 속성의 경우 기본적으로 색 공간 변환이 수행되지 않으며, 이들은 색상 데이터가 아닌 것으로 간주됩니다.)</p>



<p>It is possible to add&nbsp;<code>[Gamma]</code>&nbsp;attribute for float/vector properties to indicate that they are specified in sRGB space, just like colors (see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a>).<br>(색상과 마찬가지로 float/vector 속성이 sRGB 공간에서 지정된다는 것을 나타내기 위해 [Gamma] 속성을 추가할 수 있습니다 (<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">Properties</a> 참조).)</p>



<h4 class="wp-block-heading">See Also (참고)</h4>



<ul class="wp-block-list">
<li><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">ShaderLab Properties block</a>. (<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-Properties.html" target="_blank" rel="noreferrer noopener">ShaderLab Properties 블록</a>.)</li>



<li><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">Writing Shader Programs</a>. (<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">셰이더 프로그램 작성하기</a>.)</li>
</ul>



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



<h2 class="wp-block-heading">Providing vertex data to vertex programs (버텍스 프로그램에 버텍스 데이터 제공)</h2>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-VertexProgramInputs.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/2023.2/Documentation/Manual/SL-VertexProgramInputs.html</a></p>



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



<p>For Cg/HLSL&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">vertex program</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html">s</a>, the&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Mesh.html" target="_blank" rel="noreferrer noopener">Mesh</a> vertex data is passed as inputs to the vertex shader function.<br>Cg/HLSL <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">vertex programs</a>에서는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/class-Mesh.html" target="_blank" rel="noreferrer noopener">Mesh</a> 버텍스 데이터가  vertex shader 함수의 입력으로 전달됩니다.</p>



<p>Each input needs to have a&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderSemantics.html">semantic</a>&nbsp;specified for it: for example,&nbsp;<code>POSITION</code>&nbsp;input is the vertex position, and&nbsp;<code>NORMAL</code>&nbsp;is the vertex normal.<br>(각 입력에는 의미(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderSemantics.html">semantic</a>)가 지정되어야 합니다. 예를 들어, POSITION 입력은 vertex 위치이고, NORMAL은 vertex 노멀입니다.)</p>



<p>Often, vertex data inputs are declared in a structure, instead of listing them one by one.<br>(종종 vertex 데이터 입력은 하나씩 나열하는 대신 구조체로 선언됩니다.)</p>



<p>Several commonly used vertex structures are defined in&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html" target="_blank" rel="noreferrer noopener">UnityCG.cginc include file</a>, and in most cases it’s enough just to use those. The structures are:<br>(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html" target="_blank" rel="noreferrer noopener">UnityCG.cginc include file</a>에 여러 가지 일반적으로 사용되는 버텍스 구조체가 정의되어 있으며, 대부분의 경우 이를 사용하는 것 만으로충분합니다. 이 구조체들은 다음과 같습니다 : )</p>



<ul class="wp-block-list">
<li>&#8211; <code>appdata_base</code>: position, normal and one texture coordinate. (위치, 노멀 및 하나의 텍스처 좌표.)</li>



<li>&#8211; <code>appdata_tan</code>: position, tangent, normal and one texture coordinate. (위치, 탄젠트, 노멀 및 하나의 텍스처 좌표.)</li>



<li>&#8211; <code>appdata_full</code>: position, tangent, normal, four texture coordinates and color. (위치, 탄젠트, 노멀, 네 개의 텍스처 좌표 및 색상.)</li>
</ul>



<p><strong>Example:</strong>&nbsp;This&nbsp;<strong>shader</strong> colors the mesh based on its normals, and uses&nbsp;<code>appdata_base</code>&nbsp;as vertex program input:<br>(<strong>예시</strong>: 이 <strong>shader</strong>는 노멀에 기반하여 메시에 색상을 입히며, appdata_base를 버텍스 프로그램 입력으로 사용합니다 : )</p>



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



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Shader "VertexInputSimple" {
    SubShader {
        Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
         
            struct v2f {
                float4 pos : SV_POSITION;
                fixed4 color : COLOR;
            };
            
            v2f vert (appdata_base v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.color.xyz = v.normal * 0.5 + 0.5;
                o.color.w = 1.0;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target { return i.color; }
            ENDCG
        }
    } 
}</pre>



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



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



<p>To access different vertex data, you need to declare the vertex structure yourself, or add input parameters to the vertex shader. <br>(다른 버텍스 데이터에 접근하려면, 직접 버텍스 구조체를 선언하거나 버텍스 shader에 입력 파라미터를 추가해야 합니다.)</p>



<p>Vertex data is identified by Cg/HLSL&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderSemantics.html" target="_blank" rel="noreferrer noopener">semantics</a>, and must be from the following list:<br>(버텍스 데이터는 Cg/HLSL 의미(<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderSemantics.html">semantics</a>)에 의해 식별되며, 다음 목록 중 하나여야 합니다 : )</p>



<ul class="wp-block-list">
<li>&#8211; <code>POSITION</code>&nbsp;is the vertex position, typically a&nbsp;<code>float3</code>&nbsp;or&nbsp;<code>float4</code>. (POSITION은 버텍스 위치로, 일반적으로 float3 또는 float4입니다.)</li>



<li>&#8211; <code>NORMAL</code>&nbsp;is the vertex normal, typically a&nbsp;<code>float3</code>. (NORMAL은 버텍스 노멀로, 일반적으로 float3입니다.)</li>



<li>&#8211; <code>TEXCOORD0</code>&nbsp;is the first UV coordinate, typically&nbsp;<code>float2</code>,&nbsp;<code>float3</code>&nbsp;or&nbsp;<code>float4</code>. (TEXCOORD0은 첫 번째 UV 좌표로, 일반적으로 float2, float3 또는 float4입니다.)</li>



<li>&#8211; <code>TEXCOORD1</code>,&nbsp;<code>TEXCOORD2</code>&nbsp;and&nbsp;<code>TEXCOORD3</code>&nbsp;are the 2nd, 3rd and 4th UV coordinates, respectively. (TEXCOORD1, TEXCOORD2 및 TEXCOORD3는 각각 두 번째, 세 번째, 네 번째 UV 좌표입니다.)</li>



<li>&#8211; <code>TANGENT</code>&nbsp;is the tangent vector (used for normal mapping), typically a&nbsp;<code>float4</code>. (TANGENT는 탄젠트 벡터(노멀 맵핑에 사용되며), 일반적으로 float4입니다.)</li>



<li>&#8211; <code>COLOR</code>&nbsp;is the per-vertex color, typically a&nbsp;<code>float4</code>. (COLOR는 버텍스당 색상으로, 일반적으로 float4입니다.)</li>
</ul>



<p>When the mesh data contains fewer components than are needed by the vertex shader input, the rest are filled with zeroes, except for the&nbsp;<code>.w</code>&nbsp;component which defaults to 1. <br>(메시 데이터가 vertex shader 입력에서 요구하는 구성 요소보다 적은 경우, 나머지는 0으로 채워지며,  .w 구성 요소는 기본적으로 1이 됩니다.)</p>



<p>For example, mesh texture coordinates are often 2D vectors with just x and y components. <br>(예를 들어, 메시의 텍스처 좌표는 종종 x와 y 구성 요소만 있는 2D 벡터입니다.)</p>



<p>If a vertex shader declares a&nbsp;<code>float4</code>&nbsp;input with&nbsp;<code>TEXCOORD0</code>&nbsp;semantic, the value received by the&nbsp;<strong>vertex shader</strong> will contain (x,y,0,1).<br>(만약 <strong>vertex shader</strong>가 TEXCOORD0 의미로 float4 입력을 선언하면, <strong>vertex shader</strong>가 받는 값은 (x, y, 0, 1)이 됩니다.)</p>



<p>For examples of using these techniques to visualize vertex data in the Built-in&nbsp;<strong>Render Pipeline</strong>, see&nbsp;<a href="https://docs.unity3d.com/2023.2/Documentation/Manual/built-in-shader-examples-vertex-data.html" target="_blank" rel="noreferrer noopener">Visualizing vertex data</a>.<br>(이 기술을 사용하여 기본 렌더 파이프라인에서 버텍스 데이터를 시각화하는 예시는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/built-in-shader-examples-vertex-data.html" target="_blank" rel="noreferrer noopener">Visualizing vertex data</a>&#8220;를 참조하십시오.)</p>



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



<h2 class="wp-block-heading">Built-in shader include files </h2>



<p><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinIncludes.html</a></p>



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



<p>Unity contains several files that can be used by your <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">shader programs</a> to bring in predefined variables and helper functions. <br>(Unity에는 미리 정의된 변수와 헬퍼 함수들을 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-ShaderPrograms.html" target="_blank" rel="noreferrer noopener">shader programs</a>에서 사용할 수 있도록 하는 여러 파일이 포함되어 있습니다.)</p>



<p>This is done by the standard <code>#include</code> directive, e.g.:<br>(이는 표준 #include 지시어를 사용하여 실행됩니다. 예를 들어 : )</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">CGPROGRAM
// ...
#include "UnityCG.cginc"
// ...
ENDCG
</pre>



<p>Shader include files in Unity are with <code>.cginc</code> extension, and the built-in ones are:<br>(Unity의 셰이더 인클루드 파일은 .cginc 확장자를 가지며, 내장된 파일들은 다음과 같습니다:)</p>



<ul class="wp-block-list">
<li>&#8211; <code>HLSLSupport.cginc</code> &#8211; <em>(automatically included)</em> Helper macros and definitions for cross-platform <strong>shader</strong> compilation.<br>(자동으로 포함) 크로스 플랫폼 shader 컴파일을 위한 헬퍼 매크로 및 정의.)</li>



<li>&#8211; <code>UnityShaderVariables.cginc</code> &#8211; <em>(automatically included)</em> Commonly used global variables.<br>((자동으로 포함) 일반적으로 사용되는 전역 변수.)</li>



<li>&#8211; <code>UnityCG.cginc</code> &#8211; commonly used <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinFunctions.html" target="_blank" rel="noreferrer noopener">helper functions</a>.<br>(일반적으로 사용되는 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinFunctions.html" target="_blank" rel="noreferrer noopener">helper functions</a>.)</li>



<li>&#8211; <code>AutoLight.cginc</code> &#8211; lighting &amp; shadowing functionality, e.g. <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html">surface shaders</a> use this file internally.<br>(조명 및 그림자 기능, 예를 들어 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html">surface shaders</a>는 이 파일을 내부적으로 사용합니다.)</li>



<li>&#8211; <code>Lighting.cginc</code> &#8211; standard <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">surfa</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html">ce shader</a> lighting models; automatically included when you’re writing surface shaders.<br>(표준 서피스 셰이더 조명 모델; <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">surfa</a><a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-SurfaceShaders.html">ce shader</a>를 작성할 때 자동으로 포함됩니다.)</li>



<li>&#8211; <code>TerrainEngine.cginc</code> &#8211; helper functions for <strong>Terrain</strong> &amp; Vegetation shaders.<br>(지형 및 식물 shader 헬퍼 함수.)</li>
</ul>



<p>These files are found inside Unity application (<strong>{unity install path}/Data/CGIncludes/UnityCG.cginc</strong> on Windows, <strong>/Applications/Unity/Unity.app/Contents/CGIncludes/UnityCG.cginc</strong> on Mac), if you want to take a look at what exactly is done in any of the helper code.<br>(이 파일들은 Unity 애플리케이션 내부에서 찾을 수 있습니다 ({유니티 설치 경로}/Data/CGIncludes/UnityCG.cginc, Windows의 경우 /Applications/Unity/Unity.app/Contents/CGIncludes/UnityCG.cginc, Mac의 경우). 필요한 경우 헬퍼 코드에서 실제로 수행되는 작업을 확인할 수 있습니다.)</p>



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



<h3 class="wp-block-heading">HLSLSupport.cginc</h3>



<p>This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). <br>(이 파일은 CGPROGRAM 셰이더를 컴파일할 때 자동으로 포함되며, HLSLPROGRAM에는 포함되지 않습니다.)</p>



<p>It declares various <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinMacros.html" target="_blank" rel="noreferrer noopener">preprocessor macros</a> to aid in multi-platform shader development.<br>(멀티 플랫폼 shader 개발을 돕기 위한 여러 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinMacros.html" target="_blank" rel="noreferrer noopener">preprocessor macros</a>을 선언합니다.)</p>



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



<h3 class="wp-block-heading">UnityShaderVariables.cginc</h3>



<p>This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). <br>(이 파일은 CGPROGRAM shader를 컴파일할 때 자동으로 포함되며, HLSLPROGRAM에는 포함되지 않습니다.)</p>



<p>It declares various <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-UnityShaderVariables.html">built-in global variables</a> that are commonly used in shaders.<br>(shader에서 일반적으로 사용되는 다양한 내장 전역 변수를 선언합니다.)</p>



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



<h3 class="wp-block-heading">UnityCG.cginc</h3>



<p>This file is often included in <strong>Shader objects</strong>. <br>(이 파일은 <strong>Shader objects</strong>에 자주 포함됩니다.)</p>



<p>It declares many <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinFunctions.html" target="_blank" rel="noreferrer noopener">built-in helper functions</a> and data structures.<br>(많은 <a href="https://docs.unity3d.com/2023.2/Documentation/Manual/SL-BuiltinFunctions.html" target="_blank" rel="noreferrer noopener">built-in helper functions</a>와 데이터 구조를 선언합니다.)</p>



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



<h4 class="wp-block-heading">Data structures in UnityCG.cginc (UnityCG.cginc의 데이터 구조)</h4>



<ul class="wp-block-list">
<li>struct <code>appdata_base</code>: <strong>vertex shader</strong> input with position, normal, one texture coordinate. (위치, 법선, 하나의 텍스처 좌표를 가진 버텍스 셰이더 입력..)</li>



<li>struct <code>appdata_tan</code>: vertex shader input with position, normal, tangent, one texture coordinate. (위치, 법선, 탄젠트, 하나의 텍스처 좌표를 가진 버텍스 셰이더 입력.)</li>



<li>struct <code>appdata_full</code>: vertex shader input with position, normal, tangent, vertex color and two texture coordinates. (위치, 법선, 탄젠트, 버텍스 색상 및 두 개의 텍스처 좌표를 가진 버텍스 셰이더 입력.)</li>



<li>struct <code>appdata_img</code>: vertex shader input with position and one texture coordinate. (위치와 하나의 텍스처 좌표를 가진 버텍스 셰이더 입력.)</li>
</ul>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>
<p>The post <a href="https://lycos7560.com/unity/write-hlsl-shader-in-unity-urp_qwer/38216/">Write HLSL Shader in Unity (URP)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/write-hlsl-shader-in-unity-urp_qwer/38216/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>빛의 성질 &#8211; 요약</title>
		<link>https://lycos7560.com/etc/%eb%b9%9b%ec%9d%98-%ec%84%b1%ec%a7%88-%ec%9a%94%ec%95%bd/37972/</link>
					<comments>https://lycos7560.com/etc/%eb%b9%9b%ec%9d%98-%ec%84%b1%ec%a7%88-%ec%9a%94%ec%95%bd/37972/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 16 Feb 2024 21:17:29 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[Absorption]]></category>
		<category><![CDATA[Interference]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Refraction]]></category>
		<category><![CDATA[Scattering]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[the nature of light]]></category>
		<category><![CDATA[Transmission]]></category>
		<category><![CDATA[URP]]></category>
		<category><![CDATA[간섭]]></category>
		<category><![CDATA[간섭(Interference)]]></category>
		<category><![CDATA[굴절]]></category>
		<category><![CDATA[굴절(Refraction)]]></category>
		<category><![CDATA[그래픽]]></category>
		<category><![CDATA[반사]]></category>
		<category><![CDATA[반사(Reflection)]]></category>
		<category><![CDATA[빛의 성질]]></category>
		<category><![CDATA[산란]]></category>
		<category><![CDATA[산란(Scattering)]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[요약]]></category>
		<category><![CDATA[투과]]></category>
		<category><![CDATA[투과(Transmission)]]></category>
		<category><![CDATA[파동]]></category>
		<category><![CDATA[파장]]></category>
		<category><![CDATA[회절]]></category>
		<category><![CDATA[회절(Refraction)]]></category>
		<category><![CDATA[흡수]]></category>
		<category><![CDATA[흡수(Absorption)]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=37972</guid>

					<description><![CDATA[<p>빛의 성질 빛은 여러가지 성질을 가지고 있다. 가장 대표적인 성질은 직진하는 성질이다. 매질이 없는 진공 또는 투명한 매질을 통과할 경우 직진한다. 빛이 다른 무언가와 부딪치면 정반사(Specular Reflection) / 난반사(Diffuse Reflection) &#8211; 반사(Reflection) 굴절(Refraction)과 투과(Transmission) 굴절(Refraction) 물체를 통과하는 빛은 일반적으로 직선으로 이동하는 것이 아니라, 물체의 경계면을 통과할 때 굴절(Refraction) 현상이 일어납니다. 위와 같은 현상은 빛이 한 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/%eb%b9%9b%ec%9d%98-%ec%84%b1%ec%a7%88-%ec%9a%94%ec%95%bd/37972/">빛의 성질 &#8211; 요약</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



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



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex" style="border-width:1px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<div class="wp-block-uagb-advanced-heading uagb-block-afcbccbb"><h2 class="uagb-heading-text">빛의 성질</h2></div>



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



<p>빛은 여러가지 성질을 가지고 있다. </p>



<p>가장 대표적인 성질은 <strong>직진하는 성질</strong>이다.</p>



<p>매질이 없는 진공 또는 투명한 매질을 통과할 경우 직진한다.</p>



<p>빛이 다른 무언가와 부딪치면 </p>



<ul class="wp-block-list">
<li>반사(Reflection) : 빛이 표면과 부딪혔을 때, 표면에서 특정 각도로 반사되는 현상</li>



<li>굴절(Refraction) : 빛이 한 매질에서 다른 매질로 옮겨갈 때, 빛의 속도가 달라지면서 방향이 바뀌는 현상</li>



<li>투과(Transmission) : 빛이 투명한 매체를 통과하며 진행하는 현상으로, 투과된 빛은 매체를 통과한 후 계속 이동</li>



<li>산란(Scattering) : 빛이 표면이나 매질의 불순물과 상호 작용하여 여러 방향으로 흩어지는 현상</li>



<li>흡수(Absorption) : 빛이 물질에 흡수되어 일부 또는 전체적으로 에너지로 전환되는 현상</li>



<li>간섭(Interference): 두 개 이상의 빛 파동이 만나서 서로 상호 작용할 때 나타나는 현상으로, 파동의 합이 강화되거나 약화되는 현상</li>



<li>회절(Refraction): 빛이 물체의 경계면을 통과할 때 파동의 속도가 변함에 따라 방향이 바뀌는 현상</li>
</ul>



<div class="wp-block-uagb-container uagb-block-7215f155 default uagb-is-root-container">
<div class="wp-block-uagb-container uagb-block-ae5ae1b4">
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="816" height="452" src="https://lycos7560.com/wp-content/uploads/2024/03/image-3.png" alt="" class="wp-image-37952" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-3.png 816w, https://lycos7560.com/wp-content/uploads/2024/03/image-3-300x166.png 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-3-768x425.png 768w" sizes="(max-width: 816px) 100vw, 816px" /><figcaption class="wp-element-caption"><a href="https://www.chemi-in.com/605" target="_blank" rel="noreferrer noopener">https://www.chemi-in.com/605</a></figcaption></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image aligncenter size-full is-resized"><img decoding="async" width="551" height="349" src="https://lycos7560.com/wp-content/uploads/2024/03/image-4.png" alt="" class="wp-image-37956" style="width:615px;height:auto" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-4.png 551w, https://lycos7560.com/wp-content/uploads/2024/03/image-4-300x190.png 300w" sizes="(max-width: 551px) 100vw, 551px" /><figcaption class="wp-element-caption"><a href="https://blog.signifykorea.com/?p=10761" target="_blank" rel="noreferrer noopener">https://blog.signifykorea.com/?p=10761</a></figcaption></figure>
</div>
</div>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="border-width:1px;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)">
<p class="has-medium-font-size"><strong>정반사(Specular Reflection)</strong> / <strong>난반사(Diffuse Reflection)</strong> &#8211; <strong>반사(Reflection)</strong></p>



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



<figure class="wp-block-image alignleft size-full"><img decoding="async" width="756" height="296" src="https://lycos7560.com/wp-content/uploads/2024/03/image-5.png" alt="" class="wp-image-37957" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-5.png 756w, https://lycos7560.com/wp-content/uploads/2024/03/image-5-300x117.png 300w" sizes="(max-width: 756px) 100vw, 756px" /><figcaption class="wp-element-caption"><a href="https://commons.wikimedia.org/wiki/File:Specular_v_Diffuse_reflection.png" target="_blank" rel="noreferrer noopener">https://commons.wikimedia.org/wiki/File:Specular_v_Diffuse_reflection.png</a></figcaption></figure>



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



<ul class="wp-block-list">
<li><strong>정반사(Regular Reflection)</strong><br>정반사는 표면이 매우 매끄럽고 평평한 경우 발생<br>이 때, 빛은 표면과 수직인 방향으로 반사됩니다. <br>거울이나 유리와 같이 매우 매끄러운 표면에서 주로 나타납니다.</li>
</ul>



<ul class="wp-block-list">
<li><strong>난반사(Diffuse Reflection)</strong><br>난반사는 표면이 거친 경우나 불규칙한 표면에서 발생합니다. <br>이 때, 반사된 빛은 여러 방향으로 흩어집니다. <br>벽, 종이, 나무 등의 표면에서 주로 나타납니다.</li>
</ul>
</div>
</div>



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



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="border-width:1px;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)">
<p class="has-medium-font-size"><strong>굴절(Refraction)과 투과(Transmission)</strong></p>



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



<p class="has-medium-font-size"><strong>굴절(Refraction)</strong></p>



<p>물체를 통과하는 빛은 일반적으로 직선으로 이동하는 것이 아니라, 물체의 경계면을 통과할 때 굴절(Refraction) 현상이 일어납니다.</p>



<p>위와 같은 현상은 빛이 한 매질에서 다른 매질로 옮겨갈 때 빛의 속도가 달라지면서 발생합니다.</p>



<p>빛의 속도가 다른 매질로 옮겨갈 때, 빛은 특정 각도로 바뀌어 이동합니다. </p>



<p>이때 빛의 파장은 그대로 유지되지만, 진행 방향이 바뀌게 됩니다.</p>



<p>예를 들어, 빛이 물체에서 공기로 옮겨갈 때는 <strong>경계면을 통과할 때 빛의 속도가 증가하게 되어 굴절각이 작아지게 됩니다.</strong> </p>



<p>반대로, 빛이 공기에서 유리 등의 <strong>밀도가 높은 매질로 옮겨갈 때는 굴절각이 커지게 됩니다.</strong></p>



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



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img decoding="async" width="1574" height="1154" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6.jpg" alt="" class="wp-image-37961" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6.jpg 1574w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-300x220.jpg 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-768x563.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-1536x1126.jpg 1536w" sizes="(max-width: 1574px) 100vw, 1574px" /><figcaption class="wp-element-caption"><a href="https://www.britannica.com/science/refraction" target="_blank" rel="noreferrer noopener">https://www.britannica.com/science/refraction</a></figcaption></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img decoding="async" width="1119" height="740" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6-1.jpg" alt="" class="wp-image-37962" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6-1.jpg 1119w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-1-300x198.jpg 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-1-768x508.jpg 768w" sizes="(max-width: 1119px) 100vw, 1119px" /><figcaption class="wp-element-caption"><a href="https://en.wikipedia.org/wiki/Refraction" target="_blank" rel="noreferrer noopener">https://en.wikipedia.org/wiki/Refraction</a></figcaption></figure>
</div>
</div>



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



<p>빛은 파동과 입자의 성질을 동시에 가지고 있는데 굴절은 파동의 특성에 의해서 발생합니다.</p>



<p><a href="https://www.microscopyu.com/tutorials/refraction" target="_blank" rel="noreferrer noopener">https://www.microscopyu.com/tutorials/refraction</a></p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="520" height="394" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6.png" alt="" class="wp-image-37970" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6.png 520w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-300x227.png 300w" sizes="(max-width: 520px) 100vw, 520px" /></figure>



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



<p class="has-medium-font-size"><strong>투과(Transmission)</strong></p>



<p>빛이 투명한 매체를 통과하여 이동하는 현상을 의미합니다. </p>



<p>즉, 빛이 매질을 통과한 후 계속 진행되는 것을 말합니다. </p>



<p>투과된 빛은 매체를 통과한 후에도 에너지를 가지고 있어 이동을 계속합니다. </p>



<p>예를 들어, 유리, 공기, 물 등의 투명한 매체를 통과하는 빛은 투과된 빛입니다. </p>



<p>이는 투과된 빛이 매질의 내부에서 계속 이동하고 있음을 나타냅니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="825" height="490" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6-2.jpg" alt="" class="wp-image-37964" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6-2.jpg 825w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-2-300x178.jpg 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-2-768x456.jpg 768w" sizes="(max-width: 825px) 100vw, 825px" /><figcaption class="wp-element-caption"><a href="https://gamma-sci.com/2021/08/16/light-transmission-in-the-ocean-and-other-bodies-of-water/" target="_blank" rel="noreferrer noopener">https://gamma-sci.com/2021/08/16/light-transmission-in-the-ocean-and-other-bodies-of-water/</a></figcaption></figure>
</div>
</div>



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



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="border-width:1px;padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)">
<p class="has-medium-font-size"><strong>산란(Scattering)과 흡수(Absorption)</strong></p>



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



<p class="has-medium-font-size"><strong>산란(Scattering)</strong></p>



<p>산란(Scattering)은 빛이 표면이나 매질의 불순물과 상호 작용하여 여러 방향으로 흩어지는 현상을 의미합니다.</p>



<p>이는 불순물의 크기가 빛의 파장과 비슷한 크기일 때 특히 뚜렷하게 나타납니다. </p>



<p>산란은 물체를 통과할 때 발생할 수 있으며, 특정 방향으로 진행하는 빛이 여러 방향으로 흩어지기 때문에 빛의 진행 경로가 무작위로 바뀝니다. </p>



<p>대기 중의 먼지나 연기와 같은 입자들에 의해 발생하는 태양빛의 산란은 하늘의 푸른 색상을 만들어내는데 중요한 역할을 합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="710" height="1020" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6-3.jpg" alt="" class="wp-image-37965" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6-3.jpg 710w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-3-209x300.jpg 209w" sizes="(max-width: 710px) 100vw, 710px" /><figcaption class="wp-element-caption"><a href="https://www.color-meanings.com/why-is-the-sky-blue/" target="_blank" rel="noreferrer noopener">https://www.color-meanings.com/why-is-the-sky-blue/</a></figcaption></figure>



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



<p>따뜻한 색은 파장이 길어서 적게 산란되어 지표면에 쉽게 도달하는 반면, 대기의 공기 분자는 파장이 짧은 빛(높은 주파수)인 푸른색을 더 많이 산란시킵니다. </p>



<p>이러한 이유로 정오의 하늘이 파란색으로 보입니다.</p>



<p>노을이나 일몰 시에는 태양이 지평선 아래로 가려지면서 더 긴 파장의 빛이 더 쉽게 통과합니다. </p>



<p>태양 광선이 지평선을 통과하는 동안 지표면을 통과하는 거리가 늘어나면서, 대기를 통과하는 빛은 더 많은 산란을 겪게 됩니다. </p>



<p>이에 따라 주로 긴 파장의 색상인 주황색과 붉은색이 우세해져서 노을이 붉게 보입니다.</p>



<p>공기 중의 미세먼지, 구름, 연기, 물 속의 부유물과 같은 입자들의 산란은 빛의 파장과 무관하게 주로 흰색으로 산란됩니다. </p>



<p>이는 입자들의 크기가 빛의 파장보다 훨씬 크기 때문에 발생하며, 결과적으로 모든 색상의 빛이 균일하게 흩어지게 됩니다. </p>



<p>이러한 현상은 주로 하얀색 빛을 만들어냅니다.</p>



<figure class="wp-block-image size-medium is-resized"><img decoding="async" width="300" height="199" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6-4-300x199.jpg" alt="" class="wp-image-37966" style="width:403px;height:auto" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6-4-300x199.jpg 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-4-768x508.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-4.jpg 1313w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption class="wp-element-caption"><strong>레일리 산란</strong>(Rayleigh scattering) <br><a href="https://ko.wikipedia.org/wiki/%EB%A0%88%EC%9D%BC%EB%A6%AC_%EC%82%B0%EB%9E%80" target="_blank" rel="noreferrer noopener">https://ko.wikipedia.org/wiki/%EB%A0%88%EC%9D%BC%EB%A6%AC_%EC%82%B0%EB%9E%80</a></figcaption></figure>



<figure class="wp-block-image size-medium is-resized"><img decoding="async" width="300" height="147" src="https://lycos7560.com/wp-content/uploads/2024/03/image-6-5-300x147.jpg" alt="" class="wp-image-37968" style="width:404px;height:auto" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-6-5-300x147.jpg 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-5-768x378.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/image-6-5.jpg 830w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption class="wp-element-caption"><strong>미세먼지 산란</strong><br><a href="https://news.sbs.co.kr/news/endPage.do?news_id=N1005245972" target="_blank" rel="noreferrer noopener">https://news.sbs.co.kr/news/endPage.do?news_id=N1005245972</a></figcaption></figure>
</div>
</div>
</div>
</div>



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



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/%eb%b9%9b%ec%9d%98-%ec%84%b1%ec%a7%88-%ec%9a%94%ec%95%bd/37972/">빛의 성질 &#8211; 요약</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/%eb%b9%9b%ec%9d%98-%ec%84%b1%ec%a7%88-%ec%9a%94%ec%95%bd/37972/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>12 &#8211; 03 홀로그램(Hologram) 만들기 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity-shader-hologram-rim-light/2936/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity-shader-hologram-rim-light/2936/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 06:42:08 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[2Pass]]></category>
		<category><![CDATA[fresnel]]></category>
		<category><![CDATA[Half-Lambert]]></category>
		<category><![CDATA[Hologram]]></category>
		<category><![CDATA[Holography]]></category>
		<category><![CDATA[Lambert]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[만들기]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[유니티]]></category>
		<category><![CDATA[홀로그램]]></category>
		<category><![CDATA[홀로그램 만들기]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2936</guid>

					<description><![CDATA[<p>unity의 shader를 이용하여 홀로그램을 구현하는 방법을 정리하고 기록한 글입니다. + 2pass</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity-shader-hologram-rim-light/2936/">12 &#8211; 03 홀로그램(Hologram) 만들기 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:61px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">12 &#8211; 03 홀로그램(Hologram) 만들기 (Unity Shader)</h2>



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



<p class="has-medium-font-size">Rim 라이트를 구현할 수 있게 되었으니 알파를 사용하여 홀로그램을 만들 수 있습니다.</p>



<p class="has-medium-font-size">처음은 Lambert 기본형에서 시작합니다.</p>



<div style="height:52px" 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/Holo"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert noambient

        #pragma target 3.0
        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

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



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



<figure class="wp-block-image size-full"><img decoding="async" width="1547" height="519" src="https://lycos7560.com/wp-content/uploads/image-453.png" alt="" class="wp-image-2937" srcset="https://lycos7560.com/wp-content/uploads/image-453.png 1547w, https://lycos7560.com/wp-content/uploads/image-453-300x101.png 300w, https://lycos7560.com/wp-content/uploads/image-453-768x258.png 768w, https://lycos7560.com/wp-content/uploads/image-453-1536x515.png 1536w" sizes="(max-width: 1547px) 100vw, 1547px" /></figure>



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



<p class="has-medium-font-size">다음은 Fresnel 기본 연산을 구현합니다.</p>



<p class="has-medium-font-size">잠시 Albedo 는 끄고 Emission 으로 결과를 확인하겠습니다.&nbsp;</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1310" height="1022" src="https://lycos7560.com/wp-content/uploads/image-454.png" alt="" class="wp-image-2938" srcset="https://lycos7560.com/wp-content/uploads/image-454.png 1310w, https://lycos7560.com/wp-content/uploads/image-454-300x234.png 300w, https://lycos7560.com/wp-content/uploads/image-454-768x599.png 768w" sizes="(max-width: 1310px) 100vw, 1310px" /></figure>



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



<p class="has-medium-font-size">이제 반투명으로 구현하겠습니다.</p>



<p class="has-medium-font-size">홀로그램의 핵심원리는&nbsp;<strong>&#8221; Rim 라이트 연산을 알파 채널에 넣는다 &#8220;</strong>&nbsp;입니다.</p>



<p class="has-medium-font-size">반투명 구현은 앞 부분의 불을 만들 때 사용한 방식입니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1295" height="764" src="https://lycos7560.com/wp-content/uploads/image-455.png" alt="" class="wp-image-2939" srcset="https://lycos7560.com/wp-content/uploads/image-455.png 1295w, https://lycos7560.com/wp-content/uploads/image-455-300x177.png 300w, https://lycos7560.com/wp-content/uploads/image-455-768x453.png 768w" sizes="(max-width: 1295px) 100vw, 1295px" /></figure>



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



<p class="has-medium-font-size">마지막으로 Emission에 원하는 색상을 넣어주면 됩니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="738" height="930" src="https://lycos7560.com/wp-content/uploads/image-456.png" alt="" class="wp-image-2940" srcset="https://lycos7560.com/wp-content/uploads/image-456.png 738w, https://lycos7560.com/wp-content/uploads/image-456-238x300.png 238w" sizes="(max-width: 738px) 100vw, 738px" /></figure>



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



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



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



<p class="has-medium-font-size">다음은 두께를 조절하게 해줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="812" height="1002" src="https://lycos7560.com/wp-content/uploads/image-457.png" alt="" class="wp-image-2942" srcset="https://lycos7560.com/wp-content/uploads/image-457.png 812w, https://lycos7560.com/wp-content/uploads/image-457-243x300.png 243w, https://lycos7560.com/wp-content/uploads/image-457-768x948.png 768w" sizes="(max-width: 812px) 100vw, 812px" /></figure>



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



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



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



<p class="has-medium-font-size">입안이 이상하게 구현된 것은 캐릭터가 입안까지 모델링이 되었기 때문입니다.</p>



<p class="has-medium-font-size">반투명이 되면서 반대편의 오브젝트나 안쪽의 오브젝트가 비쳐 보이는 것은 나중에 Z버퍼를 이용한 2pass 쉐이더를 사용하여 해결합니다.</p>



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



<h2 class="has-medium-font-size wp-block-heading">전체 코드</h2>



<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/Holo"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _RimColor("RimColor", Color) = (1,1,1,1)
        _RimPower("RimPower", Range(1,10)) = 3
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"="Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert noambient alpha:fade

        #pragma target 3.0
        sampler2D _MainTex;
        float4 _RimColor;
        float _RimPower;

        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float rim = saturate(dot(o.Normal, IN.viewDir));
            rim = pow(1 - rim, _RimPower);
            o.Emission = _RimColor.rgb;
            o.Alpha = rim;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<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)"/>



<p class="has-medium-font-size">기본형은 만들었지만 이것만으로는 부족합니다.</p>



<p class="has-medium-font-size">다양한 효과를 넣어 봅시다.</p>



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



<p class="has-medium-font-size">첫번째로 이 홀로그램을 깜빡이게 표현합니다.</p>



<p class="has-medium-font-size">Sin(_Time.y) 를 이용합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="804" height="319" src="https://lycos7560.com/wp-content/uploads/image-458.png" alt="" class="wp-image-2944" srcset="https://lycos7560.com/wp-content/uploads/image-458.png 804w, https://lycos7560.com/wp-content/uploads/image-458-300x119.png 300w, https://lycos7560.com/wp-content/uploads/image-458-768x305.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



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



<p class="has-medium-font-size">깜빡임 속도 증가</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="770" height="1037" src="https://lycos7560.com/wp-content/uploads/image-459.png" alt="" class="wp-image-2945" srcset="https://lycos7560.com/wp-content/uploads/image-459.png 770w, https://lycos7560.com/wp-content/uploads/image-459-223x300.png 223w, https://lycos7560.com/wp-content/uploads/image-459-768x1034.png 768w" sizes="(max-width: 770px) 100vw, 770px" /></figure>



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



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



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



<p class="has-medium-font-size">그런데, 이러면 깜빡일 떄 안보이는 시간이 너무 길게 나타납니다.</p>



<p class="has-medium-font-size">이것은 sin 또는 cos 곡선에서 일어나는 당연한 결과 입니다.</p>



<p class="has-medium-font-size">이 곡선들이 -1 ~ 1을 반복하다 보니 그림처럼 0 이하로 내려가는 부분이 절반이기 때문입니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="748" height="443" src="https://lycos7560.com/wp-content/uploads/image-460.png" alt="" class="wp-image-2947" srcset="https://lycos7560.com/wp-content/uploads/image-460.png 748w, https://lycos7560.com/wp-content/uploads/image-460-300x178.png 300w" sizes="(max-width: 748px) 100vw, 748px" /></figure>



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



<p class="has-medium-font-size">saturate 해주는 것은 0 이나 &#8211; 1 이나 우리눈에 안보이는 것은 같기 때문에 의미가 없습니다.</p>



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



<p class="has-medium-font-size">첫번째로&nbsp; * 0.5 + 0.5 를 사용하는 방법이 있습니다.</p>



<p class="has-medium-font-size">하프 램버트에서 사용했던 공식을 이용하면 -1 ~ 1을 0 ~ 1로 변화시켜주므로 부드럽게 지속적으로 반짝이는 곡선을 구할 수 있게 됩니다.</p>



<p class="has-medium-font-size">sin(_Time.y) * 0.5 + 0.5;</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="789" height="488" src="https://lycos7560.com/wp-content/uploads/image-461.png" alt="" class="wp-image-2948" srcset="https://lycos7560.com/wp-content/uploads/image-461.png 789w, https://lycos7560.com/wp-content/uploads/image-461-300x186.png 300w, https://lycos7560.com/wp-content/uploads/image-461-768x475.png 768w" sizes="(max-width: 789px) 100vw, 789px" /></figure>



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



<p class="has-medium-font-size">또 다른 방법으로는 abs () 함수를 사용하여 모든 음수를 양수로 변화시킬 수 있습니다.</p>



<p class="has-medium-font-size">abs(sin(_Time.y));</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="790" height="503" src="https://lycos7560.com/wp-content/uploads/image-462.png" alt="" class="wp-image-2949" srcset="https://lycos7560.com/wp-content/uploads/image-462.png 790w, https://lycos7560.com/wp-content/uploads/image-462-300x191.png 300w, https://lycos7560.com/wp-content/uploads/image-462-768x489.png 768w" sizes="(max-width: 790px) 100vw, 790px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="919" height="411" src="https://lycos7560.com/wp-content/uploads/image-463.png" alt="" class="wp-image-2950" srcset="https://lycos7560.com/wp-content/uploads/image-463.png 919w, https://lycos7560.com/wp-content/uploads/image-463-300x134.png 300w, https://lycos7560.com/wp-content/uploads/image-463-768x343.png 768w" sizes="(max-width: 919px) 100vw, 919px" /></figure>



<div style="height:42px" 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/Holo"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _RimColor("RimColor", Color) = (1,1,1,1)
        _RimPower("RimPower", Range(1,10)) = 3
        _HoloTwinkling("HoloTwinkling",Range(1,5)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"="Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert noambient alpha:fade

        #pragma target 3.0
        sampler2D _MainTex;
        float4 _RimColor;
        float _RimPower;
        float _HoloTwinkling;

        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float rim = saturate(dot(o.Normal, IN.viewDir));
            rim = pow(1 - rim, _RimPower);
            o.Emission = _RimColor.rgb;

            //o.Alpha = rim * sin(_Time.y * _HoloTwinkling);
            //o.Alpha = rim * sin(_Time.y * _HoloTwinkling) *0.5 + 0.5;
            o.Alpha = rim * abs(sin(_Time.y * _HoloTwinkling));
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



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



<div style="height:43px" 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)"/>



<p class="has-medium-font-size">다음은 홀로그램의 줄무늬가 올라가는 효과를 만들겠습니다.</p>



<p class="has-medium-font-size">버텍스 컬러를 이용하여 아래에서 위로 밝아지게 칠할 수도 있고, 두번째 UV를 펴는 방법도 있습니다.</p>



<p class="has-medium-font-size">여기서는 Input 구조체에서 다른 값을 이용하겠습니다.</p>



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



<p><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/Manual/SL-SurfaceShaders.html</a> &lt;- 영문</p>



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1302" height="319" src="https://lycos7560.com/wp-content/uploads/image-464.png" alt="" class="wp-image-2952" srcset="https://lycos7560.com/wp-content/uploads/image-464.png 1302w, https://lycos7560.com/wp-content/uploads/image-464-300x74.png 300w, https://lycos7560.com/wp-content/uploads/image-464-768x188.png 768w" sizes="(max-width: 1302px) 100vw, 1302px" /></a></figure>



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



<p><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html</a> &lt;-한글</p>



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1306" height="318" src="https://lycos7560.com/wp-content/uploads/image-465.png" alt="" class="wp-image-2953" srcset="https://lycos7560.com/wp-content/uploads/image-465.png 1306w, https://lycos7560.com/wp-content/uploads/image-465-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-465-768x187.png 768w" sizes="(max-width: 1306px) 100vw, 1306px" /></a></figure>



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



<h2 class="wp-block-heading">표면 셰이더 입력 구조</h2>



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



<p class="has-medium-font-size">입력 구조&nbsp;Input에는 일반적으로 셰이더가 필요로 하는 텍스처 좌표가 있습니다. 텍스처 좌표의 이름은 텍스처 이름 앞에 “uv”가 붙는 형식으로 지어야 합니다(또는 두 번째 텍스처 좌표 세트를 사용하려면 “uv2”로 시작해야 합니다).</p>



<p class="has-medium-font-size">다음 값을 입력 구조에 추가할 수 있습니다.</p>



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



<p class="has-medium-font-size">float3 viewDir &#8211; 뷰 방향을 포함합니다. 패럴랙스 이펙트, 림 조명 등의 컴퓨팅에 사용합니다.</p>



<p class="has-medium-font-size">float4와 COLOR 시맨틱 &#8211; 보간된 버텍스당 컬러를 포함합니다.</p>



<p class="has-medium-font-size">float4 screenPos &#8211; 반사 또는 스크린 공간 효과를 위한 스크린 공간 포지션을 포함합니다. GrabPass에는 적합하지 않습니다. ComputeGrabScreenPos 함수를 사용하여 커스텀 UV를 직접 계산해야 합니다.</p>



<p class="has-medium-font-size">float3 worldPos &#8211; 월드 공간 포지션을 포함합니다.</p>



<p class="has-medium-font-size">float3 worldRefl &#8211; 표면 셰이더가 o.Normal에 기록하지 않는 경우 월드 반사 벡터를 포함합니다. 예를 들어 리플렉트-디퓨즈(Reflect-Diffuse) 셰이더가 있습니다.</p>



<p class="has-medium-font-size">float3 worldNormal &#8211; 표면 셰이더가 o.Normal에 기록하지 않는 경우 월드 노멀 벡터를 포함합니다.</p>



<p class="has-medium-font-size">float3 worldRefl; INTERNAL_DATA &#8211; 표면 셰이더가 o.Normal에 기록하는 경우 월드 반사 벡터를 포함합니다. 픽셀당 노멀 맵을 기반으로 반사 벡터를 얻으려면 WorldReflectionVector (IN, o.Normal)를 사용해야 합니다. 예를 들어 리플렉트-범프드(Reflect-Bumped) 셰이더가 있습니다.</p>



<p class="has-medium-font-size">float3 worldNormal; INTERNAL_DATA &#8211; 표면 셰이더가 o.Normal에 기록하는 경우 월드 노멀 벡터를 포함합니다. 픽셀당 노멀 맵에 기반한 노멀 벡터를 얻으려면 WorldNormalVector (IN, o.Normal)를 사용해야 합니다.</p>



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



<p class="has-medium-font-size">이번에는 float3 worldPos를 사용합니다.</p>



<p class="has-medium-font-size">해당 변수의 기능을 확인하기 위해서 코드를 변경합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="891" height="1003" src="https://lycos7560.com/wp-content/uploads/image-466.png" alt="" class="wp-image-2955" srcset="https://lycos7560.com/wp-content/uploads/image-466.png 891w, https://lycos7560.com/wp-content/uploads/image-466-267x300.png 267w, https://lycos7560.com/wp-content/uploads/image-466-768x865.png 768w" sizes="(max-width: 891px) 100vw, 891px" /></figure>



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



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



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



<p class="has-medium-font-size">해당 x, y, z 가 각각 r, g, b 에 대입하여 나타납니다.</p>



<p class="has-medium-font-size">우리는 상/하의 값인 Y만 필요하기 때문에 g (y)만 출력합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="667" height="283" src="https://lycos7560.com/wp-content/uploads/image-467.png" alt="" class="wp-image-2957" srcset="https://lycos7560.com/wp-content/uploads/image-467.png 667w, https://lycos7560.com/wp-content/uploads/image-467-300x127.png 300w" sizes="(max-width: 667px) 100vw, 667px" /></figure>



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



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



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



<p class="has-medium-font-size">위의 코드로는&nbsp; 위로 올라가면 1이 넘는 값이 될 것이고 아래로 내려가면 -1의 아래 값으로 변하게 됩니다.</p>



<p class="has-medium-font-size">이러한 상황에서 유용한 내장 함수는 frac ( ) 입니다.</p>



<p class="has-medium-font-size">frac ( ) 은 안에 들어온 숫자의 &#8220;소수점 부분&#8221; 만 리턴해 줍니다.</p>



<p class="has-medium-font-size">즉, 1.1 은 0.1을 리턴하고 1.9는 0.9를 리턴합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="716" height="299" src="https://lycos7560.com/wp-content/uploads/image-468.png" alt="" class="wp-image-2959" srcset="https://lycos7560.com/wp-content/uploads/image-468.png 716w, https://lycos7560.com/wp-content/uploads/image-468-300x125.png 300w" sizes="(max-width: 716px) 100vw, 716px" /></figure>



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



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



<p class="has-medium-font-size">이제 흰 부분을 줄여 주겠습니다.</p>



<p class="has-medium-font-size">그라디에이션에서 검정 부분을 확장시키고 흰 부분을 줄이는 것은 이전에&nbsp; fresnel 을 배울 때 pow ( ) 함수를 이용하여 해결했습니다.</p>



<p class="has-medium-font-size">추가로 시간에 따라 위로 흘러가게 해줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="642" height="211" src="https://lycos7560.com/wp-content/uploads/image-469.png" alt="" class="wp-image-2961" srcset="https://lycos7560.com/wp-content/uploads/image-469.png 642w, https://lycos7560.com/wp-content/uploads/image-469-300x99.png 300w" sizes="(max-width: 642px) 100vw, 642px" /></figure>



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



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



<p class="has-medium-font-size">NormalMap 적용 후 변경이 가능하게 프로퍼티로 설정</p>



<div style="height:37px" 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/Holo"
{
    Properties
    {
        _BumpMap("Normal Map", 2D) = "white" {}
        _RimColor ("RimColor", Color) = (1,1,1,1)
        _RimPower ("RimPower", Range(1,10)) = 3
        _HoloTwinkling ("HoloTwinkling",Range(1,5)) = 1
        _HoloSpeed ("HoloSpeed",Range(1,5)) = 1
        _HoloInterval ("HoloInterval",Range(1,5)) = 5
        
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"="Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert noambient alpha:fade

        #pragma target 3.0
        sampler2D _BumpMap;
        float4 _RimColor;
        float _RimPower;
        float _HoloTwinkling;
        float _HoloSpeed;
        float _HoloInterval;

        struct Input
        {
            float2 uv_BumpMap;
            float3 viewDir;
            float3 worldPos;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            float rim = saturate(dot(o.Normal, IN.viewDir));
            rim = pow(1 - rim, _RimPower);
            o.Emission = pow (frac(IN.worldPos.g * _HoloInterval - _Time.y * _HoloSpeed), 5) + _RimColor.rgb;
            o.Alpha = rim * abs(sin(_Time.y * _HoloTwinkling));
        }
        ENDCG
    }
    FallBack "Transparent/Diffuse"
}</pre>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="525" height="158" src="https://lycos7560.com/wp-content/uploads/image-470.png" alt="" class="wp-image-2963" srcset="https://lycos7560.com/wp-content/uploads/image-470.png 525w, https://lycos7560.com/wp-content/uploads/image-470-300x90.png 300w" sizes="(max-width: 525px) 100vw, 525px" /></figure>



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



<p class="has-medium-font-size">Transparent/Diffuse 는 그림자를 생성하지 않게 하도록 넣는 코드입니다.</p>



<p class="has-medium-font-size">원래 FallBack은 그래픽 카드에서 이 쉐이더 연산을 실패 했을 때의 대체 쉐이더를 적는 란이지만</p>



<p class="has-medium-font-size">이 책의 저자분은 그림자 연산할 때 이 FallBack에 씌여진 쉐이더가 영향을 끼치게 된다는 것을 발견했다고 합니다.</p>



<p class="has-medium-font-size">이 쉐이더는 마치 이펙트와 같은 쉐이더이기 때문에 그림자가 필요없으므로 해당 코드를 넣습니다.</p>



<div style="height:48px" 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)"/>



<h2 class="wp-block-heading">홀로그램 2Pass</h2>



<div style="height:37px" 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/Holo"
{
    Properties
    {
        _BumpMap("Normal Map", 2D) = "white" {}
        _RimColor ("RimColor", Color) = (1,1,1,1)
        _RimPower ("RimPower", Range(1,10)) = 3
        _HoloTwinkling ("HoloTwinkling",Range(1,5)) = 1
        _HoloSpeed ("HoloSpeed",Range(1,5)) = 1
        _HoloInterval ("HoloInterval",Range(1,5)) = 5
        
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"="Transparent" }

        ZWrite On
        ColorMask 0

        LOD 200

        CGPROGRAM
        #pragma surface surf _NoLight
        #pragma target 3.0

        struct Input
        {
            float4 color:COLOR;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
        }

        float4 Lighting_NoLight(SurfaceOutput s, float3 lightDir, float atten) {
            return 0;
        }
        ENDCG

        ZWrite Off

        CGPROGRAM
        #pragma surface surf Lambert noambient alpha:fade

        #pragma target 3.0
        sampler2D _BumpMap;
        float4 _RimColor;
        float _RimPower;
        float _HoloTwinkling;
        float _HoloSpeed;
        float _HoloInterval;

        struct Input
        {
            float2 uv_BumpMap;
            float3 viewDir;
            float3 worldPos;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            float rim = saturate(dot(o.Normal, IN.viewDir));
            rim = pow(1 - rim, _RimPower);
            o.Emission = pow (frac(IN.worldPos.g * _HoloInterval - _Time.y * _HoloSpeed), 30) + _RimColor.rgb;
            o.Alpha = rim * abs(sin(_Time.y * _HoloTwinkling));
        }
        ENDCG
    }
    FallBack "Transparent/Diffuse"
}</pre>



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



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



<div style="height:127px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity-shader-hologram-rim-light/2936/">12 &#8211; 03 홀로그램(Hologram) 만들기 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity-shader-hologram-rim-light/2936/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_11_19_52.mp4" length="415490" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_12_29_337.mp4" length="1110285" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_16_27_300.mp4" length="1509941" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_20_37_32.mp4" length="1043747" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_25_54_541.mp4" length="1406549" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_28_17_74.mp4" length="611718" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_29_32_254.mp4" length="325196" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_32_17_586.mp4" length="5003364" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_15_34_44_771.mp4" length="4246465" type="video/mp4" />

			</item>
		<item>
		<title>12 &#8211; 01 ~ 02 Rim 라이트의 기초 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity-shader-rim-light-fresnel/2900/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity-shader-rim-light-fresnel/2900/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 05:34:19 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[fresnel]]></category>
		<category><![CDATA[loat3 lightDir]]></category>
		<category><![CDATA[normalmap]]></category>
		<category><![CDATA[pow]]></category>
		<category><![CDATA[Rim]]></category>
		<category><![CDATA[RimLight]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[viewDir]]></category>
		<category><![CDATA[공식]]></category>
		<category><![CDATA[노멀맵]]></category>
		<category><![CDATA[림]]></category>
		<category><![CDATA[림라이트]]></category>
		<category><![CDATA[방향 벡터]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[유니티]]></category>
		<category><![CDATA[프레넬]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2900</guid>

					<description><![CDATA[<p>Rim 라이트의 기초와 유니티에서 프레넬 공식을 통하여 구현하는 방법을 예제를 통해 간단하게 작성하였습니다. </p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity-shader-rim-light-fresnel/2900/">12 &#8211; 01 ~ 02 Rim 라이트의 기초 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:45px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">12 &#8211; 01 ~ 02 Rim 라이트의 기초 (Unity Shader)</h2>



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



<p class="has-medium-font-size">주변을 자세히 보면 모든 물체는 기울어 질수록 반사가 심해집니다.</p>



<p class="has-medium-font-size">실제로 모든 물체는 기울어 질수록 심하게 반사가 되며 그 반사율은 재질에 따라 다르게 나타납니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="804" height="353" src="https://lycos7560.com/wp-content/uploads/image-432.png" alt="" class="wp-image-2901" srcset="https://lycos7560.com/wp-content/uploads/image-432.png 804w, https://lycos7560.com/wp-content/uploads/image-432-300x132.png 300w, https://lycos7560.com/wp-content/uploads/image-432-768x337.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



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



<p class="has-medium-font-size">만약 역광이 있을 떄, 털이나 반투명의 재질을 가진 물체들은 이 현상이 매우 강렬하게 나타날 수 있고</p>



<p class="has-medium-font-size">재질에 따라 때로는 잘 보이지 않게 나타날 수도 있습니다.</p>



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



<p class="has-medium-font-size">사진 분야에서는 이것을 Rim Light ( 림 라이트 ) 라고 부릅니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="553" height="239" src="https://lycos7560.com/wp-content/uploads/image-433.png" alt="" class="wp-image-2902" srcset="https://lycos7560.com/wp-content/uploads/image-433.png 553w, https://lycos7560.com/wp-content/uploads/image-433-300x130.png 300w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



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



<p class="has-medium-font-size">우리가 사용하는 Standard Shader와 같은 물리 기반의 쉐이더는 이러한 재질의 특성에 따른 반사율이</p>



<p class="has-medium-font-size">BRDF(Bidirectional Reflectance Distribution Function &#8211;&nbsp;양방향 반사 분포 함수) 를 이용하여 구현되어 있습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1341" height="809" src="https://lycos7560.com/wp-content/uploads/image-434.png" alt="" class="wp-image-2903" srcset="https://lycos7560.com/wp-content/uploads/image-434.png 1341w, https://lycos7560.com/wp-content/uploads/image-434-300x181.png 300w, https://lycos7560.com/wp-content/uploads/image-434-768x463.png 768w" sizes="(max-width: 1341px) 100vw, 1341px" /></figure>



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



<p class="has-medium-font-size">이러한 반사 공식을&nbsp;<strong>fresnel (프레넬)</strong>&nbsp;이라 부릅니다.</p>



<p class="has-medium-font-size">이번에 설명할 fresnel 공식은 그보다는 간단하게, 빛의 방향과는 전혀 상관이 없게 만드는 효과입니다.</p>



<p class="has-medium-font-size">기본적으로 배경과 캐릭터의 분리나 강조를 위해, 혹은 선택되었을때나 특정 상태를 표현하기 위한 특수한 효과를 위해 사용합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="959" height="695" src="https://lycos7560.com/wp-content/uploads/image-435.png" alt="" class="wp-image-2904" srcset="https://lycos7560.com/wp-content/uploads/image-435.png 959w, https://lycos7560.com/wp-content/uploads/image-435-300x217.png 300w, https://lycos7560.com/wp-content/uploads/image-435-768x557.png 768w" sizes="(max-width: 959px) 100vw, 959px" /></figure>



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



<p class="has-medium-font-size">직접 확인해보기 위해서 아래 에셋을 사용했습니다. (무료)</p>



<p class="has-medium-font-size"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener">https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519</a>&nbsp;&lt;- TestAsset</p>



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



<figure class="wp-block-image size-full"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1304" height="317" src="https://lycos7560.com/wp-content/uploads/image-388.png" alt="" class="wp-image-2824" srcset="https://lycos7560.com/wp-content/uploads/image-388.png 1304w, https://lycos7560.com/wp-content/uploads/image-388-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-388-768x187.png 768w" sizes="(max-width: 1304px) 100vw, 1304px" /></a></figure>



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



<h2 class="wp-block-heading"><strong>fresnel 공식 구현</strong></h2>



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



<p class="has-medium-font-size">텍스쳐를 한장만 받는 기본형으로 쉐이더를 변경합니다.</p>



<div style="height:21px" 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/RimLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        
        #pragma surface surf Lambert noambient
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

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



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



<figure class="wp-block-image size-full"><img decoding="async" width="1313" height="545" src="https://lycos7560.com/wp-content/uploads/image-436.png" alt="" class="wp-image-2905" srcset="https://lycos7560.com/wp-content/uploads/image-436.png 1313w, https://lycos7560.com/wp-content/uploads/image-436-300x125.png 300w, https://lycos7560.com/wp-content/uploads/image-436-768x319.png 768w" sizes="(max-width: 1313px) 100vw, 1313px" /></figure>



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



<p class="has-medium-font-size">o.Albedo 를 0 으로 만들어서 검게 만들고 시작하는 것이 좋습니다. </p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1533" height="476" src="https://lycos7560.com/wp-content/uploads/image-438.png" alt="" class="wp-image-2907" srcset="https://lycos7560.com/wp-content/uploads/image-438.png 1533w, https://lycos7560.com/wp-content/uploads/image-438-300x93.png 300w, https://lycos7560.com/wp-content/uploads/image-438-768x238.png 768w" sizes="(max-width: 1533px) 100vw, 1533px" /></figure>



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



<p class="has-medium-font-size">이전에 배운 Lambert 공식은 노멀 벡터와 조명 벡터를 dot 연산한 공식입니다.</p>



<p class="has-medium-font-size">이 공식을 간단하게 정의하면 두 벡터, 즉 노멀벡터와 조명 벡터의 각도가 같으면 밝고, 90도가 되면 어두워져서 검정색이 된다는 것입니다.</p>



<p class="has-medium-font-size">그렇다면 여기에서 input 구조체에서 다른 값을 받아 봅시다.</p>



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



<p><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/Manual/SL-SurfaceShaders.html</a> &lt;- 영문</p>



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



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1309" height="315" src="https://lycos7560.com/wp-content/uploads/image-439.png" alt="" class="wp-image-2908" srcset="https://lycos7560.com/wp-content/uploads/image-439.png 1309w, https://lycos7560.com/wp-content/uploads/image-439-300x72.png 300w, https://lycos7560.com/wp-content/uploads/image-439-768x185.png 768w" sizes="(max-width: 1309px) 100vw, 1309px" /></a></figure>



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



<p><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html</a> &lt;- 한글</p>



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1302" height="315" src="https://lycos7560.com/wp-content/uploads/image-440.png" alt="" class="wp-image-2909" srcset="https://lycos7560.com/wp-content/uploads/image-440.png 1302w, https://lycos7560.com/wp-content/uploads/image-440-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-440-768x186.png 768w" sizes="(max-width: 1302px) 100vw, 1302px" /></a></figure>



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



<p class="has-medium-font-size">표면 셰이더 입력 구조</p>



<p class="has-medium-font-size">입력 구조 Input에는 일반적으로 셰이더가 필요로 하는 텍스처 좌표가 있습니다. 텍스처 좌표의 이름은 텍스처 이름 앞에 “uv”가 붙는 형식으로 지어야 합니다(또는 두 번째 텍스처 좌표 세트를 사용하려면 “uv2”로 시작해야 합니다.)</p>



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



<h2 class="has-medium-font-size wp-block-heading">다음 값을 입력 구조에 추가할 수 있습니다.</h2>



<p class="has-medium-font-size">float3 viewDir&nbsp;&#8211; 뷰 방향을 포함합니다. 패럴랙스 이펙트, 림 조명 등의 컴퓨팅에 사용합니다.</p>



<p class="has-medium-font-size">float4와&nbsp;COLOR&nbsp;시맨틱 &#8211; 보간된 버텍스당 컬러를 포함합니다.</p>



<p class="has-medium-font-size">float4 screenPos&nbsp;&#8211; 반사 또는 스크린 공간 효과를 위한 스크린 공간 포지션을 포함합니다.&nbsp;GrabPass에는 적합하지 않습니다.&nbsp;ComputeGrabScreenPos&nbsp;함수를 사용하여 커스텀 UV를 직접 계산해야 합니다.</p>



<p class="has-medium-font-size">float3 worldPos&nbsp;&#8211; 월드 공간 포지션을 포함합니다.</p>



<p class="has-medium-font-size">float3 worldRefl&nbsp;&#8211;&nbsp;표면 셰이더가 o.Normal에 기록하지 않는 경우&nbsp;월드 반사 벡터를 포함합니다. 예를 들어 리플렉트-디퓨즈(Reflect-Diffuse) 셰이더가 있습니다.</p>



<p class="has-medium-font-size">float3 worldNormal&nbsp;&#8211;&nbsp;표면 셰이더가 o.Normal에 기록하지 않는 경우&nbsp;월드 노멀 벡터를 포함합니다.</p>



<p class="has-medium-font-size">float3 worldRefl; INTERNAL_DATA&nbsp;&#8211;&nbsp;표면 셰이더가 o.Normal에 기록하는 경우&nbsp;월드 반사 벡터를 포함합니다. 픽셀당 노멀 맵을 기반으로 반사 벡터를 얻으려면&nbsp;WorldReflectionVector (IN, o.Normal)를 사용해야 합니다. 예를 들어 리플렉트-범프드(Reflect-Bumped) 셰이더가 있습니다.</p>



<p class="has-medium-font-size">float3 worldNormal; INTERNAL_DATA&nbsp;&#8211;&nbsp;표면 셰이더가 o.Normal에 기록하는 경우&nbsp;월드 노멀 벡터를 포함합니다. 픽셀당 노멀 맵에 기반한 노멀 벡터를 얻으려면&nbsp;WorldNormalVector (IN, o.Normal)를 사용해야 합니다.</p>



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



<p class="has-medium-font-size">우리가 사용할 값은 float3 viewDir 입니다.</p>



<p class="has-medium-font-size">float3 는 3차원 벡터 Input 구조체 안에 있는 것으로 봐서 엔진에서 받을 수 있는 데이터입니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="718" height="186" src="https://lycos7560.com/wp-content/uploads/image-441.png" alt="" class="wp-image-2911" srcset="https://lycos7560.com/wp-content/uploads/image-441.png 718w, https://lycos7560.com/wp-content/uploads/image-441-300x78.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></figure>



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



<p class="has-medium-font-size">float3 lightDir가 <strong>버텍스에서 바라보는 조명의 방향을 나타내는 길이가 1인 벡터</strong>라면</p>



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



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



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



<p class="has-medium-font-size">float3 viewDir 은 <strong>버텍스에서 바라보는 카메라의 방향</strong>을 나타냅니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1071" height="646" src="https://lycos7560.com/wp-content/uploads/image-443.png" alt="" class="wp-image-2913" srcset="https://lycos7560.com/wp-content/uploads/image-443.png 1071w, https://lycos7560.com/wp-content/uploads/image-443-300x181.png 300w, https://lycos7560.com/wp-content/uploads/image-443-768x463.png 768w" sizes="(max-width: 1071px) 100vw, 1071px" /></figure>



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



<p class="has-medium-font-size">그럼 Normal dot lightDir&nbsp; 대신&nbsp; Normal dot viewDir 을 하면</p>



<p class="has-medium-font-size">카메라가 마치 조명처럼 인식되어 내가 바라보는 방향이 계속 밝아진다는 것입니다.&nbsp;</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="878" height="445" src="https://lycos7560.com/wp-content/uploads/image-444.png" alt="" class="wp-image-2914" srcset="https://lycos7560.com/wp-content/uploads/image-444.png 878w, https://lycos7560.com/wp-content/uploads/image-444-300x152.png 300w, https://lycos7560.com/wp-content/uploads/image-444-768x389.png 768w" sizes="(max-width: 878px) 100vw, 878px" /></figure>



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



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



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



<h2 class="wp-block-heading">반전</h2>



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



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



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



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



<div style="height:35px" 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/RimLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        
        #pragma surface surf Lambert noambient
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float rim = dot(o.Normal, IN.viewDir);
            o.Emission = 1 - rim; // 결과 뒤집기
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



<p class="has-medium-font-size">위에서 조심할 내용은 dot 연산은 -1 까지 내려가서 나중에 결과가 이상해 질 수 가 있습니다.   saturate() 를 잊지마세요</p>



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



<p class="has-medium-font-size">보는 각도를 바꿔도 언제나 외각이 밝아 보이면서 이제 Rim 라이트처럼 보이기 시작합니다.</p>



<p class="has-medium-font-size">그런데 Rim라이트가 너무 두꺼워서 Rim 라이트 느낌이 살아나지 않습니다.</p>



<p class="has-medium-font-size">흰테두리를 더 얇게 만들어줄 필요가 있습니다.</p>



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



<p class="has-medium-font-size">검정부터 흰색까지 변하는 음영을 표로 보면 아래와 같습니다.</p>



<p class="has-medium-font-size">가로축은 1 &#8211; dot(o.Normal, IN.viewDir) 이고 세로축은 색상 (흑백)을 의미합니다. 두 벡터의 각도 차이가 벌어질수록, 색상도 흰색이 됩니다. </p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="563" height="457" src="https://lycos7560.com/wp-content/uploads/image-446.png" alt="" class="wp-image-2918" srcset="https://lycos7560.com/wp-content/uploads/image-446.png 563w, https://lycos7560.com/wp-content/uploads/image-446-300x244.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></figure>



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



<p class="has-medium-font-size">pow 를 이용하면 지수함수와 같은 그래프로 어두운 부분이 한참동안 존재하다가 갑자기 밝아지는 모양이 됩니다.</p>



<p class="has-medium-font-size">이 그래프를 이용하여 흰 테두리를 얇게 만듭니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="563" height="383" src="https://lycos7560.com/wp-content/uploads/image-447.png" alt="" class="wp-image-2919" srcset="https://lycos7560.com/wp-content/uploads/image-447.png 563w, https://lycos7560.com/wp-content/uploads/image-447-300x204.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1538" height="639" src="https://lycos7560.com/wp-content/uploads/image-448.png" alt="" class="wp-image-2920" srcset="https://lycos7560.com/wp-content/uploads/image-448.png 1538w, https://lycos7560.com/wp-content/uploads/image-448-300x125.png 300w, https://lycos7560.com/wp-content/uploads/image-448-768x319.png 768w, https://lycos7560.com/wp-content/uploads/image-448-1536x638.png 1536w" sizes="(max-width: 1538px) 100vw, 1538px" /></figure>



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



<h2 class="wp-block-heading">이제 rim 라이트에 색상을 추가합니다.</h2>



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



<figure class="wp-block-image size-full"><img decoding="async" width="895" height="891" src="https://lycos7560.com/wp-content/uploads/image-449.png" alt="" class="wp-image-2921" srcset="https://lycos7560.com/wp-content/uploads/image-449.png 895w, https://lycos7560.com/wp-content/uploads/image-449-300x300.png 300w, https://lycos7560.com/wp-content/uploads/image-449-150x150.png 150w, https://lycos7560.com/wp-content/uploads/image-449-768x765.png 768w" sizes="(max-width: 895px) 100vw, 895px" /></figure>



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



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



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



<p class="has-medium-font-size">두께 조절 프로퍼티도 만들어줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="908" height="1051" src="https://lycos7560.com/wp-content/uploads/image-450.png" alt="" class="wp-image-2923" srcset="https://lycos7560.com/wp-content/uploads/image-450.png 908w, https://lycos7560.com/wp-content/uploads/image-450-259x300.png 259w, https://lycos7560.com/wp-content/uploads/image-450-768x889.png 768w" sizes="(max-width: 908px) 100vw, 908px" /></figure>



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



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



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



<h2 class="wp-block-heading">NormalMap 추가</h2>



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



<p class="has-medium-font-size">Rim 연산에서 o.Normal을 사용하기 때문에 반드시 Rim라이트 연산 이전에 NormalMap 을 적용시켜줘야 합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="762" height="1063" src="https://lycos7560.com/wp-content/uploads/image-451.png" alt="" class="wp-image-2925" srcset="https://lycos7560.com/wp-content/uploads/image-451.png 762w, https://lycos7560.com/wp-content/uploads/image-451-215x300.png 215w" sizes="(max-width: 762px) 100vw, 762px" /></figure>



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



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



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



<p class="has-medium-font-size">이제 dot 연산에서 -1로 넘어가는 부분을 막아주고 noambient 까지 지워서 완성합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="818" height="1057" src="https://lycos7560.com/wp-content/uploads/image-452.png" alt="" class="wp-image-2927" srcset="https://lycos7560.com/wp-content/uploads/image-452.png 818w, https://lycos7560.com/wp-content/uploads/image-452-232x300.png 232w, https://lycos7560.com/wp-content/uploads/image-452-768x992.png 768w" sizes="(max-width: 818px) 100vw, 818px" /></figure>



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



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



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



<p class="has-medium-font-size">이것이 Rim 라이트라고 부르는 Fresnel 이 적용된 결과 입니다.</p>



<p class="has-medium-font-size">게임에서 캐릭터가 데미지를 입었을 때나 선택할 때, 혹은 단순히 배경과 분리된 느낌을 원할 때 자주 사용되는 방식이지만</p>



<p class="has-medium-font-size">실제 존재하는 Rim 라이트를 구현했다고 부르기에는 약간 부족합니다.</p>



<p class="has-medium-font-size">우리가 만든 Rim 라이트는 조명의 방향과 전혀 연관이 없습니다.</p>



<p class="has-medium-font-size">이상적인 Rim 라이트는 역광일 때 주로 나타나고 직광일 때는 보이지 않습니다. (나중에 커스텀 라이트를 만들 때 가능합니다.)</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity-shader-rim-light-fresnel/2900/">12 &#8211; 01 ~ 02 Rim 라이트의 기초 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity-shader-rim-light-fresnel/2900/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_20_50_14.mp4" length="2364166" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_22_41_652.mp4" length="3371153" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_25_40_789.mp4" length="1297617" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_26_59_679.mp4" length="1234314" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_29_23_149.mp4" length="825114" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_14_30_45_465.mp4" length="3354833" type="video/mp4" />

			</item>
		<item>
		<title>11 &#8211; 03 ~ 04 Half-Lambert(하프 램버트) 연산 및 완성 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity_shader-half-lambert/2873/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity_shader-half-lambert/2873/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 05:04:08 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[atten]]></category>
		<category><![CDATA[Half-Lambert]]></category>
		<category><![CDATA[Lambert]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[lighting]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[공식]]></category>
		<category><![CDATA[램버트]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[연산]]></category>
		<category><![CDATA[영상]]></category>
		<category><![CDATA[유니티]]></category>
		<category><![CDATA[하프]]></category>
		<category><![CDATA[하프 램버트]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2873</guid>

					<description><![CDATA[<p>Unity Shader에서 Half-Lambert(하프 램버트) 연산이 적용되는 방식을 간략하게 예제로 설명합니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-half-lambert/2873/">11 &#8211; 03 ~ 04 Half-Lambert(하프 램버트) 연산 및 완성 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:51px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">11 &#8211; 03 ~ 04 Half-Lambert(하프 램버트) 연산 및 완성 (Unity Shader)</h2>



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



<p class="has-medium-font-size">Lambert 라이트는 꽤 가벼운 조명 공식이지만, cos 그래프 연산의 특성상 밝다가&nbsp;너무 갑자기 검게 음영이 떨어지는 단점이 있습니다.&nbsp;</p>



<p class="has-medium-font-size">그래서 이 단점을 해결하고자 만든 것이 Half-Lambert (하프 램버트) 공식입니다.</p>



<p class="has-medium-font-size">물리적으로는 옳지 않지만, 매우 가벼우며 보기 좋은 장점이 있습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="870" height="407" src="https://lycos7560.com/wp-content/uploads/image-417.png" alt="" class="wp-image-2874" srcset="https://lycos7560.com/wp-content/uploads/image-417.png 870w, https://lycos7560.com/wp-content/uploads/image-417-300x140.png 300w, https://lycos7560.com/wp-content/uploads/image-417-768x359.png 768w" sizes="(max-width: 870px) 100vw, 870px" /></figure>



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



<p class="has-medium-font-size">저번에 글에서 사용한 코드에서 시작하겠습니다.&nbsp;</p>



<div style="height:22px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = saturate(dot(s.Normal, lightDir));
            return ndotl;
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



<p class="has-medium-font-size">직접 확인해보기 위해서 아래 에셋을 사용했습니다. (무료)</p>



<p class="has-medium-font-size"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener">https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519</a>&nbsp;&lt;- TestAsset</p>



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



<figure class="wp-block-image size-full"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1304" height="317" src="https://lycos7560.com/wp-content/uploads/image-388.png" alt="" class="wp-image-2824" srcset="https://lycos7560.com/wp-content/uploads/image-388.png 1304w, https://lycos7560.com/wp-content/uploads/image-388-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-388-768x187.png 768w" sizes="(max-width: 1304px) 100vw, 1304px" /></a></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1520" height="508" src="https://lycos7560.com/wp-content/uploads/image-418.png" alt="" class="wp-image-2875" srcset="https://lycos7560.com/wp-content/uploads/image-418.png 1520w, https://lycos7560.com/wp-content/uploads/image-418-300x100.png 300w, https://lycos7560.com/wp-content/uploads/image-418-768x257.png 768w" sizes="(max-width: 1520px) 100vw, 1520px" /></figure>



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



<p class="has-medium-font-size">위의 이미지는 saturate() 함수로 인하여 0 이하의 값은 전부 0 이 되었습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="885" height="860" src="https://lycos7560.com/wp-content/uploads/image-419.png" alt="" class="wp-image-2876" srcset="https://lycos7560.com/wp-content/uploads/image-419.png 885w, https://lycos7560.com/wp-content/uploads/image-419-300x292.png 300w, https://lycos7560.com/wp-content/uploads/image-419-768x746.png 768w" sizes="(max-width: 885px) 100vw, 885px" /></figure>



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



<p class="has-medium-font-size">saturate() 를 다시 제거해서 다시 -1 ~ 1까지의 범위를 출력하도록 만들어 줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1181" height="234" src="https://lycos7560.com/wp-content/uploads/image-420.png" alt="" class="wp-image-2877" srcset="https://lycos7560.com/wp-content/uploads/image-420.png 1181w, https://lycos7560.com/wp-content/uploads/image-420-300x59.png 300w, https://lycos7560.com/wp-content/uploads/image-420-768x152.png 768w" sizes="(max-width: 1181px) 100vw, 1181px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1097" height="578" src="https://lycos7560.com/wp-content/uploads/image-421.png" alt="" class="wp-image-2878" srcset="https://lycos7560.com/wp-content/uploads/image-421.png 1097w, https://lycos7560.com/wp-content/uploads/image-421-300x158.png 300w, https://lycos7560.com/wp-content/uploads/image-421-768x405.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">변경 전</p>



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



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



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



<p class="has-medium-font-size">그리고 라이팅의 결과물에&nbsp; Half- Lamber ( 하프 람버트 ) 공식인&nbsp;&nbsp;<strong>* 0.5 + 0.5</strong>&nbsp; 를 적용해줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="948" height="167" src="https://lycos7560.com/wp-content/uploads/image-422.png" alt="" class="wp-image-2880" srcset="https://lycos7560.com/wp-content/uploads/image-422.png 948w, https://lycos7560.com/wp-content/uploads/image-422-300x53.png 300w, https://lycos7560.com/wp-content/uploads/image-422-768x135.png 768w" sizes="(max-width: 948px) 100vw, 948px" /></figure>



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



<h2 class="wp-block-heading">Half- Lamber ( 하프 람버트 공식) 적용 후</h2>



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



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



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



<p class="has-medium-font-size"><strong>* 0.5 + 0.5</strong>&nbsp; 의 식은 -1 에서부터 1까지의 숫자를 0 에서 부터 1까지의 범위로 만들어 줍니다.</p>



<p class="has-medium-font-size">아래의 푸른 cos 이 붉은 라인으로 끌어 올라오게 됩니다.</p>



<p class="has-medium-font-size">이로 인하여 매우 부드러운 결과 값이 나오게 됩니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="802" height="732" src="https://lycos7560.com/wp-content/uploads/image-423.png" alt="" class="wp-image-2882" srcset="https://lycos7560.com/wp-content/uploads/image-423.png 802w, https://lycos7560.com/wp-content/uploads/image-423-300x274.png 300w, https://lycos7560.com/wp-content/uploads/image-423-768x701.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></figure>



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



<p class="has-medium-font-size">실제 사용할 때에는 빛의 영향을 좀 줄이고자 제곱을 해서 사용합니다.&nbsp;&nbsp;</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1078" height="196" src="https://lycos7560.com/wp-content/uploads/image-424.png" alt="" class="wp-image-2883" srcset="https://lycos7560.com/wp-content/uploads/image-424.png 1078w, https://lycos7560.com/wp-content/uploads/image-424-300x55.png 300w, https://lycos7560.com/wp-content/uploads/image-424-768x140.png 768w" sizes="(max-width: 1078px) 100vw, 1078px" /></figure>



<div style="height:21px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = dot(s.Normal, lightDir) * 0.5 + 0.5;
            return pow(ndotl, 3); // pow는 제곱
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



<p class="has-medium-font-size">pow&nbsp; &nbsp;제곱 적용 후</p>



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



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



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



<h2 class="wp-block-heading">Lambert 라이트 완성하기</h2>



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



<p class="has-medium-font-size">위의 상황은 빛 방향에 따른 밝기만 구현되었을 뿐, 조명의 색상과 강고 / 빛 감쇄 Albedo 텍스쳐 는 전혀 적용되지 않았습니다.</p>



<p class="has-medium-font-size">아래에서 나머지 내용을 추가하겠습니다.&nbsp;</p>



<p class="has-medium-font-size">pow와 dot 계산식을 하나로 병합합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="968" height="171" src="https://lycos7560.com/wp-content/uploads/image-425.png" alt="" class="wp-image-2885" srcset="https://lycos7560.com/wp-content/uploads/image-425.png 968w, https://lycos7560.com/wp-content/uploads/image-425-300x53.png 300w, https://lycos7560.com/wp-content/uploads/image-425-768x136.png 768w" sizes="(max-width: 968px) 100vw, 968px" /></figure>



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



<p class="has-medium-font-size">제 텍스쳐와 조명색상, 감쇠를 연산해서 조명을 완성해줍니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1023" height="258" src="https://lycos7560.com/wp-content/uploads/image-426.png" alt="" class="wp-image-2886" srcset="https://lycos7560.com/wp-content/uploads/image-426.png 1023w, https://lycos7560.com/wp-content/uploads/image-426-300x76.png 300w, https://lycos7560.com/wp-content/uploads/image-426-768x194.png 768w" sizes="(max-width: 1023px) 100vw, 1023px" /></figure>



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



<p class="has-medium-font-size">전체 코드</p>



<div style="height:24px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = pow ( dot(s.Normal, lightDir) * 0.5 + 0.5 , 3 );
            float4 final;
            final.rgb = ndotl * s.Albedo * _LightColor0.rgb * atten;
            final.a = s.Alpha;
            return final; 
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="540" height="441" src="https://lycos7560.com/wp-content/uploads/image-427.png" alt="" class="wp-image-2887" srcset="https://lycos7560.com/wp-content/uploads/image-427.png 540w, https://lycos7560.com/wp-content/uploads/image-427-300x245.png 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



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



<p class="has-medium-font-size">비어있던 MainTex도 넣어줍니다.</p>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="935" height="134" src="https://lycos7560.com/wp-content/uploads/image-428.png" alt="" class="wp-image-2889" srcset="https://lycos7560.com/wp-content/uploads/image-428.png 935w, https://lycos7560.com/wp-content/uploads/image-428-300x43.png 300w, https://lycos7560.com/wp-content/uploads/image-428-768x110.png 768w" sizes="(max-width: 935px) 100vw, 935px" /></figure>



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



<h2 class="wp-block-heading"><strong>s.Albedo&nbsp;</strong></h2>



<p class="has-medium-font-size">Albedo 로 입력받은 텍스쳐 입니다.</p>



<p class="has-medium-font-size">SurfaceOutput이 s 로 들어왔으니 s.Albedo 가 됩니다.</p>



<p class="has-medium-font-size">여기서 들어온 Albedo 텍스쳐가 Lambert 라이트와 연산이 되어서 Diffuse (확산) 됩니다.&nbsp;</p>



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



<h2 class="wp-block-heading"><strong>_LightColor0.rgb</strong></h2>



<p class="has-medium-font-size">이전에 연산했던 Ndotl 연산은 조명과 노멀의 각도를 표현한 것 뿐입니다.</p>



<p class="has-medium-font-size">조명의 색상이나 강도는 이 내장 변수를 이용해서 조명의 색상이나 강도를 가져옵니다.</p>



<p class="has-medium-font-size">이 변수를 곱한 후 조명의 생상과 강도를 변화시키면 그대로 반영됩니다.&nbsp;</p>



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



<h2 class="wp-block-heading"><strong>atten</strong></h2>



<p class="has-medium-font-size">빛의 감쇠 현상을 시뮬레이트합니다.</p>



<p class="has-medium-font-size">빛의 감쇠가 일어나는 경우는 아래와 같습니다. (atten를 계산하지 않으면 다음 일이 일어나지 않습니다.)</p>



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



<h2 class="wp-block-heading"><strong>1. self shadow가 생기지 않습니다.</strong></h2>



<p class="has-medium-font-size">자신의 그림자를 자신이 받지 않습니다.</p>



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



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



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



<h2 class="wp-block-heading"><strong><u>2. receive shadow가 동작하지 않습니다.</u></strong></h2>



<p class="has-medium-font-size">다른 물체가 그림자를 드리우지 못합니다.</p>



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



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



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



<h2 class="wp-block-heading"><strong>3. 조명의 감쇠 현상이 일어나지 않습니다.</strong></h2>



<p class="has-medium-font-size">Directional 라이트에서는 확인이 불가능하고&nbsp; point 라이트에서 확인이 가능합니다.</p>



<p class="has-medium-font-size">point 라이트가 멀어질수록 어두워지는데 이것이 atten가 하는 일입니다.&nbsp;</p>



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



<p class="has-medium-font-size">atten 미적용</p>



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



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



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



<p class="has-medium-font-size">atten 적용</p>



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



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



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



<p class="has-medium-font-size">//&nbsp; noambient&nbsp; 제거</p>



<div style="height:33px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight //noambient  
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = pow ( dot(s.Normal, lightDir) * 0.5 + 0.5 , 3 );
            float4 final;
            final.rgb = ndotl * s.Albedo * _LightColor0.rgb * atten;
            final.a = s.Alpha;
            return final; 
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



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



<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)"/>



<figure class="wp-block-image size-full"><img decoding="async" width="1084" height="114" src="https://lycos7560.com/wp-content/uploads/image-431.png" alt="" class="wp-image-2895" srcset="https://lycos7560.com/wp-content/uploads/image-431.png 1084w, https://lycos7560.com/wp-content/uploads/image-431-300x32.png 300w, https://lycos7560.com/wp-content/uploads/image-431-768x81.png 768w" sizes="(max-width: 1084px) 100vw, 1084px" /></figure>



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



<p class="has-medium-font-size">이렇게 적용하면 얼굴이 밝아지면서 atten으로 생기는 얼굴의 그림자가 두드러지게 보이는 단점이 생길 것 입니다.</p>



<p class="has-medium-font-size">정답은 없고 atten를 제거해도 좋고 pow 함수를 이용하여 적절하게 숨기는 것도 하나의 방법입니다.</p>



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



<p class="has-medium-font-size">이제 완전한 Lambert 가 완성되었습니다.</p>



<p class="has-medium-font-size">이것은 유니티4까지 사용되었던 Bump Diffuse와 완전히 같은 쉐이더이며</p>



<p class="has-medium-font-size">유니티5에서도 Legacy Shaders / Bumped Diffuse와도 완전히 같은 쉐이더입니다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-half-lambert/2873/">11 &#8211; 03 ~ 04 Half-Lambert(하프 램버트) 연산 및 완성 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity_shader-half-lambert/2873/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_40_14_926.mp4" length="1789228" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_43_51_403.mp4" length="1396326" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_45_59_585.mp4" length="1170911" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_49_10_310.mp4" length="1081007" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_54_13_816.mp4" length="527708" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_55_17_400.mp4" length="823267" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_13_56_59_799.mp4" length="1167010" type="video/mp4" />

			</item>
		<item>
		<title>11 &#8211; 01 ~ 02 커스텀 라이트 기본형 / Lambert 라이트 연산 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity_shader-custom-lights-lambert-lights/2852/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity_shader-custom-lights-lambert-lights/2852/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 02:50:54 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[Lambert]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[lighting]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[기본형]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[유니티]]></category>
		<category><![CDATA[유니티 쉐이더 스타트업]]></category>
		<category><![CDATA[커스텀라이트]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2852</guid>

					<description><![CDATA[<p>커스텀 라이트의 기본형과 Lambert 라이트를 구현하는 방법을 예제로 간략하게 설명한 글입니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-custom-lights-lambert-lights/2852/">11 &#8211; 01 ~ 02 커스텀 라이트 기본형 / Lambert 라이트 연산 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:58px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">11 &#8211; 01 ~ 02 커스텀 라이트 기본형 / Lambert 라이트 연산 (Unity Shader)</h2>



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



<p class="has-medium-font-size">텍스처 한 장만 받는 기본형 쉐이더를 만듭니다.</p>



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



<p class="has-medium-font-size">직접 확인해보기 위해서 아래 에셋을 사용했습니다. (무료)</p>



<p class="has-medium-font-size"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener">https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519</a>&nbsp;&lt;- TestAsset</p>



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



<figure class="wp-block-image size-full"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1304" height="317" src="https://lycos7560.com/wp-content/uploads/image-388.png" alt="" class="wp-image-2824" srcset="https://lycos7560.com/wp-content/uploads/image-388.png 1304w, https://lycos7560.com/wp-content/uploads/image-388-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-388-768x187.png 768w" sizes="(max-width: 1304px) 100vw, 1304px" /></a></figure>



<div style="height:58px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert noambient  
        // noambient - 주변광 또는 라이트 프로브를 적용하지 않습니다.
        #pragma target 3.0
        
        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

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



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



<figure class="wp-block-image size-full"><img decoding="async" width="1523" height="526" src="https://lycos7560.com/wp-content/uploads/image-404.png" alt="" class="wp-image-2853" srcset="https://lycos7560.com/wp-content/uploads/image-404.png 1523w, https://lycos7560.com/wp-content/uploads/image-404-300x104.png 300w, https://lycos7560.com/wp-content/uploads/image-404-768x265.png 768w" sizes="(max-width: 1523px) 100vw, 1523px" /></figure>



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



<p class="has-medium-font-size">Lambert 라이트를 삭제하고 자신만의 라이트 이름을 지어서 커스텀 라이트를 구동시켜 보겠습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="947" height="939" src="https://lycos7560.com/wp-content/uploads/image-405.png" alt="" class="wp-image-2854" srcset="https://lycos7560.com/wp-content/uploads/image-405.png 947w, https://lycos7560.com/wp-content/uploads/image-405-300x297.png 300w, https://lycos7560.com/wp-content/uploads/image-405-150x150.png 150w, https://lycos7560.com/wp-content/uploads/image-405-768x762.png 768w" sizes="(max-width: 947px) 100vw, 947px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1530" height="476" src="https://lycos7560.com/wp-content/uploads/image-406.png" alt="" class="wp-image-2855" srcset="https://lycos7560.com/wp-content/uploads/image-406.png 1530w, https://lycos7560.com/wp-content/uploads/image-406-300x93.png 300w, https://lycos7560.com/wp-content/uploads/image-406-768x239.png 768w" sizes="(max-width: 1530px) 100vw, 1530px" /></figure>



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



<p class="has-medium-font-size">바뀌거나 추가된 내용을 하나씩 보겠습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="812" height="120" src="https://lycos7560.com/wp-content/uploads/image-407.png" alt="" class="wp-image-2856" srcset="https://lycos7560.com/wp-content/uploads/image-407.png 812w, https://lycos7560.com/wp-content/uploads/image-407-300x44.png 300w, https://lycos7560.com/wp-content/uploads/image-407-768x113.png 768w" sizes="(max-width: 812px) 100vw, 812px" /></figure>



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



<p class="has-medium-font-size">Lambert 대신에 _MyLight로 바뀌었습니다.</p>



<p class="has-medium-font-size">여기는 이름을 마음대로 지어도 상관없습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="904" height="147" src="https://lycos7560.com/wp-content/uploads/image-408.png" alt="" class="wp-image-2857" srcset="https://lycos7560.com/wp-content/uploads/image-408.png 904w, https://lycos7560.com/wp-content/uploads/image-408-300x49.png 300w, https://lycos7560.com/wp-content/uploads/image-408-768x125.png 768w" sizes="(max-width: 904px) 100vw, 904px" /></figure>



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



<p class="has-medium-font-size">우리가 만든 커스텀 함수의 모습입니다.</p>



<p class="has-medium-font-size">이전까지는 void surf 사용했습니다.</p>



<p class="has-medium-font-size">이 함수는 float4로 시작합니다. 함수가 float4 를 반환 하므로 return float4&nbsp; 출력값을 가지고 있습니다.&nbsp;</p>



<p class="has-medium-font-size">이어서 나오는 이름도 Lighting + &#8220;커스텀 라이트 이름&#8221; 을 추가해 주어야 합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="542" height="57" src="https://lycos7560.com/wp-content/uploads/image-409.png" alt="" class="wp-image-2858" srcset="https://lycos7560.com/wp-content/uploads/image-409.png 542w, https://lycos7560.com/wp-content/uploads/image-409-300x32.png 300w" sizes="(max-width: 542px) 100vw, 542px" /></figure>



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



<p class="has-medium-font-size">SurfaceOutput 구조체를 통째로 받아옵니다.</p>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="693" height="400" src="https://lycos7560.com/wp-content/uploads/image-411.png" alt="" class="wp-image-2860" srcset="https://lycos7560.com/wp-content/uploads/image-411.png 693w, https://lycos7560.com/wp-content/uploads/image-411-300x173.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></figure>



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



<p class="has-medium-font-size">float3 lightDir 은 이전 파트에서 배웠던 조명 방향의 벡터 입니다.</p>



<p class="has-medium-font-size">단, 조명 계산을 편하게 사용하기 위해서 뒤집혀지고 길이가 1인 단위 벡터의 상태입니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="818" height="455" src="https://lycos7560.com/wp-content/uploads/image-412.png" alt="" class="wp-image-2861" srcset="https://lycos7560.com/wp-content/uploads/image-412.png 818w, https://lycos7560.com/wp-content/uploads/image-412-300x167.png 300w, https://lycos7560.com/wp-content/uploads/image-412-768x427.png 768w" sizes="(max-width: 818px) 100vw, 818px" /></figure>



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



<p class="has-medium-font-size">float atten</p>



<p class="has-medium-font-size">atten ( attenuation ) 감쇠</p>



<p class="has-medium-font-size">그림자를 받거나 거리가 멀어지면서 점점 조명이 흐려지는 라이트의 거리별 감쇠 현상을 나타냅니다.</p>



<p class="has-medium-font-size">내가 빛을 받는 것을 없앨 때 사용하는 부분입니다.</p>



<div style="height:28px" 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)"/>



<p class="has-medium-font-size">Lambert&nbsp;라이트&nbsp;연산</p>



<p class="has-medium-font-size">우리가 만든 커스텀 라이트에서 변경합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1058" height="403" src="https://lycos7560.com/wp-content/uploads/image-413.png" alt="" class="wp-image-2862" srcset="https://lycos7560.com/wp-content/uploads/image-413.png 1058w, https://lycos7560.com/wp-content/uploads/image-413-300x114.png 300w, https://lycos7560.com/wp-content/uploads/image-413-768x293.png 768w" sizes="(max-width: 1058px) 100vw, 1058px" /></figure>



<div style="height:33px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        // noambient - 주변광 또는 라이트 프로브를 적용하지 않습니다.
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = dot(s.Normal, lightDir);
            // dot 노멀 백터와 라이트 벡터를 내적 연산
            // surf 에서 Normal 값을 받지 않아도 버텍스에서 노말값을 평범하게 받음

            return ndotl;
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



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



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



<p class="has-medium-font-size">lightDir은 버텍스에서 바라보는 조명의 방향인 뒤집힌 방향 이기 때문에 두 벤터를 단순하게 내적해주면 cos 값이 나오게 됩니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1533" height="530" src="https://lycos7560.com/wp-content/uploads/image-414.png" alt="" class="wp-image-2864" srcset="https://lycos7560.com/wp-content/uploads/image-414.png 1533w, https://lycos7560.com/wp-content/uploads/image-414-300x104.png 300w, https://lycos7560.com/wp-content/uploads/image-414-768x266.png 768w" sizes="(max-width: 1533px) 100vw, 1533px" /></figure>



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



<p class="has-medium-font-size">위와 같은 코드는 가장 밝은 곳이 1 / 어두워 지는 경계선은 0 / 가장 어두운 곳은 -1 값으로 되어서</p>



<p class="has-medium-font-size">나중에 추가 라이트를 비추거나 할 때 문제가 됩니다.&nbsp;</p>



<p class="has-medium-font-size">이 현상을 방지하기 위해서&nbsp; saturate (값) 함수를 사용합니다.</p>



<p class="has-medium-font-size">max 함수도 사용하지만 최대 값이 없습니다.</p>



<p class="has-medium-font-size">max(0, dot(s.Normal, lightDir));</p>



<p class="has-medium-font-size">float&nbsp;ndotl&nbsp;=&nbsp;max(0,&nbsp;dot(s.Normal,&nbsp;lightDir));</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="819" height="225" src="https://lycos7560.com/wp-content/uploads/image-415.png" alt="" class="wp-image-2865" srcset="https://lycos7560.com/wp-content/uploads/image-415.png 819w, https://lycos7560.com/wp-content/uploads/image-415-300x82.png 300w, https://lycos7560.com/wp-content/uploads/image-415-768x211.png 768w" sizes="(max-width: 819px) 100vw, 819px" /></figure>



<div style="height:28px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        // noambient - 주변광 또는 라이트 프로브를 적용하지 않습니다.
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = saturate(dot(s.Normal, lightDir));

            // dot 노멀 백터와 라이트 벡터를 내적 연산
            // surf 에서 Normal 값을 받지 않아도 버텍스에서 노말값을 평범하게 받음
            // saturate 0 이하 값을 0으로 만들어줌
            
            // float ndotl = max(0, dot(s.Normal, lightDir));
            // max 함수도 있지만 최대 값이 없습니다.

            return ndotl;
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



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



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



<p class="has-medium-font-size">NormalMap 적용</p>



<div style="height:29px" 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/CustomLight"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf _MyLight noambient  
        // noambient - 주변광 또는 라이트 프로브를 적용하지 않습니다.
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {

            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }

        
        float4 Lighting_MyLight(SurfaceOutput s, float3 lightDir, float atten)
        {
            float ndotl = saturate(dot(s.Normal, lightDir));

            // dot 노멀 백터와 라이트 벡터를 내적 연산
            // surf 에서 Normal 값을 받지 않아도 버텍스에서 노말값을 평범하게 받음
            // saturate 0 이하 값을 0으로 만들어줌
            
            // float ndotl = max(0, dot(s.Normal, lightDir));
            // max 함수도 있지만 최대 값이 없습니다.

            return ndotl;
        }

        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



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



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



<p class="has-medium-font-size">환경광 제거</p>



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



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



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



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



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-custom-lights-lambert-lights/2852/">11 &#8211; 01 ~ 02 커스텀 라이트 기본형 / Lambert 라이트 연산 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity_shader-custom-lights-lambert-lights/2852/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_38_53_802.mp4" length="1320242" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_41_55_314.mp4" length="1044809" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_43_19_983.mp4" length="2358455" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_44_56_814.mp4" length="1993886" type="video/mp4" />

			</item>
		<item>
		<title>9 &#8211; 02 ~ 03 Lambert (램버트) / Blinn-Phong(블린-퐁) (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity_shader-lambert-blinn-phong/2841/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity_shader-lambert-blinn-phong/2841/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 02:26:12 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[_SpecColor]]></category>
		<category><![CDATA[Blinn-Phong]]></category>
		<category><![CDATA[Lambert]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[lighting]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Specular]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[라이트]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[유니티]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2841</guid>

					<description><![CDATA[<p>Unity의 Lambert 라이트와 blinn-pong 라이트를 간단하게 설명하면서 구현하는 글입니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-lambert-blinn-phong/2841/">9 &#8211; 02 ~ 03 Lambert (램버트) / Blinn-Phong(블린-퐁) (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:47px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">9 &#8211; 02 ~ 03 Lambert (램버트) / Blinn-Phong(블린-퐁) (Unity Shader)</h2>



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



<p class="has-medium-font-size">유니티4 이전 시절에 존재하던 가벼운 라이팅 방식인 Lambert 라이팅</p>



<p class="has-medium-font-size">램버트 라이팅 초기 구조</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="709" height="854" src="https://lycos7560.com/wp-content/uploads/image-399.png" alt="" class="wp-image-2842" srcset="https://lycos7560.com/wp-content/uploads/image-399.png 709w, https://lycos7560.com/wp-content/uploads/image-399-249x300.png 249w" sizes="(max-width: 709px) 100vw, 709px" /></figure>



<div style="height:37px" 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/Lambert"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

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



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



<p class="has-medium-font-size">둔탁한 느낌의 이미지가 Lambert 라이트의 특징입니다.</p>



<p class="has-medium-font-size">o.Specular / o.Gloss 는 사용하지 않으므로 값을 넣어도 나타나지 않습니다.</p>



<p class="has-medium-font-size">겉으로는 크게 바뀐 것 같지 않지만 내장된 기본 라이팅 구조 중에서 가장 가벼운 라이트입니다. (저사양 기기에서도 잘 구동됩니다.)</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1307" height="874" src="https://lycos7560.com/wp-content/uploads/image-400.png" alt="" class="wp-image-2843" srcset="https://lycos7560.com/wp-content/uploads/image-400.png 1307w, https://lycos7560.com/wp-content/uploads/image-400-300x201.png 300w, https://lycos7560.com/wp-content/uploads/image-400-768x514.png 768w" sizes="(max-width: 1307px) 100vw, 1307px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1339" height="872" src="https://lycos7560.com/wp-content/uploads/image-401.png" alt="" class="wp-image-2844" srcset="https://lycos7560.com/wp-content/uploads/image-401.png 1339w, https://lycos7560.com/wp-content/uploads/image-401-300x195.png 300w, https://lycos7560.com/wp-content/uploads/image-401-768x500.png 768w" sizes="(max-width: 1339px) 100vw, 1339px" /></figure>



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



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



<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">간단한 Blinn Phong 라이트 구현&nbsp;</h2>



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



<figure class="wp-block-image size-full"><img decoding="async" width="692" height="799" src="https://lycos7560.com/wp-content/uploads/image-402.png" alt="" class="wp-image-2846" srcset="https://lycos7560.com/wp-content/uploads/image-402.png 692w, https://lycos7560.com/wp-content/uploads/image-402-260x300.png 260w" sizes="(max-width: 692px) 100vw, 692px" /></figure>



<div style="height:20px" 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/BlinnPhong"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf BlinnPhong
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };


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



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



<p class="has-medium-font-size">BlinnPhong 공식이 가동 되었지만 Specular는 보이지 않습니다.</p>



<p class="has-medium-font-size">Specular를 보기위해 추가로 데이터를 입력합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="689" height="939" src="https://lycos7560.com/wp-content/uploads/image-403.png" alt="" class="wp-image-2847" srcset="https://lycos7560.com/wp-content/uploads/image-403.png 689w, https://lycos7560.com/wp-content/uploads/image-403-220x300.png 220w" sizes="(max-width: 689px) 100vw, 689px" /></figure>



<div style="height:49px" 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/BlinnPhong"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _SpecColor("SpecColor", color) = (1,1,1,1)
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf BlinnPhong
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };


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



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



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



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



<p class="has-medium-font-size">위의 코드에서 어디에서도 _SpecColor 를 받는 부분이 없습니다.</p>



<p class="has-medium-font-size">_SpecColor 는 절대로 코드에서 받으면 안 되고, 단지&nbsp; Properties 에서만 만들어야 한다는 것 입니다.</p>



<p class="has-medium-font-size">그리고 _SpecColor 라는 이름 외에 다른 이름을 써서도 안됩니다.</p>



<p class="has-medium-font-size"><strong>BlinnPong 내부의 코드를 열어보면 _SpecColor 이름이 예약어이며 절대로 코드 내부에서 받으면 안된다는 특이한 예외 사항이 존재합니다.</strong></p>



<p class="has-medium-font-size">o.Gloss 는 0~ 1 사이의 값을 넣어야 하며 Specular 의 강도를 의미합니다.</p>



<p class="has-medium-font-size">0이면 둔탁한 재질 / 1이면 매끄러운 재질을 의미합니다.</p>



<p class="has-medium-font-size">o.Specular는 0~ 1 사이의 값을 넣어야 하며 Specular 의 크기를 의미합니다.</p>



<p class="has-medium-font-size">0이면 크기가 커지고&nbsp; / 1이면 크기가 작아집니다.</p>



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



<p class="has-medium-font-size">확인용 코드</p>



<div style="height:25px" 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/BlinnPhong"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _SpecColor("SpecColor", color) = (1,1,1,1)
        _SpecAmount("SpecAmount",Range(0,1)) = 0.5
        _GlossAmount("_GlossAmount",Range(0,1)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf BlinnPhong
        #pragma target 3.0

        sampler2D _MainTex;
        float _SpecAmount;
        float _GlossAmount;

        struct Input
        {
            float2 uv_MainTex;
        };


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



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



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



<div style="height:133px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-lambert-blinn-phong/2841/">9 &#8211; 02 ~ 03 Lambert (램버트) / Blinn-Phong(블린-퐁) (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity_shader-lambert-blinn-phong/2841/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_15_46_258.mp4" length="1365005" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_18_55_461.mp4" length="2616931" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_11_21_22_869.mp4" length="900683" type="video/mp4" />

			</item>
		<item>
		<title>9 &#8211; 01 유니티에 내장된 라이팅 구조 (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader-lighting-structure/2835/</link>
					<comments>https://lycos7560.com/unity/unity_shader-lighting-structure/2835/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 02:08:42 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[Blinn Phong]]></category>
		<category><![CDATA[Lambert]]></category>
		<category><![CDATA[lighting]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[구조체]]></category>
		<category><![CDATA[라이팅]]></category>
		<category><![CDATA[램버트]]></category>
		<category><![CDATA[블린퐁]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[스탠다드]]></category>
		<category><![CDATA[유니티]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2835</guid>

					<description><![CDATA[<p>유니티에 내장된 라이팅 구조를 간략하게 설명하는 글입니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader-lighting-structure/2835/">9 &#8211; 01 유니티에 내장된 라이팅 구조 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:57px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">9 &#8211; 01 유니티에 내장된 라이팅 구조 (Unity Shader)</h2>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1019" height="303" src="https://lycos7560.com/wp-content/uploads/image-395.png" alt="" class="wp-image-2836" srcset="https://lycos7560.com/wp-content/uploads/image-395.png 1019w, https://lycos7560.com/wp-content/uploads/image-395-300x89.png 300w, https://lycos7560.com/wp-content/uploads/image-395-768x228.png 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></figure>



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



<p class="has-medium-font-size">쉐이더를 처음 만들면 자동으로 생성되는 Standard Shader 는 유니티 5부터 기본적으로 적용된 쉐이더 형태입니다.</p>



<p class="has-medium-font-size">Standard Shader의 라이팅은 좋은 라이팅이지만 물리기반의 쉐이더 라이트이기 때문에</p>



<p class="has-medium-font-size">모바일과 같은 저 사양 기기에서 구동하기에는 다소 무겁습니다.</p>



<p class="has-medium-font-size">그래서 유니티 내부적으로는 유니티4버전 이전부터 사용하던 라이트 구조도 그대로 구현되어 있습니다.</p>



<p class="has-medium-font-size">이 라이팅은 물리 기반의 쉐이더보다 품질을 떨어질 수 있지만 상대적으로 가볍기 때문에 물리 기반의 쉐이더를 사용할 필요 없이</p>



<p class="has-medium-font-size">가볍게 처리해야 하는 모바일 프로젝트에 적합한 쉐이더 구조라고 할 수 있습니다.</p>



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



<p class="has-medium-font-size">우리가 지금까지 사용한 물리기반 쉐이더의 구조체</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1206" height="402" src="https://lycos7560.com/wp-content/uploads/image-396.png" alt="" class="wp-image-2837" srcset="https://lycos7560.com/wp-content/uploads/image-396.png 1206w, https://lycos7560.com/wp-content/uploads/image-396-300x100.png 300w, https://lycos7560.com/wp-content/uploads/image-396-768x256.png 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></figure>



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



<p class="has-medium-font-size">또는</p>



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



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



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



<p class="has-medium-font-size">물리 기반 쉐이더 이전의 쉐이더 구조인 램버트 / 블린퐁 라이트에서 사용하는 구조체 </p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1520" height="398" src="https://lycos7560.com/wp-content/uploads/image-398.png" alt="" class="wp-image-2839" srcset="https://lycos7560.com/wp-content/uploads/image-398.png 1520w, https://lycos7560.com/wp-content/uploads/image-398-300x79.png 300w, https://lycos7560.com/wp-content/uploads/image-398-768x201.png 768w" sizes="(max-width: 1520px) 100vw, 1520px" /></figure>



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



<h2 class="has-medium-font-size wp-block-heading"><strong>즉 유니티에 내장되어 있는 라이팅은 총 3가지라고 할 수 있습니다. </strong></h2>



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



<h2 class="has-medium-font-size wp-block-heading">1. Lambert 램버트</h2>



<p class="has-medium-font-size">Specular 의 공식이 없고 단지 빛에 의한 밝고 어두움이 구현된 가벼운 라이트 구조  / SurfaceOutput 구조체 사용</p>



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



<h2 class="has-medium-font-size wp-block-heading">2. Blinn Phong 블린퐁</h2>



<p class="has-medium-font-size">램버트 공식에 가벼운 Specular 공식인 블린퐁 공식이 더해진 라이트 구조,</p>



<p class="has-medium-font-size">Specular 공식은 보는 각도와 조명 각도에 따라 계산된 특정 색의 하이라이트 동그라미로 표현된다. / SurfaceOutput 구조체 사용</p>



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



<h2 class="has-medium-font-size wp-block-heading">3.&nbsp;&nbsp;Standard 스탠다드</h2>



<p class="has-medium-font-size">일명 PBS ( 물리 기반 쉐이더 : Physically Based Shader)</p>



<p class="has-medium-font-size">주변 환경을 반사하서 Specular 를 구현하며, Diffuse 와 Specular 가 에너지 보존 법칙에 의해 서로 보완관계를 자동적으로 가지며</p>



<p class="has-medium-font-size">Specular dml 칼라가 메탈릭 속성에 따라 자동적으로 결정되는 라이트 구조</p>



<p class="has-medium-font-size">SurfaceOutputStandard 또는 SurfaceOutputStandardSpecular 구조체 사용</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader-lighting-structure/2835/">9 &#8211; 01 유니티에 내장된 라이팅 구조 (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader-lighting-structure/2835/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>8 &#8211; 04 Occlusion (오클루젼) (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader/unity_shader-ambient-occlusion/2820/</link>
					<comments>https://lycos7560.com/unity/unity_shader/unity_shader-ambient-occlusion/2820/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 01 Dec 2022 01:54:04 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[Ambient]]></category>
		<category><![CDATA[Ambient Occlusion]]></category>
		<category><![CDATA[Occlusion]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[엠비언트 오클루젼]]></category>
		<category><![CDATA[오클루젼]]></category>
		<category><![CDATA[유니티]]></category>
		<category><![CDATA[환경광]]></category>
		<category><![CDATA[환경차폐]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2820</guid>

					<description><![CDATA[<p>UnityShader에서 Ambient Occlusion을 사용하는 방법을 간략하게 예제로 설명한 글입니다.</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-ambient-occlusion/2820/">8 &#8211; 04 Occlusion (오클루젼) (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:55px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><strong>8 &#8211; 04 Occlusion (오클루젼) (Unity Shader)</strong></h2>



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



<p class="has-medium-font-size">Occlusion (오클루젼)은 Ambient Occlusion (엠비언트 오클루젼) 이라고 부르며, 구석진 부분의 추가적인 음영을 표현하는 기능입니다.</p>



<p class="has-medium-font-size">일반적으로 세상에서 그림자가 드리워진 부분도 사방에서 오는 환경광 정도를 받고 있는 것이 일반적입니다.</p>



<p class="has-medium-font-size">하지만, 매우 구석져 있거나 복잡한 물체들로 가려져서 환경광도 닫지 못하는 부분은 더욱 더 어두워지는 데&nbsp;&nbsp;</p>



<p class="has-medium-font-size">이 부분은&nbsp;Ambient&nbsp;Occlusion (엠비언트 오클루젼) 환경차폐라고 부릅니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1045" height="597" src="https://lycos7560.com/wp-content/uploads/image-385.png" alt="" class="wp-image-2821" srcset="https://lycos7560.com/wp-content/uploads/image-385.png 1045w, https://lycos7560.com/wp-content/uploads/image-385-300x171.png 300w, https://lycos7560.com/wp-content/uploads/image-385-768x439.png 768w" sizes="(max-width: 1045px) 100vw, 1045px" /></figure>



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



<p class="has-medium-font-size"><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/Manual/SL-SurfaceShaders.html</a></p>



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



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1312" height="317" src="https://lycos7560.com/wp-content/uploads/image-386.png" alt="" class="wp-image-2822" srcset="https://lycos7560.com/wp-content/uploads/image-386.png 1312w, https://lycos7560.com/wp-content/uploads/image-386-300x72.png 300w, https://lycos7560.com/wp-content/uploads/image-386-768x186.png 768w" sizes="(max-width: 1312px) 100vw, 1312px" /></a></figure>



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



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



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



<p class="has-medium-font-size">직접 확인해보기 위해서 아래 에셋을 사용했습니다. (무료)</p>



<p class="has-medium-font-size"><a href="https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519" target="_blank" rel="noreferrer noopener">https://assetstore.unity.com/packages/3d/characters/humanoids/barbarian-warrior-75519</a>&nbsp;&lt;- TestAsset</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1304" height="317" src="https://lycos7560.com/wp-content/uploads/image-388.png" alt="" class="wp-image-2824" srcset="https://lycos7560.com/wp-content/uploads/image-388.png 1304w, https://lycos7560.com/wp-content/uploads/image-388-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-388-768x187.png 768w" sizes="(max-width: 1304px) 100vw, 1304px" /></figure>



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



<p class="has-medium-font-size">사용했던 바바리안 몸체는 잠시 비활성화 하고 도끼를 활성화 했습니다.</p>



<p class="has-medium-font-size">쉐이더 코드는 바바리안 바디에 적용했던 코드를 사용했습니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1298" height="900" src="https://lycos7560.com/wp-content/uploads/image-389.png" alt="" class="wp-image-2825" srcset="https://lycos7560.com/wp-content/uploads/image-389.png 1298w, https://lycos7560.com/wp-content/uploads/image-389-300x208.png 300w, https://lycos7560.com/wp-content/uploads/image-389-768x533.png 768w" sizes="(max-width: 1298px) 100vw, 1298px" /></figure>



<div style="height:64px" 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/AxeOC"
{
    Properties
    {
        _MainTex("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {} // NormalMap
        _Test("TestFloat",Range(0.5, 3)) = 1
    }
        SubShader
        {
            Tags { "RenderType" = "Opaque" }
            LOD 200

            CGPROGRAM
            #pragma surface surf Standard
            #pragma target 3.0

            sampler2D _MainTex;
            sampler2D _BumpMap; // NormalMap
            float _Test;

            struct Input
            {
                float2 uv_MainTex;
                float2 uv_BumpMap; // NormalMap
            };

            void surf(Input IN, inout SurfaceOutputStandard o)
            {
                float4 c = tex2D(_MainTex, IN.uv_MainTex);

                float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
                o.Normal = float3(d.x * _Test, d.y * _Test, d.z);
                // _Test에 따라서 수치 변화  2  2배  0.5  0.5배 
                o.Albedo = c.rgb;
                o.Alpha = c.a;
            }
            ENDCG
        }
            FallBack "Diffuse"
}</pre>



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



<p class="has-medium-font-size">Occlusion 추가</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="761" height="999" src="https://lycos7560.com/wp-content/uploads/image-390.png" alt="" class="wp-image-2826" srcset="https://lycos7560.com/wp-content/uploads/image-390.png 761w, https://lycos7560.com/wp-content/uploads/image-390-229x300.png 229w" sizes="(max-width: 761px) 100vw, 761px" /></figure>



<div style="height:55px" 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/AxeOC"
{
    Properties
    {
        _MainTex("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "white" {}
        _Test("TestFloat",Range(0.5, 3)) = 1
        _Occlusion("Occlusion", 2D) = "white" {} // Occlusion
    }
        SubShader
    {
        Tags { "RenderType" = "Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard
        #pragma target 3.0

        sampler2D _MainTex;
        sampler2D _BumpMap;
        sampler2D _Occlusion;

        float _Test;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            // 주의 uv_Occlusion 포함 X

        };

        void surf(Input IN, inout SurfaceOutputStandard o)
        {
            float4 c = tex2D(_MainTex, IN.uv_MainTex);
            o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex); // Occlusion
            // _MainTex와 동일한 UV 값을 받습니다.

            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = float3(d.x * _Test, d.y * _Test, d.z);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
        FallBack "Diffuse"
}</pre>



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



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



<p class="has-medium-font-size">Occlusion 적용 전</p>



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



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



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



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



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



<p class="has-medium-font-size">Occlusion 적용 후</p>



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



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



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



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



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



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



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



<p class="has-medium-font-size">Normal Map 의 강도를 조절하면 더 확실하게 알 수 있습니다.</p>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="921" height="114" src="https://lycos7560.com/wp-content/uploads/image-394.png" alt="" class="wp-image-2833" srcset="https://lycos7560.com/wp-content/uploads/image-394.png 921w, https://lycos7560.com/wp-content/uploads/image-394-300x37.png 300w, https://lycos7560.com/wp-content/uploads/image-394-768x95.png 768w" sizes="(max-width: 921px) 100vw, 921px" /></figure>



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



<p class="has-medium-font-size">지금 사용한 코드에서는 Occlusion은 half (SurfaceOutput -float4)를 받습니다. (r 채널만 사용합니다.)</p>



<p class="has-medium-font-size">Occlusion 기능을 위해서 rgb 채널을 사용하는 텍스쳐를 사용하는 것은 낭비입니다.</p>



<p class="has-medium-font-size">_MainTex의 a 채널에 Occlusion 맵을 넣고 사용한다면 텍스쳐를 절약 할 수 있습니다.</p>



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



<p></p>



<p></p>



<p></p>



<p></p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader/unity_shader-ambient-occlusion/2820/">8 &#8211; 04 Occlusion (오클루젼) (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader/unity_shader-ambient-occlusion/2820/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_10_43_19_134.mp4" length="700005" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_10_45_53_811.mp4" length="1113394" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_10_48_01_712.mp4" length="444913" type="video/mp4" />

			</item>
		<item>
		<title>8 &#8211; 01 ~ 02 Standard Shader / Metallic, Smoothness (Unity Shader)</title>
		<link>https://lycos7560.com/unity/unity_shader_standard-shader-metallic-smoothness-unity-shader/2791/</link>
					<comments>https://lycos7560.com/unity/unity_shader_standard-shader-metallic-smoothness-unity-shader/2791/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 30 Nov 2022 23:50:30 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[UnityShader]]></category>
		<category><![CDATA[Albedo]]></category>
		<category><![CDATA[Emission]]></category>
		<category><![CDATA[Metallic]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Smoothness]]></category>
		<category><![CDATA[Standard Shader / Metallic]]></category>
		<category><![CDATA[Standard Surface Shader]]></category>
		<category><![CDATA[Unity Shader]]></category>
		<category><![CDATA[쉐이더]]></category>
		<category><![CDATA[유니티]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2791</guid>

					<description><![CDATA[<p>08 &#8211; 01 Standard Shader https://docs.unity3d.com/kr/2020.3/Manual/UpgradeGuide5.html 유니티 5.0이 되면서 다른 많은 그래픽 툴이나 엔진처럼 최신의 쉐이더 시스템인 &#8216;물리 기반 쉐이더&#8217; 시스템을 도입하게 되었습니다. 기존의 쉐이더 시스템과는 다르게, 주변 환경에 따른 재질 변화를 물리 법칙에 기반하여 실시간으로 재질을 구현해주는 사실적인 쉐이더 표현 기법입니다. 유니티에 있는 기본 Standard Shader 가 대표적인 물리 기반 쉐이더입니다. https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html 우리가 사용한&#160; [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/unity/unity_shader_standard-shader-metallic-smoothness-unity-shader/2791/">8 &#8211; 01 ~ 02 Standard Shader / Metallic, Smoothness (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">08 &#8211; 01 Standard Shader</h2>



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



<p class="has-medium-font-size"><a href="https://docs.unity3d.com/kr/2020.3/Manual/UpgradeGuide5.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/kr/2020.3/Manual/UpgradeGuide5.html</a></p>



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



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/kr/2020.3/Manual/UpgradeGuide5.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1085" height="264" src="https://lycos7560.com/wp-content/uploads/image-370.png" alt="" class="wp-image-2792" srcset="https://lycos7560.com/wp-content/uploads/image-370.png 1085w, https://lycos7560.com/wp-content/uploads/image-370-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-370-768x187.png 768w" sizes="(max-width: 1085px) 100vw, 1085px" /></a></figure>



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



<p class="has-medium-font-size">유니티 5.0이 되면서 다른 많은 그래픽 툴이나 엔진처럼 최신의 쉐이더 시스템인</p>



<p class="has-medium-font-size">&#8216;물리 기반 쉐이더&#8217; 시스템을 도입하게 되었습니다.</p>



<p class="has-medium-font-size">기존의 쉐이더 시스템과는 다르게, 주변 환경에 따른 재질 변화를 물리 법칙에 기반하여</p>



<p class="has-medium-font-size">실시간으로 재질을 구현해주는 사실적인 쉐이더 표현 기법입니다.</p>



<p class="has-medium-font-size">유니티에 있는 기본 Standard Shader 가 대표적인 물리 기반 쉐이더입니다.</p>



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



<p class="has-medium-font-size"><a href="https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/kr/2021.3/Manual/SL-SurfaceShaders.html</a></p>



<div style="height:26px" 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-SurfaceShaders.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1098" height="271" src="https://lycos7560.com/wp-content/uploads/image-371.png" alt="" class="wp-image-2793" srcset="https://lycos7560.com/wp-content/uploads/image-371.png 1098w, https://lycos7560.com/wp-content/uploads/image-371-300x74.png 300w, https://lycos7560.com/wp-content/uploads/image-371-768x190.png 768w" sizes="(max-width: 1098px) 100vw, 1098px" /></a></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1322" height="336" src="https://lycos7560.com/wp-content/uploads/image-372.png" alt="" class="wp-image-2795" srcset="https://lycos7560.com/wp-content/uploads/image-372.png 1322w, https://lycos7560.com/wp-content/uploads/image-372-300x76.png 300w, https://lycos7560.com/wp-content/uploads/image-372-768x195.png 768w" sizes="(max-width: 1322px) 100vw, 1322px" /></figure>



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



<p class="has-medium-font-size">우리가 사용한&nbsp; o.Emission과 o.Albedo 같은 변수들은 바로 이 구조체 안에 정의되어 있는 것을 사용한 것이고</p>



<p class="has-medium-font-size">우리는 여기에 알맞은 값을 넣어 주면 알아서 결과가 나오게 되는 것입니다.&nbsp;</p>



<p class="has-medium-font-size">이제 다른 구조체들을 사용해 보겠습니다.</p>



<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">08 &#8211; 02 Metallic,&nbsp;Smoothness</h2>



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



<p class="has-medium-font-size">새로운 쉐이더와 메테리얼을 만들어서 Sphere에 적용 시켜줍니다.</p>



<div style="height:20px" 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/Metallic"
{
    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:29px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="704" height="679" src="https://lycos7560.com/wp-content/uploads/image-373.png" alt="" class="wp-image-2796" srcset="https://lycos7560.com/wp-content/uploads/image-373.png 704w, https://lycos7560.com/wp-content/uploads/image-373-300x289.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></figure>



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



<p class="has-medium-font-size">기존 쉐이더에 이미 Metallic, Smoothness 가 생성되어 있습니다.</p>



<p class="has-medium-font-size">공부를 위해서 만들어 봅시다.</p>



<p class="has-medium-font-size">이제 Properties에 Metallic, Smoothness를</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1008" height="1026" src="https://lycos7560.com/wp-content/uploads/image-374.png" alt="" class="wp-image-2797" srcset="https://lycos7560.com/wp-content/uploads/image-374.png 1008w, https://lycos7560.com/wp-content/uploads/image-374-295x300.png 295w, https://lycos7560.com/wp-content/uploads/image-374-768x782.png 768w" sizes="(max-width: 1008px) 100vw, 1008px" /></figure>



<div style="height:39px" 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/Metallic"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Metallic ("Metallic", Range(0, 1)) = 0 
        _Smoothness("Smoothness", Range(0, 1)) = 0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard
        #pragma target 3.0

        sampler2D _MainTex;
        float _Smoothness;
        float _Metallic;

        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;
            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



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



<p class="has-medium-font-size">이제 적당한 텍스쳐를 넣고 결과를 확인합니다.</p>



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



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



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



<p class="has-medium-font-size">Smoothness는 이 재질이 매끄러운지 거친 지를 결정하는 부분입니다.</p>



<p class="has-medium-font-size">0이면 완벽히 거칠어서 난반사(Diffise)만 일어나고 1이면 완벽히 매끄러워서 정반사(Specular)만 일어나게 됩니다.</p>



<p class="has-medium-font-size">유니티에서 Standard Shader라는 물리기반렌더링의 기본 개념은</p>



<p class="has-medium-font-size">나가는 빛의 양은 들오는 빛의 양을 넘길 수 없다라는 에너지 보존법칙 개념입니다.</p>



<p class="has-medium-font-size">재질의 거칠기에 따라서 난반사와 정반사의 비율이 결정되므로 정반사가 높아지면 그만큼 난반사의 비율이 적어집니다.</p>



<p class="has-medium-font-size">물리 기반 쉐이더에서 Metallic 이 0이면 스페큘러 컬러가 흑백이 되며 1이면 Albedo에 넣은 색이 됩니다.</p>



<p class="has-medium-font-size">금속은 고유의 스펙큘러 컬러를 가지고 있기 때문입니다.</p>



<p class="has-medium-font-size">가급적 0과 1외의 값은 쓰지 않는 것이 정확한 물리 기반 쉐이더를 다루는 방법입니다.&nbsp;</p>



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



<p class="has-medium-font-size"><a href="https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html" target="_blank" rel="noreferrer noopener">https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html</a></p>



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



<figure class="wp-block-image size-full"><a href="https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html" target="_blank" rel="noreferrer noopener"><img decoding="async" width="1096" height="267" src="https://lycos7560.com/wp-content/uploads/image-375.png" alt="" class="wp-image-2799" srcset="https://lycos7560.com/wp-content/uploads/image-375.png 1096w, https://lycos7560.com/wp-content/uploads/image-375-300x73.png 300w, https://lycos7560.com/wp-content/uploads/image-375-768x187.png 768w" sizes="(max-width: 1096px) 100vw, 1096px" /></a></figure>



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



<p class="has-medium-font-size">유니티에서는 이러한 재질의 올바른 사용법을 위해서 아래와 같은 차트를 제공합니다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1317" height="913" src="https://lycos7560.com/wp-content/uploads/image-376.png" alt="" class="wp-image-2800" srcset="https://lycos7560.com/wp-content/uploads/image-376.png 1317w, https://lycos7560.com/wp-content/uploads/image-376-300x208.png 300w, https://lycos7560.com/wp-content/uploads/image-376-768x532.png 768w" sizes="(max-width: 1317px) 100vw, 1317px" /></figure>



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



<p class="has-medium-font-size">노멀맵 추가 후 확인해보면 진짜 금속같이 보이네요</p>



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



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



<div style="height:49px" 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/Metallic"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Metallic ("Metallic", Range(0, 1)) = 0 
        _Smoothness("Smoothness", Range(0, 1)) = 0
        _BumpMap("NormalMAp", 2D) = "bump" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard
        #pragma target 3.0

        sampler2D _MainTex;
        float _Smoothness;
        float _Metallic;
        sampler2D _BumpMap;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            float3 d = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Normal = d;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
            o.Metallic = _Metallic;
            o.Smoothness = _Smoothness;
        }
        ENDCG
    }
    FallBack "Diffuse"
}</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/unity/unity_shader_standard-shader-metallic-smoothness-unity-shader/2791/">8 &#8211; 01 ~ 02 Standard Shader / Metallic, Smoothness (Unity Shader)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/unity/unity_shader_standard-shader-metallic-smoothness-unity-shader/2791/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_08_38_26_196.mp4" length="4317206" type="video/mp4" />
<enclosure url="https://lycos7560.com/wp-content/uploads/녹화_2022_12_01_08_41_41_662.mp4" length="3072517" type="video/mp4" />

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