浏览代码

refine fastShadow (to best match non-fastShadow effects)

/main
xingwei.zhu 5 年前
当前提交
a08f2daf
共有 5 个文件被更改,包括 7 次插入14 次删除
  1. 4
      Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader
  2. 4
      Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader
  3. 4
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader
  4. 4
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader
  5. 5
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shadow_utils.cs

4
Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader


//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader

Blend [_SrcBlend] [_DstBlend]
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128

4
Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader


//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader

Blend [_SrcBlend] [_DstBlend]
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128

4
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader


//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader

Blend [_SrcBlend] [_DstBlend]
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128

4
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader


//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader

Blend [_SrcBlend] [_DstBlend]
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128

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


}
var bound = path.getBounds();
var sigma = state.scale * paint.maskFilter.Value.sigma;
var sigma = state.scale * paint.maskFilter.Value.sigma / 3f;
var vertices = ObjectPool<uiList<Vector3>>.alloc();
vertices.SetCapacity(4);

ObjectPool<uiMeshMesh>.release(meshBounds);
ObjectPool<uiMeshMesh>.release(blurMesh);
var mesh = uiMeshMesh.create(state.matrix, vertices, _triangles);
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));
var shadowColor = paint.color.withAlpha(128);
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));
}
}
正在加载...
取消
保存