冯乐乐的《Unity Shader入门精要》附带项目,其中部分shader已经修改测试
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.5 KiB

3 years ago
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Unlit/TestVertexShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Param1 ("y2",Float) = 1.0
_Param2 ("weight",Float) = 1.0
_Param3 ("Param3",Float) = 1.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 srcPos : TEXCOORD1;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Param1;
float _Param2;
float _Param3;
v2f vert(appdata v){
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.srcPos = ComputeScreenPos(o.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag(v2f i) : SV_target{
float2 wcoord = (i.srcPos.xy/i.srcPos.w);
//float a = lerp(wcoord.x,_Param1,_Param2);
float r = smoothstep(_Param1,_Param2,wcoord.x);
//float g = smoothstep(0.5,0.8,wcoord.y);
return fixed4(r,0.0,0.0,1.0);
}
ENDCG
}
}
}