Showing grid using Shader in Unity - Grid Placement System P2

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 86

  • @BlueDuck-vv3eu
    @BlueDuck-vv3eu Місяць тому +2

    Thanks, this is a great introduction to both grid and shadergraph

  • @bishopjackson2264
    @bishopjackson2264 5 місяців тому +4

    If you are missing the Grid. You need to go into Window > Package Manager > Select the Shader Graph package > Select the Samples tab > Import he Procedural Patterns

  • @vvbgamedevx11
    @vvbgamedevx11 8 місяців тому

    Excellent Tutorial. Really helpful.. Another part done.. Thanks..

  • @bluzenkk
    @bluzenkk Рік тому +2

    looking good! Thanks

  • @mancheckitout
    @mancheckitout 5 днів тому +1

    Thanks

  • @NightRunStudio
    @NightRunStudio Рік тому +2

    Love your videos, man! Concise, but clear. Keep it up!

  • @CreeperMinecraft2000
    @CreeperMinecraft2000 Рік тому +4

    Wow! your vids are so easy to follow along to! Can you plz make a tutorial on the alteruna multiplayer packgage?

  • @jiezhou-r8m
    @jiezhou-r8m Рік тому +1

    I really like your tutorial, Peter! Thank you very much, and I also bought your tutorial!

  • @nesaransari7453
    @nesaransari7453 Рік тому

    Well explained....Waiting for next video.

  • @Karlthuluu
    @Karlthuluu Рік тому +2

    Could you maybe show how you would implement this on an uneven surface / terrain?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Unless you need a continuous placement you could still have a flat 2D grid since even if you are selecting a mountain its X and Z coordinates are the same as on the flat area. All you would need to to is shoot a raycast from the edges of your object to place it at an angle relative to the terrain shape. The easier approach would be to shoot a raycast from the center point and place it at this altitude. You would also need to use some form of a boxcast against your terrain to check if by any any you are not intersecting a mountain edge when placing your object. Can be a lot of work to implement this.
      I hope it helps!

  • @Tozerus1
    @Tozerus1 Рік тому

    Thank you for the great video. I've been following your content on Udemy and you have a talent for really well put together training material! Great Stuff!

  • @vierminus
    @vierminus 2 місяці тому

    Danke!

  • @heikkort
    @heikkort 4 місяці тому +1

    Great Video it helps me a lot. How would it work though if my cells have a different size? I have a prefab I want to place that is 2.75/3/1 in scale. I changed the grid size and that works but changing the shader to show this size correctly gives me problems. Any help would greatly be appreciated!

    • @SunnyValleyStudio
      @SunnyValleyStudio  4 місяці тому

      You could have a custom grid that supports it. Most times you would make the cells of a size that can fit your object. The size is 2.75. You could make it occupy 3 tiles of 1 unit of size or maybe make the cells have 0.5 unit (which doesn't changes much but maybe you have other objects that are 2.5 and here it does make a difference). I would suggest to adjust the size of your grid to to the smallest object that you have .

  • @baby-sheesh
    @baby-sheesh Рік тому

    the sphere which serves as the cursor always has an offset to the cellindicator, it points at one cell but the cellindicator is on the diagonal opposite cell

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Hey! in the code we are relying on the "grid.CellToWorld(gridPosition);" so the method from the Grid class. Any offset might be caused by 1) offset added to the GRID object in the hierarchy or 2) offset added to the cell indicator prefab or 3) some error in the code. You can view the code here github.com/SunnyValleyStudio/Grid-Placement-System-Unity-2022/commits/main
      I hope it helps. if not feel free to write me on discord (link in the description) and attach screenshot so i have a better understanding of the problem 🙂

    • @baby-sheesh
      @baby-sheesh Рік тому

      @@SunnyValleyStudio Hey! Thanks for your quick answer, I made sure that every prefab and the grid start at 0,0,0. I fixed the problem by adding 1 to each the x and z position to the cellindicator position. Other than that everything worked fine, thank you for this awesome tutorial!

    • @cheesecakenl1980
      @cheesecakenl1980 Місяць тому

      I got the same issue. The mouse indicator shows at the correct spot but when placing the cell calculation is off by one. My grid and plane transforms are at 0,0,0. I only offset the cube inside the empty parent by 0.5f so the pivot point is lower left.

  • @mnicodev
    @mnicodev Рік тому +1

    Will you cover also stacking objects like 'Unpacking game' in this series? Nice content, thank you for sharing!!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      I will cover how to place floor and on it furniture (or rather how to place both) and how to detect when deleting the furniture first and next the floor.
      Stacking would be done similarly - detect IF there is a floor and only then allow to place furniture. You should have really easy time figuring it out when I release the "Removing objects" part of the tutorial 🙂

  • @vierminus
    @vierminus 2 місяці тому +1

    Cool tutorial, thank you!
    I'm trying to build a grid system for a VR game and i hvae the problem, that shaders only get rendered in a correct way on the left eye and not on the right. Same applies Skyboxes.
    You don't have an idea by any chance whats the problem?

    • @SunnyValleyStudio
      @SunnyValleyStudio  2 місяці тому

      Check your XR Manager (project settings). Are you using Single Pass Stereo Rendering Mode ? I think it has to be set to Multi Pass Stereo Rendering Mode for shaders (among other things) to work properly.

    • @vierminus
      @vierminus 2 місяці тому

      @@SunnyValleyStudio That's it thank you so much! I'm gonna leave a donation, keep up the good work!

  • @nathanav1634
    @nathanav1634 Місяць тому +1

    the shader stuff, can you do that in code or does it have to be in the editor using connection lines?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Місяць тому +1

      I bet that you can do it in HLSL but I am not that experiences to explain that. Feel free to browse documentation docs.unity3d.com/Manual/SL-ShaderPrograms.html

  • @vladtzapone7737
    @vladtzapone7737 8 місяців тому +2

    I've successfully managed to create the grid, everything is nice, the only thing is that in the distance the cells are flickering when i'm moving my character. Any fix for this? Thank you !

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому +2

      Flickering can be cause by z-fighting (that is why we move the grid plane in front of the ground). When you zoom far away the flickering can be dues to Anti-aliasing and the fact that our grid is "thin" when viewed from afar). I'm not an expert when it comes to solving graphics related problems so it's something you would have to research 🙂

  • @emeraldskelly
    @emeraldskelly Рік тому

    Great tutorial, but the grid seems to have a thin black outline that I don't like. Do you know how I might get rid of it? Or is it just due to imprecision with the grid node?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      I am not sure. It might be something connected to rendering settings. I am not that advanced with fixing visual bugs. Very often it can be connected to Anti Aliasing but again that is just what I would check.

    • @emeraldskelly
      @emeraldskelly Рік тому

      @@SunnyValleyStudio okay thank you. Do you know if you're experiencing the same thing?

  • @vatsoffice
    @vatsoffice Рік тому +1

    my object in the shader editor only has position and scale. why?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Can be some changes done to the Shader Graph docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Object-Node.html . It shouldn't affect the shader that we create though 👍

  • @tr25ny
    @tr25ny Рік тому +1

    I'm having a problem with the grid lines jittering when the camera moves. the only thing that works is setting render scale in URP settings to 2 and turning anti-aliasing off. however, this isn't ideal and I'm wondering if there's something else, I can adjust withing the shader.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      It sounds like anti-aliasing issue. You can try making your grid thicker but I'm note entirely sure what do you mean by jittering. Feel free to share screenshot on discord.

  • @SafwatAhmad_GD
    @SafwatAhmad_GD Рік тому

    The shader you created shows thin lines on the border of the grid. How to make it show even lines on the edges of the grid as well?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      This is because we only get half of it on the edges. You could use a Rectangle nod and add a thicker outline to the edges of the plane - just have to find the correct value based on the scale and the base thickness. You could just use "Add" node to the result that we have so far and for safety "Clamp" it to 0-1.

  • @chibamoon6410
    @chibamoon6410 6 місяців тому

    the ball in the grid shader is just black it doesn't have the lines when we change the value to 1

    • @SunnyValleyStudio
      @SunnyValleyStudio  6 місяців тому

      Strange. I remember that indeed some parameters had to be limited in range from 0 - 0.99 because otherwise the shader logic would not work. Maybe I forgot to add clamp node to prevent that. Sorry about that!
      I'm fairly confident about the shader itself so if it is not the issue that you are experiencing maybe take a look again at the section of the video where I present the graph and compare it with yours. Feel free to join my discord discord.com/invite/RQEtYHz if you need me to send you a screenshot of my graph 🙂

  • @asierlizaso7348
    @asierlizaso7348 Рік тому

    Hey! Thanks for the video! I have a question about the grid cells. Wouldn't it be possible to connect the shader tiling attribute to the grid's cell size? That way, changing the shader should automatically make the grid cell size match, right? (I mainly use Maya so I am not very familiarized with Unity). Thanks again! :D

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Hey! Yes you can do it. I show how in my House Building Template courses.sunnyvalleystudio.com/p/house-building-system-in-unity to encourage people to support my work 🙂
      It isn't hard to figure out. It just takes a custom script.

  • @thiagosoares7414
    @thiagosoares7414 3 місяці тому

    Shader part should be a 1 week daily tutorials, otherwise we just lear how to copy and paste

  • @shazboi
    @shazboi Рік тому

    How to limit the object while placing it? If I place the table at the right border, some part of it goes out of the grid. How do I clamp it's size?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      The easiest way is to specify by hand the grid borders (later you can calculate those). Next just ask this "GridB0rders.cs" component "Are the positions selected for placement outside the grid border? "
      All you would have there is a "center point" and the "size" and single method with an if stement "If origin.x + offset.x < placement.x .. " (the same for negative offset and the y value).
      I hope it makes sense

    • @shazboi
      @shazboi Рік тому

      @@SunnyValleyStudio Yep I kinda figured it out by taking limits of the Grid then doing something
      in the CalculateGridPositions(); function like
      Vector3Int desiredPosition = gridPosition + new Vector3Int(x, 0, y);
      if (desiredPosition.x < -gridXLimit / 2 || desiredPosition.x > (gridXLimit / 2) - 1
      || desiredPosition.z < -gridYLimit / 2 || desiredPosition.z > (gridYLimit / 2) - 1)
      {
      return null;
      }
      and then
      in the CanPlaceObjectAt(); function
      if (positionToOccupy == null) return false;
      Solved the thing 👍

  • @developer7551
    @developer7551 Рік тому

    when you are changing plane size your grid size also change i assume because you prefab indicator indicate move to last shader visualize grid cell but mine are not move in that way my grid size remain same tell me about this

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      I will be talking about the prefab in the next video. The prefab is of size 1x1 (grid cursor indicator). Then we modify the shader size it doesn't affect the Grid component. We have to manual (you can use a customs script) set the Grid component size to 0.5 when you set the shader size to be (2,2,2) - because we multiply there and 1 / 0.5f = 2.
      Anyhow the only moment that your cursor should move is when we modify the Transform of the "Grid Parent" object since it applies offset to the Grid components calculations.
      I hope it answers your question 🙂

  • @amenalaya1417
    @amenalaya1417 Рік тому

    i don't have the samples folder where can i find it

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      If you mean for the shader Grid parameter you have to open Package Manager (from the Top menu I think "View" category ?) and find in it the Shader graph. Next on the right you should find "samples" and have a way to download the shader graph samples.

  • @7azDingo
    @7azDingo Рік тому

    When making grid shader(connecting nodes and all that), the preview shows a pink sphere. If I change preview to Quad, it's just a pink rectangle. If I make it to material and put it on plane, the plane just turns pink. I'm sure I connect minus one out to fragment color. Please help.

    • @7azDingo
      @7azDingo Рік тому

      Fixed it. It was a renderer issue

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Glad to hear that you were able to solve it 🙂

    • @7azDingo
      @7azDingo Рік тому

      @@SunnyValleyStudio Great Guides! Thanks!

  • @flikera
    @flikera 9 місяців тому

    I'm using 2d sprites for my game and the grid appears in front of the sprites, how to fix that?
    Also how do you make the grid transparent?

    • @flikera
      @flikera 9 місяців тому

      I found the answer of the first: Material > Sorting Priority -1

    • @SunnyValleyStudio
      @SunnyValleyStudio  9 місяців тому

      Good to hear that you have found a solution!

    • @flikera
      @flikera 9 місяців тому

      Do you know how to control the grid alpha/transparency?@@SunnyValleyStudio
      I tried the color, but it doesn't do anything.

  • @dmsassassin
    @dmsassassin Рік тому +1

    No "Open Shader Editor" button!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Are you using URP pipeline? Another reason for it might be that you have created a default shader file and not the "Shader graph" asset. You can check this forum to read more about this issue forum.unity.com/threads/cant-open-shader-graph.669955/

  • @FatRogSlim
    @FatRogSlim Місяць тому +1

    The changing grid size part doesn't explain how to do it. you go half way and just say "but I will not do that, lol"... frustrating

    • @SunnyValleyStudio
      @SunnyValleyStudio  Місяць тому

      Sorry about that! You are the first person to mention it. I think all you need to do is adjust Grid component and the shader material to modif the grid size.

  • @uso2484
    @uso2484 Рік тому +1

    comment for promoting your channel

  • @fabexl5898
    @fabexl5898 11 місяців тому +1

  • @hypercritical6712
    @hypercritical6712 4 місяці тому

    my material just shows pink//// i HAD TO USE BUILT-IN SHADER GRAPH... oh ok

    • @SunnyValleyStudio
      @SunnyValleyStudio  4 місяці тому +1

      I believe that we use URP in the project. Still this is definitely a shared problem where you fix it by swapping the shader of your material to a compatible one.

  • @timow6929
    @timow6929 6 місяців тому +3

    Had a hard time following the shader part. It was too fast and the explanations quite shallow. Otherwise good video.

  • @joaocarlosp.p.6550
    @joaocarlosp.p.6550 Рік тому

    Sample doesn't have a Grid!

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      What do you mean? We create the grid in the tutorial

    • @Survivor_Shelter
      @Survivor_Shelter Рік тому

      he's talking about the shader.@@SunnyValleyStudio

    • @osan99999
      @osan99999 7 місяців тому

      0:55 package manager->shader graph>samples>import

    • @bishopjackson2264
      @bishopjackson2264 5 місяців тому

      @@SunnyValleyStudio In the recent starter package, there is no samples folder.