SlideShare a Scribd company logo
1 of 15
Download to read offline
04. Custom effect
이상윤 http://illu.tistory.com
3주차 과제 확인
Shader "Study/Fire" {
Properties {
_MainTex("텍스쳐", 2D) = "white" {}
}
SubShader {
Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
LOD 200
Blend One One
CGPROGRAM
#pragma surface surf Unlit alpha
fixed4 LightingUnlit (SurfaceOutput s, half3 lightDir, half atten)
{
return fixed4(s.Albedo, s.Alpha);
}
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x * 0.25 + (0.25 *
ceil(_Time.z * 2)) , IN.uv_MainTex.y));
//ceil(x) : x이상의 최소 정수
o.Albedo = c.rgb;
o.Alpha = c.r;
}
ENDCG
}
}
Rim Light
Fresnel Effect
우리가 물체가 인식하는 현상은 빛이 매질에 반사되어 시신경에 맺히는 과정을 거쳐 인식하게 됩니다.
이를 물체의 표면에 빛이 반사하는 모델을 BRDF(Bidirectional
reflectance distribution function) 양방향 반사 분포 함수라고
합니다.
물체와 면이 수직으로 이룰때는 면의 내부가 잘 들여다보이지만 면의 내부와 이루는 각이 커질수록 내부가 보이는
것이 아닌 입사각의 빛의 많이 반사하게 된다.
모든 물체는 프레넬을 가진다.
NDC2013 김동석 – UDK3로 물리기반 셰이더 구현하기
Rim light
실제 프레넬 계산을 좀 더 가볍게 구현한
것이 Rim light 방식입니다.
Rim light의 효용.
객체와 배경을 분리시켜준다.
분위기를 더하는 효과
광원의 연출을 빛이 없이 가능
Fresnel effect
struct Input {
float2 uv_MainTex;
float3 viewDir;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutput o) {
float rim = dot(normalize(IN.viewDir), normalize(IN.worldNormal));
fixed3 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c * _Color;
o.Emission = rim;
}
ENDCG
}
}
struct Input {
float2 uv_MainTex;
float3 viewDir;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutput o) {
float rim = dot(normalize(IN.viewDir), normalize(IN.worldNormal));
fixed3 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c * _Color;
o.Emission = 1 - rim;
}
ENDCG
}
}
Half rim = 1.0 – saturate(dot(normalize(IN.viewDir), o.Normal);
pow = pow(rim, a)
normalize : 벡터의 크기를 1로 만든다. 정규화라고도
하며 벡터의 방향은 그대로 유지한채 크기만 0~1 사
이로 변경하는 것.
Saturate(x) : x를 0, 1 범위로 절삭한다.(0보다 적으면
0으로 1보다 크면 1로 반환한다)
pow (a, b) : a^b. a의 b 제곱.
기왕에 만든거 color와 세기도 조절해 봅시다.
Rim Intensity
Rim Color
Compiler code의 halfasview의 기능에 대해서도 확인해봅시다
하는김에 반투명도 그려봅시다.
Cull option 도 제어해봅니다.
Cull off : 앞뒷면을 다 그림
Cull front : 앞면 안그림
Cull back : 뒷면 안그림
2 side라고 이야기하는 면을 앞뒤로 그리는 명령입니다.
당연히 폴리곤도 X2 배~!!
수고하셨습니다.

More Related Content

What's hot

13장 연산자 오버로딩
13장 연산자 오버로딩13장 연산자 오버로딩
13장 연산자 오버로딩유석 남
 
Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Circulus
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Circulus
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기Chris Ohk
 
2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자Circulus
 
D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of fieldYoupyo Choi
 
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Circulus
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objectsyong gyun im
 
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...Seok-joon Yun
 
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
 
Data Structure - 1st Study
Data Structure - 1st StudyData Structure - 1st Study
Data Structure - 1st StudyChris Ohk
 
어플 개발자의 서버개발 삽질기
어플 개발자의 서버개발 삽질기어플 개발자의 서버개발 삽질기
어플 개발자의 서버개발 삽질기scor7910
 
[170517 5주차]C언어 A반
[170517 5주차]C언어 A반[170517 5주차]C언어 A반
[170517 5주차]C언어 A반arundine
 
이산치수학 Project5
이산치수학 Project5이산치수학 Project5
이산치수학 Project5KoChungWook
 
Cpp 0x kimRyungee
Cpp 0x kimRyungeeCpp 0x kimRyungee
Cpp 0x kimRyungeescor7910
 

What's hot (20)

13장 연산자 오버로딩
13장 연산자 오버로딩13장 연산자 오버로딩
13장 연산자 오버로딩
 
Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 6 - 함수, 스코프, 클로저
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
 
2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자2.Startup JavaScript - 연산자
2.Startup JavaScript - 연산자
 
D2 Rain (2/2)
D2 Rain (2/2)D2 Rain (2/2)
D2 Rain (2/2)
 
D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of field
 
D2 Rain (1/2)
D2 Rain (1/2)D2 Rain (1/2)
D2 Rain (1/2)
 
Ch11
Ch11Ch11
Ch11
 
Ch10
Ch10Ch10
Ch10
 
3D Graphics 101
3D Graphics 1013D Graphics 101
3D Graphics 101
 
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objects
 
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
 
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
 
Data Structure - 1st Study
Data Structure - 1st StudyData Structure - 1st Study
Data Structure - 1st Study
 
어플 개발자의 서버개발 삽질기
어플 개발자의 서버개발 삽질기어플 개발자의 서버개발 삽질기
어플 개발자의 서버개발 삽질기
 
[170517 5주차]C언어 A반
[170517 5주차]C언어 A반[170517 5주차]C언어 A반
[170517 5주차]C언어 A반
 
이산치수학 Project5
이산치수학 Project5이산치수학 Project5
이산치수학 Project5
 
Cpp 0x kimRyungee
Cpp 0x kimRyungeeCpp 0x kimRyungee
Cpp 0x kimRyungee
 

Viewers also liked

유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석SangYun Yi
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art TechnologiesSangYun Yi
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다Lee Dustin
 
Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01SangYun 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
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해SangYun Yi
 
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
 
Unite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunUnite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunSangYun Yi
 
Rooms2 vr ArtWorks
Rooms2 vr ArtWorksRooms2 vr ArtWorks
Rooms2 vr ArtWorksSangYun Yi
 
Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?Igc2016 Technical Artist가 뭐하는 사람이에요?
Igc2016 Technical Artist가 뭐하는 사람이에요?SangYun Yi
 

Viewers also liked (13)

유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art Technologies
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
 
Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01Unity Surface Shader for Artist 01
Unity Surface Shader for Artist 01
 
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ライティング最新情報
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해
 
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
 
Unite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYunUnite Seoul 2017 Yi SangYun
Unite Seoul 2017 Yi SangYun
 
Rooms2 vr ArtWorks
Rooms2 vr ArtWorksRooms2 vr ArtWorks
Rooms2 vr ArtWorks
 
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 04

  • 1. 04. Custom effect 이상윤 http://illu.tistory.com
  • 3. Shader "Study/Fire" { Properties { _MainTex("텍스쳐", 2D) = "white" {} } SubShader { Tags {"Queue" = "Transparent" "RenderType"="Transparent" } LOD 200 Blend One One CGPROGRAM #pragma surface surf Unlit alpha fixed4 LightingUnlit (SurfaceOutput s, half3 lightDir, half atten) { return fixed4(s.Albedo, s.Alpha); } sampler2D _MainTex; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, float2(IN.uv_MainTex.x * 0.25 + (0.25 * ceil(_Time.z * 2)) , IN.uv_MainTex.y)); //ceil(x) : x이상의 최소 정수 o.Albedo = c.rgb; o.Alpha = c.r; } ENDCG } }
  • 5. Fresnel Effect 우리가 물체가 인식하는 현상은 빛이 매질에 반사되어 시신경에 맺히는 과정을 거쳐 인식하게 됩니다. 이를 물체의 표면에 빛이 반사하는 모델을 BRDF(Bidirectional reflectance distribution function) 양방향 반사 분포 함수라고 합니다. 물체와 면이 수직으로 이룰때는 면의 내부가 잘 들여다보이지만 면의 내부와 이루는 각이 커질수록 내부가 보이는 것이 아닌 입사각의 빛의 많이 반사하게 된다.
  • 6. 모든 물체는 프레넬을 가진다. NDC2013 김동석 – UDK3로 물리기반 셰이더 구현하기
  • 7. Rim light 실제 프레넬 계산을 좀 더 가볍게 구현한 것이 Rim light 방식입니다. Rim light의 효용. 객체와 배경을 분리시켜준다. 분위기를 더하는 효과 광원의 연출을 빛이 없이 가능
  • 8.
  • 9. Fresnel effect struct Input { float2 uv_MainTex; float3 viewDir; float3 worldNormal; }; void surf (Input IN, inout SurfaceOutput o) { float rim = dot(normalize(IN.viewDir), normalize(IN.worldNormal)); fixed3 c = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = c * _Color; o.Emission = rim; } ENDCG } }
  • 10. struct Input { float2 uv_MainTex; float3 viewDir; float3 worldNormal; }; void surf (Input IN, inout SurfaceOutput o) { float rim = dot(normalize(IN.viewDir), normalize(IN.worldNormal)); fixed3 c = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = c * _Color; o.Emission = 1 - rim; } ENDCG } }
  • 11. Half rim = 1.0 – saturate(dot(normalize(IN.viewDir), o.Normal); pow = pow(rim, a) normalize : 벡터의 크기를 1로 만든다. 정규화라고도 하며 벡터의 방향은 그대로 유지한채 크기만 0~1 사 이로 변경하는 것. Saturate(x) : x를 0, 1 범위로 절삭한다.(0보다 적으면 0으로 1보다 크면 1로 반환한다) pow (a, b) : a^b. a의 b 제곱.
  • 12. 기왕에 만든거 color와 세기도 조절해 봅시다. Rim Intensity Rim Color
  • 13. Compiler code의 halfasview의 기능에 대해서도 확인해봅시다
  • 14. 하는김에 반투명도 그려봅시다. Cull option 도 제어해봅니다. Cull off : 앞뒷면을 다 그림 Cull front : 앞면 안그림 Cull back : 뒷면 안그림 2 side라고 이야기하는 면을 앞뒤로 그리는 명령입니다. 당연히 폴리곤도 X2 배~!!