Unity/TA&Development
[BUILT-IN] Basic shader
김성인
2024. 4. 25. 00:28
[BUILT-IN] Basic shader
가끔 필요해서 남겨둔다.
Shader "SungIn/Diffuse"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#pragma multi_compile_fog
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
UNITY_FOG_COORDS(2)
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
//
o.uv1 = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 color = tex2D(_MainTex, i.uv);
//
color.rgb *= DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv1));
UNITY_APPLY_FOG(i.fogCoord, color);
return color;
}
ENDCG
}
}
}