- Home /
Question by
JuiceArt · Sep 28, 2017 at 04:21 AM ·
strange ioc
UnityObjectToClipPos: o matching function, when develop in Linux Unity
(Some trouble with Topics: there are no Items in the list) Hello, I am trying to migrate my project to Linux Unity. On Windows everything works fine, but Linux version gives an error in my shader:
'UnityObjectToClipPos' : no matching overloaded function found
Compiling Vertex program
Could You, please, advice something ?
Here is my shader code:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/TransformSystem"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_ShiftY("ShiftY",Int) = 0
_Swing_Left("Swing_Left", Range(0.1, 1.0)) = 1.0
_Swing_Right("Swing_Right", Range(0.1, 1.0)) = 1.0
_NF("NF",Float) = 1
_MiddlePos("MiddlePos",Float) = 0.5
_LeftShift("LeftShift", Vector) = (0,0,0,0)
_MiddleShift("MiddleShift", Vector) = (0,0,0,0)
_RightShift("RightShift", Vector) = (0,0,0,0)
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#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;
}
static const float startShift = 0.0f;
static const float numSize = 0.094f;
static const float scaleFactor = 1.5f;
sampler2D _MainTex;
int _ShiftY;
float _MiddlePos;
float _Swing_Left;
float _Swing_Right;
float _NF;
float _Ky;
Vector _LeftShift;
Vector _MiddleShift;
Vector _RightShift;
float getDistance(float2 pixelPos, float2 cornerPos)
{
float xDist = cornerPos[0] - pixelPos[0];
float yDist = cornerPos[1] - pixelPos[1];
float distSqr = xDist * xDist + yDist * yDist;
if(distSqr ==0.0f)
distSqr = 0.001f;
return sqrt(xDist * xDist + yDist * yDist );
}
int biggerFlag = 0;
float2 gePixelShiftLeft(float2 pixelPos)
{
float4 weights = float4(0,0,0,0);
if(pixelPos[0] <=_MiddlePos)
{
float2 dp0 = float2(pixelPos[0], 0);
float2 dp1 = float2(_MiddlePos, pixelPos[1]);
float2 dp2 = float2(pixelPos[0],1);
float2 dp3 = float2(0,pixelPos[1]);
//dp0
float2 weights_dp0 = float2(0,0);
weights_dp0[0] = 1.0f / getDistance(dp0, float2(0.0f, 0.0f));
weights_dp0[1] = 1.0f / getDistance(dp0, float2(_MiddlePos, 0.0f));
weights_dp0 /= (weights_dp0[0] + weights_dp0[1]);
//return weights_dp0;
float2 shift_dp0 = float2(0,0);
shift_dp0[0] = _LeftShift[0] * weights_dp0[0] + _MiddleShift[2] * weights_dp0[1];
shift_dp0[1] = _LeftShift[1] * weights_dp0[0] + _MiddleShift[1] * weights_dp0[1];
//return shift_dp0;
//return float2( shift_dp0[0], 0);
//dp1
float2 weights_dp1 = float2(0,0);
weights_dp1[0] = 1.0f / getDistance(dp1, float2(_MiddlePos, 0.0f));
weights_dp1[1] = 1.0f / getDistance(dp1, float2(_MiddlePos, 1.0f));
weights_dp1 /= (weights_dp1[0] + weights_dp1[1]);
float2 shift_dp1 = float2(0,0);
shift_dp1[0] = _MiddleShift[2] * weights_dp1[0] + _MiddleShift[0] * weights_dp1[1];
shift_dp1[1] = _MiddleShift[1] * weights_dp1[0] + _MiddleShift[3] * weights_dp1[1];
//dp2
float2 weights_dp2 = float2(0,0);
weights_dp2[0] = 1.0f / getDistance(dp2, float2(_MiddlePos, 1.0f));
weights_dp2[1] = 1.0f / getDistance(dp2, float2(0.0f, 1.0f));
weights_dp2 /= (weights_dp2[0] + weights_dp2[1]);
float2 shift_dp2 = float2(0,0);
shift_dp2[0] = _MiddleShift[0] * weights_dp2[0] + _LeftShift[2] * weights_dp2[1];
shift_dp2[1] = _MiddleShift[3] * weights_dp2[0] + _LeftShift[3] * weights_dp2[1];
//return shift_dp2;
//dp3
float2 weights_dp3 = float2(0,0);
weights_dp3[0] = 1.0f / getDistance(dp3, float2(0.0f, 1.0f));
weights_dp3[1] = 1.0f / getDistance(dp3, float2(0.0f, 0.0f));
weights_dp3 /= (weights_dp3[0] + weights_dp3[1]);
float2 shift_dp3 = float2(0,0);
shift_dp3[0] = _LeftShift[0] * weights_dp3[0] + _LeftShift[2] * weights_dp3[1];
shift_dp3[1] = _LeftShift[1] * weights_dp3[0] + _LeftShift[3] * weights_dp3[1];
if(shift_dp3[0] > -2)
biggerFlag = 1;
else
biggerFlag = 0;
//return shift_dp3;
weights[0] = 1.0f / getDistance(pixelPos, float2(0.0f, 0.0f));
weights[1] = 1.0f / getDistance(pixelPos, float2(_MiddlePos, 0.0f));
weights[2] = 1.0f / getDistance(pixelPos, float2(_MiddlePos, 1.0f));
weights[3] = 1.0f / getDistance(pixelPos, float2(0.0f, 1.0f));
weights /= (weights[0] + weights[1] + weights[2] + weights[3]);
//return float2(weights[0], weights[1]);
float weight_dp0 = pixelPos[1];
float weight_dp1 =pixelPos[0];
float weight_dp2 = 1 - pixelPos[1];
float weight_dp3 = _MiddlePos - pixelPos[0];
//return float2(weight_dp1, weight_dp3);
float2 shift = float2(0,0);
shift[0] = shift_dp1[0] * weight_dp1 + shift_dp3[0] * weight_dp3;
shift[1] = shift_dp0[1] * weight_dp0 + shift_dp2[1] * weight_dp2;
float2 sign2 = float2( shift[0] / abs(shift[0]), shift[1] / abs(shift[1]));
float2 shift_save = shift;
float test_value = (-1.0f * _Swing_Left);
float shifted_functon_value = test_value + test_value * test_value / 2;
float additional_function_mul_y = -0.5f / shifted_functon_value;
float my_k_x= 1.0f+ 2 / (shift_dp3[0] - shift_dp1[0] );
//my_k_x = 1;
shift[0] = ((shift[0] * _Swing_Left + shift[0] * shift[0] * _Swing_Left * _Swing_Left / 2) * additional_function_mul_y ) * my_k_x;
//if(shift_save[0] < -1.0f )
// shift[0] = 1.01f;
return shift;
}
return float2(0,0);
}
float2 gePixelShiftRight(float2 pixelPos)
{
if(pixelPos[0] > _MiddlePos)
{
float2 dp0 = float2(pixelPos[0], 0);
float2 dp1 = float2(1, pixelPos[1]);
float2 dp2 = float2(pixelPos[0],1);
float2 dp3 = float2(_MiddlePos,pixelPos[1]);
//dp0
float2 weights_dp0 = float2(0,0);
weights_dp0[0] = 1.0f / getDistance(dp0, float2(_MiddlePos, 0.0f));
weights_dp0[1] = 1.0f / getDistance(dp0, float2(1.0f, 0.0f));
weights_dp0 /= (weights_dp0[0] + weights_dp0[1]);
//return weights_dp0;
float2 shift_dp0 = float2(0,0);
shift_dp0[0] = _MiddleShift[0] * weights_dp0[0] + _RightShift[2] * weights_dp0[1];
shift_dp0[1] = _MiddleShift[1] * weights_dp0[0] + _RightShift[1] * weights_dp0[1];
//return shift_dp0;
//return float2( shift_dp0[0], 0);
//dp1
float2 weights_dp1 = float2(0,0);
weights_dp1[0] = 1.0f / getDistance(dp1, float2(1.0f, 0.0f));
weights_dp1[1] = 1.0f / getDistance(dp1, float2(1.0f, 1.0f));
weights_dp1 /= (weights_dp1[0] + weights_dp1[1]);
float2 shift_dp1 = float2(0,0);
shift_dp1[0] = _RightShift[2] * weights_dp1[0] + _RightShift[0] * weights_dp1[1];
shift_dp1[1] = _RightShift[1] * weights_dp1[0] + _RightShift[3] * weights_dp1[1];
if(shift_dp1[0] < 2)
biggerFlag = 1;
else
biggerFlag = 0;
//dp2
float2 weights_dp2 = float2(0,0);
weights_dp2[0] = 1.0f / getDistance(dp2, float2(1.0f, 1.0f));
weights_dp2[1] = 1.0f / getDistance(dp2, float2(_MiddlePos, 1.0f));
weights_dp2 /= (weights_dp2[0] + weights_dp2[1]);
float2 shift_dp2 = float2(0,0);
shift_dp2[0] = _RightShift[0] * weights_dp2[0] + _MiddleShift[2] * weights_dp2[1];
shift_dp2[1] = _RightShift[3] * weights_dp2[0] + _MiddleShift[3] * weights_dp2[1];
//dp3
float2 weights_dp3 = float2(0,0);
weights_dp3[0] = 1.0f / getDistance(dp3, float2(_MiddlePos, 1.0f));
weights_dp3[1] = 1.0f / getDistance(dp3, float2(_MiddlePos, 0.0f));
weights_dp3 /= (weights_dp3[0] + weights_dp3[1]);
float2 shift_dp3 = float2(0,0);
shift_dp3[0] = _MiddleShift[0] * weights_dp3[0] + _MiddleShift[2] * weights_dp3[1];
shift_dp3[1] = _MiddleShift[1] * weights_dp3[0] + _MiddleShift[3] * weights_dp3[1];
//return shift_dp3;
float weight_dp0 = pixelPos[1];
float weight_dp1 =pixelPos[0] -_MiddlePos;
float weight_dp2 = 1 - pixelPos[1];
float weight_dp3 = 1 - pixelPos[0];
//return float2(weight_dp1, weight_dp3);
float2 shift = float2(0,0);
shift[0] = shift_dp1[0] * weight_dp1 + shift_dp3[0] * weight_dp3;
shift[1] = shift_dp0[1] * weight_dp0 + shift_dp2[1] * weight_dp2;
float2 sign2 = float2( shift[0] / abs(shift[0]), shift[1] / abs(shift[1]));
float2 shift_save = shift;
float test_value = (1.0f * _Swing_Right);
float shifted_functon_value = -test_value + test_value * test_value / 2;
float additional_function_mul_y = 0.5f / shifted_functon_value;
float my_k_x= 1.0f- 2 / (shift_dp1[0] - shift_dp3[0] );
//my_k_x = 1;
shift[0] = ((-shift[0] * _Swing_Right + shift[0] * shift[0] * _Swing_Right * _Swing_Right / 2) * additional_function_mul_y ) * my_k_x;
//if(shift_save[0] > 1.0f )
// shift[0] = 1.01f;
return shift;
}
return float2(0,0);
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col;
float2 new_uv ;
if(i.uv[0] <= _MiddlePos)
{
float2 shift = gePixelShiftLeft(i.uv);
float2 shift_to_test = gePixelShiftLeft(i.uv +float2(0.01f,0.0f));
new_uv = i.uv + shift;
col = tex2D(_MainTex, new_uv);
if(shift_to_test[0] < shift[0] - 0.0035f )
if(biggerFlag ==0)
{
col = fixed4(0,0,0,1);
}
// col = fixed4(shift[0] +2,0,0,1);
//if(biggerFlag ==1)
// col = fixed4(0,1,0,1);
// else
// col = fixed4(0,0,1,1);
}
else
{
float2 shift = gePixelShiftRight(i.uv);
float2 shift_to_test = gePixelShiftRight(i.uv +float2(0.001f,0.0f));
new_uv = i.uv + shift;
col = tex2D(_MainTex, new_uv);
if(shift_to_test[0] < shift[0] - 0.001f )
if(biggerFlag ==0)
{
col = fixed4(0,0,0,1);
}
}
if(new_uv[0] > 1.0f || new_uv[1] > 1.0f || new_uv[0] < 0.0f || new_uv[1] < 0.0f )
col = fixed4(0,0,0,0);
return col;
}
ENDCG
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Avoiding Bloom Pop 1 Answer
Enabling disabling objects via raycast 0 Answers
How to create an Animated 2D Line to help the user aim and shoot? 0 Answers
Compiler failed to execute. 1 Answer
How to make a script slow down to a stop 0 Answers