• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by alexander11 · Aug 17, 2017 at 02:28 PM · unity 5errorcg

How do i fix Shader file "syntax error at line 7" Unity 5?

Hello i am having some Trouble with this shader. It says my error is at line 7 but there is nothing wrong with the code in that line, I keep looking but i cant seem to find the error.

Error

Shader error in 'Custom/Shader_10': Parse error: syntax error at line 7

Here is the Code.

 Shader "Custom/Shader_10" {
     Properties {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Albedo (RGB)", 2D) = "white" {}
         _RoughTex ("Roughness Texture",2D) = "white" {}
         _Roughness ("Roughness", Range(0, 1)) = 0.5f
         _SpeculColor ("Specular Color", Color) = (1,1,1,1)
         _SpeculPower ("Specular Power", Range(0, 30)) = 2f
         _Fresnel ("Fresnel Value", Range,(0,1.0f)) = 0.05f
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         
         CGPROGRAM
         // Physically based Standard lighting model, and enable shadows on all light types
         #pragma surface surf MetallicSofts
 
         // Use shader model 3.0 target, to get nicer looking lighting
         #pragma target 3.0
 
         sampler2D _MainTex;
         sampler2D _RoughTex;
         float _Roughness;
         float _Fresnel;
         float _SpeculPower;
         fixed4 _SpeculColor;
 
         struct Input {
             float2 uv_MainTex;
         };
 
         
         fixed4 _Color;
 
         void surf (Input IN, inout SurfaceOutput o) {
             // Albedo comes from a texture tinted by color
             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
             o.Albedo = c.rgb;
             o.Alpha = c.a;
         }
 
         inline fixed4 LightingMetallicSofts (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
         {
             float3 halfVector = normalize(lightDir + viewDir);
             float NdotL = saturate(dot(s.Normal, normalize(lightDir)));
             float NdotH_raw = dot(s.Normal, halfVector);
             float NdotH = saturate(dot(s.Normal, halfVector));
             float NdotV = saturate(dot(s.Normal, normalize(viewDir)));
             float VdotH = saturate(dot(halfVector, normalize(viewDir)));
 
             float geoEnum = 2.0*NdotH;
             float3 G1 = (geoEnum * NdotV)/NdotH;
             float3 G2 = (geoEnum * NdotL)/NdotH;
             float3 G = min(1.0f, min(G1, G2));
 
             float roughness = tex2D(_RoughTex, float2(NdotH_raw * 0.5 + 0.5, _Roughness)).r;
 
             float fresnel = pow(1.0-VdotH, 5.0);
             fresnel *= (1.0 - _Fresnel);
             fresnel += _Fresnel;
 
             float3 spec = float3(fresnel * G * roughness * roughness) * _SpeculPower;
 
             float4 c;
             c.rgb = (s.Albedo * _LightColor0.rgb * NdotL) + (spec * _SpeculColor.rgb) * (atten * 2.0f);
             c.a = s.Alpha;
             return c;
         }
 
         ENDCG
     }
     FallBack "Diffuse"
 }
 





Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Bodhid · Aug 17, 2017 at 02:41 PM

Remove the F's, shaders don't use these. And there is a comma after the last "Range"

 Properties {
          _Color ("Color", Color) = (1,1,1,1)
          _MainTex ("Albedo (RGB)", 2D) = "white" {}
          _RoughTex ("Roughness Texture",2D) = "white" {}
          _Roughness ("Roughness", Range(0, 1)) = 0.5
          _SpeculColor ("Specular Color", Color) = (1,1,1,1)
          _SpeculPower ("Specular Power", Range(0, 30)) = 2
          _Fresnel ("Fresnel Value", Range(0,1.0)) = 0.05
      }

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image alexander11 · Aug 17, 2017 at 05:38 PM 1
Share

Thanks, i did not see that comma.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

155 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error on build since upgrading to unity 5 1 Answer

PrefabUtility does not exist? 1 Answer

Unity 5.6 upgrade pains 0 Answers

"Error building Player" WebGL build error 2 Answers

mac unity fbx import error 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges