關于shader報錯Shader error in 'CustomVR/TransitionEffect': invalid input semantic 'POSITION': Legal indices are in [1,15] invalid ps_3_0 input semantic 'POSITION' at line 32 (on d3d9)的問題求各位大佬幫忙解決,謝謝了
Shader "CustomVR/TransitionEffect"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_radius ("Radius", Range(0, 1)) = 1
_thickness ("ThickNess", Range(0, 1)) = 0.2
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
fixed _radius;
fixed _thickness;
fixed4 postProcess(v2f i, fixed4 col);
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col = postProcess(i, col);
return col;
}
fixed4 postProcess(v2f i, fixed4 col)
{
float screenRadius = 0.5 * sqrt(_ScreenParams.x * _ScreenParams.x + _ScreenParams.y * _ScreenParams.y);
float r0 = _radius * (1 + _thickness) - _thickness;
float r1 = _radius * (1 + _thickness);
float r = sqrt((i.vertex.x - _ScreenParams.x * 0.5) * (i.vertex.x - _ScreenParams.x * 0.5) +
(i.vertex.y - _ScreenParams.y * 0.5) * (i.vertex.y - _ScreenParams.y * 0.5)) / screenRadius;
if (r >= r1)
{
clip(-1);
}
else if (r > r0)
{
col.a = (r - r0) / (r1 - r0);
col.rgb *= (1 - col.a * 2);
}
return col;
}
ENDCG
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/25699.html
標籤:Unity3D
上一篇:求Maya 應用
下一篇:Unity2017打包問題
