Composite Canvas Renderer

repository·main·Indexed 42 days ago

https://github.com/mob-sakai/compositecanvasrenderer

A Unity tool (version 2.1.1) that bakes multiple source graphics into a single RenderTexture bake-buffer. It enables advanced UI effects such as blur, soft outlines, and soft shadows while improving performance by reducing draw calls.

Tokens
928
Snippets
3
Records
5
Agent score
3%

What's inside Composite Canvas Renderer

  1. Quickstart: Using Composite Canvas Renderer

    main

    Follow these steps to set up a composite rendering area:

    1. Create a GameObject: Add the CompositeCanvasRenderer component to a new GameObject.
    2. Add UI Elements: Add child UI elements such as Image, RawImage, Text, or TextMeshProUGUI to this GameObject.
    3. Define Baking Area: The baking area is determined by the RectTransform.size and the Expands option. You can visualize this area in the Scene view as a magenta rectangle.
    4. Configure Effects: Adjust the CompositeCanvasRenderer settings in the Inspector and select an effect to fine-tune its parameters.
  2. Install Composite Canvas Renderer via UPM (Git URL)

    main

    You can install the package manually by adding it to your manifest.json file in the project's Packages folder. Add the following entry to the dependencies block:

    {
      "dependencies": {
        "com.coffee.composite-canvas-renderer": "https://github.com/mob-sakai/CompositeCanvasRenderer.git?path=Packages/src",
        ...
      }
    }

    To target a specific version, append #version to the URL. For example: "com.coffee.composite-canvas-renderer": "https://github.com/mob-sakai/CompositeCanvasRenderer.git?path=Packages/src#2.0.0"

  3. Configure Composite Canvas Renderer Project Settings

    main

    Global settings can be adjusted via Edit > Project Settings > UI > Composite Canvas Renderer.

    General Settings

    • Transform Sensitivity: Controls the sensitivity of transforms that trigger an automatic rebuild of the soft mask buffer.
    • Enable Culling In Play Mode: Toggles culling during runtime.
    • Enable Culling In Edit Mode: Toggles culling during editor time.

    Shader Management

    • Registered Variants: A list of shader variants available at runtime. You can remove unused variants using the - button to reduce build size and time.
    • Unregistered Variants: A list of variants not currently registered. Use the + button to add them.
    • Error On Unregistered Variant: If enabled, using an unregistered variant will trigger an error and automatically add it to the Unregistered Variants list.

    Note: The settings file is saved at Assets/ProjectSettings/CompositeCanvasRendererProjectSettings.asset. You should include this in your version control system.

  4. Hot-update Shader Variants via Addressables

    main

    If Pre Load Settings In Build is disabled in Project Settings, you must load the settings manually via Resources, AssetBundles, or Addressables. This allows you to hot-update shader variants and presets by re-enabling CompositeCanvasRendererProjectSettings.

    private static IEnumerator HotUpdateCoroutine()
    {
        const string k_SettingsAddress = "Assets/ProjectSettings/CompositeCanvasRendererProjectSettings.asset";
        yield return Addressables.LoadAssetAsync<CompositeCanvasRendererProjectSettings>(k_SettingsAddress);
        while (CompositeCanvasRendererProjectSettings.shaderVariantCollection.WarmUpProgressively(5) == false) yield return null;
    }