在法线连续的情况下效果凑合,目前项目着急,先用着,以后有时间慢慢改进。
Shader "ShenDong/SimpleSection"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_IntensityX("Side X Intensity",range(0,2)) = 1
_IntensityY("Side Y Intensity",range(0,2)) = 1
_IntensityZ("Side Z Intensity",range(0,2)) = 1
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float3 normal : NORMAL;
float4 vertex : TEXCOORD0;
float4 screenvert : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _IntensityX;
fixed _IntensityY;
fixed _IntensityZ;
v2f vert(appdata v)
{
v2f o;
o.vertex = v.vertex;
o.normal = v.normal;
o.screenvert = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float3 f3 = i.vertex.xyz;
f3.x = frac(f3.x);
f3.y = frac(f3.y);
f3.z = frac(f3.z);
fixed4 c0 = tex2D(_MainTex, f3.xy * _MainTex_ST.xy + _MainTex_ST.zw);
fixed4 c1 = tex2D(_MainTex, f3.yz * _MainTex_ST.xy + _MainTex_ST.zw);
fixed4 c2 = tex2D(_MainTex, f3.zx * _MainTex_ST.xy + _MainTex_ST.zw);
return c0 * i.normal.z* i.normal.z * _IntensityZ + c1 * i.normal.x * i.normal.x * _IntensityX + c2 * i.normal.y * i.normal.y * _IntensityY;
}
ENDCG
}
}
}