Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Recreating t3ssel8r's 3D pixel art

Discussion in 'Visual Effect Graph' started by Zucchinipi, Sep 11, 2023.

  1. Zucchinipi

    Zucchinipi

    Joined:
    Jan 12, 2017
    Posts:
    9
    I recently stumbled across t3ssel8r's 3D pixel art, and I'm obsessed!



    I would love to try to recreate effect used on the grass and trees in Unity. I found that they shared a high level overview (https://imgur.com/gallery/qwhbHQq), but I'm getting tripped up on a couple things.

    I know the particles need to be on the GPU, so I started with the built-in VFX graph system with URP. It was easy enough to get flipbook sprites spawning on a mesh using the experimental sample mesh nodes, but from there I hit a couple blocks:
    1. Each grass sprite is colored with the same toon coloring as the terrain it sits on. How can I achieve this?
    2. The sample mesh nodes weigh each triangle evenly, regardless of area. Is there a way to bias it so that particles spawn more uniformly?
    3. Less important, but how do you think the sprites don't occlude with the geometry of the mesh on which they're spawned? Are they just offset by the normal at the point they're on? Is that also achievable?
    Curious if this is something I can pull off without writing a custom shader.

    Thanks!
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Morning sir, while I won't have the time to help you achieve the level of polish showed in t3ssel8r's 3D pixel art, I'll try to help you with your questions.

    1. So, usually, to spawn particles on a Mesh with VFX Graph, you can use either a Set position (Mesh) block or a Sample Mesh Operator. In your case, I would suggest using the Sample Mesh operator. This allows you to get more information out of the sampled Mesh like the Uvs, Vertex Colors, Normals etc...
      So the question is how Terrain's colored are being stored ? Is it thanks to textures, are the colors baked in Vertex colors ? Based on this, the sample Mesh operator allows you to get the UV's of the terrain to samples the same color texture, or to get the Vertex Colors or other information needed.

      An alternative to this node is to use a Point Cache.

    2. To answer this question, I will invite you to take a look at this recent thread where I've been covering this notion of Uniform distribution when sampling a Mesh.

      Also thinking about grass and particle distribution, I would propose that you take a look at this talk by graphic programmer Eric Wohllaib. While it's technical and maybe isn't totally relevant to what you are trying to achieve, you should find some nice information about grass, distribution, clumping or how to make the grass distribution visually interesting and natural/organic.

    3. Regarding this, If I understand, you're afraid that some grass might be long enough so that we can see them penetrating the Mesh ? I guess it can be an issue with Object that are very low, close to the terrain.
      If so, one solution would be to create a “Spawn Map”. A texture, or data (can be bake in one of the channel of vertex color) that will hold the “object” traces from a top-down view. This would allow you to prevent spawning particles under those Objects. This would also mean less particles spawn and better performances overall. houdini_36pBhMcp34.gif
      A simple example prototype with a “Spawn Map” bake in a DCC to prevent grass to spawn in the Dark Area (Areas covered/intersect by objects)

      But, this might not be needed and depend on the height of your grass and your objects. Here's I've made a very fast prototype with VFX Graph, but the issue isn't that obvious.
      Unity_vqupk8AGeO_0000-0037_1000x558.gif

      Hope this post help, and don't hesitate to post your results or new questions. Always happy to see what people are doing with VFX Graph. Have a great day.
     
    Last edited: Sep 12, 2023
  3. Zucchinipi

    Zucchinipi

    Joined:
    Jan 12, 2017
    Posts:
    9
    Wow, thank you for the response! Was not expecting such a thorough answer :) I'm excited to put your recommendations into action.
     
    OrsonFavrel likes this.
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Nice result! Did you use single quad facing the camera or crossed quads facing up?
     
  5. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Thanks. In this case,as I was assuming an Orthographic Camera with rotation only around the Up-Axis, I've just used single quads with the Orient Block set to Fixed Axis. This way, particles aligns with the World-Up axis while their front face is still following the Camera.
     
    Qriva likes this.