Files
JJBB/Assets/Project/Shader/NpcBase.cginc
2024-08-23 15:49:34 +08:00

29 lines
948 B
HLSL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef NpcBase_INCLUDE
#define NpcBase_INCLUDE
#include "UnityCG.cginc"
#include "Gles2Helper.cginc"
#include "FlowColorBase.cginc"
uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform half _Emission;
uniform half4 _Color;
uniform half4 _AddColor;
uniform half _Outline;
uniform half4 _OutlineColor;
// 注边缘光是优化算法无法线贴图时切线空间法线为0,0,1点乘结果为viewDir的z
#define NPC_VERT_COMMON(o) \
o.pos = UnityObjectToClipPos(v.vertex); \
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); \
half3 objectViewDir = ObjSpaceViewDir(v.vertex); \
TANGENT_SPACE_ROTATION; \
o.rim = saturate(1 - normalize(MUL_3x3_WITH_VECTOR(rotation, objectViewDir)).z); \
o.rim = pow(o.rim, _Outline);
#define NPC_FRAG_COMMON(col) \
col = tex2D(_MainTex, i.texcoord); \
col.rgb *= _Color.rgb; \
col.rgb += col.rgb * _Emission + _AddColor; \
col.rgb += _OutlineColor.rgb * _OutlineColor.a * i.rim
#endif