- Home /
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
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
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612132930im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
exception on Webplayer 1 Answer
Exception: Il2cp did not run properly. 2 Answers
mono.security.dll is denied? 1 Answer
cross product in cg shader - error "can't find __getVectorIndex" 1 Answer
Unity5 v Unity4 Shader array errors 1 Answer