All Projects → mob-sakai → BlurringAtlasForUGUI

mob-sakai / BlurringAtlasForUGUI

Licence: MIT license
A blur effect for uGUI in Unity, that is effective even for atlas images including dynamic fonts.

Programming Languages

C#
18002 projects
ShaderLab
938 projects
shell
77523 projects

Projects that are alternatives of or similar to BlurringAtlasForUGUI

Uieffect
UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
Stars: ✭ 3,449 (+11793.1%)
Mutual labels:  blur, ugui, effect
X Postprocessing Library
Unity Post Processing Stack Library | Unity引擎的高品质后处理库
Stars: ✭ 1,079 (+3620.69%)
Mutual labels:  blur, effect
UBind
UBind is a value binding component for Unity, which is used to quickly realize the association binding between UI and logical data.
Stars: ✭ 57 (+96.55%)
Mutual labels:  ugui, uguicomponent
DissolveEffectForTMPro
DissolveEffectForTMPro provide dissolve effect component for TextMeshPro in Unity.
Stars: ✭ 86 (+196.55%)
Mutual labels:  ugui, effect
MirrorReflectionEffectForUGUI
A simple mirror reflection effect for a uGUI without reflection probes or shaders.
Stars: ✭ 99 (+241.38%)
Mutual labels:  ugui, effect
DissolveEffectForUGUI
A dissolve effect for uGUI, without material instancing. Please star and watch this project :)
Stars: ✭ 67 (+131.03%)
Mutual labels:  ugui, effect
postcss-font-pack
PostCSS plugin to simplify font declarations by validating only configured font packs are used and adding fallbacks.
Stars: ✭ 18 (-37.93%)
Mutual labels:  font
eczar
Eczar: fonts for Devanagari and Latin
Stars: ✭ 52 (+79.31%)
Mutual labels:  font
catmoji-colr
Twemoji, but with cats! Unicode 13.1! 🐱
Stars: ✭ 41 (+41.38%)
Mutual labels:  font
EasyFont
Android Library to set font of TextView, Button, EditText, and RadioButton in XML without editing Java code to set Typeface.
Stars: ✭ 20 (-31.03%)
Mutual labels:  font
esp8266-oled-ssd1306-font-creator
Font creator for the esp8266-oled-ssd1306 library
Stars: ✭ 22 (-24.14%)
Mutual labels:  font
Xlua UGUI Demo
A MVC UGUI hot fix demo using Xlua.
Stars: ✭ 16 (-44.83%)
Mutual labels:  ugui
metrico
Font for metric equations in music notation.
Stars: ✭ 36 (+24.14%)
Mutual labels:  font
unity-ugui-edit-tools
编辑器下的界面工具集合
Stars: ✭ 30 (+3.45%)
Mutual labels:  ugui
chiron-sans-hk
昭源黑體:現代筆形風格,平衡標準字形和印刷體慣用筆形的免費開源黑體字型
Stars: ✭ 131 (+351.72%)
Mutual labels:  font
ttf2hershey
Convert True Type Fonts (.ttf) to Hershey vector fonts
Stars: ✭ 29 (+0%)
Mutual labels:  font
FP
Simple FontPreview Shell Script
Stars: ✭ 17 (-41.38%)
Mutual labels:  font
nuxt-speedkit
nuxt-speedkit will help you to improve the lighthouse performance score (100/100) of your website.
Stars: ✭ 401 (+1282.76%)
Mutual labels:  font
ReuseScroller
Reuse cell for uGUI ScrollView
Stars: ✭ 29 (+0%)
Mutual labels:  ugui
CompositeToggle
Composite toggle system for unity
Stars: ✭ 38 (+31.03%)
Mutual labels:  ugui

BlurringAtlasForUGUI

ダイナミックフォントを含むアトラス画像でも効果的な, UGUI用のブラーエフェクト.

A blur effect for uGUI that is effective even for atlas images including dynamic fonts.

NOTE: This project has been integrated into UIEffect, so we are NOT continuing development in this repository.

<< Description | WebGL Demo | Download | Usage | Development Note >>

What's new? Please see RELEASE NOTE





Description

このプラグインは, uGUI用のブラーエフェクトにおいて発生しうる一般的なアーティファクト(=副産物, ノイズ)を軽減します.
以下の2つのアーティファクトについて解決します.

NOTE: アーティファクトの名称は適当です.

This plug-in reduces common artifacts in the blur effect for uGUI.
This plug-in solve the following two artifacts.

NOTE: I do not know if the name of the artifact is an exact name;)



1. UV Conflict

ぼかし効果は, カーネルに基づきフラグメントシェーダで複数のテクセルを合成します.
カーネルサイズが大きい, またはアトラスのパディングサイズが小さいなどの理由から, 隣接スプライトのUVを参照した場合, アーティファクトが発生します.

The blur effect combines multiple texels based on the kernel size, in the fragment shader.
Artifacts will occur when referencing the UVs of adjacent sprites, for example because the kernel size is large or the padding size of the atlas is small.


#### Solution: UV Masking

頂点毎に参照しうるUVをマスクします.
UIの場合, スプライトや文字のUV範囲と一致します.
マスクされていないUVを参照した場合(=範囲外のUVを参照した場合), そのテクセルは(0,0,0,0)の色を返すものと見なします.

For each vertex, mask UVs that vertices can reference.
In the case of UI element, it will match the UV range of the sprite or the character.
When referring to unmasked UV, the texel returns color (0,0,0,0).

float4 mask;  // xy: minimum uv, zw: maximum uv.
float2 uv;
float4 color = tex2D(_MainTex, uv)
                * step(mask.x, uv.x)
                * step(mask.y, uv.y)
                * step(uv.x, mask.z)
                * step(uv.y, mask.w);



2. Mesh clipping

フラグメントシェーダで描画できるピクセルは, ラスタライズによって生成されます.
通常, UIシェーダは与えられたmeshより外側の領域を描画しません.
カーネルサイズが大きい, またはスプライトのマージンが小さいとき, 「meshでクリップされたように見えるアーティファクト」が発生します.

Pixels that can be rendered with fragment shaders are generated by rasterization.
In most cases, the UI shader does not draw areas outside the given mesh.
When the kernel size is large or the margin of the sprite is small, "artifacts that looks like clipped by mesh" will occur.


#### Solution: Edge Expanding

外周にある頂点をUVごと外側に膨張させ, 描画領域を拡大します.
この解決方法は, 頂点数を増やしません. また, 「9-Sliced」や「Tiled」に対しても有効です.

Expand the drawing area by expanding the coordinates and UV of the vertices on the outer side.
This solution does not increase the number of vertices. It is also available for "9-Slice" and "Tiled".



Features

  • Easy to use
  • Controls amount of the blurring from inspector or script
  • Supports RawImage, Image, Text element
  • Supports 'small padding' atlas such as dynamic fonts
  • Supports draw call batching





Demo

WebGL Demo





Usage

  1. Download BlurringAtlasForUGUI.unitypackage from Releases.
  2. Import the package into your Unity project. Select Import Package > Custom Package from the Assets menu.
  3. In Unity5.6+, enable TexCoord1 channel of canvas. See also Development Note.
  4. Add UIBlurringAtlas component to UI element (Image, RawImage, Text, etc...) from Add Component in inspector.
  5. Enjoy!
Requirement
  • Unity 5.5+ (including Unity 2018.x)
  • No other SDK are required





Development Note

Note: Unity 5.6+

In Unity 5.6+, Canvas supports Additional Shader Channels.
Please enable TexCoord1 to use this plugin.
image

How to pack UV range to vertex

See UIEffect.

このプラグインでは, UV範囲(uMin, vMin, uMax, vMax)の各要素に12bit(4096ステップ)を使用し, 頂点のuv1に割り当てます. (Unity 5.6+において, TexCoord1チャンネルを有効にすべき理由です.)

This plugin uses 12bit (4096 steps) for each element of the UV range (uMin, vMin, uMax, vMax) and assigns it to the vertex uv1. (In Unity 5.6+, it is the reason to activate TexCoord 1 channel.)

uiVertex.uv1 = new Vector2( Packer.ToFloat(uMin, vMin), Packer.ToFloat(uMax, vMax) );

Application idea

この手法を応用すると, uvずらしを使った表現(グローエフェクトやソフトシャドウなど)がuGUI要素単体に対しても利用できます.
後ほどグローエフェクトを公開予定です.

By applying this technique, effects using uv shift (such as glow effect or soft shadow) can be used for a single uGUI element.
I will release the glow effect later.

(WIP)

Future plans





License

Author

mob-sakai

See Also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].