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.
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.
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:
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.)
soft shadows are not enabled at all, literally 1 slider to make the shadows 10x better
day night cycle + shadows system is amazing. I didn’t even realize you could use 2d lights as 2d shadows!!!. Amazing.
rain droplets are amazing
transition scene could use a camera with a background image instead of just a black screen
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)
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.)
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
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:
Thanks @venediklee for sharing your experience, it’s great that you share it with us… let me comment each one of your points here:
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
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
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
We don’t because they are not available in Unity 2022 LTS, we will enable them when we update to 23 LTS
Yeah, the 2D team calls the technique negative lighting, super powerful, it’s one of the things we wanted to showcase in the demo
Ah thanks, very simple effect to achieve, could be better, but does the job to showcase VFX
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
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.
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
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
Thanks, the water shader or fire VFX I think will also be useful to other users we hope
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.
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
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
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:
CropInitializer is only called once because the crop data is then stored in GameManager, which is a persistent object.
However, the VisualEffect for each crop is stored in the outdoor scene when a crop is planted.
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.
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
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.
@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?
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
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
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?
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)
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.