=================================================================================
2. 서브 쉐이더
쉐이더 구조체 내용
struct SurfaceOutputStandard
{
fixed3 Albedo; // base (diffuse or specular) color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Metallic; // 0=non-metal, 1=metal
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
struct SurfaceOutputStandardSpecular
{
fixed3 Albedo; // diffuse color
fixed3 Specular; // specular color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
struct Input {
float2 uv_MainTex;
float2 uv_GlossTex;
float2 uv_BumpMap;
float3 viewDir;
float3 worldRefl;
INTERNAL_DATA
};
블랜드 설정(http://docs.unity3d.com/Manual/SL-Blend.html)
Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft Additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x Multiplicative
=================================================================================
3. shader 변수
- 텍스처 수치 변경 하지 못하게 하는 법
[NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
- 변수에 접근
Material material;
material = transform.GetComponent<Renderer>().material;
float ddd = 1.0f;
ddd -= Time.deltaTime / 10.0f;
material.SetFloat("_Alpha", ddd);
=================================================================================
=================================================================================
6. sementics
- screenPos : 를 쓰기 위해서는 아래 참고
fixed4 frag(v2f i, UNITY_VPOS_TYPE screenPos : VPOS) : SV_Target{}
- face ( normal direction )
fixed4 frag(fixed facing : VFACE) : SV_Target
- vid ( vertex id 인듯)
v2f vert(float4 vertex : POSITION, uint vid : SV_VertexID)
- normal ( 노말 )
v2f vert(float4 vertex : POSITION, float3 normal : NORMAL)
=================================================================================
7. Culling & Depth Testing
Syntax
- Cull Back | Front | Off
- ZWrite On | Off (default is On)
Drawing solid objects, leave this on
Drawing semitransparent effects, switch to ZWrite Off
- ZTest Less | Greater | LEqual | GEqual | Equal | NotEqual | Always
(Default is LEqual : Draw objects in from or at the distance as existing objects; hide objects behind them)