x


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;
}
more ▼

asked Feb 22 '12 at 10:31 AM

Xatoku gravatar image

Xatoku
152 73 81 88

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The error message is an unhelpful lie; it just means that your shader has errors.

more ▼

answered Feb 22 '12 at 02:34 PM

Jessy gravatar image

Jessy
15.6k 72 95 196

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, _MidSize ... and it should work (or comment out a bunch and just try adding 1 darkSize by itself.)

Feb 22 '12 at 09:27 PM Owen Reynolds

That worked, Owen. Thank you very much :).

Feb 23 '12 at 01:04 AM Xatoku
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1652
x103
x37
x22
x4

asked: Feb 22 '12 at 10:31 AM

Seen: 648 times

Last Updated: Feb 23 '12 at 01:05 AM