Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit f4eaad4

Browse files
committed
refine fastShadow (to best match non-fastShadow effects)
1 parent d898bc6 commit f4eaad4

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ Shader "UIWidgets/ShadowBox"
33
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
44
Properties
55
{
6-
_SrcBlend("_SrcBlend", Int) = 1 // One
7-
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
86
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
97
}
108
SubShader
119
{
1210
ZTest Always
1311
ZWrite Off
14-
Blend [_SrcBlend] [_DstBlend]
12+
Blend SrcAlpha OneMinusSrcAlpha
1513

1614
Stencil {
1715
Ref 128

Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ Shader "UIWidgets/ShadowRBox"
33
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
44
Properties
55
{
6-
_SrcBlend("_SrcBlend", Int) = 1 // One
7-
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
86
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
97
}
108
SubShader
119
{
1210
ZTest Always
1311
ZWrite Off
14-
Blend [_SrcBlend] [_DstBlend]
12+
Blend SrcAlpha OneMinusSrcAlpha
1513

1614
Stencil {
1715
Ref 128

Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ Shader "UIWidgets/ShadowBox_cb"
33
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
44
Properties
55
{
6-
_SrcBlend("_SrcBlend", Int) = 1 // One
7-
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
86
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
97
}
108
SubShader
119
{
1210
ZTest Always
1311
ZWrite Off
14-
Blend [_SrcBlend] [_DstBlend]
12+
Blend SrcAlpha OneMinusSrcAlpha
1513

1614
Stencil {
1715
Ref 128

Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ Shader "UIWidgets/ShadowRBox_cb"
33
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
44
Properties
55
{
6-
_SrcBlend("_SrcBlend", Int) = 1 // One
7-
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
86
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
97
}
108
SubShader
119
{
1210
ZTest Always
1311
ZWrite Off
14-
Blend [_SrcBlend] [_DstBlend]
12+
Blend SrcAlpha OneMinusSrcAlpha
1513

1614
Stencil {
1715
Ref 128

Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shadow_utils.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void _drawRRectShadow(uiPath path, uiPaint paint) {
4646
}
4747

4848
var bound = path.getBounds();
49-
var sigma = state.scale * paint.maskFilter.Value.sigma;
49+
var sigma = state.scale * paint.maskFilter.Value.sigma / 3f;
5050

5151
var vertices = ObjectPool<uiList<Vector3>>.alloc();
5252
vertices.SetCapacity(4);
@@ -67,7 +67,8 @@ void _drawRRectShadow(uiPath path, uiPaint paint) {
6767
ObjectPool<uiMeshMesh>.release(meshBounds);
6868
ObjectPool<uiMeshMesh>.release(blurMesh);
6969
var mesh = uiMeshMesh.create(state.matrix, vertices, _triangles);
70-
layer.draws.Add(CanvasShader.fastShadow(layer, mesh, sigma, path.isRect, path.isCircle, path.rRectCorner, new Vector4(bound.left, bound.top, bound.right, bound.bottom), paint.color));
70+
var shadowColor = paint.color.withAlpha(128);
71+
layer.draws.Add(CanvasShader.fastShadow(layer, mesh, sigma, path.isRect, path.isCircle, path.rRectCorner, new Vector4(bound.left, bound.top, bound.right, bound.bottom), shadowColor));
7172
}
7273

7374
}

0 commit comments

Comments
 (0)