SlideShare a Scribd company logo
1 of 21
Download to read offline
02. 기본 Unity Surface Shader 작성
이상윤 http://illu.tistory.com
1주차 과제 확인
Red(1,0,0)
Orange(1, 0.5, 0)
Yellow(1,1,0)
Green(0,1,0)
Blue(0,0,1)
Indigo(0.25, 0, 0.5)
Violet(0.5, 0, 1)
Shader "Study/TintColor" {
Properties {
_TintColor(“색깔”, color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
fixed4 _TintColor;
struct Input {
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _TintColor;
}
ENDCG
}
}
Shader "Study/RGBColor" {
Properties {
_Red (“빨간채널”, Range(0,1)) = 1
_Green (“초록채널”, Range(0,1)) = 1
_Blue (“파랑채널”, Range(0,1)) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
fixed _Red; // fixed _Red, _Green, _Blue;
fixed _Green;
fixed _Blue;
struct Input {
float4 color:COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = float3( _Red, _Green, _Blue);
}
ENDCG
}
}
변수~
Properties에 정의되는 이름~
* 숫자로 시작하면 안됨
* 예약어는 안됨
* 대소문자 구별함
보통 많이 쓰는
_MainTex
_TintColor
_Emission
_Gloss
: 이런 변수명 그냥 씁시다…
스크립트로 이를 제어할때도 이걸 사용함.(그러니까 많이 쓰
는걸 걍 쓰자~!)
이제 메쉬의 UV를 사용해 mapping을 해봅시다.
Shader "Study/Diffuse" {
Properties {
_MainTex(“텍스쳐”, 2D) = “white” {}
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
struct Input {
float4 color:COLOR; // 얘는 vertex color를 사용하는 구조체 선언문입니다.
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
}
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
이걸 아래처럼.
fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb;
o.Albedo = c.rgb;
o.Albedo 출력을 치환해서 처리해봅시다.
텍스쳐를 한장 더 쓸수 있게 하여 두장을 더하고 빼고 곱해봅시다~!
Hint
_MainTex1(“텍스쳐1”, 2D) = “white” {}
_MainTex2(“텍스쳐2”, 2D) = “white” {}
c1 + c2 ; c1-c2;
Reverse : 1-(c1+c2)
흑백 이미지를 만들어 봅시다.
fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb;
fixed grayTex = (c.r + c.g + c.b) / 3;
o.Albedo = grayTex;
* NTSC 가중치에 따른 공식(National Television System Committee, 국가 텔레비전 시스템 위원회)
(0.299 * R + 0.587 * G + 0.114 * B) - 대마왕님 자료 참조
흑백 이미지를 만들어 봅시다.
o.Emission으로 Emissive effect를 만들어 봅시다.
struct Input {
float2 uv_MainTex;
}
fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb;
fixed3 e = tex2D(_MainTex2, IN.uv_MainTex).rgb;
o.Albedo = c.rgb;
o.Emission = e.rgb;
Color를 변경할수 있게 만들어 봅시다.
변수에 Range 타입을 선언해 값의 세기를 변경할 수 있게 해봅시다.
o. Albedo = c;
o. Emission = c * fixed3(1,1,0);
o. Albedo = c.rgb;
o. Emission = e * _EmissionColor;
o. Albedo = c.rgb;
o. Emission = e.rgb;
Vertex color를 활용해 봅니다.
Vertex color는 항상 검은색을 깔고 위에 RGB
Color를 입힌다고 생각하면 됩니다.
struct Input {
fixed4 color:COLOR;
}
fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb;
o.Albedo = c.rgb * IN.color.rgb;
Vertex Alpha도 적용해 봅니다.
흐르는 물을 표현할때 알파 텍스쳐와 더불어 활
용하기 좋은 방법입니다.
struct Input {
fixed4 color:COLOR;
}
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb * IN.color.rgb;
o.Alpha = c.a * IN.color.a;
함수를 사용해 봅니다.
Lerp(Linear Interpolation) : 선형 보간법.
Lerp(a, b, f) : (1-f) * a + b * f
a 와 b의 사이의 f 값에 따른 값을 구할때 사용 하는 함수.
Terrain splatting에 가장 기본적으로 사용하는 함수.
A texture + B texture = blending texture.
Texture 두장을 더하고 빼고 했던것을 Vertex color를 이용
해 lerp 함수를 사용해 만들어 봅시다.
fixed3 c1 = tex2D(_MainTex1, IN.uv_MainTex).rgb;
fixed3 c2 = tex2D(_MainTex2, IN.uv_MainTex).rgb;
fixed3 c = lerp (a, b, ? ) ;
o.Albedo = c ;
수고하셨습니다.

More Related Content

What's hot

SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SUNGCHEOL KIM
 
2. c언어의 기본
2. c언어의 기본2. c언어의 기본
2. c언어의 기본SeonMan Kim
 
D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of fieldYoupyo Choi
 
13장 연산자 오버로딩
13장 연산자 오버로딩13장 연산자 오버로딩
13장 연산자 오버로딩유석 남
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Circulus
 
Startup JavaScript 3 - 조건문, 반복문, 예외처리
Startup JavaScript 3 - 조건문, 반복문, 예외처리Startup JavaScript 3 - 조건문, 반복문, 예외처리
Startup JavaScript 3 - 조건문, 반복문, 예외처리Circulus
 
Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Circulus
 
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field종빈 오
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objectsyong gyun im
 
TestBCD2018-2(answer)
TestBCD2018-2(answer)TestBCD2018-2(answer)
TestBCD2018-2(answer)Yong Heui Cho
 
2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자Circulus
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayYEONG-CHEON YOU
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기Chris Ohk
 
Cpp 0x kimRyungee
Cpp 0x kimRyungeeCpp 0x kimRyungee
Cpp 0x kimRyungeescor7910
 

What's hot (20)

SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진
 
2. c언어의 기본
2. c언어의 기본2. c언어의 기본
2. c언어의 기본
 
D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of field
 
D2 Rain (2/2)
D2 Rain (2/2)D2 Rain (2/2)
D2 Rain (2/2)
 
D2 Rain (1/2)
D2 Rain (1/2)D2 Rain (1/2)
D2 Rain (1/2)
 
13장 연산자 오버로딩
13장 연산자 오버로딩13장 연산자 오버로딩
13장 연산자 오버로딩
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
 
Startup JavaScript 3 - 조건문, 반복문, 예외처리
Startup JavaScript 3 - 조건문, 반복문, 예외처리Startup JavaScript 3 - 조건문, 반복문, 예외처리
Startup JavaScript 3 - 조건문, 반복문, 예외처리
 
3D Graphics 101
3D Graphics 1013D Graphics 101
3D Graphics 101
 
Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저
 
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objects
 
TestBCD2018-2(answer)
TestBCD2018-2(answer)TestBCD2018-2(answer)
TestBCD2018-2(answer)
 
2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture Array
 
Ch11
Ch11Ch11
Ch11
 
Ch10
Ch10Ch10
Ch10
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
 
Ssao
SsaoSsao
Ssao
 
Cpp 0x kimRyungee
Cpp 0x kimRyungeeCpp 0x kimRyungee
Cpp 0x kimRyungee
 

Viewers also liked

Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01SangYun Yi
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art TechnologiesSangYun Yi
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다Lee Dustin
 
유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석SangYun Yi
 
GameMath-Chapter 08 고급렌더링
GameMath-Chapter 08 고급렌더링GameMath-Chapter 08 고급렌더링
GameMath-Chapter 08 고급렌더링Mark Choi
 
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012devCAT Studio, NEXON
 
LCD Monitor 선택 가이드와 Gamma의 이해
LCD Monitor 선택 가이드와 Gamma의 이해LCD Monitor 선택 가이드와 Gamma의 이해
LCD Monitor 선택 가이드와 Gamma의 이해SangYun Yi
 
【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報Unite2017Tokyo
 
Unite seoul 2016 Rooms2 mobile to VR
Unite seoul 2016 Rooms2 mobile to VRUnite seoul 2016 Rooms2 mobile to VR
Unite seoul 2016 Rooms2 mobile to VRSangYun Yi
 
Rooms2 vr ArtWorks
Rooms2 vr ArtWorksRooms2 vr ArtWorks
Rooms2 vr ArtWorksSangYun Yi
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해SangYun Yi
 
Unite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunUnite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunSangYun Yi
 
Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?SangYun Yi
 

Viewers also liked (13)

Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art Technologies
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
 
유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석
 
GameMath-Chapter 08 고급렌더링
GameMath-Chapter 08 고급렌더링GameMath-Chapter 08 고급렌더링
GameMath-Chapter 08 고급렌더링
 
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012
전형규, 가성비 좋은 렌더링 테크닉 10선, NDC2012
 
LCD Monitor 선택 가이드와 Gamma의 이해
LCD Monitor 선택 가이드와 Gamma의 이해LCD Monitor 선택 가이드와 Gamma의 이해
LCD Monitor 선택 가이드와 Gamma의 이해
 
【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報
 
Unite seoul 2016 Rooms2 mobile to VR
Unite seoul 2016 Rooms2 mobile to VRUnite seoul 2016 Rooms2 mobile to VR
Unite seoul 2016 Rooms2 mobile to VR
 
Rooms2 vr ArtWorks
Rooms2 vr ArtWorksRooms2 vr ArtWorks
Rooms2 vr ArtWorks
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해
 
Unite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunUnite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYun
 
Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?
 

More from SangYun Yi

Devtree lightmapping unity5_2_1stday
Devtree lightmapping unity5_2_1stdayDevtree lightmapping unity5_2_1stday
Devtree lightmapping unity5_2_1stdaySangYun Yi
 
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례SangYun Yi
 
Unite2015 probelight English version
Unite2015 probelight English versionUnite2015 probelight English version
Unite2015 probelight English versionSangYun Yi
 
Unite2015 probelight(150417)
Unite2015 probelight(150417)Unite2015 probelight(150417)
Unite2015 probelight(150417)SangYun Yi
 
Kgc2013 defense technica_converting_이상윤
Kgc2013 defense technica_converting_이상윤Kgc2013 defense technica_converting_이상윤
Kgc2013 defense technica_converting_이상윤SangYun Yi
 

More from SangYun Yi (7)

Devtree lightmapping unity5_2_1stday
Devtree lightmapping unity5_2_1stdayDevtree lightmapping unity5_2_1stday
Devtree lightmapping unity5_2_1stday
 
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례
Unity3D 엔진을 활용한 게임환경 분석 및 3D 그래픽스 기술 /제작 사례
 
Unite2015 probelight English version
Unite2015 probelight English versionUnite2015 probelight English version
Unite2015 probelight English version
 
Unite2015 probelight(150417)
Unite2015 probelight(150417)Unite2015 probelight(150417)
Unite2015 probelight(150417)
 
Gametech2015
Gametech2015Gametech2015
Gametech2015
 
Devtree illu
Devtree illuDevtree illu
Devtree illu
 
Kgc2013 defense technica_converting_이상윤
Kgc2013 defense technica_converting_이상윤Kgc2013 defense technica_converting_이상윤
Kgc2013 defense technica_converting_이상윤
 

Unity Surface Shader for Artist 02

  • 1. 02. 기본 Unity Surface Shader 작성 이상윤 http://illu.tistory.com
  • 2. 1주차 과제 확인 Red(1,0,0) Orange(1, 0.5, 0) Yellow(1,1,0) Green(0,1,0) Blue(0,0,1) Indigo(0.25, 0, 0.5) Violet(0.5, 0, 1)
  • 3. Shader "Study/TintColor" { Properties { _TintColor(“색깔”, color) = (1,1,1,1) } SubShader { Tags { "RenderType"="Opaque" } CGPROGRAM #pragma surface surf Lambert fixed4 _TintColor; struct Input { float4 color:COLOR; }; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = _TintColor; } ENDCG } }
  • 4. Shader "Study/RGBColor" { Properties { _Red (“빨간채널”, Range(0,1)) = 1 _Green (“초록채널”, Range(0,1)) = 1 _Blue (“파랑채널”, Range(0,1)) = 1 } SubShader { Tags { "RenderType"="Opaque" } CGPROGRAM #pragma surface surf Lambert fixed _Red; // fixed _Red, _Green, _Blue; fixed _Green; fixed _Blue; struct Input { float4 color:COLOR; }; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = float3( _Red, _Green, _Blue); } ENDCG } }
  • 5. 변수~ Properties에 정의되는 이름~ * 숫자로 시작하면 안됨 * 예약어는 안됨 * 대소문자 구별함 보통 많이 쓰는 _MainTex _TintColor _Emission _Gloss : 이런 변수명 그냥 씁시다… 스크립트로 이를 제어할때도 이걸 사용함.(그러니까 많이 쓰 는걸 걍 쓰자~!)
  • 6. 이제 메쉬의 UV를 사용해 mapping을 해봅시다.
  • 7. Shader "Study/Diffuse" { Properties { _MainTex(“텍스쳐”, 2D) = “white” {} } SubShader { Tags { "RenderType"="Opaque" } CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; struct Input { float4 color:COLOR; // 얘는 vertex color를 사용하는 구조체 선언문입니다. float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb; } ENDCG } }
  • 8. o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb; 이걸 아래처럼. fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb; o.Albedo = c.rgb; o.Albedo 출력을 치환해서 처리해봅시다. 텍스쳐를 한장 더 쓸수 있게 하여 두장을 더하고 빼고 곱해봅시다~! Hint _MainTex1(“텍스쳐1”, 2D) = “white” {} _MainTex2(“텍스쳐2”, 2D) = “white” {} c1 + c2 ; c1-c2; Reverse : 1-(c1+c2)
  • 10. fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb; fixed grayTex = (c.r + c.g + c.b) / 3; o.Albedo = grayTex; * NTSC 가중치에 따른 공식(National Television System Committee, 국가 텔레비전 시스템 위원회) (0.299 * R + 0.587 * G + 0.114 * B) - 대마왕님 자료 참조 흑백 이미지를 만들어 봅시다.
  • 11. o.Emission으로 Emissive effect를 만들어 봅시다.
  • 12. struct Input { float2 uv_MainTex; } fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb; fixed3 e = tex2D(_MainTex2, IN.uv_MainTex).rgb; o.Albedo = c.rgb; o.Emission = e.rgb; Color를 변경할수 있게 만들어 봅시다. 변수에 Range 타입을 선언해 값의 세기를 변경할 수 있게 해봅시다.
  • 13. o. Albedo = c; o. Emission = c * fixed3(1,1,0); o. Albedo = c.rgb; o. Emission = e * _EmissionColor; o. Albedo = c.rgb; o. Emission = e.rgb;
  • 14. Vertex color를 활용해 봅니다. Vertex color는 항상 검은색을 깔고 위에 RGB Color를 입힌다고 생각하면 됩니다.
  • 15. struct Input { fixed4 color:COLOR; } fixed3 c = tex2D(_MainTex, IN.uv_MainTex).rgb; o.Albedo = c.rgb * IN.color.rgb;
  • 16. Vertex Alpha도 적용해 봅니다. 흐르는 물을 표현할때 알파 텍스쳐와 더불어 활 용하기 좋은 방법입니다.
  • 17. struct Input { fixed4 color:COLOR; } fixed4 c = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = c.rgb * IN.color.rgb; o.Alpha = c.a * IN.color.a;
  • 18. 함수를 사용해 봅니다. Lerp(Linear Interpolation) : 선형 보간법. Lerp(a, b, f) : (1-f) * a + b * f a 와 b의 사이의 f 값에 따른 값을 구할때 사용 하는 함수.
  • 19. Terrain splatting에 가장 기본적으로 사용하는 함수. A texture + B texture = blending texture.
  • 20. Texture 두장을 더하고 빼고 했던것을 Vertex color를 이용 해 lerp 함수를 사용해 만들어 봅시다. fixed3 c1 = tex2D(_MainTex1, IN.uv_MainTex).rgb; fixed3 c2 = tex2D(_MainTex2, IN.uv_MainTex).rgb; fixed3 c = lerp (a, b, ? ) ; o.Albedo = c ;