Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Xatoku · Feb 22, 2012 at 10:31 AM · shaderslidertoonramp

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;
 }
Comment
Add comment
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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Show 2 · 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 Owen-Reynolds · Feb 22, 2012 at 09:27 PM 2
Share

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.)

avatar image Xatoku · Feb 23, 2012 at 01:04 AM 0
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

7 People are following this question.

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

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


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