MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

分析:lukakldiashvili/Unified-Universal-Blur

项目背景与痛点

统一全局模糊效果(Unified-Universal-Blur)是一个专门为 Unity 游戏引擎设计的库,用于在游戏或应用程序中实现高品质的模糊效果。在现代 UI 设计中,模糊效果可以增强用户体验,但实现起来却颇有挑战。传统的模糊算法耗时耗力,对性能要求很高。此外,多平台兼容性也成为开发者的一大痛点。这个项目提供的解决方案不仅高效,而且极大地简化了跨平台模糊效果的实现与维护。

核心技术揭秘

Unified-Universal-Blur 采用了基于 GPU 的渲染技术来实现模糊效果。其关键点在于通过着色器(Shader)程序对场景进行实时模糊处理,从而达到高效渲染的目的。这不仅减少了 CPU 的计算负担,还确保了低延迟和高帧率。

项目架构中,模糊效果的实现分为几个主要步骤,包括获取渲染纹理、在 GPU 上执行模糊操作以及最终输出模糊后的场景。下图展示了其核心的数据处理流程。

graph TD A[主摄像机渲染] --> B[获取渲染纹理] B --> C{"开始模糊?"} C -->|"是"| D[执行模糊Shader] C -->|"否"| E[直接输出] D --> F[输出模糊场景] F --> G[显示模糊结果]

这些步骤中,着色器的编写和优化是核心内容。项目利用 Unity 的可编程渲染管线(Scriptable Render Pipeline, SRP),灵活控制渲染过程,从而实现不同强度和类型的模糊效果。

功能亮点与差异

与同类插件相比,Unified-Universal-Blur 以其高度可定制性和性能优化能力为显著优势。通过可自定义的着色器参数,开发者可以根据不同场景的性能需求和视觉效果偏好调整模糊效果的参数,如模糊半径范围、强度和模糊类型的自由切换。

此外,项目支持多种平台,包括iOS、Android与PC,并采用 Unity 的Cross-Platform 特性进行优化,保证了跨平台的一致体验。这种平台无关性大大增强了项目的适用范围和灵活性。

应用场景与落地建议

适配 Unified-Universal-Blur 于生产环境,需要根据实际情况调整和优化模糊操作。例如,在性能受限的移动设备上,建议降低模糊效果的计算复杂度,减少对 GPU 的要求。项目文档里提供了详细的配置指南,可以帮助开发者快速掌握实施细节。

适用的业务场景主要包括但不限于:

  • 增强现实与虚拟现实应用,模糊效果可以用于提示用户与虚拟世界的交互距离。
  • UI 设计,创建富有层次且流畅的用户交互界面,提升用户体验。
  • 游戏开发,在复杂的场景渲染中使用模糊效果,增强视觉焦点和引导玩家注意力。

综合评价

Unified-Universal-Blur 作为一款 Unity 项目中模糊处理的利器,具有高度的可定制性与灵活度。它不仅仅是一种效果实现的工具,更是为复杂场景中增强视觉体验带来的技术突破。尽管它在性能优化上的表现非常出色,但也需要注意配置不当可能导致的性能瓶颈,特别是在处理大量渲染纹理时。

综上所述,Unified-Universal-Blur 是Unity开发者在追求高质量模糊效果时的一个强有力的选项,其高度优化的性能与强大的灵活性使其在众多依赖模糊效果的应用场景中成为理想的选择。

关于

GitHub 原始描述(英文)

UI blur (translucent) effect for Unity.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1180
价值分
620
活跃状态
活跃

语言占比

C#
HLSL
ShaderLab

Release

README

Unified Blur Showcase

Unified Blur

A modern screen blur for Unity, built on Render Graph with performance and compatibility in mind.

Latest release URP HDRP BIRP

Supported Tested with Unity 2022.3.62, 6000.0.72, 6000.3.11, 6000.4.2, 6000.6.0

Introduction

Unified Blur is a performant and flexible screen blur effect for Unity, built using the new Render Graph API.

It supports both modern Unity 6 projects and some of the older versions through a legacy compatibility path.

Designed to be easy to use, efficient, and highly customizable, Unified Blur is perfect for creating clean translucent effects for your games and applications.


Installation · Setup · Use Cases · How It Works · Troubleshooting · Limitations

Installation

  • Unity Package Manager - Copy git url and add it via package manager’s Add package from git URL... (for a specific version visit releases).
  • Open UPM - For more information, visit OpenUPM Page.
  • Manual - Download zip, extract and put its content anywhere in the project (preferably in Plugins folder).

Setup

  1. Add Unified Blur Render Feature
    Add Unified Blur Render Feature to the renderer data asset used by your project. Step by step:

    1. Open Project Settings → Graphics and locate the Scriptable Render Pipeline Settings field (this is your URP Asset). Alternatively, open Project Settings → Quality and read the URP Asset assigned to the currently active quality level.
    2. Select the URP Asset in the Project window and look at the Renderer List in its inspector. Each entry points to a renderer data asset (e.g. PC_Renderer, Mobile_Renderer).
    3. Select the renderer data asset you want to extend in the Project window.
    4. In the inspector, scroll down to the Renderer Features section and click Add Renderer Feature → Universal Blur Feature.

    A project can have multiple renderer assets (one per platform/quality level - PC, Mobile, WebGL, etc.). The feature must be added to the renderer asset used by the active quality preset, otherwise the blur will not appear at runtime. If you target multiple platforms, add the feature to each renderer asset that needs the effect (see Troubleshooting).

  2. Assign Blur Material to UI Image Component
    Assign UniversalBlurUI material to any UI Image component that you want to display the blurred screen on.

  3. Play with Settings
    Adjust settings in the Unified Blur Render Feature settings to get the desired blur effect.

Use Cases

Unified Blur works best with UI components that are part of the Screen Space - Overlay canvas. Other canvas types are supported as well, although with some limitations (see the limitations section).

  • Option 1: UI Image Component with Blur Material
    Display a blurred version of the screen on a UI Image component. This is useful for creating translucent UI effects.

  • Option 2: Custom Shader with Unified Blur
    Use the global texture generated by Unified Blur Render Feature in your custom shader to create unique effects.

How It Works

Unified Blur works by inserting a custom render pass into the render graph, at a configurable injection point, which copies the back buffer and applies a blur effect to it. Once the pass completes, the blurred result is exposed as a global texture for downstream shaders to sample.

Troubleshooting

Blur material shows but no blur effect

  • Confirm the Universal Blur Feature is added to the renderer data asset used by the active quality level. Open Project Settings → Quality, check which URP Asset is assigned to the active level, then verify the renderer asset it references is the one carrying the feature. A common pitfall is adding the feature to a desktop renderer while the active quality level points at a mobile renderer (or vice versa).
  • Verify post-processing is enabled on the main camera: select the camera, then in the inspector under Rendering make sure Post Processing is checked. Without it, the blur pass output may not reach the screen as expected.
  • If the camera renders to a custom render target, make sure the target format is compatible with the blur pass. A mismatched format (e.g. no alpha, unexpected color space) can produce a transparent or blank result.

WebGL build shows no blur

WebGL builds typically fall back to the Mobile renderer data, not the desktop renderer. If you only added Universal Blur Feature to the PC renderer, the WebGL build will run without it.

  • Open the URP Asset assigned to the WebGL/Mobile quality level, locate its renderer data asset, and add Universal Blur Feature to that asset as well.
  • After adding it, rebuild the WebGL player so the updated renderer asset is included.

Can I configure the blur per-platform?

Yes. Each Quality Level can reference a different URP Asset, and each URP Asset can reference a different renderer data asset. By adding Universal Blur Feature to multiple renderer assets, you can tune blur settings (intensity, downsample, iterations) independently per platform or quality preset.

Limitations

  • Limited support for world space or screen space camera canvases.
    To enable this, change the injection point in the Render Feature’s settings panel to BeforeRenderingTransparents. Note: transparent objects and other canvases will not be visible in this scenario.

评论

暂无评论