Toon Shader in Unity Using a Shader Graph with Custom Lighting! ✔️ 2020.3 | Game Dev Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ย. 2024

ความคิดเห็น • 525

  • @hamishpaget1619
    @hamishpaget1619 3 ปีที่แล้ว +74

    For anyone getting an error saying "Invalid conditional expression"
    instead of:
    #if SHADERGRAPH_PREVIEW
    It has to be:
    #if defined(SHADERGRAPH_PREVIEW)

  • @CaveHeroesofficial
    @CaveHeroesofficial 4 ปีที่แล้ว +19

    This is by far the best and cleanest tutorial I've ever seen.

  • @gamethingstuff
    @gamethingstuff 3 ปีที่แล้ว +6

    Followed another tutorial that massively overcomplicated everything and didn't get the desired result and then I watch this one and it's so simple. Great job man

  • @kilanlarsen7692
    @kilanlarsen7692 ปีที่แล้ว +1

    I searched through a fair number of toon shader tutorials but this is the only one I found that properly addressed dynamic lighting from point/spot lights in the scene. Hands down the best shader and I'm extremely grateful for the information - you've earned a sub good sir

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi, thank you so much! I hope you enjoy future tutorials.

  • @madifoldstudio8064
    @madifoldstudio8064 3 ปีที่แล้ว +3

    One of the best Toon Shader explanations there are (including the Open Projects one that is a drag).

  • @kayohwai
    @kayohwai 3 ปีที่แล้ว +20

    After completing the tutorial, I added a small bit extra onto the graph. Since I didn't want everything toon shaded to be shiny, I threw in an extra bool ("Matte"), and a Branch. If Matte is true, it cuts out the Add for the shine branch. If Matte is false, it feeds through the full branch.

    • @inxendere
      @inxendere ปีที่แล้ว

      Wait this is really cool how did you set this up exactly? How can the branch cut out the add or not cut it out??

    • @inxendere
      @inxendere ปีที่แล้ว

      nvm i got it

  • @poisonouspurple
    @poisonouspurple 3 ปีที่แล้ว +42

    For everyone who runs into the 'Invalid conditional expression' error, here is the solution:
    simply write
    #if defined(SHADERGRAPH_PREVIEW)
    instead of
    #if SHADERGRAPH_PREVIEW
    Hope this works for you :D

    • @burakhandogan6076
      @burakhandogan6076 3 ปีที่แล้ว +2

      i want to thank you crying

    • @kennyamat
      @kennyamat 2 ปีที่แล้ว +1

      i dont know why but for some reason do I already have shadows without the shadow part. so I don't see the use of that part

    • @poisonouspurple
      @poisonouspurple 2 ปีที่แล้ว +1

      @@kennyamat yeah this video is one year old and Unity updated and added a lot so it will be probably already implemented in some render pipelines or basic shading

  • @chorong7351
    @chorong7351 5 หลายเดือนก่อน +2

    Thank you what a detailed description!
    Here are my edited code for those who have trouble receiving shadow on the object itself:
    void CalculateMainLight_float(float3 WorldPos, out float3 Direction, out float3 Color,
    out half DistanceAtten, out half ShadowAtten)
    {
    #if SHADERGRAPH_PREVIEW
    Direction = float3(0.5,0.5,0);
    Color = 1;
    DistanceAtten = 1;
    ShadowAtten = 1;
    #else
    #if SHADOW_SCREEN
    half4 clipPos = TransformWorldToHClip(WorldPos);
    half4 shadowCoord = ComputeScreenPos(clipPos);
    #else
    half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
    #endif
    Light mainLight = GetMainLight(0);
    Direction = mainLight.direction;
    Color = mainLight.color;
    DistanceAtten = mainLight.distanceAttenuation;
    #if SHADOWS_SCREEN
    ShadowAtten = SampleScreenSpaceShadowmap(shadowCoord);
    //ShadowAtten = mainLight.shadowAttenuation;
    #else
    ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
    half shadowStrength = GetMainLightShadowStrength();
    ShadowAtten = SampleShadowmap(shadowCoord, TEXTURE2D_ARGS(_MainLightShadowmapTexture,
    sampler_MainLightShadowmapTexture),
    shadowSamplingData, shadowStrength, false);
    #endif

    #endif
    }

    • @llamas_attack
      @llamas_attack 8 วันที่ผ่านมา

      Hi! I tried this code and I'm not getting any errors, but I'm also still not receiving shadows -- are there any additional keywords or pipeline asset settings to also be aware of?

  • @sam8686
    @sam8686 4 ปีที่แล้ว +1

    Just want to thank you for breaking this down so well. As someone who is learning this stuff, it is really difficult sometimes to understand what people are doing in tutorials and why they might add certain nodes. Your tutorial is incredibly well explained and easy to understand. This level of detail is very much appreciated, keep it up! :)

  • @bencollom2513
    @bencollom2513 3 ปีที่แล้ว +16

    Since I ran into this issue:
    When creating custom shader - Error: wrong file type, must be .hlsl:
    Your windows directory may not be showing file extensions, and your text file is Lighting.hlsl.txt. In your windows directory, click "View" up at the top, then check "Show file extensions." now you can rename your file to Lighting.hlsl

  • @mochou_p
    @mochou_p ปีที่แล้ว +6

    In Unity 2021.3.25f1, to get shadows, change the keyword scopes to Global
    (select a keyword in Blackboard > go to Graph Inspector > Node Settings > Scope)
    You should see shadows now, so you can ignore the material inspector debug thingie

  • @NedMakesGames
    @NedMakesGames  4 ปีที่แล้ว +4

    Hi everyone! Thank you for all your comments! Also, if you're using a version after Unity 2020.2, please check the top of the video description for fixes!
    I created a follow up video to this which adds spot light shadows and some lighting improvements. Check it out here: th-cam.com/video/whmPkDp3dqo/w-d-xo.html

    • @Stinger-rq4gy
      @Stinger-rq4gy 3 ปีที่แล้ว

      So to make a small FPS multiplayer building with toon shading style/cell shaded style I need to apply cell shading style to the walls, and floors of the building, if the walls and floors are not already toon shaded?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      @@Stinger-rq4gy Yeah, you would need to apply the toon material, or a variation of it, to get them toon shaded as well

    • @Stinger-rq4gy
      @Stinger-rq4gy 3 ปีที่แล้ว

      @@NedMakesGames Excellent thanks ill do that, I am studying Unity its very complex. I am building a FPS game called Zombie💀Castle, with a castle with 100 zombie bosses on each 100 floors. I would like the building, guns, zombies to have the toon shading style. Thanks for your help🙋‍♂️🍻

    • @Stinger-rq4gy
      @Stinger-rq4gy 3 ปีที่แล้ว

      @@NedMakesGames This is mt to do list to build my game, I only have 2 people to build this app game. 1. Find a way to make props, walls floors, etc in cell-shaded/toon shading style.
      2. Build a FPS gun in Unity 3D.
      3. Find lots of free props for Zombie Castle💀
      4. Learn how to do enemy A.I.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      @@Stinger-rq4gy Sounds like a good plan! Good luck with your game!

  • @tbdtandres
    @tbdtandres 3 ปีที่แล้ว +1

    I'm going through all your tutorials and they are SO GOOD, I've learned so much, THANK YOU

  • @cortlandia7618
    @cortlandia7618 3 ปีที่แล้ว

    I've spent the past few hours trying to find a tutorial that works and this one does! Tysm

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! I'm glad to hear that. Thanks for watching!

  • @mochou_p
    @mochou_p ปีที่แล้ว +3

    for me, only directional light is toon, the additional lights have normal smooth falloff, which is weird since i ramp all of them since they are combined

  • @megalon2d685
    @megalon2d685 3 ปีที่แล้ว +6

    For anyone getting an error about invalid if statement in Lighting.hlsl
    You need to change
    "#if SHADERGRAPH_PREVIEW"
    to
    "#ifdef SHADERGRAPH_PREVIEW"

    • @captain_baru
      @captain_baru 3 ปีที่แล้ว

      OMG thank you so much for this

    • @Lastered
      @Lastered 2 ปีที่แล้ว

      I love you

  • @iOJPF69854
    @iOJPF69854 ปีที่แล้ว +3

    Hello, I also have a error like Shader error in
    'Master': 'CalculateMainLight_float': output parameter 'Direction' not completely initialized at Assets/Scripts/includes/Lighting.hlsl(4) (on d3d11)
    On the script I can see -- Light mainLight = GetMainLight(0); -- this as a red font color. Do you know how to fix it? Thanks

    • @iOJPF69854
      @iOJPF69854 ปีที่แล้ว

      Oh, I think I figured out. Go to Graph Inspector in the shader graph and add Universal on the Target Setting.

  • @mochou_p
    @mochou_p ปีที่แล้ว +1

    optimization suggestion:
    since here we dont use an actual "color" from the ramp textures (we only take the value), we can combine up to 4 maps into one image file. each will only affect one color channel.
    a texture with transparency can hold pixels as vector4s (RGBA). many games use memory efficiently this way, and just split it into the individual maps in shader graph.

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว +1

      Hi, yes! This can be a good optimization if your ramps are plain grayscale.

  • @durgam_sumerian7815
    @durgam_sumerian7815 3 ปีที่แล้ว

    Wow, didn't know there are such free cool tutorials with rich info & explanation like this one, well, Subscribed.

  • @jeriswatching
    @jeriswatching 3 ปีที่แล้ว

    Liked and subbed. You saved me where Unity's own tutorial didn't.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Thank you! Yeah, their toon shader tutorial just plain doesn't work in newer versions... they don't add the needed keywords to the graph.

  • @NathanPrince1
    @NathanPrince1 4 ปีที่แล้ว

    Thank you sir I have been trying to get good looking shadows for a long time in URP and cascades never worked for me. Until I found you lovely vids and the shadow keywords fixed my problem. thanks and you get a like and subscribe for life :)

    • @LexGear
      @LexGear 2 ปีที่แล้ว

      Hey Nathan, it might be because I'm using a much later version of Unity, but I cannot get this shader to recieve shadows at all and I followed this video to a T. Including all the keyword tricks. What version of unity did you use?

  • @nicolasL009
    @nicolasL009 3 ปีที่แล้ว +1

    Awesome tutorial man, thanks a lot, keep up the good work!

  • @BLOXOBIZZAREMK2
    @BLOXOBIZZAREMK2 2 ปีที่แล้ว

    Rater than using a texture sample node and texture, a quicker and easier to hot-edit option is using a gradient node set to fixed with a gradient sample node, when X or Time is the output of the saturated N dot L (or the light direction dot normal) :)

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      This can work great! Just keep in mind you can't edit gradients in the material inspector (as of 2020.3 anyway), so if you plan to do that, stick with textures.

  • @noperiest8320
    @noperiest8320 ปีที่แล้ว +1

    This is a great tutorial video however I got stuck at implementing for additional lights. If I write the method ' GetAdditionalLightsCount(); ' in hlsl code file and apply it to custom function node in shader graph, the node says GetAdditionalLightsCount is undefined identifier. Wasn't it built in method for hlsl? idk why I can't use it. Could you please help me?

  • @FistFlameful
    @FistFlameful 4 ปีที่แล้ว

    Thanks for the tutorial! This was really helpful for learning about custom lighting and shaders!

  • @VyvyanTheGreat
    @VyvyanTheGreat 3 ปีที่แล้ว +2

    Phenomenal tutorial. Thank you SO much!

  • @ralfaralf6805
    @ralfaralf6805 3 ปีที่แล้ว +2

    I was wondering for a while why I don't get shadows. Turns out shadows were deactivated in the directional light settings by default for me in Unity 2020.3. I case of someone else is struggling...

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      Thanks for letting people know! Glad it’s working now

    • @ralfaralf6805
      @ralfaralf6805 3 ปีที่แล้ว

      @@NedMakesGames Thank you for making such great tutorials. It's working great and I'm having a lot of fun learning about shaders thanks to your tutorials :)

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      @@ralfaralf6805 I’m really glad to hear that! That’s my goal!

    • @jessehenao4555
      @jessehenao4555 3 ปีที่แล้ว

      Thanks a bunch ! I was going nuts hahah

  • @abhirutmeherishi5738
    @abhirutmeherishi5738 3 ปีที่แล้ว +1

    Wow! Thanks for this.
    Now all thats left is how to create comic like black outline and how to give it a jelly like appearance.

  • @217tman3
    @217tman3 3 ปีที่แล้ว +1

    This tutorial like a treasure

  • @lesarch
    @lesarch 4 ปีที่แล้ว

    This is an amazing tutorial! Thank you for this!

  • @GreenCream
    @GreenCream 3 ปีที่แล้ว

    This is great, but is it supposed to work with differen light colors or just white? You didn't show that in the video and colors don't seem to be working for me (even with just the main light without the ramp).

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      Thank you! It should work with different light colors, since that was one of my goals with this shader. Make sure you multiply the light color with the output of the ramp subgraph!

    • @GreenCream
      @GreenCream 3 ปีที่แล้ว

      @@NedMakesGames You're right. My bad! I Messed up one of the inputs as a float instead of a vector3. Thanks again for the fantastic tutorials. Hope to see more! 😊

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      @@GreenCream Ah, no problem! That happens to me too frequently...
      Thank you! I'm writing the next tutorial's script as we speak!

  • @AdXxRi
    @AdXxRi 4 ปีที่แล้ว +1

    Great video mate! love it

  • @dennisj8149
    @dennisj8149 3 ปีที่แล้ว

    Thank you for sharing your knowledge! Hope you have a great day :)

  • @BLOXOBIZZAREMK2
    @BLOXOBIZZAREMK2 2 ปีที่แล้ว

    Btw anyone watching now you can get the light position and other data by making a vector 3 (for position, or a colour for light colour) variable, clicking on it and opening the 'node settings' in the graph inspector, unchecking expose, and changing the reference to specific key words. I cannot remember them off the top of my head but if you google 'get main light position shader graph' you should find them. Will save some time :)

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Yes, this is a nice trick to get main light data quickly! The variable names are the same ones used in this tutorial.

  • @dianjakap4805
    @dianjakap4805 2 ปีที่แล้ว

    Great job, best shader tutorial ever!

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Thank you, that means a lot!

    • @dianjakap4805
      @dianjakap4805 ปีที่แล้ว

      @@NedMakesGames hello, I am back with a question. I am using unity 2021. for shadow, after modified the hlsl, the shadow work without implementing "MAIN_LIGHT_CALCULATE_SHADOWS" key. do I still need to use the key?

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      @@dianjakap4805 If it works, no there's no reason to use the keyword. Just make sure your shader both casts and receives shadows, since they're separate concepts when it comes to rendering.

  • @ty-xq7bl
    @ty-xq7bl 3 ปีที่แล้ว

    Great guide man thank you so much

  • @kostjaaf
    @kostjaaf 4 ปีที่แล้ว +1

    I would Love to see more!

  • @minhhai9281
    @minhhai9281 ปีที่แล้ว +1

    I'm using Unity 2022.2.21 f1 and a have problem with Add Additional Lights custom node(variable CustomFunction_9d076c439b9d46d794647 4fc35720596 Diffuse 10 Float' used without having been completely initialized at line 180). I need help please

  • @hidemat5141
    @hidemat5141 3 ปีที่แล้ว

    Omg. Thank you for this, some toon shader tutorials out there don't tackle the shadows issue, and your shader is so well organized. You made my day :) Just one question though. The shader looks weird in the scene view, is there a way to fix this? Edit: Oh fixed it. I had lights disabled in my scene viewer.

  • @larsmaas07
    @larsmaas07 ปีที่แล้ว +1

    Unity 2021.3 works perfect

    • @chetanamali956
      @chetanamali956 6 หลายเดือนก่อน

      hey I'm using unity 2022.3 but it gives me an initialized error for directional light "output parameter 'Direction' not completely initialized at Assets/Includes/Lighting.hlsl(4) (on d3d11)" what should I do?

    • @larsmaas07
      @larsmaas07 6 หลายเดือนก่อน

      i've quit gamedev for like half a year now

  • @BarcelonaMove
    @BarcelonaMove 4 ปีที่แล้ว +2

    I came for cooper and found gold.

  • @Hazzanamous
    @Hazzanamous ปีที่แล้ว +1

    Hi there Ned great tutorial! I am running into an issue at the additional lights section where the "GetAdditionalLightsCount" function doesnt seem to work properly even after copy and pasting your final code. The error I get is "undeclared identifier 'GetAdditionalLightsCount' at line 34" Definitely at a loss for what to do at the moment since even copying the code completely didn't fix the issue. I am running on Unity 2021.2.19f.

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! That is strange, GetAdditionalLightsCount seems to work correctly for me in 2021.2! Can you please make sure that URP is a "target" of your graph? In the graph inspector, it should list it under "Targets."

    • @angelgabrielcaviedesjoya9368
      @angelgabrielcaviedesjoya9368 ปีที่แล้ว

      @@NedMakesGames I have the same problem and it is shown as a target in the graph inspector

    • @ColtPtrHun
      @ColtPtrHun ปีที่แล้ว

      I'm getting a similar error on 2022:
      "undeclared identifier 'AddAdditionalLights_half' at line 190".

    • @ColtPtrHun
      @ColtPtrHun ปีที่แล้ว +3

      For me it can be solved by:
      - Clicking on the custom function node
      - In Graph Inspector/Node Settings change the Precision from "Inherit" To "Single"

    • @izzydev9919
      @izzydev9919 7 หลายเดือนก่อน

      ​@@ColtPtrHun Life saver, much appreciated

  • @brennanbugbee
    @brennanbugbee 2 ปีที่แล้ว

    Instead of a texture you can use a gradient node and sample the gradient using the diffuse values

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      That's true! Just note that you can't edit gradients in the material inspector, so all materials will have to use the same gradient. If that's OK, this can be a good trick!

  • @Nebraf
    @Nebraf 3 ปีที่แล้ว

    Thank you very much! this was so helpfull!

  • @mobartingames2053
    @mobartingames2053 2 ปีที่แล้ว

    Thanks for the tutorial :) One thing, you are speaking with same mono voice tone during all tutorial, it makes hard to follow up. thanks again

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi, I think I improve on that a bit in later tutorials. But thanks for watching!

  • @mattlepage1898
    @mattlepage1898 3 ปีที่แล้ว

    Love ur video! Glad I clicked! :)

  • @kostjaaf
    @kostjaaf 4 ปีที่แล้ว

    Very nice Tutorial!

  • @abara7591
    @abara7591 3 ปีที่แล้ว +1

    how to get main light in hdrp project?
    it doesn't work the way it worked with urp

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      I don't have any experience with HDRP, so I don't know. You could look through the HDRP source's shader library. There should be a a file related to lighting that you can read through to find the right functions to call.

  • @shabadava62
    @shabadava62 ปีที่แล้ว

    no matter what i do, the smoothness dot on the main light source does not change size by editing the smoothness value. Any help?

  • @Kopftier
    @Kopftier 2 ปีที่แล้ว

    great Tutorial, thanks! :D

  • @fun2run4
    @fun2run4 3 ปีที่แล้ว +2

    Anyone wondering about how to do rim lighting. I've found the fresnel effect works quite well.

  • @Weenmeen
    @Weenmeen ปีที่แล้ว

    With the second lighting script that adds shadow I'm getting this error ""MainLight_float": no matching 0 parameter function at line 174"

  • @hibiscusbear
    @hibiscusbear 4 ปีที่แล้ว

    really cool and well done :)

  • @anonymoussloth6687
    @anonymoussloth6687 3 ปีที่แล้ว

    at 12:54 why do we have to normalize the result of view dir + cam dir? since we are taking the dot product, the result would always be between -1 and 1 (and if we saturate, btw 0 to 1). I don't get why, mathematically, this is necessary? I tried to do it without the normalization, the the specular highlight became to big.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +2

      We need the half vector to be a unit length. The dot product scales with the length of each vector, so it’s only -1to 1 if both vectors are unit length!

  • @LexGear
    @LexGear 2 ปีที่แล้ว

    SOVLED: If you have issues getting the shadows to be recieved, it might be because you gradient step is too similar to the color of the shadow and so it doesnt appear to cast, even though it does.

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว +1

      Good point! It can be useful to bypass the toon effect by setting the ramp to a simple gradient texture. Makes it easy to catch things like this!

  • @f0xta1l99
    @f0xta1l99 10 หลายเดือนก่อน

    How would you go by adding a custom texture to your toon shader's calculate lighting ramp?

  • @anonymoussloth6687
    @anonymoussloth6687 3 ปีที่แล้ว

    Lol I am new to Unity so I didn't understand a thing in this video XD but it seems like a great video. Do you have any suggestions/resources that are helpful in starting shader graphs?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +2

      This tutorial seems pretty good: www.raywenderlich.com/3744978-shader-graph-in-unity-for-beginners. Unity also has official tutorials here: learn.unity.com/tutorial/introduction-to-shader-graph. Thanks for watching though, I hope these help!

  • @WALT_LIVE
    @WALT_LIVE 3 ปีที่แล้ว

    Hey i was wondering why you would use a 2D texture for the color of your materail instead of just using a color property? Great tutorial btw.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi, thank you! Do you mean the texture around 8:40? That's the main texture, used to add details to your object. You can add a color tint pretty easily though. Just add a color property and multiply it with the ramp output.

  • @samoliverdev
    @samoliverdev 3 ปีที่แล้ว +1

    Note: for me, setting keywords to global
    was enough to see receive shadows

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Oh, that's great! Do you mind telling me what version of Unity and URP you're using?

    • @samoliverdev
      @samoliverdev 3 ปีที่แล้ว

      I am using unity 2019.4, urp 7.5.1

  • @GustavoMondini
    @GustavoMondini 8 หลายเดือนก่อน

    does it work as well for HDRP or is the coding completely different ? I can handle the graph easily, but im a completely noob at shader coding

  • @jamjam.100
    @jamjam.100 ปีที่แล้ว

    This toon shader would be perfect with the 3d pixel style, any informative methods onto how to add pixelated style??

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      This video looks nice! th-cam.com/video/R9MoyEOdmeA/w-d-xo.html

  • @marigo856
    @marigo856 3 ปีที่แล้ว +1

    I'm using 2020.3. I followed the instructions for the shadows precisely and quadruple checked that I did everything exactly but its still not receiving any shadows. I made sure to read the description for the changes needed for 2020.3 and copied the "Final Version for 2020.2" script. There's no misspellings in the keywords for the materials nor shader graph. I made sure to use a directional light. Been scratching my head at this for hours. Any ideas what I'm doing wrong? I can provide more details if needed.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      Hi! Ah, Shadows are really annoying to get right at the moment, there are a lot of places to make mistakes.
      I would make sure that your camera has render shadows turned on and that your URP settings asset has shadow cascades and soft shadows turned on. Make sure your mesh renderers have cast shadows turned on. If a mesh with a standard lit shader receives shaders, you know that part's all set up. Additionally, your ramp or some other part of the graph could be obscuring things. I would try to route the main light shadow attenuation directly into the base color field of the master stack to see if shadows show up that way.

    • @marigo856
      @marigo856 3 ปีที่แล้ว

      @@NedMakesGames I FINALLY got the shadows to work! After two weeks of poking the shader and digging the internet, I found the fix. Turns out, I just needed some extra lines of code (pastebin.com/buzfq0eJ) which I found on this forum (forum.unity.com/threads/shadow-and-distance-attenuation-do-not-work-in-urp-unlit-graph.803025/). I don't understand shader language, so I have no idea how this works, but it works and I can finally sleep well! I hope you might be able to find this helpful too or at least interesting.

  • @niiiiiiiiiiiiiiiiiiiiiiiiiiick
    @niiiiiiiiiiiiiiiiiiiiiiiiiiick 3 ปีที่แล้ว

    Hi thanks for the great tutorial :) Wondering if there's a reference somewhere I can look at for URP related functions in shader graph - would love to expand this shader so that it is affected by environment lighting, even just the sky / equator / ground colors from the gradient mode would be really cool.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! Thanks, I’m glad it helped you out!
      You can see a list of nodes here: docs.unity3d.com/Packages/com.unity.shadergraph@10.4/manual/Node-Library.html
      It’s pretty difficult to get full environmental lighting in an unlit graph, but check out the “Ambient” and “Baked GI” nodes.

  • @JR3D
    @JR3D 2 ปีที่แล้ว +1

    hello, thank you for the tutorial
    i am getting a shader error with the additional lights section:
    "undeclared identifier 'GetAdditionalLightsCount' at Assets/Test/Includes/Lighting.hlsl(50) (on d3d11)"

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi! This is usually caused by the Shader Graph being set to unlit mode. I would double check that.

    • @dhruvbajaj1054
      @dhruvbajaj1054 2 ปีที่แล้ว

      @@NedMakesGames What should it be then?

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      @@dhruvbajaj1054 Oops, I misspoke here. Unlit mode is correct, make sure the "target" is URP.

  • @sealsharp
    @sealsharp 3 ปีที่แล้ว

    Hey Ned! Nice work, Sir! Question: When URP gets deferred rendering, will that work with this shader? ( And your hull outline shader ).

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi, thanks! I doubt it will automatically since lights are handled differently in deferred rendering. I will probably make a video about it when deferred mode is released! Same with the hull outlines.

    • @sealsharp
      @sealsharp 3 ปีที่แล้ว

      @@NedMakesGames Wow, that answer came fast. Looking forward to it. Have a nice weekend, Ned!

  • @WillzyX07
    @WillzyX07 ปีที่แล้ว

    It might sound stupid, but how can I apply the shader to my existing objects in the scene? Ideally I would like to apply it to all texture at once instead of one by one...

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! Unfortunately, there's not an easy way to do this. If you set the reference name for your properties to match the names in your shader, they may move over. For instance, the main texture for the default lit shader uses "_MainTex"

  • @anonymoussloth6687
    @anonymoussloth6687 3 ปีที่แล้ว +1

    When I type the keywords in the debug mode, the ramp strips become very distorted and bad looking (I can see a bit happening in yours as well at 11:27). Why does this happen and is there a way to fix it?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! It could be your shadow settings. Go to your URP settings asset and up the shadow resolution. I’d also check the ramp’s texture importer settings. Turn off compression, sRGB, automatic power of 2, and mipmaps.

    • @anonymoussloth6687
      @anonymoussloth6687 3 ปีที่แล้ว

      @@NedMakesGames The shadow res only affects the shadows and not the ramp texture used to get the cell shading effect on the object. This happens right after i put the keywords in the debug mode. Also, for some reason, I am getting shadows without using the keywords (I am using unity 2020.2 and URP 10.2.2) as I mentioned in another comment just now. I just don't get shadows on the object itself (is this because it is unlit)?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      @@anonymoussloth6687 A small shadow map resolution could affect the apparent ramp, since shadows would be pixelated. Also, the keywords enable shadows on the object, so you do need them in that case. Objects will cast shadows regardless, but only receive shadows with the keywords enabled.

    • @anonymoussloth6687
      @anonymoussloth6687 3 ปีที่แล้ว

      @@NedMakesGames I played around with the settings a bit more and it seems that the URP shadow settings is the culprit. For some reason, if soft shadows is enabled, the ramp outlines on the object are fine, but when it is disabled, they become distorted and pixelated

    • @diamonds8014
      @diamonds8014 2 ปีที่แล้ว +1

      For anyone else reading this in 2022! I'm using unity version 2020.3.21f1, to fix the ragged edges on the toon ramp, go into Universal RP settings and changing the Shadows-> Depth Bias setting or the Shadows -> Normal Bias setting. This fixed the ragged edges for me.

  • @jtherussian
    @jtherussian 2 ปีที่แล้ว

    I'd like to see how we can add something similar to a Rim Shadow / Outline that's affected by Multiple Light sources

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Oh, good suggestion! I do have a tutorial on hull outlines and a rim light shader graph. Maybe those can set you on the right path in the meantime.

  • @ERBaruin
    @ERBaruin 4 ปีที่แล้ว

    Loved this tutorial!
    I'm testing different toon shaders and Shadows are always a problem. How do you handle shadows cast by other objects?.
    First problem is blocking the directional light and apply shadow accordingly.
    Next issue are objects with the toon shader casting shadows between themselves.
    And for some reason the objects dont block light, they are affected by point lights, but the light is still reaching the ground behind them.
    I hope you make a part 2 :D
    Thank you very much!

    • @NedMakesGames
      @NedMakesGames  4 ปีที่แล้ว +1

      Thank you! Yeah, shadows are always tricky.
      This shader uses URP's (Universal Render Pipeline) shadow code for the main directional light. So that is fully featured.
      Unfortunately, URP does not support point light shadows, so this shader cannot either. If you need them, I would consider using the High Definition Render Pipeline, but I don't know how easily my shader graph will move over to it.
      Spot lights are another issue entirely. URP does support spot light shadows, but they were really buggy for me, so I did not include support for them in this video. Maybe I should look more into it?

    • @ERBaruin
      @ERBaruin 4 ปีที่แล้ว

      @@NedMakesGames I really hope that Unity expand the support for shadows in shadergraph... Thanks! I learned a lot from this tutorial, but I guess we have to wait a little longer :D

  • @Auroron
    @Auroron 3 ปีที่แล้ว

    Cant for the life of me get the light colors to work properly, not even the main light. Following the tutorial the point lights give off light but dont give off any color on my object. Fiddling with the graph im able to get point light colors to work (Foregoing the CalculateLightningRamp for the specular for example), but only some colors seems to show? For example blues wont show, any idea why?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! I think this might have to do with the way the shader handles light colors. It multiplies the light color with the texture color, so, for example, if the texture is pure red (1, 0, 0) and the light is pure blue (0, 0, 1), the resulting color will be black (0, 0, 0). This is how Unity handles lights normally, but since this toon shader doesn't have ambient lighting, it's extra pronounced. If you don't like this, you could convert each color to HSV and combine them somehow.
      If you change the light colors to white, does everything work as expected? If not, please post an image of your graph along with what version of unity you're using, and I can take a look.

  • @dhruvbajaj1054
    @dhruvbajaj1054 2 ปีที่แล้ว

    Help. I cant get the object to receive shadows. Im using Unity 2021 LTS, tried it on 2020LTS too

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi! Sometimes it works better if you put the keywords in a subgraph instead of the main graph. Try copy and pasting them there.

  • @matcha.t3a
    @matcha.t3a 2 ปีที่แล้ว

    Getting an error that dont seam to go away no matter what I do
    1 is "expected identifier as macro name"
    2 is "unterminated conditional expression"
    sorry if this is a very easy fix but any help would be greatly appreciated

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi! I would guess there's a typo in your shader. Check the video description for some reference scripts to compare yours to.

  • @Bluequaz
    @Bluequaz 3 ปีที่แล้ว +1

    For anyone having issues with the shader .hlsl file throwing an error:
    forum.unity.com/threads/invalid-conditional-expression-in-custom-function.1043452/
    Change:
    #if SHADERGRAPH_PREVIEW
    to:
    #if defined(SHADERGRAPH_PREVIEW)

  • @danbirman3374
    @danbirman3374 2 ปีที่แล้ว

    This was an awesome tutorial -- I have one issue though which is that shadows don't render for additional lights for me. The shadowAttenuation is always 1 -- is there another keyword that has to be enabled for them to work or possibly some other issue?

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว +1

      Hi, thank you! I made a follow up tutorial to fix that, which you can find in the video description. Keep in mind point light shadows are only possible in Unity 2021.1 and later, though.

  • @IshaiMeresman
    @IshaiMeresman 3 ปีที่แล้ว

    Thanks for the great tutorial!
    Can it be that the shadows part is unnecessary? I get shadows after the diffuse part

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      Thank you!
      Shadows seem to work for some people out of the box, so if they do for you, you can skip all that with keywords. Just be sure that both casting and receiving shadows works, because they’re separate concepts when working with shaders.

  • @milky743
    @milky743 ปีที่แล้ว

    Hii, I followed very clearly your tutorial, but I'm stuck at the part of the ToonRamp, It doesn't work for me... I made the same one as you with the same pic size 128x2 px, but it does nothing... Please can someone help me TuT

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว +1

      Hi! What do you see? Does your object have no lighting, is it black, or does it just not match up with your ramp?

  • @Bluequaz
    @Bluequaz 3 ปีที่แล้ว

    My objects cast shadows, but do not receive them. Anybody have fixes? the entirety of the shader graph UI is different, so I cant find settings for MultiCompile and Local. Any help appreciated on this. Is this example even supposed to receive shadows?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! Yes receving shadows is supported! In 2020.2 and later, Unity changed the UI so that keyword settings are in the inspector window (by default in the top right corner). You might have to switch tabs to see them.

  • @aAaAaAaAaAaAaAaAaAaAaAaAaAaAh6
    @aAaAaAaAaAaAaAaAaAaAaAaAaAaAh6 2 ปีที่แล้ว

    Hi, I have a problem in Shadows part, Unity say to me this: Shader error in 'Master': Invalid conditional expression. at Assets/Includes/Lighting.hlsl(5)

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi! Are you using Unity 2020.2 or later? Try changing the "#if SHADER_GRAPH_PREVIEW" at that line to "#ifdef SHADER_GRAPH_PREVIEW". You might also have to do that later on in the file too.

  • @sealsharp
    @sealsharp 3 ปีที่แล้ว

    It's been some time but rewatching this after watching Daniel Iletts humongous "all 200 nodes" video, i wonder if there is a reason to use a shading ramp texture instead of a gradiant.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      That will work just fine! The only drawback is that you cannot edit gradients in the material inspector (as of 2020.3), so if you might have different ramps on different materials, it's probably not the right way to go.

    • @sealsharp
      @sealsharp 3 ปีที่แล้ว

      Thanks for the fast answer! Have a good day, Ned!

  • @Likii_Handle
    @Likii_Handle ปีที่แล้ว

    Hi, I’m using Unity 2022 something and it seems that you cannot access the shadow keywords as you did but after some aimless scrolling I did find them in some sub menu in the material inspector. They were turned on by default however the shadows are still not appearing… All the other requirements for the shadows you mentioned were present too. Do you know what’s the cause for the shadows not showing? Thanks!

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! Unfortunately, I have not been able to try this out in 2022, so I'm not sure what the issue could be. I have heard that some viewers can get it working by copy-pasting the keyword properties to a subgraph or defining the keywords at the top of the HLSL include file, like "#inlcude _MAIN_LIGHT_SHADOWS", ect.

  • @robosoup2873
    @robosoup2873 2 ปีที่แล้ว

    hey, thanks for the tutorial ned!
    I swear I am having some kind of fundamental issue calculating just the basic specular angle.
    the highlight shows up in roughly the center of a sphere no matter what, and does not react to changing a directional light whatsoever. It also doesn't change in the shader graph previews when I adjust the default light angle supplied in your script.
    Your script is clearly working just fine, because the toon shading adjusts to the light angle as predicted.
    I have gone over each node carefully, they all have the exact same settings as in the video. the problem is somewhere before the saturation of the dot product at 13:04 in the video.
    did unity change something about the view direction node? I'm on 2020.3.34.
    EDIT: it's always when you finally write out your problem that you find the solution! I had to normalize the view direction before using it, as you point out in a newer video :)

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว +1

      Oh yeah, there's a bug in certain versions of Unity where world space view direction isn't normalized. I should make a note of that in the description. Glad its working now, thanks for watching!

  • @ChasmerPlays
    @ChasmerPlays ปีที่แล้ว

    Hey, really nice tutorial. I got shadows working but they are so bad. Jagged edges, ugly self-shadowing. How did you manage to make them look so crisp in your project? I tried fiddling with RP asset settings like distance, cascades and so on... But all shadows just look so bad. On things like capsule or sphere my diffuse shadows are completely covered by ugly self-shadowing. Do you know how to get rid of that?

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! Sounds like you need to change the shadow biases. You can edit these on the URP settings asset or the main light in your scene. If adjusting biases doesn't change the look at all, there must be some other cause. I would see if shadow map resolution, soft shadows, or cascades adjust the shadows at all.

  • @howarthstudios1217
    @howarthstudios1217 3 ปีที่แล้ว

    Is there anyway I could implement some sort of AO using this? I heard you say at the end about Ambient Lighting
    What sources did you use to learn about all this? Much appreciated thank you!

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! The easiest way to do AO would be to sample the AO texture and multiply that value with the diffuse and specular attenuation before exiting the CalculateLights graph.
      I listed some sources in the video description! But mostly, I looked at the URP source code. There's not a lot of documentation yet.

  • @J0ta_Emee
    @J0ta_Emee ปีที่แล้ว

    Hello, thanks for the video, the shaders turned out exactly how I expected. However, I'm having some troubles and have some questions, I'm new to unity and to programing, so, sorry if any of them are dumb questions. The first one is: how can I use the shaders I made in the new project in other projects that I have ?
    The second one is: when I tried to make the specular lighting, my view direction added with the custom function always turned out with the "add circle" being fully the same color as the custom function circle, no matter what I did, what could be the cause of it ?

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! Sorry for the late reply, I was away for the holidays.
      I'm glad you liked the video!
      1. In Unity, you can export assets into an "asset package" file which you can import into another project. docs.unity3d.com/2018.1/Documentation/Manual/HOWTO-exportpackage.html
      2. The preview nodes usually don't have all lighting data available, so even if they look strange, your shader might still work correctly! Be sure to test it out on an object in the scene.

  • @gonzaloburgos6444
    @gonzaloburgos6444 3 ปีที่แล้ว

    Hi Ned, I'm working on Unity 2020.3.0f1
    I'm trying to replicate this tutorial using your "Main and additional lights" scripts.
    When I set up the custom function on the graph inspector I get this bug message instead of the green color of the 4:51-->
    Shader error in 'hidden/preview/CalculateMainLightCustomFunction_c82dff837c5f4d038c71b6ca881cb0c4': Invalid conditional expression. at Assets/Shaders/New-toon-shader/includes/Lighting.hlsl(4)
    Pointing me to the 4th line of the Lightning.hlsl-->
    void CalculateMainLight_float(float3 WorldPos, out float3 Direction, out float3 Color, out half DistanceAtten, out half ShadowAtten) {
    What I'm doing wrong?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! Are you using 2020.2 or newer? Try changing “#if” to “#ifdef” Unity changed how one of their keywords worked in 2020.2

  • @mhrohan917
    @mhrohan917 3 ปีที่แล้ว

    Love this Channel For Shader. Thanks @Ned

  • @bramboeykens6030
    @bramboeykens6030 3 ปีที่แล้ว

    Hi for some reason the additional lights didnt contribute to the the shadow on the model, any ideas what i missed?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! I made a follow up video detailing how to add additional light shadows here m.th-cam.com/video/whmPkDp3dqo/w-d-xo.html

  •  ปีที่แล้ว

    Great tut! but any ideas on how to add the keywords in 2021.3? the debug option in the material is gone. Now there is one called "valid keywords" which is an array, but it wont let you modify it :/

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! Yeah... Unity has made several changes to the way keywords interact with Shader Graph since I made this video. The method explained in this video may not work depending on the version you're using. Sometimes, just placing all the keyword properties on a sub graph works, ignoring the material steps.
      You can also change your graph to a Lit graph and route everything through Emission (be sure to set base color to pure black). This will work for most uses.

  • @adityarahmanda
    @adityarahmanda 3 ปีที่แล้ว

    Help, my prefab is casting shadow if I drag it to the scene, but it doesnt cast shadow when I instantiate it.
    Do anyone know how to solve it?
    Edited : Solved. It cast shadow, but a small shadow. I used a low res shadow and bad lighting angle so it look like it doesnt appear.
    Nice tutorial 👍

  • @anselmonoriega8014
    @anselmonoriega8014 ปีที่แล้ว

    I dont know if anyone can help me with the problem output parameter 'Direction' not completely initialized in "Direction = mainLight.direction". I did put everything correct as vector 3 and I know thats the problem because if i change that whith some random numbers that are vector 3 will work. I need help please.

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Hi! That usually happens because some data in mainLight is not set before you use it. First, make sure you call GetMainLight before accessing direction. What version of Unity are you using?

    • @mochou_p
      @mochou_p ปีที่แล้ว +1

      for me (2021.3.25f1), it was from the lack of keywords, changing their scopes to global helped (i had this happen to DistanceAtten, but you could still try this)

  • @222ableVelo
    @222ableVelo 3 ปีที่แล้ว

    I wish someone would show how to get the "Light" in HDRP. Because I've tried this before, and in HDRP the master node always says "unrecognized identifier 'Light'" for an error. HDRP can't easily get the Light apparently, like you can in URP. Can you show how to get the "Light" in HDRP please?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +2

      Yeah, HDRP handles lights differently. This is on my to do list!

  • @gabrielpereira6930
    @gabrielpereira6930 ปีที่แล้ว

    How can I make the object cast shadow on another object using this toon shader for unity 2021.3? I tried to follow the video by in the debug mode, there isn't the field to insert the keywords anymore.

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว +1

      Hi! I've had some conflicting reports on this, but you might be OK with just the keyword entries in the subgraph's properties. Also try copy-pasting them to the main Toon graph.
      If that doesn't work, you can change your graph to a Lit graph, and then route the final color into Emission instead of Base Color / Albedo. This last option might have some strange side effects with baked lighting, but I'd try it out and see if it works for your game.

    • @NuggsSauce07
      @NuggsSauce07 7 หลายเดือนก่อน

      @@NedMakesGames just confirming, ran into same bug, copy and pasted "CalculateLights" shader to "Toon" shader and it worked! thanks for the tutorial and still helping w trouble shooting 3 years later, your awesome!!

  • @ultravires385
    @ultravires385 3 ปีที่แล้ว

    any chance of a tutorial on how to add a wind or mock wind shader to this?

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      I have a video on a grass graph which has wind, maybe that’s what you need! th-cam.com/video/JDpt9xYaUYc/w-d-xo.html

  • @RichardPieterse
    @RichardPieterse 2 ปีที่แล้ว

    Having trouble it light cookies, they appear in bakes but not in realtime

    • @NedMakesGames
      @NedMakesGames  2 ปีที่แล้ว

      Hi! I think you need to add another keyword for light cookie support, but it should work after that. I can't remember it off the top of my head. Check URP/Shaders/Lit.shader file for the correct keyword. Should be something like "_MAIN_LIGHT_COOKIE"

  • @mrjustina
    @mrjustina 4 ปีที่แล้ว

    So adding a second light isn't quite working for me. Seems like the attenuation isn't quite right? The light has to basically be right next to the model it's casting the light on to before it does anything with the shadow.

    • @NedMakesGames
      @NedMakesGames  4 ปีที่แล้ว

      You probably need to increase the light's intensity or range. Usually, because of the ramp, you need more intense lights than you would expect with PBR shaders.

    • @mrjustina
      @mrjustina 4 ปีที่แล้ว

      @@NedMakesGames hmm, no matter how I change the range or intensity it's exactly the same. I've blended this with another ramping solution so it's probably on my end.

    • @NedMakesGames
      @NedMakesGames  4 ปีที่แล้ว

      @@mrjustina Could be. This shader handles multiple lights a bit differently than others I've seen.

  • @ItsIntelligentDesign
    @ItsIntelligentDesign ปีที่แล้ว

    Does this shader allow for materials that receive shadows, or just materials that cast shadows? I'm getting issues with my model not "seeing" shadows cast by other objects when using a material with this shader applied

    • @NedMakesGames
      @NedMakesGames  ปีที่แล้ว

      Yes, you should be able to receive and cast shadows.
      Since I made this video, Unity has made several changes to the way keywords interact with Shader Graph. The method explained in this video may not work depending on the version you're using. Sometimes, just placing all the keyword properties on a sub graph works.
      You can also change your graph to a Lit graph and route everything through Emission (be sure to set base color to pure black). This will work for most uses.

    • @ItsIntelligentDesign
      @ItsIntelligentDesign ปีที่แล้ว

      @@NedMakesGames Thanks. This comment made me realize my issue was that I had created regular booleans and not keyword booleans

  • @ty-xq7bl
    @ty-xq7bl 3 ปีที่แล้ว

    I was wondering if its possible to remove the rounding of shadows and instead opt for heavy artifacts(boxy shadows) instead?
    Which nodes would I need to use in order to
    -Remove the shine in the object and have it completely flat texture?
    -Reduce the automatic rounding of the shadows and keep the artifacts(it looks cool imo but its a very strange request i know)
    Thanks in advance!

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว +1

      Hi!
      You can remove the shine by setting the specular ramp to black, or just removing the specular ramp nodes.
      If you want blocky shadows, remove the SHADOWS_SMOOTH keyword from your graph and turn off smooth shadows on your URP settings asset. This will probably degrade the toon effect near shadows, but maybe that's what you're looking for!

    • @ty-xq7bl
      @ty-xq7bl 3 ปีที่แล้ว

      @@NedMakesGames Thank you!

  • @BANANADOMAU
    @BANANADOMAU 3 ปีที่แล้ว

    change this values to float on \Lighting.hlsl
    out float DistanceAtten, out float ShadowAtten) {
    because theres no more vector1.

  • @krishnasripathi6322
    @krishnasripathi6322 3 ปีที่แล้ว

    Hello, this isn't a toon shader question but the shadows of all game objects in my scene, including the ones using toon materials, only appear in a certain angle. I am using URP, and I even went into standard render pipeline and installed urp, and still got the same problem

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! You can try editing your shadow settings in the URP settings asset. Specifically, try changing cascades count and shadow bias settings.

    • @krishnasripathi6322
      @krishnasripathi6322 3 ปีที่แล้ว

      @@NedMakesGames Oh wow that fixed it! I set it to 3 cascades and the shadows work pretty well now

  • @omerfsa
    @omerfsa 3 ปีที่แล้ว

    thx for tutorial. i am using 2020.2.0f1.. without switch debug mode my models has shadow.. is it still necesserly to add that keywords ? I deleted keywords from my shader also nothing changed. and also instead of adding texture I make gradient input from unity it works well too.

    • @NedMakesGames
      @NedMakesGames  3 ปีที่แล้ว

      Hi! It's weird, some other people have reported this, but if having no keywords works for you, it's OK to delete them! Keep in mind the keywords enable the toon material receiving shadows, not casting shadows, so make sure both work.
      Oh yeah, a gradient works well too! Use whatever fits your workflow the best