浏览代码

Merge pull request #272 from UnityTech/computebuffer

Computebuffer
/main
GitHub 5 年前
当前提交
0a3b5ff0
共有 80 个文件被更改,包括 1213 次插入159 次删除
  1. 1
      Runtime/editor/surface.cs
  2. 31
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
  3. 81
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs
  4. 4
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_utils.cs
  5. 5
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shadow_utils.cs
  6. 3
      Runtime/ui/renderer/cmdbufferCanvas/rendering/render_cmd.cs
  7. 4
      Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader
  8. 4
      Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader
  9. 8
      Runtime/Resources/shaders.meta
  10. 98
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs
  11. 11
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs.meta
  12. 9
      Runtime/Resources/shaders/UIWidgets_GUITexture.shader.meta
  13. 9
      Runtime/Resources/shaders/UIWidgets_UIDefault.shader.meta
  14. 9
      Runtime/Resources/shaders/UIWidgets_canvas.cginc.meta
  15. 9
      Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader.meta
  16. 9
      Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader.meta
  17. 9
      Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader.meta
  18. 9
      Runtime/Resources/shaders/UIWidgets_canvas_filter.shader.meta
  19. 9
      Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader.meta
  20. 9
      Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader.meta
  21. 9
      Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader.meta
  22. 9
      Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader.meta
  23. 9
      Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader.meta
  24. 9
      Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader.meta
  25. 9
      Runtime/Resources/shaders/UIWidgets_canvas_tex.shader.meta
  26. 8
      Runtime/Resources/shaders/computebuffer.meta
  27. 27
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc
  28. 76
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader
  29. 33
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader
  30. 76
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader
  31. 20
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader
  32. 62
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader
  33. 75
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader
  34. 29
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader
  35. 75
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader
  36. 74
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader
  37. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc.meta
  38. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader.meta
  39. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader.meta
  40. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader.meta
  41. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader.meta
  42. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader.meta
  43. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader.meta
  44. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader.meta
  45. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader.meta
  46. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader.meta
  47. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader.meta
  48. 9
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader.meta
  49. 90
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader
  50. 123
      Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader
  51. 3
      Runtime/Resources/UIWidgets_GUITexture.shader.meta
  52. 9
      Runtime/Resources/UIWidgets_UIDefault.shader.meta
  53. 9
      Runtime/Resources/UIWidgets_canvas.cginc.meta
  54. 9
      Runtime/Resources/UIWidgets_canvas_fill0.shader.meta
  55. 9
      Runtime/Resources/UIWidgets_canvas_fill1.shader.meta
  56. 9
      Runtime/Resources/UIWidgets_canvas_filter.shader.meta
  57. 9
      Runtime/Resources/UIWidgets_canvas_stencil.shader.meta
  58. 9
      Runtime/Resources/UIWidgets_canvas_stroke0.shader.meta
  59. 9
      Runtime/Resources/UIWidgets_canvas_stroke1.shader.meta
  60. 9
      Runtime/Resources/UIWidgets_canvas_tex.shader.meta
  61. 9
      Runtime/Resources/UIWidgets_canvas_convexFill.shader.meta
  62. 9
      Runtime/Resources/UIWidgets_canvas_strokeAlpha.shader.meta
  63. 9
      Runtime/Resources/UIWidgets_canvas_shadowBox.shader.meta
  64. 9
      Runtime/Resources/UIWidgets_canvas_shadowRBox.shader.meta
  65. 0
      /Runtime/Resources/shaders/UIWidgets_GUITexture.shader
  66. 0
      /Runtime/Resources/shaders/UIWidgets_UIDefault.shader
  67. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader
  68. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_filter.shader
  69. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader
  70. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader
  71. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader
  72. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader
  73. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader
  74. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_tex.shader
  75. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader
  76. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader
  77. 0
      /Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader
  78. 0
      /Runtime/Resources/shaders/UIWidgets_canvas.cginc

1
Runtime/editor/surface.cs


if (this._canvas != null) {
this._canvas.reset();
this._canvas.dispose();
this._canvas = null;
}
}

31
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs


this._lastScissor = null;
this._layers.Clear();
}
_instanceNum--;
_releaseComputeBuffer();
}
public PictureFlusher(RenderTexture renderTexture, float devicePixelRatio, MeshPool meshPool) {

this.___drawTextDrawMeshCallback = this._drawTextDrawMeshCallback;
this.___drawPathDrawMeshCallback2 = this._drawPathDrawMeshCallback2;
this.___drawPathDrawMeshCallback = this._drawPathDrawMeshCallback;
_instanceNum++;
}
readonly _drawPathDrawMeshCallbackDelegate ___drawTextDrawMeshCallback;

public void flush(uiPicture picture) {
this._reset();
this._resetRenderTextureId();
this._resetComputeBuffer();
this._drawUIPicture(picture, false);

// this is necessary for webgl2. not sure why... just to be safe to disable the scissor.
cmdBuf.DisableScissorRect();
this._bindComputeBuffer();
Graphics.ExecuteCommandBuffer(cmdBuf);
}

if (mesh == null) {
continue;
}
D.assert(mesh.vertices.Count > 0);
cmd.meshObj.SetVertices(mesh.vertices?.data);
cmd.meshObj.SetTriangles(mesh.triangles?.data, 0, false);
cmd.meshObj.SetUVs(0, mesh.uv?.data);
if (mesh.matrix == null) {
cmd.properties.SetFloatArray(CmdDraw.matId, CmdDraw.idMat3.fMat);
}

cmd.properties.SetFloatArray(CmdDraw.matId, this._drawLayer_matArray);
}
cmdBuf.DrawMesh(cmd.meshObj, CmdDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties.mpb);
D.assert(mesh.vertices.Count > 0);
if (CanvasShader.supportComputeBuffer) {
this._addMeshToComputeBuffer(mesh.vertices?.data, mesh.uv?.data, mesh.triangles?.data);
cmd.properties.SetBuffer(CmdDraw.vertexBufferId, _computeBuffer);
cmd.properties.SetBuffer(CmdDraw.indexBufferId, _indexBuffer);
cmd.properties.SetInt(CmdDraw.startIndexId, _startIndex);
cmdBuf.DrawProcedural(Matrix4x4.identity, cmd.material, cmd.pass, MeshTopology.Triangles, mesh.triangles.Count, 1, cmd.properties.mpb);
}
else {
cmd.meshObj.SetVertices(mesh.vertices?.data);
cmd.meshObj.SetTriangles(mesh.triangles?.data, 0, false);
cmd.meshObj.SetUVs(0, mesh.uv?.data);
cmdBuf.DrawMesh(cmd.meshObj, CmdDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties.mpb);
}
if (cmd.layerId != null) {
cmdBuf.SetGlobalTexture(CmdDraw.texId, BuiltinRenderTextureType.None);
}

81
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs


return shader;
}
public static bool enableComputeBuffer = true;
public static readonly bool supportComputeBuffer;
var convexFillShader = GetShader("UIWidgets/canvas_convexFill");
var fill0Shader = GetShader("UIWidgets/canvas_fill0");
var fill1Shader = GetShader("UIWidgets/canvas_fill1");
var stroke0Shader = GetShader("UIWidgets/canvas_stroke0");
var stroke1Shader = GetShader("UIWidgets/canvas_stroke1");
var texShader = GetShader("UIWidgets/canvas_tex");
var stencilShader = GetShader("UIWidgets/canvas_stencil");
var filterShader = GetShader("UIWidgets/canvas_filter");
var shadowBoxShader = GetShader("UIWidgets/ShadowBox");
var shadowRBoxShader = GetShader("UIWidgets/ShadowRBox");
var strokeAlphaShader = GetShader("UIWidgets/canvas_strokeAlpha");
var convexFillShaderCompute = GetShader("UIWidgets/canvas_convexFill_cb");
supportComputeBuffer = enableComputeBuffer && SystemInfo.supportsComputeShaders && convexFillShaderCompute.isSupported;
//if compute buffer is not supported, load normal shader
if (!supportComputeBuffer) {
var convexFillShader = GetShader("UIWidgets/canvas_convexFill");
var fill0Shader = GetShader("UIWidgets/canvas_fill0");
var fill1Shader = GetShader("UIWidgets/canvas_fill1");
var stroke0Shader = GetShader("UIWidgets/canvas_stroke0");
var stroke1Shader = GetShader("UIWidgets/canvas_stroke1");
var texShader = GetShader("UIWidgets/canvas_tex");
var stencilShader = GetShader("UIWidgets/canvas_stencil");
var filterShader = GetShader("UIWidgets/canvas_filter");
var shadowBoxShader = GetShader("UIWidgets/ShadowBox");
var shadowRBoxShader = GetShader("UIWidgets/ShadowRBox");
var strokeAlphaShader = GetShader("UIWidgets/canvas_strokeAlpha");
_convexFillMat = new MaterialByBlendModeStencilComp(convexFillShader);
_fill0Mat = new MaterialByStencilComp(fill0Shader);
_fill1Mat = new MaterialByBlendMode(fill1Shader);
_stroke0Mat = new MaterialByBlendModeStencilComp(stroke0Shader);
_stroke1Mat = new Material(stroke1Shader) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat = new MaterialByBlendModeStencilComp(strokeAlphaShader);
_texMat = new MaterialByBlendModeStencilComp(texShader);
_stencilMat = new Material(stencilShader) {hideFlags = HideFlags.HideAndDontSave};
_filterMat = new Material(filterShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox = new Material(shadowBoxShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox = new Material(shadowRBoxShader) {hideFlags = HideFlags.HideAndDontSave};
}
else {
var fill0ShaderCompute = GetShader("UIWidgets/canvas_fill0_cb");
var fill1ShaderCompute = GetShader("UIWidgets/canvas_fill1_cb");
var stroke0ShaderCompute = GetShader("UIWidgets/canvas_stroke0_cb");
var stroke1ShaderCompute = GetShader("UIWidgets/canvas_stroke1_cb");
var texShaderCompute = GetShader("UIWidgets/canvas_tex_cb");
var stencilShaderCompute = GetShader("UIWidgets/canvas_stencil_cb");
var filterShaderCompute = GetShader("UIWidgets/canvas_filter_cb");
var shadowBoxShaderCompute = GetShader("UIWidgets/ShadowBox_cb");
var shadowRBoxShaderCompute = GetShader("UIWidgets/ShadowRBox_cb");
var strokeAlphaShaderCompute = GetShader("UIWidgets/canvas_strokeAlpha_cb");
_convexFillMat = new MaterialByBlendModeStencilComp(convexFillShader);
_fill0Mat = new MaterialByStencilComp(fill0Shader);
_fill1Mat = new MaterialByBlendMode(fill1Shader);
_stroke0Mat = new MaterialByBlendModeStencilComp(stroke0Shader);
_stroke1Mat = new Material(stroke1Shader) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat = new MaterialByBlendModeStencilComp(strokeAlphaShader);
_texMat = new MaterialByBlendModeStencilComp(texShader);
_stencilMat = new Material(stencilShader) {hideFlags = HideFlags.HideAndDontSave};
_filterMat = new Material(filterShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox = new Material(shadowBoxShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox = new Material(shadowRBoxShader) {hideFlags = HideFlags.HideAndDontSave};
_convexFillMat = new MaterialByBlendModeStencilComp(convexFillShaderCompute);
_fill0Mat = new MaterialByStencilComp(fill0ShaderCompute);
_fill1Mat = new MaterialByBlendMode(fill1ShaderCompute);
_stroke0Mat = new MaterialByBlendModeStencilComp(stroke0ShaderCompute);
_stroke1Mat = new Material(stroke1ShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat = new MaterialByBlendModeStencilComp(strokeAlphaShaderCompute);
_texMat = new MaterialByBlendModeStencilComp(texShaderCompute);
_stencilMat = new Material(stencilShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_filterMat= new Material(filterShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox = new Material(shadowBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox = new Material(shadowRBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
}
public static Material shadowBox => _shadowBox;
static readonly int _viewportId = Shader.PropertyToID("_viewport");
static readonly int _alphaId = Shader.PropertyToID("_alpha");

public static PictureFlusher.CmdDraw convexFill(PictureFlusher.RenderLayer layer, uiPaint paint,
uiMeshMesh mesh) {
var mat = _convexFillMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props);
return PictureFlusher.CmdDraw.create(

4
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_utils.cs


public void SetFloatArray(int mid, float[] array) {
this.mpb.SetFloatArray(mid, array);
}
public void SetBuffer(int mid, ComputeBuffer buffer) {
this.mpb.SetBuffer(mid, buffer);
}
}
}

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));
}
}

3
Runtime/ui/renderer/cmdbufferCanvas/rendering/render_cmd.cs


public static readonly Matrix3 idMat3 = Matrix3.I();
public static readonly int texId = Shader.PropertyToID("_tex");
public static readonly int matId = Shader.PropertyToID("_mat");
public static readonly int vertexBufferId = Shader.PropertyToID("databuffer");
public static readonly int indexBufferId = Shader.PropertyToID("indexbuffer");
public static readonly int startIndexId = Shader.PropertyToID("_startVertex");
public override void clear() {

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

8
Runtime/Resources/shaders.meta


fileFormatVersion: 2
guid: db2eb33ed6fce4c999c8481059ee7e6c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

98
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs


using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public partial class PictureFlusher {
struct uiVertex
{
public Vector2 position;
public Vector2 uv;
}
static ComputeBuffer _computeBuffer;
static List<uiVertex> _vertices;
static ComputeBuffer _indexBuffer;
static List<int> _indices;
static int _startVertex;
static int _startIndex;
static int _instanceNum;
public const int COMPUTE_BUFFER_MAX_ITEM_NUM = 1024 * 1024; // maxsize = 1M vertex/index
static void _releaseComputeBuffer() {
if (!CanvasShader.supportComputeBuffer) {
return;
}
if (_computeBuffer == null) {
return;
}
if (_instanceNum != 0) {
return;
}
_computeBuffer.Dispose();
_indexBuffer.Dispose();
_vertices = null;
_indices = null;
_computeBuffer = null;
_indexBuffer = null;
}
void _initComputeBuffer() {
var stride = Marshal.SizeOf(typeof(uiVertex));
var strideIndex = Marshal.SizeOf(typeof(int));
_computeBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, stride);
_vertices = new List<uiVertex>();
_indexBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, strideIndex);
_indices = new List<int>();
}
void _resetComputeBuffer() {
if (!CanvasShader.supportComputeBuffer) return;
if (_computeBuffer == null) {
this._initComputeBuffer();
}
_vertices.Clear();
_indices.Clear();
_startVertex = 0;
_startIndex = 0;
}
void _bindComputeBuffer() {
if (!CanvasShader.supportComputeBuffer) return;
_computeBuffer.SetData(_vertices);
_indexBuffer.SetData(_indices);
}
void _addMeshToComputeBuffer(List<Vector3> vertex, List<Vector2> uv, List<int> triangles) {
if (!CanvasShader.supportComputeBuffer) return;
_startVertex = _vertices.Count;
_startIndex = _indices.Count;
var hasUv = uv != null;
for (int i = 0; i < vertex.Count; i++) {
_vertices.Add(new uiVertex {
position = new Vector2(vertex[i].x, vertex[i].y),
uv = hasUv ? uv[i] : Vector2.zero
});
}
foreach (var triangleId in triangles) {
_indices.Add(triangleId + _startVertex);
}
}
}
}

11
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs.meta


fileFormatVersion: 2
guid: 88f2ad2c8ab504c5d95b1f70539f8d86
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_GUITexture.shader.meta


fileFormatVersion: 2
guid: f592638352fff481487dec316e583967
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_UIDefault.shader.meta


fileFormatVersion: 2
guid: 3434943ef6cfa4c80b424b818d1ccd46
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas.cginc.meta


fileFormatVersion: 2
guid: 12533dde17d054c58aa5aef1f8df7067
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader.meta


fileFormatVersion: 2
guid: 4ad4bfab828614fd090399d0cd793b1a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader.meta


fileFormatVersion: 2
guid: 104c51408606c4531bd029a900ff26b3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader.meta


fileFormatVersion: 2
guid: cccc75413df09406bad8aab430428aec
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_filter.shader.meta


fileFormatVersion: 2
guid: 080129d418c1c442985d3aba354d88ca
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader.meta


fileFormatVersion: 2
guid: e3e75e0dcee5243e2b95bc639eea758e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader.meta


fileFormatVersion: 2
guid: cc9374790071e4da883a3319cda6cb20
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader.meta


fileFormatVersion: 2
guid: 57f3d43bd5ba648cda816d05ceb3b643
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader.meta


fileFormatVersion: 2
guid: 3072a3ddd64a34c8cb3aa713b9705d72
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader.meta


fileFormatVersion: 2
guid: c5ba00af1b3a24619b8572f17b98917a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader.meta


fileFormatVersion: 2
guid: 72c25fdac75cf4041bf9ef313a342a28
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/UIWidgets_canvas_tex.shader.meta


fileFormatVersion: 2
guid: 9b0b3e1e797834f3abaefee47bce19df
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

8
Runtime/Resources/shaders/computebuffer.meta


fileFormatVersion: 2
guid: ad6fc8c9236144ca78ce73afd7a87833
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

27
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc


struct vdata
{
float2 vertex;
float2 uv;
};
StructuredBuffer<vdata> databuffer;
StructuredBuffer<int> indexbuffer;
int _startVertex;
v2f vert_compute (uint vertex_id: SV_VertexID)
{
v2f o = (v2f)0;
vdata v = databuffer[indexbuffer[_startVertex + vertex_id]];
o.ftcoord = v.uv;
o.fpos = v.vertex;
float3x3 mat = float3x3(_mat[0], _mat[1], _mat[2], _mat[3], _mat[4], _mat[5], 0, 0, 1);
float2 p = mul(mat, float3(v.vertex.xy, 1.0)).xy - _viewport.xy;
#if UNITY_UV_STARTS_AT_TOP
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 2.0 * p.y / _viewport.w - 1.0, 0, 1);
#else
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 1.0 - 2.0 * p.y / _viewport.w, 0, 1);
#endif
return o;
}

76
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader


Shader "UIWidgets/canvas_convexFill_cb"
{
Properties
{
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 3 // - Equal, 8 - Always
}
SubShader
{
ZTest Always
ZWrite Off
Blend [_SrcBlend] [_DstBlend]
Stencil {
Ref 128
Comp [_StencilComp]
}
Pass { // 0, color
CGPROGRAM
#pragma require compute
#define UIWIDGETS_COLOR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 1, linear
CGPROGRAM
#pragma require compute
#define UIWIDGETS_LINEAR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 2, radial
CGPROGRAM
#pragma require compute
#define UIWIDGETS_RADIAL
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 3, sweep
CGPROGRAM
#pragma require compute
#define UIWIDGETS_SWEEP
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 4, image
CGPROGRAM
#pragma require compute
#define UIWIDGETS_IMAGE
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
}
}

33
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader


Shader "UIWidgets/canvas_fill0_cb"
{
Properties {
_StencilComp("_StencilComp", Float) = 3 // - Equal, 8 - Always
}
SubShader {
ZTest Always
ZWrite Off
Cull Off
ColorMask 0
Stencil {
Ref 128
CompFront [_StencilComp]
CompBack [_StencilComp]
ReadMask 128
WriteMask 127
PassFront IncrWrap
PassBack DecrWrap
}
Pass {
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stencil
ENDCG
}
}
}

76
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader


Shader "UIWidgets/canvas_fill1_cb"
{
Properties {
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
}
SubShader {
ZTest Always
ZWrite Off
Blend [_SrcBlend] [_DstBlend]
Stencil {
Ref 0
Comp NotEqual
ReadMask 127
WriteMask 127
Pass Zero
}
Pass { // 0, color
CGPROGRAM
#pragma require compute
#define UIWIDGETS_COLOR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 1, linear
CGPROGRAM
#pragma require compute
#define UIWIDGETS_LINEAR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 2, radial
CGPROGRAM
#pragma require compute
#define UIWIDGETS_RADIAL
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 3, sweep
CGPROGRAM
#pragma require compute
#define UIWIDGETS_SWEEP
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 4, image
CGPROGRAM
#pragma require compute
#define UIWIDGETS_IMAGE
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
}
}

20
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader


Shader "UIWidgets/canvas_filter_cb"
{
Properties {
}
SubShader {
ZTest Always
ZWrite Off
Pass { // 0, mask filter
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_mf
ENDCG
}
}
}

62
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader


Shader "UIWidgets/canvas_stencil_cb"
{
Properties {
}
SubShader {
ZTest Always
ZWrite Off
Pass { // 0, stencil clear
ColorMask 0
Stencil {
Ref 128
Pass Replace
}
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stencil
ENDCG
}
Pass { // 1, stencil intersect 0
Cull Off
ColorMask 0
Stencil {
WriteMask 127
PassFront IncrWrap
PassBack DecrWrap
}
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stencil
ENDCG
}
Pass { // 2, stencil intersect 1
ColorMask 0
Stencil {
Ref 128
Comp Less
Pass Replace
Fail Zero
}
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stencil
ENDCG
}
}
}

75
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader


Shader "UIWidgets/canvas_stroke0_cb"
{
Properties {
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 3 // - Equal, 8 - Always
}
SubShader {
ZTest Always
ZWrite Off
Blend [_SrcBlend] [_DstBlend]
Stencil {
Ref 128
Comp [_StencilComp]
Pass IncrSat
}
Pass { // 0, color
CGPROGRAM
#pragma require compute
#define UIWIDGETS_COLOR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 1, linear
CGPROGRAM
#pragma require compute
#define UIWIDGETS_LINEAR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 2, radial
CGPROGRAM
#pragma require compute
#define UIWIDGETS_RADIAL
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 3, sweep
CGPROGRAM
#pragma require compute
#define UIWIDGETS_SWEEP
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
Pass { // 4, image
CGPROGRAM
#pragma require compute
#define UIWIDGETS_IMAGE
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag
ENDCG
}
}
}

29
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader


Shader "UIWidgets/canvas_stroke1_cb"
{
Properties {
}
SubShader {
ZTest Always
ZWrite Off
ColorMask 0
Stencil {
Ref 0
Comp NotEqual
ReadMask 127
WriteMask 127
Pass Zero
}
Pass {
CGPROGRAM
#pragma require compute
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stencil
ENDCG
}
}
}

75
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader


Shader "UIWidgets/canvas_strokeAlpha_cb"
{
Properties {
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 3 // - Equal, 8 - Always
}
SubShader {
ZTest Always
ZWrite Off
Blend [_SrcBlend] [_DstBlend]
Stencil {
Ref 128
Comp [_StencilComp]
Pass IncrSat
}
Pass { // 0, color
CGPROGRAM
#pragma require compute
#define UIWIDGETS_COLOR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stroke_alpha
ENDCG
}
Pass { // 1, linear
CGPROGRAM
#pragma require compute
#define UIWIDGETS_LINEAR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stroke_alpha
ENDCG
}
Pass { // 2, radial
CGPROGRAM
#pragma require compute
#define UIWIDGETS_RADIAL
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stroke_alpha
ENDCG
}
Pass { // 3, sweep
CGPROGRAM
#pragma require compute
#define UIWIDGETS_SWEEP
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stroke_alpha
ENDCG
}
Pass { // 4, image
CGPROGRAM
#pragma require compute
#define UIWIDGETS_IMAGE
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_stroke_alpha
ENDCG
}
}
}

74
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader


Shader "UIWidgets/canvas_tex_cb"
{
Properties {
_SrcBlend("_SrcBlend", Int) = 1 // One
_DstBlend("_DstBlend", Int) = 10 // OneMinusSrcAlpha
_StencilComp("_StencilComp", Float) = 3 // - Equal, 8 - Always
}
SubShader {
ZTest Always
ZWrite Off
Blend [_SrcBlend] [_DstBlend]
Stencil {
Ref 128
Comp [_StencilComp]
}
Pass { // 0, color
CGPROGRAM
#pragma require compute
#define UIWIDGETS_COLOR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_tex
ENDCG
}
Pass { // 1, linear
CGPROGRAM
#pragma require compute
#define UIWIDGETS_LINEAR
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_tex
ENDCG
}
Pass { // 2, radial
CGPROGRAM
#pragma require compute
#define UIWIDGETS_RADIAL
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_tex
ENDCG
}
Pass { // 3, sweep
CGPROGRAM
#pragma require compute
#define UIWIDGETS_SWEEP
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_tex
ENDCG
}
Pass { // 4, image
CGPROGRAM
#pragma require compute
#define UIWIDGETS_IMAGE
#include "../UIWidgets_canvas.cginc"
#include "UIWidgets_canvas_cb.cginc"
#pragma vertex vert_compute
#pragma fragment frag_tex
ENDCG
}
}
}

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc.meta


fileFormatVersion: 2
guid: 703259d9f57a14f58a79e9bb2de8195f
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader.meta


fileFormatVersion: 2
guid: 1b5261459dc1b4070bf275274cb5dcdc
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader.meta


fileFormatVersion: 2
guid: 8d1dce436d5e143c0a2f90e25210070a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader.meta


fileFormatVersion: 2
guid: 609f86cb483334c4396d574a338c7921
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader.meta


fileFormatVersion: 2
guid: 2c7a9c90ab5af4b02875f760080b1c51
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader.meta


fileFormatVersion: 2
guid: 6c8a50e3adb8349e0a98bd0de080c7e5
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader.meta


fileFormatVersion: 2
guid: 813531ada8c4e40c597b19027ac7fc87
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader.meta


fileFormatVersion: 2
guid: 5bde36357cad4438faa8e580cd85f2cd
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader.meta


fileFormatVersion: 2
guid: b6b3fce2866044f15aa7571d9d983a93
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader.meta


fileFormatVersion: 2
guid: e87b6538afcca45d5af06b744d26e3bb
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader.meta


fileFormatVersion: 2
guid: 444296b3078c944388a1f81cf1821808
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader.meta


fileFormatVersion: 2
guid: 4037f8954a4124abf93d3ff663baa78d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

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


Shader "UIWidgets/ShadowBox_cb"
{
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader
{
ZTest Always
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128
Comp [_StencilComp]
}
Pass {
CGPROGRAM
#pragma require compute
float4 _sb_box;
float4 _viewport;
float _sb_sigma;
float4 _sb_color;
float _mat[9];
struct vdata
{
float2 vertex;
float2 uv;
};
StructuredBuffer<vdata> databuffer;
StructuredBuffer<int> indexbuffer;
int _startVertex;
struct v2f
{
float4 vertex : SV_POSITION;
float2 coord : TEXCOORD0;
};
float4 erf(float4 x)
{
float4 s = sign(x);
float4 a = abs(x);
x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;
x = x * x;
return s - s / (x * x);
return s;
}
float boxShadow(float2 lower, float2 upper, float2 pnt, float sigma)
{
float4 query = float4(pnt - lower, pnt - upper);
float4 integral = 0.5 + 0.5 * erf(query * (sqrt(0.5) / sigma));
return (integral.z - integral.x) * (integral.w - integral.y);
}
v2f vert(uint vertex_id: SV_VertexID){
v2f o;
vdata v = databuffer[indexbuffer[_startVertex + vertex_id]];
float padding = 3.0 * _sb_sigma;
o.coord = lerp(_sb_box.xy - padding, _sb_box.zw + padding, v.vertex.xy);
float3x3 mat = float3x3(_mat[0], _mat[1], _mat[2], _mat[3], _mat[4], _mat[5], 0, 0, 1);
float2 p = mul(mat, float3(o.coord.xy, 1.0)).xy - _viewport.xy;
#if UNITY_UV_STARTS_AT_TOP
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 2.0 * p.y / _viewport.w - 1.0, 0, 1);
#else
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 1.0 - 2.0 * p.y / _viewport.w, 0, 1);
#endif
return o;
}
float4 frag(v2f i) : SV_TARGET {
float4 fragColor = _sb_color;
fragColor.a = fragColor.a * boxShadow(_sb_box.xy, _sb_box.zw, i.coord, _sb_sigma);
return fragColor;
}
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}

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


Shader "UIWidgets/ShadowRBox_cb"
{
//originally from http://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
Properties
{
_StencilComp("_StencilComp", Float) = 8 // - Equal, 8 - Always
}
SubShader
{
ZTest Always
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 128
Comp [_StencilComp]
}
Pass {
CGPROGRAM
#pragma require compute
float4 _sb_box;
float4 _viewport;
float _sb_sigma;
float4 _sb_color;
float _sb_corner;
float _mat[9];
struct vdata
{
float2 vertex;
float2 uv;
};
StructuredBuffer<vdata> databuffer;
StructuredBuffer<int> indexbuffer;
int _startVertex;
struct v2f
{
float4 vertex : SV_POSITION;
float2 coord : TEXCOORD0;
};
float gaussian(float x, float sigma)
{
float pi = 3.141592653589793;
return exp(-(x*x) / (2.0 * sigma * sigma)) / (sqrt(2.0 * pi) * sigma);
}
float2 erf(float2 x)
{
float2 s = sign(x);
float2 a = abs(x);
x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;
x = x * x;
return s - s / (x * x);
return s;
}
float roundedBoxShadowX(float x, float y, float sigma, float corner, float2 halfSize)
{
float delta = min(halfSize.y - corner - abs(y), 0.0);
float curved = halfSize.x - corner + sqrt(max(0.0, corner * corner - delta * delta));
float2 integral = 0.5 + 0.5 * erf((x + float2(-curved, curved)) * (sqrt(0.5)/sigma));
return integral.y - integral.x;
}
float roundedBoxShadow(float2 lower, float2 upper, float2 pnt, float sigma, float corner)
{
float2 center = (lower + upper) * 0.5;
float2 halfSize = (upper - lower) * 0.5;
pnt -= center;
float low = pnt.y - halfSize.y;
float high = pnt.y + halfSize.y;
float start = clamp(-3.0 * sigma, low, high);
float end = clamp(3.0 * sigma, low, high);
float step = (end - start) / 4.0;
float y = start + step * 0.5;
float value = 0.0;
for(int i=0; i<4;i++)
{
value += roundedBoxShadowX(pnt.x, pnt.y - y, sigma, corner, halfSize) * gaussian(y, sigma) * step;
y += step;
}
return value;
}
v2f vert(uint vertex_id: SV_VertexID){
v2f o;
vdata v = databuffer[indexbuffer[_startVertex + vertex_id]];
float padding = 3.0 * _sb_sigma;
o.coord = lerp(_sb_box.xy - padding, _sb_box.zw + padding, v.vertex.xy);
float3x3 mat = float3x3(_mat[0], _mat[1], _mat[2], _mat[3], _mat[4], _mat[5], 0, 0, 1);
float2 p = mul(mat, float3(o.coord.xy, 1.0)).xy - _viewport.xy;
#if UNITY_UV_STARTS_AT_TOP
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 2.0 * p.y / _viewport.w - 1.0, 0, 1);
#else
o.vertex = float4(2.0 * p.x / _viewport.z - 1.0, 1.0 - 2.0 * p.y / _viewport.w, 0, 1);
#endif
return o;
}
float4 frag(v2f i) : SV_TARGET {
float4 fragColor = _sb_color;
fragColor.a = fragColor.a * roundedBoxShadow(_sb_box.xy, _sb_box.zw, i.coord, _sb_sigma, _sb_corner);
return fragColor;
}
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}

3
Runtime/Resources/UIWidgets_GUITexture.shader.meta


fileFormatVersion: 2
guid: ea02b3553b38477c85b9ca45949cc85c
timeCreated: 1544158153

9
Runtime/Resources/UIWidgets_UIDefault.shader.meta


fileFormatVersion: 2
guid: 43b4ae1d316ca415589f96e49cc0fcab
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas.cginc.meta


fileFormatVersion: 2
guid: 6565922d18a5e4ee29fa183d2600eccc
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_fill0.shader.meta


fileFormatVersion: 2
guid: e75e9debfc1ad4e1687365932de72aa0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_fill1.shader.meta


fileFormatVersion: 2
guid: 7dbfb4eecc7a84ddc90c53891aa77e0b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_filter.shader.meta


fileFormatVersion: 2
guid: 756de2a3eb91745ba853728245a033d9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_stencil.shader.meta


fileFormatVersion: 2
guid: b4673a8cf87214fdb8643b32e0ec3316
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_stroke0.shader.meta


fileFormatVersion: 2
guid: 7e33032771e1e46a6b5eda923148503f
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_stroke1.shader.meta


fileFormatVersion: 2
guid: ee8a29ca6a09f4510bbf6e3b70922edc
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_tex.shader.meta


fileFormatVersion: 2
guid: 1702a648d08de40d9aacd9bbab1188b3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_convexFill.shader.meta


fileFormatVersion: 2
guid: da4e74e0b377e41699f5c3ed2c7c69e4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_strokeAlpha.shader.meta


fileFormatVersion: 2
guid: c57ed8e638931f946a7b5e26a54725d8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_shadowBox.shader.meta


fileFormatVersion: 2
guid: 105f52491741049d88708e718c749e34
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Runtime/Resources/UIWidgets_canvas_shadowRBox.shader.meta


fileFormatVersion: 2
guid: 77c8565b9b449434490473ef8f7f0e91
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

/Runtime/Resources/UIWidgets_GUITexture.shader → /Runtime/Resources/shaders/UIWidgets_GUITexture.shader

/Runtime/Resources/UIWidgets_UIDefault.shader → /Runtime/Resources/shaders/UIWidgets_UIDefault.shader

/Runtime/Resources/UIWidgets_canvas_fill1.shader → /Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader

/Runtime/Resources/UIWidgets_canvas_filter.shader → /Runtime/Resources/shaders/UIWidgets_canvas_filter.shader

/Runtime/Resources/UIWidgets_canvas_stencil.shader → /Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader

/Runtime/Resources/UIWidgets_canvas_stroke1.shader → /Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader

/Runtime/Resources/UIWidgets_canvas_convexFill.shader → /Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader

/Runtime/Resources/UIWidgets_canvas_fill0.shader → /Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader

/Runtime/Resources/UIWidgets_canvas_stroke0.shader → /Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader

/Runtime/Resources/UIWidgets_canvas_tex.shader → /Runtime/Resources/shaders/UIWidgets_canvas_tex.shader

/Runtime/Resources/UIWidgets_canvas_strokeAlpha.shader → /Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader

/Runtime/Resources/UIWidgets_canvas_shadowBox.shader → /Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader

/Runtime/Resources/UIWidgets_canvas_shadowRBox.shader → /Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader

/Runtime/Resources/UIWidgets_canvas.cginc → /Runtime/Resources/shaders/UIWidgets_canvas.cginc

正在加载...
取消
保存