0

I have 2 errors on my Timer.shader file, but don't understand why, I'm new on Unity3D

this is the error:

Shader error in 'Timer': 'dot': no matching 0 parameter intrinsic function; Possible intrinsic functions are: dot(floatM|halfM|doubleM|min10floatM|min16floatM|intM|uintM|min12intM|min16intM|min16uintM, floatM|halfM|doubleM|min10floatM|min16floatM|intM|uintM|min12intM|min16intM|min16uintM) at line 51 (on gles3)
Shader error in 'Timer': syntax error: unexpected token 'h' at line 51 (on gles3)

And the file with the errors: Timer.shader

Shader "Timer"
{
   Properties
   {
      _MainTex ("Texture Image", 2D) = "white" {} 
          _SecondTex ("Second Image", 2D) = "white" {} 
          _MaskTime ("Time", Range (0, 1)) = 0
          _MPow ("Pow", Range (5, 50)) = 5
   }
   SubShader
   {
      Pass
          {    
         CGPROGRAM

         #pragma vertex vert  
         #pragma fragment frag 

         sampler2D _MainTex;
                 sampler2D _SecondTex;
                 fixed _MaskTime;
                 fixed _MPow;

         struct vertexInput
                 {
            float4 vertex : POSITION;
            fixed4 texcoord : TEXCOORD0;
         };
         struct vertexOutput
                 {
            fixed4 pos : SV_POSITION;
            fixed2 tex : TEXCOORD0;
         };

         vertexOutput vert (vertexInput input) 
         {
            vertexOutput output;

            output.tex = input.texcoord;
            output.pos = UnityObjectToClipPos (input.vertex);
            return output;
         };

         float4 frag (vertexOutput input) : COLOR
         {
                        fixed3 c0 = tex2D (_MainTex, fixed2 (input.tex));
                        fixed3 c1 = tex2D (_SecondTex, fixed2 (input.tex));

                        fixed dot1 = dot (normalize (input.tex.xy-fixed2 (0.5h, 0.5h)), fixed2 (0h, 1h));

                        half ang = acos (dot1);

                        ang = degrees (ang);
                        ang = (input.tex.x<0.5h)?360h-ang:ang;


                        fixed pos = min ((ang/360h), 360h);
                        pos = pos+0.9h-_MaskTime+(0.2h*(1h-_MaskTime));
                        pos = saturate (pow (pos, _MPow*_MPow));


                        fixed3 c = lerp (c1.rgb, c0, pos);

                        return fixed4 (c, 1h);
                        //return pos;
         }

         ENDCG
      }
   }
   }

Please let me know if need more info, because like I say I'm new, and I don't understand much of this error.

Im trying to build to Android, and there's where everything crash, because if I only press play everything runs without warnings.

Of course the error trigger on other platforms, but I pretend to build to Android

1
  • why do you used h In your shader? just remove any h In your shader for example 0.5h to 0.5 Commented Apr 22, 2018 at 3:43

1 Answer 1

1

suffixes specify number types. They instruct the C# compiler that an integral literal such as 1000 be considered a certain type of number—for example, a long (1000L). We look into how you can add numeric suffixes to numbers.

https://www.dotnetperls.com/suffix

but In shader you shouldn't use suffix.I just remove any h In your shader for example 0.5h to 0.5 and works correctly

try this one:

Shader "Timer"
    {
       Properties
       {
          _MainTex ("Texture Image", 2D) = "white" {} 
              _SecondTex ("Second Image", 2D) = "white" {} 
              _MaskTime ("Time", Range (0, 1)) = 0
              _MPow ("Pow", Range (5, 50)) = 5
       }
       SubShader
       {
          Pass
              {    
             CGPROGRAM

             #pragma vertex vert  
             #pragma fragment frag 

             sampler2D _MainTex;
                     sampler2D _SecondTex;
                     fixed _MaskTime;
                     fixed _MPow;

             struct vertexInput
                     {
                float4 vertex : POSITION;
                fixed4 texcoord : TEXCOORD0;
             };
             struct vertexOutput
                     {
                fixed4 pos : SV_POSITION;
                fixed2 tex : TEXCOORD0;
             };

             vertexOutput vert (vertexInput input) 
             {
                vertexOutput output;

                output.tex = input.texcoord;
                output.pos = UnityObjectToClipPos (input.vertex);
                return output;
             };

             float4 frag (vertexOutput input) : COLOR
             {
                            fixed3 c0 = tex2D (_MainTex, fixed2 (input.tex));
                            fixed3 c1 = tex2D (_SecondTex, fixed2 (input.tex));

                            fixed dot1 = dot (normalize (input.tex.xy-fixed2 (0.5, 0.5)), fixed2 (0, 1));

                            half ang = acos (dot1);

                            ang = degrees (ang);
                            ang = (input.tex.x<0.5)?360-ang:ang;


                            fixed pos = min ((ang/360), 360);
                            pos = pos+0.9-_MaskTime+(0.2*(1-_MaskTime));
                            pos = saturate (pow (pos, _MPow*_MPow));


                            fixed3 c = lerp (c1.rgb, c0, pos);

                            return fixed4 (c, 1);
                            //return pos;
             }

             ENDCG
          }
       }
       }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.