Hello everyone!
I’m very new to shader programming and have been scouring the web for a while in order to get some effects.
I am now trying to add a new pass from sample code to my shader, but the includes in this pass seem to break and give me this warning: Malformed #include (no start quote found): #include “UnityCG.cginc”
I’ve been looking for obvious typos and such but couldn’t find a thing.
The errors occur in the Pass, I’m including the source code (cobbled together from various sources) below:
Shader "Toon/Diffuse" {
Properties
{
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_RampPower ("Toon Ramp Power", Range(0.0,1)) =1
_RimColor ("Rim Color", Color) = (1,1,1,1)
_RimPower ("Rim Power", Range(0.1,10)) = 2.5
_DiffuseTreshold ("Lighting Treshold", Range(-1.1,1)) = 0.1
}
SubShader
{
Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase"}
LOD 200
CGPROGRAM
#pragma surface surf ToonRamp
sampler2D _Ramp;
float _RampPower;
float2 uv_MainTex : TEXCOORD0;
// custom lighting function that uses a texture ramp based
// on angle between light direction and normal
#pragma lighting ToonRamp exclude_path:prepass
inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
{
#ifndef USING_DIRECTIONAL_LIGHT
lightDir = normalize(lightDir);
#endif
half d = dot (s.Normal, lightDir)*0.5 + 0.5;
half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
float power = _RampPower;
float neutralramp = 0.5;
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * ((ramp * power) + (neutralramp * (1-power))) * (atten * 2);
c.rgb = s.Albedo * _LightColor0.rgb;
c.a = 0;
return c;
}
sampler2D _MainTex;
half4 _Color;
float4 _RimColor;
float _RimPower;
struct Input
{
float2 uv_MainTex : TEXCOORD0;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = (_RimColor.rgb * c) * pow (rim, _RimPower);
o.Alpha = c.a;
}
ENDCG
Pass
{
Blend DstColor Zero
Fog { Mode Off}
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#pragma fragmentoption ARB_precision_hint_fastest
#include “UnityCG.cginc“
#include “AutoLight.cginc“
struct appdata
{
fixed4 vertex : POSITION;
fixed4 color : COLOR;
};
struct v2f
{
fixed4 pos : SV_POSITION;
fixed4 color : TEXCOORD0;
LIGHTING_COORDS(1, 2)
};
v2f vert (appdata v)
{
v2f o;
o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
o.color = 1;
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed atten = LIGHT_ATTENUATION(i);
fixed4 c = i.color;
c.rgb *= atten;
return c;
}
ENDCG
}
}
Fallback "Diffuse"
}