반응형
- 코드 작성
Shader "Custom/ExampleShader" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_Speed ("Speed", Range(0, 10)) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _Color;
float _Speed;
v2f vert (appdata v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target {
float offset = _Time.y * _Speed; // animate based on time and speed
float2 uv = i.uv + float2(offset, 0); // shift texture coordinates
fixed4 texcol = tex2D(_MainTex, uv); // sample the texture
fixed4 col = texcol * _Color; // apply color tint
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
FallBack "Diffuse"
}
반응형
'개발 > Unity' 카테고리의 다른 글
java.io.IOException: Can't read [C:\Users\shahp\.gradle\caches\transforms-2\files- 에러 대응법 (0) | 2023.08.24 |
---|---|
Unity iOS Xcode 빌드시 Info.plist 자동 수정 간단 구현 (0) | 2023.08.19 |
유니티 C# 스크롤바 Scrollbar 사용법 간단 구현 (0) | 2023.05.11 |
유니티 C# 네임스페이스 간단 사용법 Unity namespace (0) | 2023.04.30 |
유니티 에디터 단축키 간단 사용법 Unity Editor (0) | 2023.02.17 |
유니티 생명 주기 Life Cycle 간단 설명 (0) | 2022.08.17 |
유니티 허브 설치 및 개발 환경 세팅하기 Unity Hub (0) | 2022.07.12 |
유니티 모바일 64비트 빌드 최적화 세팅 모음 Unity Moblie Build (0) | 2022.07.09 |
댓글