Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 JoeD86 · Mar 10, 2017 at 11:25 PM · shadershaderscel shadingcellshading

Custom cel shaded Unity shader not casting shadows

I'm having an issue where my custom cel shading Shader (Wow that's redundant!) is creating the cel shaded effect I want, but it's not casting shadows.

I followed this tutorial here http://www.gamasutra.com/blogs/DavidLeon/20150702/247602/NextGen_Cel_Shading_in_Unity_5.php

Here is the code and what it looks like right now.

alt text

 Shader "Maiko/CelShader7"
 {
     Properties
     {
         _Color("Main Color", Color) = (1, 1, 1, 1)
         _MainTex("Albedo (RGB)", 2D) = "white" {}
     }
 
         SubShader
         {
             Tags
             {
                 "RenderType" = "Opaque"
             }
         LOD 200
 
         CGPROGRAM
         #pragma surface surf CelShadingForward
         #pragma    target 3.0
         #include "AutoLight.cginc"
         #define UnityStandardBRDFCustom.cginc
 
         half4 LightingCelShadingForward(SurfaceOutput s, half3 lightDir, half atten)
     {
         half NdotL = dot(s.Normal, lightDir);
         if (NdotL <= 0.0) NdotL = 0.14f;
         else if (NdotL > 0.0f && NdotL <= 0.1f) NdotL = 0.15f;
         else if (NdotL > 0.1f && NdotL <= 0.2f) NdotL = 0.2f;
         else if (NdotL > 0.2f && NdotL <= 0.3f) NdotL = 0.3f;
         else if (NdotL > 0.3f && NdotL <= 0.4f) NdotL = 0.4f;
         else if (NdotL > 0.4f && NdotL <= 0.5f) NdotL = 0.5f;
         else if (NdotL > 0.5f && NdotL <= 0.6f) NdotL = 0.6f;
         else if (NdotL > 0.6f && NdotL <= 0.7f) NdotL = 0.7f;
         else if (NdotL > 0.7f && NdotL <= 0.8f) NdotL = 0.8f;
         else if (NdotL > 0.8f && NdotL <= 0.9f) NdotL = 0.9f;
         else NdotL = 1;
 
         NdotL = smoothstep(0, 0.625f, NdotL);
         NdotL /= 2.5f;
 
 
         half4 c;
         c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten  * 2); // THe *2 makes it brighter
         c.a = s.Alpha;
         return c;
     }
 
 
 
     sampler2D _MainTex;
     fixed4 _Color;
 
     struct Input
     {
         fixed2 uv_MainTex;
 
     };
 
     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;
     }
     ENDCG
     } // End of Subshader
         FallBack "Diffuse"
 
 }
 


noshadows.png (92.1 kB)
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

Answer by xyiphk · Apr 17, 2018 at 02:24 AM

Buccura get the answer in here:

https://www.reddit.com/r/Unity3D/comments/6006ql/custom_cel_shaded_unity_shader_not_casting_shadows/

I hope the following people can know the answer that:

change #pragma surface surf CelShadingForward

to #pragma surface surf CelShadingForward fullforwardshadows

Comment
Add comment · 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

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

92 People are following this question.

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

Related Questions

Single tone shadows in forward rendering 0 Answers

How to clamp lighting values for cel-shading post 5.5? 0 Answers

Has cellshading been removed in 5.4? 0 Answers

Cel Shading Possible In Unity Free Version? 2 Answers

Weird lighting with cel shader 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