Search Unity

Official New URP 2D sample project: Happy Harvest - Download now

Discussion in '2D' started by eduardooriz, Jul 4, 2023.

  1. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    Hi everyone

    We’re very excited to announce our new 2D URP demo, Happy Harvest, that shows new techniques for creating 2D lights, shadows, animation, and VFX with the Universal Render Pipeline in Unity 2022 LTS.

    The project incorporates best practices any 2D creator can use, including not baking shadows into a sprite, keeping sprites flat, moving shadow and volume information to secondary textures, advanced Tilemap features, and much more.

    >> Download the Happy Harvest project <<



    Announcement Unity blog post

    Along with the demo, we created a series of in-depth articles to show you how to create the 2D visuals so you can add them to your own projects:
    1. 2D light and shadow techniques in the Universal Render Pipeline
    2. How to animate 2D characters in Unity 2022 LTS
    3. How to create art and gameplay with 2D tilemaps
    4. Coming soon: 2D special effects with the VFX Graph and Shader Graph

    Expand on the sample, reuse its elements and scripts in your own projects, and test it on your mobile and desktop devices. This sample and its supporting content is designed to provide useful tips for everyone, from beginners to experienced 2D developers.

    You can explore the techniques shown in Happy Harvest, plus many more, in the e-book 2D game art, animation, and lighting for artists. You’ll find all of Unity’s advanced e-books and articles in the Unity best practices hub.

    Happy harvesting! ‍
     

    Attached Files:

    Last edited: Jul 5, 2023
    DragonCoder and adamgolden like this.
  2. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    218
    very cool sample project, here is my experience with it:

    Unity version 2023.1.0b4
    1. 2d feature doesn't have a version 2.0, I needed to update it to 1.0
    2. ground normal maps are technically wrong/bad for the builtin 2d light system. upload_2023-7-6_4-15-39.png As you can see, the lights cant illuminate in the +y direction(+y distance depends on the distance value of the light). I rotate the normals 60 degrees on the X axis to get proper normals for the ground tiles. My ground tile normals and the results look something like this: upload_2023-7-6_4-17-3.png upload_2023-7-6_4-17-9.png
    3. Using a single colored mask or normal map is a waste of vram and performance; you dont need exactly matching size for normals/masks and main texture; a 1x1 texture for them is enough(Sprite_Tiles_Dirt_normal etc.)
    4. soft shadows are not enabled at all, literally 1 slider to make the shadows 10x better upload_2023-7-6_4-17-52.png upload_2023-7-6_4-18-2.png
    5. day night cycle + shadows system is amazing. I didn't even realize you could use 2d lights as 2d shadows!!!. Amazing.
    6. rain droplets are amazing
    7. transition scene could use a camera with a background image instead of just a black screen
    8. fps was really bad in editor(<15 without fullscreening, ~20 with fullscreen; 5ms editor loop for some reason), smooth 60 in game(~40% gpu utilization on gtx 1060 3gb; max 30% cpu utilization on ryzen 3600)
    9. overall code isnt perfect(really unoptimized update methods etc.) but it has some good utilities and systems(save system, stackable-single slot inventory system, scene transition system, 2d fade system, 2d day night system(amazing) etc.)
    10. there isnt any adjacent rule tile in the project but that looks like a cool rule tile, it will definetely help with painting path rule tiles etc. into ground rule tiles
    11. plant shader is very nice
     
    onetimepad likes this.
  3. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    218
    bug: sometimes, after leaving the house I had about 20% gpu usage even with the zoom animation going on. After going left towards street_lamp (3), the usage skyrocketed to 50%. Going back towards the house doesn't reduce the gpu usage to even 30%.
    After leaving the house:
    upload_2023-7-6_4-29-58.png

    After going left and coming back:
    upload_2023-7-6_4-29-38.png

    screenshots are taken at different in-game days
     
  4. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    Thanks @venediklee for sharing your experience, it's great that you share it with us.. let me comment each one of your points here:
    1. We currently support Unity 2022 LTS and the packages that come with it, we will work on preparing it for 2023.x close to the release of 2023 LTS
    2. I think I see what you mean, we can see a bit of that in the outdoor fire place area. Overall it worked well in this case but I'm discussing with the artist to change this for an update soon
    3. Admittedly we focused on the art creation process techniques more than performance optimisation, we are also gonna do the project a pass about that, this one can about the masks can be an easy change
    4. We don't because they are not available in Unity 2022 LTS, we will enable them when we update to 23 LTS
    5. Yeah, the 2D team calls the technique negative lighting, super powerful, it's one of the things we wanted to showcase in the demo
    6. Ah thanks, very simple effect to achieve, could be better, but does the job to showcase VFX
    7. Yep I think we got into time constrains, since we focused on other aspects, some like this transition or the UI work, was simple but functional
    8. We haven't experienced that, is it also the case in Unity 2022 LTS? I also ran the demo on a few older phones and the performance was ok.
    9. We gave the priority to the simplicity of the code vs highly optimal code, since the target is artists we didn't want to make code that wouldn't be straightforward to understand by a less experienced user. We might still optimize parts in the pass I was mentioning before. Glad you found the utilities useful, there's many things that can come handy from the project apart from assets
    10. Nice, we stuck to what comes in the Tilemap extras package, we discussed at some point making new scripts, but we kept it simple, we overall created rule tiles for those tiles that are meant to be used like a brush, which is mostly the ground tiles
    11. Thanks, the water shader or fire VFX I think will also be useful to other users we hope
     
    venediklee likes this.
  5. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    thanks, I'm sharing the thread with the team who is gonna do the project an additional QA pass
     
    venediklee likes this.
  6. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    177
    Really like the demo, would like to expand upon adding more mechanics like getting meat from hens & other animals. Also adding a quest system e.g. deliver some seeds or fruits to a person or market. I have one question would it work for mobiles devices? Main issue seems to me is mouse input which needed to be converted to touch.
     
  7. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    yes, it works. You can easily add support for mobile from the input map asset
     
  8. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    177
    m_CurrentWorldMousePos = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());
    how to convert this to touch, even i tried to make a virtual mouse pointer for interactions using virtual pointer script of inputs system but that did not work
     
  9. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    From the top of my head (I would recommend you to check on the forum for input) I think clicks work like touch points automatically
     
    khushalkhan likes this.
  10. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    177
    Just exported it to ios device, click are not working as touch. I used inputs system on screen controls demo. Walk etc works while interactions are not working
     
    GameLover90 likes this.
  11. CoraBlue

    CoraBlue

    Joined:
    Nov 16, 2017
    Posts:
    60
    This is a neat little demo and I think it's a great representation of where 2DLights and Unity is right now. Would still love Spritebased shadows in the future. It's nice to see Unity is making the Tilemap and data play together, I wonder if anything jumped out at them while doing this?

    But also you've got a game breaking bug! It causes crops to become unharvestable if you ever go back inside the house. This is because:

    1) CropInitializer is only called once because the crop data is then stored in GameManager, which is a persistent object.
    2) However, the VisualEffect for each crop is stored in the outdoor scene when a crop is planted.
    3) Therefore, when you leave the scene and reenter, GameManager will tell CropInitializer that a crop has already been planted there. The crop will not plant, so no VisualEffect is generated, causing an error on HarvestAt.
     
  12. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    Thanks a lot, adding this one for the next update that we will push. The CropInitializer was added last to have some already planted crops for demo purposes, we will fix those corner cases like that one
     
  13. liumario

    liumario

    Joined:
    Aug 2, 2023
    Posts:
    1
    I test the demo on my android device. It work well on Snapdragon 8 Gen 1. But freezed on Snapdragon 710, when enter the outdoor scene.

    When the demo freeze, in android logcat, it shows
    Adreno-GSL <gsl_ldd_control:549>: ioctl fd 77 code 0xc040094a (IOCTL_KGSL_GPU_COMMAND) failed: errno 71 Protocol error
    Adreno-GSL <log_gpu_snapshot:458>: panel.gpuSnapshotPath is not set.not generating user snapshot

    Is there any solution to make the demo work on most devices? we really want to make a 2D game use this 2D Light system.
     
  14. Rand_D

    Rand_D

    Joined:
    Oct 24, 2017
    Posts:
    44
    @eduardooriz is there any plan to push any new update for this demo yet. Why this demo doesnt have github as many other demos so that we can at least check out some of the experimental stuff?
     
    X2DGmDev likes this.
  15. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    yes, we have to do that, not a huge update though, a bit of polishing, a bit later we will update it with soft shadows and other small things. We only plan Asset Store as it already includes most of the things that we meant to include to talk about throughout our content, like this new article about VFX in Happy Harvest
     
  16. GameLover90

    GameLover90

    Joined:
    Jan 5, 2021
    Posts:
    5
    unfortunately it does not work on mobile. How to fix please? Is it possible to get precise instructions?
     
  17. eduardooriz

    eduardooriz

    Unity Technologies

    Joined:
    May 28, 2018
    Posts:
    97
    I got it running on iOS with no problem, what's the exact issue?, I would recommend looking for any tutorial that shows how to run on mobile devices because there's a few steps
     
  18. onetimepad

    onetimepad

    Joined:
    Dec 30, 2021
    Posts:
    7
    Great example. Many tricks and resources to learn from.
    I have question about NormalMap color. Neutral/flat color is considered to be #8080FF (0.5, 0.5, 1.0). In project, for tiles like dirt, grass, etc. is used color #7FE8C8 (127,232,200). My question is why not #8080FF?
     
  19. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    218
    That is the error I talked about here
    Take a look at this example(camera at 60,0,45 rotation) for 2 isometric cubes(they are moved a bit off-center so they aren't truly isometric)
    upload_2024-4-4_14-33-38.png
    If the normals were prepared like the left side(without -60 degree rotation to "normalize" the normal map) you get the colors around #7FE8C8(wrong)
    If you rotate the normals -60 degrees on the X axis, you get the actual correct values. You need to use the normals like right side cube because the camera in 2d unity is not rotated, hence when doing the normal calculations you need to treat the normals as if they were rotated -60 degrees

    If the game was actually 3d and the unity camera was rotated 60 degrees to give an isometric look, your normal maps would indeed look like the left side.
     
    onetimepad likes this.
  20. onetimepad

    onetimepad

    Joined:
    Dec 30, 2021
    Posts:
    7
    Thank you venediklee. Now I understand and I'm impressed. Good job.
     
    venediklee likes this.