유니티/쉐이더
-
05/07 유니티 쉐이더 Diffuse Warping유니티/쉐이더 2021. 5. 7. 17:11
Diffuse Warping "Warped diffuse" 빛공식으로 쓰이는 노멀과 라이트 벡터의 내적을 UV로 사용한다 Ramp Texture 순서 Ramp Texture를 적용 하프램버트 커스텀라이트 작성, Lighting_Warp(SurfaceOutput s, float3 lightDir, float atten) float ndotl = dot(s.Normal, lightDir)*0.5 +0.5; 변수ramp 작성 float4 ramp = tex2D(_RampTex, float2(ndotl, 0.5)); s.Albedo * ramp.rgb; 추가로 specular 적용 빛 벡터와 뷰 벡터를 노멀라이즈, normalize(lightDir + viewDir); 노멀과 1. 의 내적을 구하고 satura..
-
05/06 유니티 쉐이더 라이트 Rim Light유니티/쉐이더 2021. 5. 6. 15:06
림 라이트(Rim Lighting) 역광 프레넬 공식 Shader "Custom/RimLight" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _BumpMap ("NormalMap", 2D) = "bump" {} _RimColor ("RimColor", Color) = (1,1,1,1) _RimPower ("RimPower", Range(1, 10)) = 1 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert noambient #pragma target 3.0 sampler2D _MainTex; sampler2D _BumpMap; fl..
-
05/06 유니티 쉐이더 라이트 lambert와 half-lambert 연습유니티/쉐이더 2021. 5. 6. 13:06
텍스쳐 한장을 받는 쉐이더 생성 라이트이름 설정 : Test Lighting + Test 이름으로 함수 선언 반환타입은 float4 매개변수 (surfaceOutput s, float3 lightDir, //단위벡터, 뒤집힌 방향 float atten) //빛의 감쇠 : Directional Light (x), Point Light (o) 램버트 공식 : 표면벡터와 조명벡터를 내적 옵션 : saturate(표면벡터와 조명벡터를 내적) 0 ~ 1까지를 표현하고 그 값을 반환 하프 램버트 공식 : 표면벡터와 조명벡터를 내적 * 0.5 + 0.5 라이트 함수 내에서 SurfaceOutput 구조체 값 사용가능 예) s.Albedo _LightColor0 내장변수 : 조명의 색상, 강도 저장된 내장변수 Shad..
-
05/04 유니티 쉐이더 노멀 맵(범프 매핑)유니티/쉐이더 2021. 5. 4. 18:20
Shader "Custom/Standard" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _MainTex2 ("Albedo (RGB)", 2D) = "white" {} _SpecColor("Specular Color", color) = (1,1,1,1) } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf BlinnPhong sampler2D..
-
05/04 유니티 쉐이더 램버트, 블린퐁, 스탠다드유니티/쉐이더 2021. 5. 4. 16:37
Lambert #pragma 스탠다드를 Lambert로 inout 매개변수타입를 SurfaceOutput로 BlinnPhong #pragma 스탠다드를 BlinnPhong로 inout 매개변수타입를 SurfaceOutput로 스탠다드 Shader "Custom/Standard" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Standard sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; ..
-
05/04 유니티 쉐이더 Smoothness 연습유니티/쉐이더 2021. 5. 4. 15:46
Shader "Custom/Test" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _MainTex2("Albedo (RGB)", 2D) = "white" {} _MainTex3("Albedo (RGB)", 2D) = "white" {} _MainTex4("Albedo (RGB)", 2D) = "white" {} _Glossiness("Smoothness", Range(0,1)) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Standard sampler2D _MainTex; sampler2D _MainTex2; sampler2D _Mai..
-
05/03 유니티 쉐이더 불 타는 효과 만들기유니티/쉐이더 2021. 5. 3. 17:59
1. 두 텍스쳐를 받는 쉐이더 작성 2. 첫번째 : check, 두번째 : source (data) 3. check의 uv좌표를 source의 값으로 이동 (r) 4. source의 uv의 y좌표를 위로 올라가게 애니메이션 (_Time.y값을 빼줌) 5. check를 fire로 변경 Shader "Custom/Test" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _MainTex2 ("Albedo (RGB)", 2D) = "white" {} _Speed("Speed", Range(-10, 10)) = 0 } SubShader { Tags { "RenderType"= "Transparent" "Queue" = "Transparent" } LOD 2..
-
05/03 유니티 쉐이더 UV가 Time으로 흘러가게 하기유니티/쉐이더 2021. 5. 3. 16:53
Shader "Custom/Test" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _UV("uv value", Range(-1, 1)) = 0 _USpeed("Uspeed", Range(-2, 2)) = 0 _VSpeed("Vspeed", Range(-2, 2)) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Standard fullforwardshadows sampler2D _MainTex; struct Input { float2 uv_MainTex; }; float _UV; float _USpeed; float _VSpeed; voi..