PixTrick
PixTrick
  • Видео 14
  • Просмотров 67 873
[TUTORIAL] Unity Shaders - Vertex, Fragment and Fundamentals
Hey, game dev enjoyers!
In this episode, we focus on the rendering pipeline as well as fundamentals you have to know before actually writing shaders. I hope you'll like it (and if you do, don't forget to like and subscribe) :D
Feel free to add some things or to correct me in the comment section, i'll be glad to answer! I've tried to be as concise as possible, but tell me whether you would like me to take more time or not.
Also, you can join the discord server of the community if you want to discuss about your projects and/or about game dev in general, everyone is welcomed !
Here's the link : discord.gg/TnGhH5CAnj
In any case, i'll see you in the next episode !
Take care !
Chapters:
0:00 Intro
0:36...
Просмотров: 436

Видео

Unity Shaders - A Quick Overview (in 3 minutes)
Просмотров 9885 месяцев назад
Hey, game dev enjoyers ! Here's the first video of a series about shaders. This episode is a quick overview of what are shaders, i hope you'll like it (and if you do, don't forget to like and subscribe) :D Feel free to add some things or to correct me in the comment section, i'll be glad to answer ! Please join the discord server of the community if you want to discuss about your projects or ab...
[TUTORIAL] Stencil buffer in Unity URP (cutting holes, impossible geometry, magic card)
Просмотров 25 тыс.Год назад
Hey game dev enjoyers! Here we are: the mighty tutorial about the stencil buffer that I’ve been working on for weeks now. I hope you’ll enjoy it ;) WARNING: Please make sure to follow the instructions of the “IMPORTANT” chapter (it's only 30 seconds long no worries), otherwise you would not be able to use the stencil buffer. The shader and the 3D model of the impossible geometry : github.com/Pi...
Stencil buffer in Unity URP (advanced hole cutting, ground crack, magic card)
Просмотров 1,7 тыс.Год назад
Hey game dev enjoyers ! Here's the last video showcasing my work on the stencil buffer in Unity. I'm currently working on a huge video about this topic, so there's no need to ask for a tutorial this time ;) EDIT : Here's the link to the tutorial : ruclips.net/video/y-SEiDTbszk/видео.html Also, I created a discord server to discuss about the videos and to build a little community of game dev enj...
Monument Valley movement system remake in Unity
Просмотров 1,1 тыс.Год назад
Hey game dev enjoyers ! Here's my work on the Monument Valley movement system. The main difference is that i did not use some pathfinding to move the player, so that the player can move freely. The full Monument Valley gameplay : ruclips.net/video/Yy2bXqs0x3o/видео.html Let me know if you're interested in a tutorial or some explanations ! Also, I created a discord server to discuss about the vi...
Stencil Buffer in Unity URP (cutting holes, impossible geometry/magic box)
Просмотров 2,1 тыс.Год назад
Hey guys, here's a different topic than usually ;) I did not use the ProBuilder tool to cut holes but only the stencil buffer. Let me know if you're interested in a tutorial or some explanations. EDIT : Here's the link to the tutorial : ruclips.net/video/y-SEiDTbszk/видео.html Also, I created a discord server to discuss about the videos and to build a little community of game dev enjoyers, like...
[TUTORIAL] Interactive Shadows in Unity
Просмотров 4,6 тыс.Год назад
Hey, game dev enjoyers ! Here's the tutorial on the interactive shadows, i hope you'll learn some things ! I tried to keep it as short as i could, but i also tried to explain different things at the same time. If i said something wrong or that is irrelevant in the video, please tell me in the comment section. I'll be glad to answer ! The scripts made in the tutorial : github.com/PixTrick/Intera...
3D Volumetric Shadows in Unity
Просмотров 951Год назад
Hey guys, this is one of the last shadow-related topics i worked on. Disclaimer : this is not a light shaft technique nor a volumetric light technique. This is basically a mesh created by the projection of some object vertices in the light direction, depending on what type of light it is. I admit the shadows can behave weirdly sometimes in motion, still this is great for static shadows. I'm wor...
Interactive Shadows in Unity
Просмотров 1,9 тыс.Год назад
Just a showcase of my work on interactive shadows in Unity. Let me know if you're interested in a tutorial or more in-depth explanations ;) EDIT : The link to the tutorial : ruclips.net/video/3MnA8lYQ_P0/видео.html (I admit i tried to make a more attractive thumbnail) Cheers ! #unity3d #gamedev #shadows #interactive
[TUTORIAL] Custom Shadows in Unity URP using Shader Graph
Просмотров 24 тыс.Год назад
Here we are. I tried to keep it as short as i could, but i also tried to explain different things at the same time. If i said something wrong or that is irrelevant in the video, please tell me in the commentary section. I'll be glad to answer ! Regarding the files needed for the custom shadows : github.com/PixTrick/PixTrickCustomShadows To configure a URP project from a built-in one : ruclips.n...
Shleep Chaser
Просмотров 201Год назад
Hey ! I just finished a game jam and released my game. Go check it out if you're interested : pixtrick.itch.io/shleep-chaser Cheers ! EDIT : The final results got me 3/66 for the jam :D #unity3d #gamedev #gamejam #puzzle #puzzlegame #sleep #sheep
Mirrors in Unity URP (read description)
Просмотров 1,2 тыс.Год назад
A showcase of my work on mirrors in Unity URP. This is NOT a reflection probes technique, it is just uses a camera, a render texture and the power of mathematics. Let me know is you're interested in a tutorial or more in-depth explanations ;) Cheers ! #unity3d #gamedev #mirror #reflection
Custom Shadows in Unity URP using Shader Graph
Просмотров 2 тыс.Год назад
Just a showcase of my work on custom shadows using Shader Graph in Unity. Here's the tutorial : ruclips.net/video/GiJbur0CrnU/видео.html I used a toon shader base that i modified to get this result. I used this video for the base : ruclips.net/video/K5yhPrjttaI/видео.html Cheers ! #unity3d #shadows #gamedev #shaders

Комментарии

  • @knowercoder
    @knowercoder 4 дня назад

    Thanks a lot. You saved me!

  • @JaiUjjwal
    @JaiUjjwal 13 дней назад

    Please make more shader tutorials!

  • @Geckoo1337
    @Geckoo1337 24 дня назад

    Ton accent français te trahit :) Très bon tutoriel. J'apprécie beaucoup ta chaîne YT - très pédagogique. Bonne continuation ++

    • @pixtrick
      @pixtrick 23 дня назад

      Je ne m'en déferai jamais de celui-là ;) Merci beaucoup, ça me touche !

  • @amac333
    @amac333 Месяц назад

    You didn't use DistanceAtten right? or did I miss something. Also, suggestions for adding normal maps to this? Just WorldNormal and BlendNormals node or something?

    • @pixtrick
      @pixtrick Месяц назад

      I didn't use DistanceAtten indeed About the normal map, you should add a texture for the normal map, then multiply the output of the texture sample 2D node with the normal vector, and use the result instead of just the normal vector for the dot product with the light Hope that makes sense

  • @umidmalikov3005
    @umidmalikov3005 Месяц назад

    Я очень сильно хочу увидеть твой туториал

  • @Twenty7Official
    @Twenty7Official Месяц назад

    I was looking for this!! Thank you sooo much

  • @cenklar
    @cenklar Месяц назад

    Thanks! It's a great tutorial, worked perfectly right off the bat.

  • @adranfloran2827
    @adranfloran2827 Месяц назад

    Please when it's the next video coming out 😭 love ur work

    • @pixtrick
      @pixtrick Месяц назад

      Patience mate! I'm a bit overwhelmed these last months but I will definitely make the sequel in the future

  • @mmertduman
    @mmertduman 2 месяца назад

    Great tutorial! I have a question, why do we create a new layer for each view? Can’t we modify the materials of each object and change their stencil ref values to be equal to 1 2 3 4 respectively and set the test to equal? I don’t want to clutter the project with many layers just for some effect. Same for the first ground crack effect. Follow up Q for the Mask shader, could we have said Comp Never and Fail Replace? Wouldn’t that also make the mask invisible? Would we still need Blend Zero One in that case? Another follow up Q.. for the objects that fail the stencil test and not get drawn, does Unity still write them to the depth buffer?

    • @pixtrick
      @pixtrick 2 месяца назад

      Only great questions here! About the layers, you can use materials that have stencil behaviours for the objects in the cube without having to modify their layer indeed. The drawback of this method is that you have to create a custom shader for these objects so that you can customise their stencil behaviour. You wouldn't be able to use any material for these objects, whereas you can with the layer method. About the mask shader: yes, Comp Never / Fail Replace is a great method for making an invisible mask. However, it won't draw at all, so it won't write into the depth buffer. It could be annoying for some edge cases, but for I tend to prefer that approach too. You don't need ZWrite Off or Blend Zero One with that technique, I find that quite elegant. About your last question, I partially answered it before but just to clarify: if a pixel fails the stencil test, it is not rendered. If it is not rendered, it cannot write into the depth buffer. Hope that helps!

    • @mmertduman
      @mmertduman 2 месяца назад

      @@pixtrick Amazing! Thank you

  • @neromasti9109
    @neromasti9109 2 месяца назад

    this is truly amazing, thank you for your mind boggeling work

  • @user-ct8ws3qp7c
    @user-ct8ws3qp7c 3 месяца назад

    Could this be used for making bullet holes on walls etc?

    • @pixtrick
      @pixtrick 3 месяца назад

      If you want to see through the hole, yes it could be useful. However, most games use decals for that, which is basically slapping a bullet impact texture on a wall. Still, I would be curious to see that! That's kind of a good idea :)

  • @Lina-pr5kz
    @Lina-pr5kz 3 месяца назад

    So nice, I'd love to have a tutorial on this plz!!!

  • @HordorDev-ms7sj
    @HordorDev-ms7sj 3 месяца назад

    This helps a lot! You make my day!🤫

  • @sujayaryabodhi1164
    @sujayaryabodhi1164 3 месяца назад

    what sorcery is this? i must know!!! we need a tuto

  • @ThingsMadeOfOtherThings
    @ThingsMadeOfOtherThings 3 месяца назад

    Yes please do a tutorial!

  • @lulloxa
    @lulloxa 3 месяца назад

    Great video, thank you for your work !

    • @pixtrick
      @pixtrick 3 месяца назад

      It is my pleasure!

  • @watercat1248
    @watercat1248 4 месяца назад

    This custom shadow's work on the floor and ever other mash I have on the Sean ? The reason I asked it's because if that is and If the transparentcy work with this I will able make shadow's for glass and other similar stuff. For example if have glass bottle I will able to make White showdow and experiment with paternt in the order to look like better. Shame on the beer bottle 🍾 I will make green transparent shadow and I will look so much better seen if I add normal shadow on those object looks pretty bad.

    • @pixtrick
      @pixtrick 4 месяца назад

      This shader works only for opaque rendering, it does not handle the transparency unfortunately ... It would be something to dig in if I would remake this shader

    • @watercat1248
      @watercat1248 4 месяца назад

      @@pixtrick i know that but if is possible to make the shadow to have lighter color's and add objects that only have shadow I'm probably able to make the system i wand to make.

  • @RindGame
    @RindGame 4 месяца назад

    Nice Video, Learn A Lot

    • @pixtrick
      @pixtrick 4 месяца назад

      That's good news!

  • @yourssincerely7857
    @yourssincerely7857 4 месяца назад

    Hello! Reallyyyy cool shader! Do you know why it makes my pattern still show in the whole object and not just the shadows that we create?

    • @pixtrick
      @pixtrick 4 месяца назад

      Hey ! Thanks ! Yes it's my bad actually, I should do an updated version of this tutorial since it's quite old now. It's due to the order in the operations, I posted a fix last week on the GitHub repository if you want to take a look !

  • @m1glw97
    @m1glw97 4 месяца назад

    Is this effect somehow possible with depth priming set to auto or forced?

    • @pixtrick
      @pixtrick 4 месяца назад

      Not sure, but all the tests I've made so far point to the fact it is not

  • @jarvinvruizeeslao
    @jarvinvruizeeslao 4 месяца назад

    I'm confused as to why I'm getting this error. Shader error in 'Shader Graphs/Master': 'MainLight_float': output parameter 'Direction' not completely initialized at Texture/CustomLighting.hlsl(4) (on d3d11) Using Unity 2022.3.20f1

    • @pixtrick
      @pixtrick 4 месяца назад

      Hey ! You can check the pinned comment, maybe it would solve your problem

    • @jarvinvruizeeslao
      @jarvinvruizeeslao 4 месяца назад

      @@pixtrick I found the problem I was not using URP T_T Anyways awesome video and I appreciate the response!

    • @pixtrick
      @pixtrick 4 месяца назад

      @@jarvinvruizeeslao happens x)

  • @watercat1248
    @watercat1248 4 месяца назад

    I think this 3D mask system i was looking for i will definitely do some tests tomorrow.

    • @pixtrick
      @pixtrick 4 месяца назад

      Don't hesitate to message me on discord if you need anything

  • @Ari_M17
    @Ari_M17 4 месяца назад

    Hey, I'm using unity version 2022.3.27, I've used your shadergraph from github, however the material is not working and is just a pink output. Do you know what im doing wrong?

    • @pixtrick
      @pixtrick 4 месяца назад

      Hey ! Have you also imported the .hlsl file that was provided in the files ?

    • @Ari_M17
      @Ari_M17 4 месяца назад

      ​@@pixtrick Yea I did

    • @pixtrick
      @pixtrick 4 месяца назад

      Can you contact me on discord? It would be easier to understand your issue

  • @Digildon
    @Digildon 5 месяцев назад

    I spent my entire childhood learning not to step on shadows. And I guess I figured out why.

    • @pixtrick
      @pixtrick 5 месяцев назад

      I'm still doing it today 😭

  • @bjaksel
    @bjaksel 5 месяцев назад

    Your brain is massive

    • @pixtrick
      @pixtrick 5 месяцев назад

      You're flattering me x)

  • @lulloxa
    @lulloxa 5 месяцев назад

    You explain very well! Good anim.

    • @pixtrick
      @pixtrick 5 месяцев назад

      Thanks a lot ! :D

  • @misterlonely6057
    @misterlonely6057 5 месяцев назад

    Woohoo, good topic! Can't wait for more content.

    • @pixtrick
      @pixtrick 5 месяцев назад

      Thanks a lot !

  • @ilario-gd
    @ilario-gd 5 месяцев назад

    Very intersting, glad to see a new serie emerge, can't wait for the next episode ;)

    • @pixtrick
      @pixtrick 5 месяцев назад

      Thanks ! I'll try to post it as soon as possible

  • @bovineox1111
    @bovineox1111 6 месяцев назад

    Disabling the ground collider is fine for a single entity but you’re quite likely to have multiple entities and those will still rely on the ground entity!!

    • @pixtrick
      @pixtrick 5 месяцев назад

      Absolutely, that was just an example, it's totally up to you to improve this ;) In this case what you would do instead is disabling the collision between the 2 colliders basically

  • @TheGameLecturer
    @TheGameLecturer 6 месяцев назад

    This works greatly in Editor for me, but in the build it doesn't function properly (neither on Android nor on PC) and I just get plain geometry.

    • @pixtrick
      @pixtrick 5 месяцев назад

      What unity version are you using ?

    • @TheGameLecturer
      @TheGameLecturer 5 месяцев назад

      2022.3.17f1@@pixtrick

    • @pixtrick
      @pixtrick 5 месяцев назад

      You have to make sure that the depth priming is off, and I'm not entirely sure but I think setting the rendering path to forward can help as well

    • @TheGameLecturer
      @TheGameLecturer 5 месяцев назад

      @@pixtrick yes it is disabled and the rendering path to forward, I tried different depth texture modes as well. I'll try to isolate the problem by making a new project and make some test and I'll come back to you.

    • @pixtrick
      @pixtrick 5 месяцев назад

      @@TheGameLecturer all right ! By the way you can message me on discord if you prefer

  • @zave1776
    @zave1776 6 месяцев назад

    Is there any chance to apply the same effect in the HD render pipeline? needed very very much

    • @pixtrick
      @pixtrick 6 месяцев назад

      Hey, I'm not very sure about that, you should try ! In any case, if the render features are not available, you can still use the stencil buffer through custom shaders

  • @kahnetop
    @kahnetop 6 месяцев назад

    great explanation! is this possible in the build in render pipeline ? i struggle a lot to convert the technique correctly

    • @pixtrick
      @pixtrick 6 месяцев назад

      It is indeed possible, but you won't have access to the render features. Basically, the URP allows a per-layer rendering with its render features (so you don't have to worry about the materials of each object of the layer), whereas the built-in RP don't, so you'll have to write custom shaders to get the same result, it's a bit harder but 100% doable in my opinion.

    • @kahnetop
      @kahnetop 6 месяцев назад

      @@pixtrick thanks for the response! I finally succeeded! I think the hardest part was that i used Amplify and its stencil buffer parameters were some time buggy 😅 But you're explanation was really great and help me find the way!!

  • @InstantStarWars
    @InstantStarWars 6 месяцев назад

    Merci, maintenant c'est limpide

  • @marcmcdonald1132
    @marcmcdonald1132 6 месяцев назад

    this looks really cool i want a tutorial!

  • @hldfgjsjbd
    @hldfgjsjbd 7 месяцев назад

    Can these be done in Shader Graph?

    • @pixtrick
      @pixtrick 7 месяцев назад

      Unfortunately no, shader graph doesn't support the stencil buffer

  • @aprilyang8204
    @aprilyang8204 7 месяцев назад

    Hii, thank you so much for the tutorial, but I just tried everything you did in the video but there isn't any change or interaction for my shadow. I'm wondering could you share the project file somewhere so that I can take a look?

  • @helikaon00
    @helikaon00 7 месяцев назад

    I can't seem to follow your instructions when it comes to NOT using a shader to solve it. You pop up the render object settings but I can't figure out how to set it up to work. I am trying to solve this without shaders because I am developing something that can't use normal shaders at all. It could use shader graph, but I don't know how to do this in shader graph either.

    • @pixtrick
      @pixtrick 7 месяцев назад

      Hey ! You just have to use a render feature then. Basically, instead of using a shader for the mask material, you just have to create a render feature with a Never stencil comparison operation, so that it won't show on screen. You can use any material you want for that mask then since it won't show on screen at all. EDIT : I forgot to mention that after doing that, you'll have to use the Fail operation instead of the Pass operation, because the comparison operation will always be false, so that the Pass operation will never trigger.

    • @helikaon00
      @helikaon00 7 месяцев назад

      Hmm, yeah, I just can't seem to figure it out. I was trying to make something for the Apple Vision Pro but you can't use normal shaders, you can only use shader graph (or other node based shading methods), because they use MaterialX which requires node based shading. Thanks for your help though! Appreciate you taking the time to respond.@@pixtrick

    • @cutsceneentertainment6706
      @cutsceneentertainment6706 2 месяца назад

      @@helikaon00 I struggled with the same thing and got it to work. I don't know if it will work for you or anyone else reading, but this is what I did: - Make sure that the culling mask dropdown menu of your main camera has both your walls layer and your occlusion object layer checked - Make sure the proper render pipeline asset (the one you have the stencil on) is set in the quality section of project settings - Make sure that in the "Filtering" section of the render pipeline asset inspector window, the Opaque Layer Mask dropdown has both your walls layer and your occlusion layer UNchecked - On the render feature for the walls, set Event to AfterRenderingOpaques, set the layer mask to your walls layer, enable Stencil and set its value to 1, and then go "Not Equal, Keep, Keep, Keep" for the next four dropdown menus, in that order from top to bottom. - On the render feature for the obscuring object, set Event to BeforeRenderingOpaques, set the layer mask to your obscuring object layer, enable Stencil and set its value to 1, and then go "Never, Keep, Replace, Keep" for the next four dropdown menus, in that order from top to bottom. Lastly, in case anyone wants this to only work when behind a wall, not in front, give your obscuring object a new script. Have it fire a raycast from itself to the main camera every frame. If the raycast is obstructed by any object in the wall layer, change it's scale to whatever size you want. Otherwise, change its scale to 0. I'm not a professional at this, I figured this out through trial and error. So if it doesn't work for you, I'm really sorry but I have no clue how to fix this. I just hate when people post "I figured it out" and don't say how, so hopefully this helps someone.

  • @tufanaydin6340
    @tufanaydin6340 7 месяцев назад

    SSAO and DECALS not working how can we fix it ?

    • @pixtrick
      @pixtrick 7 месяцев назад

      Decals are not compatible with the stencil buffer, or at least I haven't find a way to make them work together yet. We discussed about it on the discord server of the community but didn't find a solution ... Regarding SSAO, I'm not entirely sure why it doesn't work as intended ... It may be either the AfterRenderingOpaques event queue or simply because objects rendered through a render feature are not considered as "real" geometries

  • @tufanaydin6340
    @tufanaydin6340 7 месяцев назад

    Thank you so much you done great job

  • @TheInSinging
    @TheInSinging 7 месяцев назад

    THIS IS THE BEST TUTORIAL out there for URP / Stencil / Depth mask - for AR masking as well. Don't search further. I checked other tutorials, this one is the best. Thank you for your work!

    • @pixtrick
      @pixtrick 7 месяцев назад

      Thanks for the kind words ! :D

  • @cometgamerid
    @cometgamerid 8 месяцев назад

    Op bro

  • @RT-qi7rn
    @RT-qi7rn 8 месяцев назад

    I'd really like to learn how to do it without requiring a special layer for the ground as I'm working on a game where the layers have already been carefully setup and can't really be changed

    • @pixtrick
      @pixtrick 8 месяцев назад

      I'll try to make a video on that

  • @empluna
    @empluna 8 месяцев назад

    Hi, how did you manage to make the inverted cube invisible from the side? Like the tunnel to go through? Great tutorial

    • @pixtrick
      @pixtrick 8 месяцев назад

      Hi ! It's an inverted render culling, you can access this parameter in the material editor

  • @ToniehGaming
    @ToniehGaming 8 месяцев назад

    New sub! I have a doubt, basically in the example of the letter it's as if it were a "hologram" on a cellphone using the position of your eyes (camera). Is there a possibility to obtain that texture relative to the camera position so that on the full screen I can create this hologram effect? This is not with stencils, but I have been looking for how to do this and can't find any information :c.

    • @pixtrick
      @pixtrick 8 месяцев назад

      Hey, thanks a lot ! I'm not sure to fully understand your request to be honest, is it about the floating text in the magic card? If that so, it's only a canvas in world space with appropriate dimensions

    • @ToniehGaming
      @ToniehGaming 8 месяцев назад

      @@pixtrick nonono, I have an eyetracker device, I can know the user position and I want that the monitor screen act like that portal to make that card effect, It's so tricky. If you atatch the game camara to the user real position works but not that good that the card effect

    • @ToniehGaming
      @ToniehGaming 8 месяцев назад

      It's hard to explain, also is similar to the 3d wallpaper efect, but that use the acelerometer, is not that real effect

    • @pixtrick
      @pixtrick 8 месяцев назад

      @@ToniehGaming ok i think i'm slowly getting it. Is it like a parallax effect ?

    • @ToniehGaming
      @ToniehGaming 8 месяцев назад

      @@pixtrick Not so much like a parallax, more like the monitor was a window and there were things through it. It looks the same as what the card effect looks like.

  • @WalrusesAreTheOne
    @WalrusesAreTheOne 9 месяцев назад

    Hi, one of the first portal tutorials I saw relied on a mask material instead of a stencil buffer, to make the outsides of the portal invisible. It seemed way easier to me than setting up a stencil buffer. Is there a reason this is better? Thanks!

    • @pixtrick
      @pixtrick 9 месяцев назад

      Hi ! I think that what you saw is also based on the stencil buffer, but perhaps the main difference here is the use of the URP which allows you to add stencil parameters on any rendered material. However, I agree it might be annoying to set up, so if you're only using hand-written shaders (shader graphs doesn't count), you can add these stencil behaviours way more easily. Does it answer your question? x)

    • @WalrusesAreTheOne
      @WalrusesAreTheOne 8 месяцев назад

      @@pixtrick Thanks! Yes, that answers it:)

  • @ninocoillard6775
    @ninocoillard6775 9 месяцев назад

    This is awesome however when I apply the card part to my game with a door I want to mask I can still see the shadow, do you know how to fix it ?

    • @pixtrick
      @pixtrick 9 месяцев назад

      Hey there ! You just have to disable shadow casting in the mesh renderer

    • @ninocoillard6775
      @ninocoillard6775 9 месяцев назад

      Okay, and if I want to cast just when it is enabled and then when it is masked, disable it ?@@pixtrick

    • @pixtrick
      @pixtrick 9 месяцев назад

      @@ninocoillard6775 when you say enabled, do you mean when you can see through the door or do you have something that enables or disables the view through the door ?

  • @Shado_devlog
    @Shado_devlog 9 месяцев назад

    I'm dumb af and I don't know much about Unity nor C#, can you make a tutorial for 2D interactive shadows?

    • @pixtrick
      @pixtrick 9 месяцев назад

      I'll try !

  • @urod7149
    @urod7149 9 месяцев назад

    Hello. Big thanks for your tutorial. But my material, for some reason, doesn't render any self-cast shadows as it was shown on 3:50 of your video. I even tried to apply your shader from your github on my model but it still has no self-shadows. Do you happen to know what the problem might be?

    • @pixtrick
      @pixtrick 9 месяцев назад

      Hello there ! What unity version do you use ?

    • @urod7149
      @urod7149 9 месяцев назад

      @@pixtrick22.3.15f1. Also made that line fix you mentioned in the pinned comment

  • @fleity
    @fleity 9 месяцев назад

    I will ask this here because your video is truly one of the best stencil buffer explanations I have seen over the years (especially considering read/write mask)^^ You say turn off shadow casting for the ground. That is because the shadow caster pass does not care about the stencil value. That is really not ideal. I see the workaround of setting the walls to draw shadows both sided okay but it still feels a bit broken.. the same is true for for any kind of depth pre pass unfortunately. Since the ground is disabled from the regular rendering loop it does not show up in the depth pre pass at all which will prevent us from using depth priming as optimization and the objects will also be missing in the depth texture (except depth priming is disabled, but unfortunately this only applies the the game view, scene view is always using a depth pre pass). Btw SSAO in DepthNormals mode forces a depthNormals pre pass.. so the same issue applies here as well. That is why it was not working for stylie473joker5. After Opaque mode + priming disabled copies depth from the depth written by the color pass, but that works only in very few cases. Do you have any ideas how one could fix / work around that issue? The way you show here is the way everyone seems to implement stencil buffer usage in URP but it's seems incredibly limited due to these limitation. Thanks for thinking about it :)

    • @pixtrick
      @pixtrick 9 месяцев назад

      Hey! Thanks for the comment and the kind words I appreciate that! Now, about your question, I don't really think there's a real workaround for that, since the shadow caster pass uses the vertex data to draw shadows. Since the fake geometry created by the stencil buffer is not an actual geometry (I mean it is not some vertex data, it's just pixels on screen), the shadow caster pass cannot render there properly. Then, I don't really see any workaround for keeping the ground shadows while not rendering them into a hole. Now, if you really need your ground shadow (I assume it would be for like a platformer game or something), I would suggest not to use the stencil buffer unless you're really forced to. Use real geometries as much as you can. I think this is not (or maybe it is but it would be such a pain regarding performance) possible to draw shadows pixel by pixel, so that the shadows are not rendered into the hole but are rendered for the ground, but that is absolutely not reasonable. May I ask you what you are trying to achieve? Maybe there's a workaround in your situation and I would be glad to help :) Have a great day !

    • @fleity
      @fleity 9 месяцев назад

      ​@@pixtrickThanks so much for the reply :) I think, I figured out two possible solutions by now but either way it sucks a bit that this is so exhausting to do. Beware this will be a long text, thanks for letting me rubberduck a bit. It is in fact not a plattformer, rather an isometric adventure type of game. I am making this example up but the situation is basically like this. Imagine a hill and ground mesh with a meteor crater on top. The crater is the hole I would like to stencil out. I can not build this right into the mesh because it is procedurally placed. Inside the crater I have a plane which reads the depth texture to create some fog-ish dust. Issue 1: Shadows of the hill are drawn without the stencil cutout hence everything in the crater is shadowed. Turning of the shadows would mean no shadows in the surrounding area by the hill. Issue 2: the information in the depth texture is also wrong. This is a bit harder to explain and needed a bit of digging in the frame debugger and render pipeline. The Render objects feature only writes to the cameras color target. The color target contains a depth channel but it is only used when certain conditions are met. For example in the game view, if depth priming is disabled and nothing else forces a depth pre pass (like ssao in depthNormals mode). The scene view always uses a depth pre pass not matter what we do. When we remove the ground from the regular render loop and only render it through render objects it is completely removed from the depth pre pass because the render objects feature does not set that up and the mask definition that we have set excludes it from ALL main passes (except for shadows...). I wonder why this isn't done in the render feature but that I guess that this is the reason why the feature still says experimental. Unity didnt figure out a way to make it compatible with any possible srp renderer. This is an issue what the typical "hey draw the characters silhouette" tutorials don't have because they draw the character in the regular loop too. As for solutions, one option I can make work is not using stencils at all. Render everything in the main loop, set the queue for ground materials to 1990 and create a depth mask shader + material that overwrites the depth where it is rendered with infinitely far away. Then everything that is rendering afterwards renders as usual and even shadows are correct (because the shadow passes use the depth only passes of the shaders too). The other solution is to modify the render objects feature to also create a depth pre pass or inject the missing draw calls into the existing pass with the correct stencil renderblock set and render the stencil render objects feature extremely early (before pre passes). Second solution is more flexible / cleaner and actually allows using the stencil buffer fully but it is much more work. I am at the point where stuff renders in the depth pass but not with stencils yet. I guess my issue here is simply summarized with: Render Objects does not work with depth pre pass, stencil in render objects does not work with shadows in URP, but it could, unity just didn't finish it yet 😕.

    • @pixtrick
      @pixtrick 9 месяцев назад

      Hmmm your thinking process might be good, but I think there's a much simpler solution for such a problem. Basically, your problem is : how to generate a hole in a procedurally generated terrain. To me, this is much simpler than having to deal with depth pre passes and everything, plus it would be much more cleaner. As I said before, you have to use real geometries as much as you can, and only use the stencil buffer when it's needed. To me, you shouldn't use the stencil buffer at all for this problem since the crater will not move in your scene (I mean I assume it won't move). I don't know how you generate your terrain and how it should look, but I think you should use techniques such as the wave function collapse that allows you to design "tiles" that you can put together in numerous ways. That way, you can keep a procedurally generated terrain and would only have to make a tile where there is the crater. If you still really want to use the stencil buffer, well don't xD I cannot really help since I think it would feel broken ether way. Still, it was extremely interesting to read your different solutions, but yeah to me you should change your approach to this problem. Hope that helps !

  • @muhammedensarsandkc4466
    @muhammedensarsandkc4466 10 месяцев назад

    Just excellent.

    • @pixtrick
      @pixtrick 10 месяцев назад

      Thank you so much !