전체 글(295)
-
[Unity] URP 셰이더 HLSL 추가사항 (#pragma, 변수 Scope)
#pragma 셰이더 타겟 어떤 셰이더 모델로 컴파일할지를 정한다. 최신 GPU를 사용하려면 높은 버전의 셰이더 타겟을 사용해야 한다. #pragma hull 또는 #pragma domain 명령어로 Tessellation Shader를 사용해야 하는 경우 4.6으로 설정해야 한다. Default는 2.5이다. #pragma target 4.5 Shader Feature와 Multi Compile 셰이더의 파생 버전인 Shader Variants를 만들기 위한 기능이다. #pragma shader _feature_local _RECEIVE_SHADOWS_OFF #pragma multi_compile _LIGHTMAP_ON HLSL에서 #ifdef, #else, #endif 등 조건부 컴파일 지시자에 의해..
2023.06.12 -
[Unity] URP 셰이더 HLSL Pass와 Pass Commands
Pass Pass는 하나의 셰이더가 여러 번 그려야 하는 경우 사용된다. Pass 아래에 Tags 명령어가 또 나오는데, SubShader의 Tags 명령어와 이름은 같지만 다른 목적을 가지고 있다. URP 렌더 파이프 라인에 의해 이 패스를 그릴지 말지를 결정하는 기준이 된다. Pass 안에 있는 명령어를 생략해도 디폴트 값으로 적용되며, SubShader에서 사용해도 된다. SubShader에서 Pass의 명령어를 사용하면 모든 Pass에 적용된다. Shader "Universal Render Pipeline/Lit" { Properties { // Specular vs Metallic workflow [HideInInspector] _WorkflowMode("WorkflowMode", Float) ..
2023.06.12 -
[Unity] URP 셰이더 HLSL ShaderLab Properties, SubShader Tags
Properties https://docs.unity3d.com/kr/2021.1/Manual/SL-Properties.html ShaderLab: 머티리얼 프로퍼티 정의 - Unity 매뉴얼 이 페이지는 ShaderLab 코드에서 Properties 블록을 사용하여 셰이더 오브젝트의 머티리얼 프로퍼티를 정의하는 방법에 대한 정보를 포함합니다. docs.unity3d.com 유니티 매뉴얼에 프로퍼티에 대한 내용이 잘 나와있다. Integer, Int 정수형에 대한 설명이다. _ExampleName ("Integer display name", Integer) = 1 _ExampleName ("Int display name", Int) = 1 Float Float와 Range 타입이 있다. Range 타입은..
2023.06.12 -
[Unity] URP 셰이더 HLSL Lambert 셰이더
Shader "Custom/BRDF/Lambert" { Properties { [MainTexture] _BaseMap("Base Map", 2D) = "white" {} [MainColor][HDR]_BaseColor("BaseColor", Color) = (1, 1, 1, 1) } SubShader { Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" } Pass { HLSLPROGRAM #pragma vertex vert #pragma fragment frag #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Pa..
2023.06.10 -
[Unity] URP 셰이더 HLSL 텍스쳐 적용
HLSL의 변수 float4 testVar; //초기 값 없이 변수만 선언 float4 testVar = float4(1,2,3,4); // 초기 값과 함께 변수 선언 float2 newVar1 = testVar.xy; float2 newVar2 = testVar.zw; float3 newVar3 = testVar.zxy; 위와 같이 구성 성분을 조합해서 사용 가능하다. testVar.xygb //Error testVar.xx = float(1, 2); //Error (xx가 문제) xyzw 방식과 rgba 방식을 혼용할 수 없다. HLSL의 함수 half4 frag(Varyings IN) : SV_Target { half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_B..
2023.06.09 -
[Unity] URP 셰이더 HLSL 구조와 _BaseColor 적용
ShaderLab ShaderLab은 범용적인 HLSL만으로는 유니티 3D 엔진만의 여러 기능들을 제어할 수 없어서 만든 규칙이다. OpenGL이나 HLSL 같은 셰이더 언어는 유니티 엔진이 존재하기 전부터 사용된 언어이기 때문. 특징은 간단한 문법 구조를 가지고 있고 엔진 기능들에 관련된 것들이다. 직접적으로 셰이딩 연산에 관한 것들은 없다. // 이것은 주석입니다. (Comment) Shader "Custom/ShaderLab HLSL/CustomUnlit" { Properties { } SubShader { Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" } Pass { HLSLPROGRAM #pragma vertex ve..
2023.06.08