From ae7ffad789030cf4c49a8b4d0760878a3ca143cc Mon Sep 17 00:00:00 2001
From: mob-sakai <12690315+mob-sakai@users.noreply.github.com>
Date: Sat, 20 Jun 2026 16:14:22 +0900
Subject: [PATCH] chore: update readme
---
Packages/src/README.md | 20 ++++++++++++++++++++
Packages/src/Shaders/UIEffect.shader | 9 ++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/Packages/src/README.md b/Packages/src/README.md
index 4c98472..f76cd73 100644
--- a/Packages/src/README.md
+++ b/Packages/src/README.md
@@ -60,6 +60,7 @@ Apply professional-grade filters like grayscale, blur, and dissolve directly fro
- [Usage with SoftMaskForUGUI](#usage-with-softmaskforugui)
- [Usage with ShaderGraph](#usage-with-shadergraph)
- [Usage with Timeline](#usage-with-timeline)
+ - [Usage with Custom Shader](#usage-with-custom-shader)
- [Runtime/Editor Preset for UIEffect](#runtimeeditor-preset-for-uieffect)
- [Usage with Code](#usage-with-code)
- [Project Settings](#project-settings)
@@ -545,6 +546,25 @@ Timeline is a powerful animation tool that can control UIEffect using `ControlTr
+### Usage with Custom Shader
+
+To make your custom shader support UIEffect, it must satisfy the following requirements.
+Refer to the sections enclosed by `==== UIEFFECT START ===` and `==== UIEFFECT END ====` in the built-in `Hidden/UI/Default (UIEffect)` shader included in the package.
+
+https://github.com/mob-sakai/UIEffect/blob/main/Packages/src/Shaders/UIEffect.shader
+
+- Blend: `Blend [_SrcBlend] [_DstBlend]`
+- Shader variants: `#pragma shader_feature_local_fragment ***`
+- Vertex shader input structure: `float4 uvMask : TEXCOORD***;`
+- Vertex shader: `OUT.uvMask = v.uvMask;` and `OUT.worldPosition = v.vertex;`
+- Pixel shader input structure: `float4 uvMask : TEXCOORD***;` and `float4 worldPosition : TEXCOORD***;`
+- UIEffect micro pixel shader: a function that returns the color of the specified pixel and has the signature `half4 uieffect_frag(v2f IN, float2 uv)`.
+- Pixel shader input structure name definition: `#define UIEFFECT_FRAG_STRUCT v2f`
+- Include the UIEffect library: `#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"`
+- Pixel shader: `half4 c = uieffect(IN.texcoord, IN.uvMask, IN.worldPosition, IN);`
+
+
+
### Runtime/Editor Preset for UIEffect

diff --git a/Packages/src/Shaders/UIEffect.shader b/Packages/src/Shaders/UIEffect.shader
index c5a1a49..4c0baf6 100644
--- a/Packages/src/Shaders/UIEffect.shader
+++ b/Packages/src/Shaders/UIEffect.shader
@@ -42,7 +42,9 @@ Shader "Hidden/UI/Default (UIEffect)"
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
+ // ==== UIEFFECT START ====
Blend [_SrcBlend] [_DstBlend]
+ // ==== UIEFFECT END ====
ColorMask [_ColorMask]
Pass
@@ -117,7 +119,6 @@ Shader "Hidden/UI/Default (UIEffect)"
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
float4 vPosition = UnityObjectToClipPos(v.vertex);
- OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
float2 pixelSize = vPosition.w;
@@ -141,20 +142,20 @@ Shader "Hidden/UI/Default (UIEffect)"
// ==== UIEFFECT START ====
OUT.uvMask = v.uvMask;
+ OUT.worldPosition = v.vertex;
// ==== UIEFFECT END ====
return OUT;
}
// ==== UIEFFECT START ====
- fixed4 uieffect_frag(v2f IN, float2 uv)
+ half4 uieffect_frag(v2f IN, float2 uv)
{
half4 color = (tex2D(_MainTex, uv) + _TextureSampleAdd);
color.rgb *= IN.color.rgb;
color.rgb *= color.a;
return color;
}
-
#define UIEFFECT_FRAG_STRUCT v2f
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
// ==== UIEFFECT END ====
@@ -168,7 +169,9 @@ Shader "Hidden/UI/Default (UIEffect)"
const half invAlphaPrecision = half(1.0 / alphaPrecision);
IN.color.a = round(IN.color.a * alphaPrecision) * invAlphaPrecision;
+ // ==== UIEFFECT START ====
half4 c = uieffect(IN.texcoord, IN.uvMask, IN.worldPosition, IN);
+ // ==== UIEFFECT END ====
c *= IN.color.a;
#ifdef UNITY_UI_CLIP_RECT