-
05/03 유니티 쉐이더 Texture 2장으로 lerp메서드 연습유니티/쉐이더 2021. 5. 3. 14:59
Texture 2장을 받는 쉐이더 작성
Shader "Custom/Test" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _SubTex ("SubTex", 2D) = "white" {} _Lerp ("lerp", Range(0,1)) = 0.5 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Standard fullforwardshadows sampler2D _MainTex; sampler2D _SubTex; struct Input { float2 uv_MainTex; float2 uv_SubTex; }; float _Lerp; void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex); fixed4 d = tex2D (_SubTex, IN.uv_SubTex); o.Albedo = lerp(c.rgb, d.rgb, _Lerp); } ENDCG } FallBack "Diffuse" }
Texture 각각 밝기 조절
Shader "Custom/Test" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _SubTex ("SubTex", 2D) = "white" {} _Lerp ("lerp", Range(0,1)) = 0.5 _BrightnessMain("BrightnessMian", Range(-1,1)) = 0 _BrightnessSub("BrightnessSub", Range(-1,1)) = 0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Standard fullforwardshadows sampler2D _MainTex; sampler2D _SubTex; struct Input { float2 uv_MainTex; float2 uv_SubTex; }; float _Lerp; float _BrightnessMain; float _BrightnessSub; void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex); fixed4 d = tex2D (_SubTex, IN.uv_SubTex); o.Albedo = lerp(c.rgb + _BrightnessMain/3, d.rgb + _BrightnessSub, 1-c.a); } ENDCG } FallBack "Diffuse" }
'유니티 > 쉐이더' 카테고리의 다른 글
05/04 유니티 쉐이더 Smoothness 연습 (0) 2021.05.04 05/03 유니티 쉐이더 불 타는 효과 만들기 (0) 2021.05.03 05/03 유니티 쉐이더 UV가 Time으로 흘러가게 하기 (0) 2021.05.03 05/03 유니티 쉐이더 스피어 rgb 값을 슬라이더로 조절하기 (0) 2021.05.03 05/03 유니티 쉐이더 Sphere에 색 적용하기 (0) 2021.05.03