Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andersystems/unity-grass-interaction
This repository contains a custom solution for grass collision in Unity URP. Unlike traditional methods that create a single collision point, this approach uses an orthographic camera to render a top-down view and applies the rendered image as a collision mask on the grass.
https://github.com/andersystems/unity-grass-interaction
shader shadergraph unity unity-3d urp
Last synced: about 1 month ago
JSON representation
This repository contains a custom solution for grass collision in Unity URP. Unlike traditional methods that create a single collision point, this approach uses an orthographic camera to render a top-down view and applies the rendered image as a collision mask on the grass.
- Host: GitHub
- URL: https://github.com/andersystems/unity-grass-interaction
- Owner: AnderSystems
- License: mit
- Created: 2024-09-11T14:38:26.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T14:42:44.000Z (4 months ago)
- Last Synced: 2024-10-15T21:22:48.194Z (3 months ago)
- Topics: shader, shadergraph, unity, unity-3d, urp
- Language: C#
- Homepage:
- Size: 88.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Grass Collision Solution in Unity URP
Description
This repository contains a custom solution for grass collision in Unity URP. Unlike traditional methods that create a single collision point, this approach uses an orthographic camera to render a top-down view and applies the rendered image as a collision mask on the grass. The solution includes a custom shader that lowers the grass based on the alpha channel of the texture.
Features
-
Orthographic Camera: Captures a top-down view of the scene, synchronized with the main camera. -
Render Mask: Renders only the objects that interact with the grass. -
Custom Shader: Uses the alpha channel to lower the grass in the collision areas. -
Pixel Perfect Update: Ensures stable rendering by updating camera coordinates with integer values.
Limitations
-
Distance: The effectiveness depends on the rendering distance of the collision camera. -
Quality: Higher texture resolution improves collision precision but increases computational load. -
Object Height: The system only captures a top-down map, which may cause grass to move even if the object is not directly colliding with it.
How to Use
- Clone the repository.
- Open the project in Unity.
- Assign the orthographic camera and configure the render mask.
- Apply the custom shader to your grass material.
- Adjust the settings as needed to fit your scene.
Contributing
Feel free to fork this repository and submit pull requests. Any contributions to improve the solution are welcome!
License
This project is licensed under the MIT License.