Snowtracks Shader - Unity CG/C# Tutorial [Part 3 - Draw to Splatmap]

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

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

    For a pure C# user, I feel shader is like a magic...
    Very nice tutorial btw! it's really easy to follow.

  • @Guyonahi
    @Guyonahi 7 ปีที่แล้ว +12

    Happy Birthday! Love this series.

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

    Thank you so much for the video. This was what i was looking for a month.

  • @leftyfourguns
    @leftyfourguns 7 ปีที่แล้ว

    Thank you for not only tackling a feature like dynamic trails/displacement that's hard to pull off without any advanced knowledge but also for explaining what exactly tessellation is and does so simply and clearly. No matter how much I read before, I just could not "get" tessellation. But your videos really help it click with me

  • @MikeKing710
    @MikeKing710 7 ปีที่แล้ว

    I thought it will be last video tutorial, but result looks great))) I'll wait for the continuation

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

      I don't want a video to be longer than 20min, so I try to divide it into chapters. This complete tutorial will have 5 parts, and maybe an extra 6th part on custom footsteps/textures

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

    you know what? i tried to create a 2d texture every frame, read the old one, restore the colors of the pixels in an array, then delete the old one, then create another one and write on top of that using the color array, and finally read from it from shader:DDDDD . actually its the same as this logic-wise, but, the performance is better using render textures. wish i had found this instead of trying to make things work by my own wasting hours on it. knowledge is power. whatever. nice tutorial. thanks.

  • @seanloughran6714
    @seanloughran6714 7 ปีที่แล้ว

    Excellent tutorial series!

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

    love this tutorial, i activaded the notificatons to know when you continue this. c:

  • @ByteBarista
    @ByteBarista 4 หลายเดือนก่อน

    Thank you, wizard!

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

    you saved my life...thanks a lot...

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

    Hey! Can you remake this in URP? Thanks!

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

    when i create instance material, it become pink. (my project render is URP)

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

      Did you solve it?

  • @TheMichaelholden
    @TheMichaelholden 7 ปีที่แล้ว

    Hey thanks heaps =] great job easy to understand and follow. The starter episode explaining the base structure was a nice touch. When should we expect the next episodes?

    • @PeerPlay
      @PeerPlay  7 ปีที่แล้ว

      Some very busy times here, with different projects, but I'm hoping to release at least 1 new part this coming weekend.

    • @TheMichaelholden
      @TheMichaelholden 7 ปีที่แล้ว

      Hey man, no rush. quality over quantity ;) You might be able to quickly answer a question though. If i'm using a sphere collider to "imprint" would i use a Physics.sphereCast and fix that vector3 to my sphere collider transform?. Thanks again.

    • @TheMichaelholden
      @TheMichaelholden 7 ปีที่แล้ว

      This is my temp fix until i figure out how to do the brushes lol
      RaycastHit hit = new RaycastHit();
      Ray ray = new Ray(col.contacts[0].point - col.contacts[0].normal, col.contacts[0].normal);
      if (Physics.Raycast(ray, out hit))
      {
      if (col.gameObject.CompareTag("Pen"))
      {
      _drawMaterial.SetVector("_Coordinate", new Vector4(hit.textureCoord.x, hit.textureCoord.y, 0, 0));
      RenderTexture temp = RenderTexture.GetTemporary(_splatMap.width, _splatMap.height, 0, RenderTextureFormat.ARGBFloat);
      Graphics.Blit(_splatMap, temp);
      Graphics.Blit(temp, _splatMap, _drawMaterial);
      RenderTexture.ReleaseTemporary(temp);
      }
      }

    • @TheMichaelholden
      @TheMichaelholden 6 ปีที่แล้ว

      I was also thinking, why can't I update the meshCollider? a ball for example will not collide with anything but the original flat meshCollider... I've tried
      // DestroyImmediate(meshColldier.GetComponent());
      // meshColldier.AddComponent();
      //meshColldier.GetComponent().sharedMesh = meshFilter.meshToUpdate;
      and
      meshColldier.GetComponent().sharedMesh = null;
      meshColldier.GetComponent().sharedMesh = meshToUpdate.sharedMesh;
      any ideas?

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

    When I draw on mesh, the 'red dot' keeps on the mesh. Its seems Blit doesnt work and Render Texture is still updating.. Help!

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

    QUESTION- If i had a limited amount of land with snow and i am removing snow with mouse so please tell me how to calculate percentage of snow removed so that i can call a function when all snow is removed. i am curious about it.

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

    Great tutorial but I don't get the part where you say we need to invert the distance to get a color. Can you explain it to me please?

    • @PeerPlay
      @PeerPlay  5 ปีที่แล้ว +2

      If the distance is small, which means you are about at the point to draw, the output would be for example 0.01. In colors that would be about black value.
      By inverting the number, or actually doing a 'one minus', which is different from inverting, 0.01, would become 0.99. So the center becomes white, and the further away from the hitpoint, the value becomes smaller, and thus more black.
      This creates the round circle, with a smooth gradient falloff

    • @Novecento
      @Novecento 5 ปีที่แล้ว

      @@PeerPlay Thanks a lot sir! Now I understand!

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

    I have a confusion in Graphics.Blit() function,
    first we copied the Splat Map into temporary texture (line:32) and then copied temporary texture into SplatMap (line:33).
    When I tried to use [Blit(_splatMap, _drawMaterial)] function directly (without copying into temporary texture) it"s not working.
    So, what exactly use of temporary texture here.

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

    how can i change the color that is painted? to green instead of red for example

  • @姜金浩-o2s
    @姜金浩-o2s 6 ปีที่แล้ว

    Hey Peer Play, Thanks a lot for your tutorial. I just learn the concept of Compute Shader. It's it possible to compute the SplatMap using Compute Shader? Could you do a tutorial about this thing?

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

    I'm trying to paint using multiple color. For example I start with red, then I use green but instead of covering the previous red color it gives me yellow. How can I use multiple colors?

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

      Nevermind I'ved solved it. The problem was in the DrawTracks shader, at the end instead of doing "col + drawcol" I lerp between the col and the drawcol. Can you explain a little bit more the Graphics.Blits passages that I cannot really understand please? Thanks!

  • @tingleoncrack2167
    @tingleoncrack2167 5 ปีที่แล้ว

    I'm having an issue where the render texture is only drawing as white. Any ideas as to how to make it red?

  • @antoinedevldn
    @antoinedevldn 5 ปีที่แล้ว

    WOnderfully done!

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

    can you in any way save the current texture of the ground as a new texture?, I am trying to make a game where you can paint different objects. I have this problem that when I change the color all the colors on the object turns into that color, I wonder if you could save the current Texture and apply it to the "_snowtexture", so when I am changing the groundcolor the "_groundcolor" that is already painted on still will be the old groundcolor, and I can paint with a new color on to the object? Pretty hard to explain but I hope you understood a little bit.

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

      photos.app.goo.gl/CCWacY9NQ8jat6js7, here is a link to a short video which maybe helps you to understand

  • @INeatFreak
    @INeatFreak 6 ปีที่แล้ว

    Thanks a lot but there is have an issue on my game. Whenever i scale the z axis of plane brush's z axis increasing too :( can you help me please ?

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

    Well when I draw to my landscape, I'm just making a hole exactly where the hit is.. its not drawing... help

    • @yosrijerbi
      @yosrijerbi 5 ปีที่แล้ว +2

      I had a simmilar problem, turns out had a typo in my C# script in the update
      Make sure that when calling the
      _drawMaterial.SetVector("_Coordinate" ...
      you use the name of the variable in the drawtracks script
      (i called it _Coordinates which caused the bug for me haha)

  • @doblajesimberbe1966
    @doblajesimberbe1966 6 ปีที่แล้ว

    Thank u for these amazing tutorials, but it would be great to upload the script code on pastebin and turn up your voice volume

  • @dhumildholiya3464
    @dhumildholiya3464 5 ปีที่แล้ว

    Hey, How to apply this snow tracks on sphere ?

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

    Anyone know why when I click play and then on the plane the little box turns pink and the texture changes? There are no errors in the console? Please help!

  • @EwanM84
    @EwanM84 5 ปีที่แล้ว

    when i click on my terrain to draw the black box just goes pink any ideas why?
    here are the errors
    Shader error in 'Unlit/DrawTracks': syntax error: unexpected token 'uv' at line 52 (on d3d11)
    Shader error in 'Unlit/DrawTracks': 'distance': no matching 0 parameter intrinsic function; Possible intrinsic functions are: distance(floatM|halfM|min10floatM|min16floatM, floatM|halfM|min10floatM|min16floatM) at line 52 (on d3d11)

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

      Did you solve the problem?

  • @hotadoga00789
    @hotadoga00789 5 ปีที่แล้ว

    Small question. Hopefully this gets through. I am getting an error when I enter playmode. "Syntax error: unexpected token 'half4' at line 51 (on d3d11)" Im not sure how to fix this. Can anyone help?

    • @limageur
      @limageur 5 ปีที่แล้ว

      At this line who is in the fixed4 frag normally you have mistakent a point or a ; with half4. I had the same problem, I checked and I resolved it.

  • @Donbros
    @Donbros 5 ปีที่แล้ว

    IT doesn't work :( it draws in only small piece of that all window

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

    did anyone else thingk he was writing 'pee' into the snow? lmao

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

      it's your dirty mind :p

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

      @@PeerPlay why it's not working on Terrain :(

  • @sat.chid.ananda
    @sat.chid.ananda 6 ปีที่แล้ว

    fuck me this is so good, keep em coming

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

      That's what he/she said.

    • @sat.chid.ananda
      @sat.chid.ananda 6 ปีที่แล้ว

      @@PeerPlay aaaaayyeeee