- Home /
Shader Slider
So I am trying to add some sliders to have more control over my shaders for each different mesh. I'm adding them to the Toon/Lighted Shader so I can control the ramp sizes.
For some reason though, it's giving me an error saying that the variables do not exist. I put them there, so I'm not sure why it can't access them. I am using Toon/Lighted Outline as the actual Shader, but I know the lighting is affected from this one. Could someone tell me whats up?
Shader "Toon/Lighted" {
Properties {
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_LightSize ("Light Size", Range (0, 1)) = 0.75
_MidSize ("Mid Size", Range (0, 1)) = 0.75
_DarkSize ("Dark Size", Range (0, 1)) = 0.25
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf ToonRamp
sampler2D _Ramp;
#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)*_LightSize + _MidSize + _DarkSize;
half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
c.a = 0;
return c;
}
Answer by Jessy · Feb 22, 2012 at 02:34 PM
The error message is an unhelpful lie; it just means that your shader has errors.
The Inspector sprays them at you, hiding the original error, way up on top, which at least gives you a line number.
Your _darkSize
lines near the top say to create a slider for _darkSize
in the Inspector, but you never actually create a darksize. Notice how _Ramp
is also declared down below. Toss in float _Darksize, _$$anonymous$$idSize ...
and it should work (or comment out a bunch and just try adding 1 darkSize by itself.)
Your answer
![](https://koobas.hobune.stream/wayback/20220613064344im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Better Outlines 0 Answers
Interior Outlines? 0 Answers
Shader: Changing a Ramp Size 1 Answer
Outlines Defined by Shading Groups? 0 Answers
Combinning light shading and slider? 1 Answer