Creating a Foliage Shader in Unity URP! Grass, Trees, Flowers, Hedges and More | Game Dev Tutorial




🚀 Download Core to create games for FREE at https://bit.ly/Core-NedMakesGames

✔️ Tutorial tested in Unity URP 2020.3 & 2021.1

Plants, foliage and vegetation are really challenging to get right! It requires a custom made shader to tackle issues like translucency and wind. In this tutorial, I show how to create a foliage shader in the Unity URP (Universal Render Pipeline) Shader Graph. It supports all light types, shadows, and baked lighting, and includes several strategies for translucency, like separate normals for diffuse lighting and subsurface scattering. I also implement programmable wind animation and show a simple method to reconstruct normals. For grass billboards and tree leaf cards, I also demonstrate how to create double sided materials with normal map support.

📚 If you prefer reading, check out the written version of this tutorial here:
► https://nedmakesgames.medium.com/creating-a-foliage-shader-in-unity-urp-shader-graph-5854bf8dc4c2

✏️ Text-only shader version coming soon!

🌟Previous videos:
► Custom lighting in the shader graph: https://youtu.be/GQyCPaThQnA
► Intro to culling and double sided rendering: https://youtu.be/3WWKHt92XKQ
► Creating a grass mesh with a compute shader: https://youtu.be/6SFTcDNqwaA

🌞 Interactive lighting math explorer:
► https://nedmakesgames.itch.io/lighting-explorer

👋 Subscribe for weekly game development videos!
► https://www.youtube.com/c/nedmakesgames?sub_confirmation=1

👑 Join my Patreon to watch videos early, download all project files, vote on future topics, and more! Thank you so much!
► https://patreon.com/nedmakesgames

🔗 Visit my website for a searchable list of tutorials!
► https://nedmakesgames.github.io

2️⃣ 2nd Channel ► https://www.youtube.com/nedmakesgames2
🔴 Twitch ► https://www.twitch.tv/nedmakesgames
🐦 Twitter ► https://twitter.com/nedmakesgames
🎮 Discord ► https://discordapp.com/invite/ubxSVBK
📸 Instagram ► https://instagram.com/nedmakesgames
👽 Reddit ► https://reddit.com/u/nedmakesgames
🎶 TikTok ► https://www.tiktok.com/@nedmakesgames
☕ Ko-fi ► https://ko-fi.com/nedmakesgames

💻 Script reference:
► https://gist.github.com/NedMakesGames/5a8b9fc186d62d277f79ab2172457801

⏲️ Timestamps:
0:00 Intro
0:26 Core ad
1:58 Tutorial info
3:35 Project set up
6:41 Two sided rendering
9:27 Shape normals
15:54 Translucent lighting
21:12 Data maps
25:23 Wind
34:14 Normal reconstruction
40:25 Examples
41:23 Wrap up and credits

🎖️ Credits, references and further reading:
• Lee Rosevere: Music for Podcasts – https://leerosevere.bandcamp.com/
• Cyanilux: URP_ShaderGraphCustomLighting – https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
• XfrogPlants: Curry Leaf Tree Free 3D model – https://www.cgtrader.com/free-3d-models/plant/other/xfrogplants-curry-leaf-tree
• Ada_King: LowPoly Trees & Carrot & Crystal 3D model – https://www.turbosquid.com/3d-models/blender-carrot-crystal-oak-tree-3d-model-1189852
• Lennart Demes: Grass 001 – https://ambientcg.com/view?id=Grass001
• Baptiste Manteau: Bark old ginko – https://substance3d.adobe.com/community-assets/assets/e6c4bae683772a06aabb38dc1a13b3203060acd1
• Render Knight: Fantasy Skybox FREE – https://assetstore.unity.com/packages/2d/textures-materials/sky/fantasy-skybox-free-18353
• Alan Zucconi: Fast Subsurface Scattering in Unity – https://www.alanzucconi.com/2017/08/30/fast-subsurface-scattering-1/
• GetDeadEntertainment: CliffRockTwo 3D model – https://www.turbosquid.com/3d-models/rock-cliff-3d-model-1623414
• TotallyRonja: Vertex Displacement – https://www.ronja-tutorials.com/post/015-wobble-displacement/
• CatLikeCoding: Rendering 6 (normal mapping) – https://catlikecoding.com/unity/tutorials/rendering/part-6/
• Ben Golus: Normal Mapping for a Triplanar Shader – https://bgolus.medium.com/normal-mapping-for-a-triplanar-shader-10bf39dca05a#0576
• Ben Golus: Generating Perfect Normal Maps for Unity (and Other Programs) – https://bgolus.medium.com/generating-perfect-normal-maps-for-unity-f929e673fc57#c508
• Travel Photographer: garden hedges (photo of Atlanta Botanical Garden) – https://stocksnap.io/photo/garden-hedges-ZKKBLIVMNW

Neon Laser Horizon by Kevin MacLeod
Link: https://incompetech.filmmusic.io/song/7015-neon-laser-horizon
License: https://filmmusic.io/standard-license

#GameDev #IndieDev #Unity

Youtube original link

Leave a Reply

Your email address will not be published. Required fields are marked *