// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/testShader" {
properties{
_TextureSample0("Texture Sample 0", 2D) = "white" {}
_normal("normal", 2D) = "white" {}
}
subshader {
pass{
Tags{ "RenderType" = "Opaque" "IsEmissive" = "true" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Lighting.cginc"
uniform sampler2D _TextureSample0;
uniform sampler2D _normal;
uniform float4 _normal_ST;
struct a2v
{
float3 vertex : POSITION;
float3 normal : NORMAL;
float4 texcoord : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION; //告诉unity,pos里包含了顶点在裁剪空间中的位置信息
fixed3 worldNormal:TEXCOORD0;
};
v2f vert(a2v v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex); //使用v.vertex来访问模型空间的顶点坐标
o.worldNormal=mul(v.normal,(float3x3)unity_WorldToObject);
return o ;
}
fixed4 frag() : SV_Target
{
return fixed4(1.0, 1.0, 1.0, 1.0);
}
ENDCG
}
}
}
网友评论