<< ๐ Documentation | ๐ฎ Demo | โ Installation | ๐ Usage | ๐ค Contributing >>
CompositeCanvasRenderer bakes multiple source graphics into a bake-buffer (RenderTexture) and renders it.
It also supports additional material modification, mesh modification, and baking effects, allowing you to enjoy effects that were challenging to implement with standard UI shaders, such as blur, soft outline, and soft shadow.
Key Features:
- Bakes multiple source graphics into a
RenderTexture
as bake-buffer. - Utilizes the materials set on the source graphics during the baking process.
- The bake-buffer is automatically baked as needed, or you can trigger manual baking with
SetDirty()
. - Apply custom effects to the bake-buffer using a
CommandBuffer
after baking (as post-bake effect). - You can use custom materials for rendering the bake-buffer.
Let's enjoy a wide range of effects that were previously challenging to achieve with standard UI shaders!
![](https://private-user-images.githubusercontent.com/12690315/288389100-28a3cab1-d939-4161-8ef5-d24c760c5d49.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NjI4NTksIm5iZiI6MTcyMzY2MjU1OSwicGF0aCI6Ii8xMjY5MDMxNS8yODgzODkxMDAtMjhhM2NhYjEtZDkzOS00MTYxLThlZjUtZDI0Yzc2MGM1ZDQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDE5MDkxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIzNmNjZmNiM2ZhODJjOGRjMTA0MGY2MjlhMDk5MmNkZDFjYmRhYTA0YWIzMDY5NmYxYzQwM2E3YzMyZjUyYzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Zg94r_rAD862Nb2FBxYoyJwuAflHOEYGcyQV090Cx-Y)
-
Efficiency: By combining multiple graphics into a bake-buffer, it reduces the number of draw calls and can significantly improve rendering performance.
-
Automated Baking: The bake-buffer is automatically generated as needed, simplifying the rendering process and reducing manual intervention.
-
Control: Users have the flexibility to manually trigger the baking process using SetDirty(), giving them control over when and how the graphics are baked.
-
Material Usage: It ensures that the materials set on the graphics are used during the baking process, maintaining visual consistency.
-
Post-Bake Effects: After baking, you can apply various effects to the bake buffer using a command buffer, allowing for additional visual enhancements or post-processing.
-
Built-in Effects: Several effects are available out of the box!
-
Custom Material Support: You can use custom materials for rendering the bake-buffer.
-
Foreground/Background Rendering: Supports both foreground and background rendering.
-
Color and Blend Mode: Allows you to change color modes and blend modes.
-
Quality and Performance Control: You can fine-tune quality and performance using the
Down Sampling Rate
parameter.
-
Perspective/Orthographic Rendering: Supports both perspective and orthographic rendering. In orthographic rendering (where relative
position.z
and relativerotation.xy
are 0), baking is less frequent.
-
TextMeshPro Compatibility: Works seamlessly with TextMeshPro.
<font>
and<sprite>
tags are supported, and it may also be compatible with other custom UI classes.
-
Editor Support: Enjoy a convenient editing experience with the ability to preview the bake buffer in the inspector and visualize the baking region in the scene view. You can also customize the behavior from the project settings.
Check out the detailed documentation to learn more about the project and its features.
This package requires Unity 2019.4 or later.
This package is available on OpenUPM package registry. This is the preferred method of installation, as you can easily receive updates as they're released.
If you have openupm-cli installed, then run the following command in your project's directory:
openupm add com.coffee.composite-canvas-renderer
Navigate to your project's Packages folder and open the manifest.json
file. Then add this package somewhere in the dependencies
block:
{
"dependencies": {
"com.coffee.composite-canvas-renderer": "https://github.com/mob-sakai/CompositeCanvasRenderer.git?path=Packages/src",
...
},
}
To update the package, change suffix #{version}
to the target version.
- e.g.
"com.coffee.composite-canvas-renderer": "https://github.com/mob-sakai/CompositeCanvasRenderer.git?path=Packages/src#1.0.0",
-
Create a GameObject with the
CompositeCanvasRenderer
component. -
Add UI elements such as Image, RawImage, Text, TextMeshProUGUI, etc., to the GameObject.
![](https://private-user-images.githubusercontent.com/12690315/278513991-571dd4ed-2ab7-49fd-be88-d176728fdcb8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NjI4NTksIm5iZiI6MTcyMzY2MjU1OSwicGF0aCI6Ii8xMjY5MDMxNS8yNzg1MTM5OTEtNTcxZGQ0ZWQtMmFiNy00OWZkLWJlODgtZDE3NjcyOGZkY2I4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDE5MDkxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY5ODg5ODUzNTAyMDNkYjFmYWQ0NGEzYmU2NjE2NDg5OTM2NjBmYzQ5NjVjNWQ3Nzg4NDAwZjc5OTYxYmQwMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.5wJi7ht151YeoP9ZhoGmyvXkU5t3F3zOe7rlGAZnqvs)
- The baking area is determined by the
RectTransform.size
and theExpands
option. In the scene view, the baking area is displayed as a magenta rectangle.
![](https://private-user-images.githubusercontent.com/12690315/278513989-c614e39d-f3f4-4178-a870-6198a71fbf01.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NjI4NTksIm5iZiI6MTcyMzY2MjU1OSwicGF0aCI6Ii8xMjY5MDMxNS8yNzg1MTM5ODktYzYxNGUzOWQtZjNmNC00MTc4LWE4NzAtNjE5OGE3MWZiZjAxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDE5MDkxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY0NDZlMjFmZDI5YzBiYTM3NDgxYjMxODBkODEyNjEyNTczYWFjYTU3MDE5MTgxOTA5OTNiODA4NDg4NDE2MGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iRYfh2QT6j8FfqpClf8wNMdc-GTWdFY3Gftp407oA1o)
- Adjust the
CompositeCanvasRenderer
settings in the inspector.
![](https://private-user-images.githubusercontent.com/12690315/278513986-8369b4e2-4463-4469-af1c-e7ac81959d03.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NjI4NTksIm5iZiI6MTcyMzY2MjU1OSwicGF0aCI6Ii8xMjY5MDMxNS8yNzg1MTM5ODYtODM2OWI0ZTItNDQ2My00NDY5LWFmMWMtZTdhYzgxOTU5ZDAzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDE5MDkxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg3YzRlYTI1MmY2ZjQwYjA1ZjQzOWQxNzkzMDhiZDk4ZDY5MDBjODlhMzQ4OGJjMzMwYzUzYzUyYjIyODNiOTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lxmTjVldOULAo5gzMjd27TWi6RlatWZS_oA_bA5rL-Y)
- Select an effect in the inspector and fine-tune its settings.
![](https://private-user-images.githubusercontent.com/12690315/278513980-569d59ac-8bf5-421f-baaa-8487967f15a1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NjI4NTksIm5iZiI6MTcyMzY2MjU1OSwicGF0aCI6Ii8xMjY5MDMxNS8yNzg1MTM5ODAtNTY5ZDU5YWMtOGJmNS00MjFmLWJhYWEtODQ4Nzk2N2YxNWExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDE5MDkxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE5Y2VmNjQ2YzhlMWViNDhkMGYxM2M2NTE0ZWM5YmU3OGFkZmFmN2QzNmY0NTM5MTIxY2ZmYjNiNzI0MTNiYmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GfmvmoaeNTN2P3OWOozDIFqdA68empvPX58bWUWdV3Q)
- Enjoy!
Issues are incredibly valuable to this project:
- Ideas provide a valuable source of contributions that others can make.
- Problems help identify areas where this project needs improvement.
- Questions indicate where contributors can enhance the user experience.
Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md
and develop branch for guidelines.
This is an open-source project developed during my spare time.
If you appreciate it, consider supporting me.
Your support allows me to dedicate more time to development. ๐
- MIT
- GitHub page : https://github.com/mob-sakai/CompositeCanvasRenderer
- Releases : https://github.com/mob-sakai/CompositeCanvasRenderer/releases
- Issue tracker : https://github.com/mob-sakai/CompositeCanvasRenderer/issues
- Change log : https://github.com/mob-sakai/CompositeCanvasRenderer/blob/main/CHANGELOG.md