[Shader] 텍스처 회전 (Texture Rotation)
Shader "Custom/Rotation" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Speed ("Speed", float) = 30.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
float _Speed;
struct Vertex {
float4 vertex : POSITION;
float2 uv_MainTex : TEXCOORD0;
};
struct Fragment {
float4 vertex : POSITION;
float2 uv_MainTex : TEXCOORD0;
};
Fragment vert (Vertex v) {
Fragment o;
float sinX = sin(_Speed * _Time);
float cosX = cos(_Speed * _Time);
float2x2 rotationMatrix = float2x2(cosX, -sinX, sinX, cosX);
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv_MainTex = mul(v.uv_MainTex - float2(0.5, 0.5), rotationMatrix) + float2(0.5, 0.5);
return o;
}
float4 frag(Fragment IN) : COLOR {
return tex2D(_MainTex, IN.uv_MainTex);
}
ENDCG
}
}
FallBack "Diffuse"
}
'Unity' 카테고리의 다른 글
[UnityUI] Text Gradient (0) | 2016.08.08 |
---|---|
그라데이션 배경 (Gradient Shader 활용) (0) | 2015.11.19 |
[Shader] 그라데이션 (Gradient) (0) | 2015.11.19 |
[Struct] Point (0) | 2015.11.07 |
[Struct] Size (0) | 2015.11.07 |
C# 리스트(List)를 이용해 만든 우선순위큐(PriorityQueue) (0) | 2015.07.23 |
리플렉션 응용 (C# Reflection) (0) | 2015.07.01 |
MonoBehaviour Lifecycle (0) | 2014.06.30 |
Android Local Notification Plugin (0) | 2013.04.23 |
포물선 공식 (0) | 2013.01.21 |