GitHub
5 年前
当前提交
6ae2ed99
共有 86 个文件被更改,包括 1399 次插入 和 198 次删除
-
9Runtime/Plugins/platform/ios/DeviceScreen.mm
-
1Runtime/editor/surface.cs
-
2Runtime/engine/DisplayMetrics.cs
-
67Runtime/engine/UIWidgetsPanel.cs
-
4Runtime/ui/painting/image.cs
-
53Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
-
55Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs
-
4Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_utils.cs
-
5Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shadow_utils.cs
-
3Runtime/ui/renderer/cmdbufferCanvas/rendering/render_cmd.cs
-
4Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader
-
4Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader
-
8Runtime/Resources/shaders.meta
-
98Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs
-
11Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs.meta
-
136Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_initializer.cs
-
11Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_initializer.cs.meta
-
9Runtime/Resources/shaders/UIWidgets_GUITexture.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_UIDefault.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas.cginc.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_filter.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader.meta
-
9Runtime/Resources/shaders/UIWidgets_canvas_tex.shader.meta
-
8Runtime/Resources/shaders/computebuffer.meta
-
27Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc
-
76Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader
-
33Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader
-
76Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader
-
20Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader
-
62Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader
-
75Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader
-
29Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader
-
75Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader
-
74Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_cb.cginc.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_convexFill_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill0_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_fill1_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_filter_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stencil_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke0_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_stroke1_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_strokeAlpha_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_tex_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader.meta
-
9Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader.meta
-
90Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowBox_cb.shader
-
123Runtime/Resources/shaders/computebuffer/UIWidgets_canvas_shadowRBox_cb.shader
-
3Runtime/Resources/UIWidgets_GUITexture.shader.meta
-
9Runtime/Resources/UIWidgets_UIDefault.shader.meta
-
9Runtime/Resources/UIWidgets_canvas.cginc.meta
-
9Runtime/Resources/UIWidgets_canvas_fill0.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_fill1.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_filter.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_stencil.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_stroke0.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_stroke1.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_tex.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_convexFill.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_shadowBox.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_shadowRBox.shader.meta
-
9Runtime/Resources/UIWidgets_canvas_strokeAlpha.shader.meta
-
0/Runtime/Resources/shaders/UIWidgets_GUITexture.shader
-
0/Runtime/Resources/shaders/UIWidgets_UIDefault.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_fill1.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_filter.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_stencil.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_stroke1.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_convexFill.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_fill0.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_stroke0.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_tex.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas.cginc
-
0/Runtime/Resources/shaders/UIWidgets_canvas_shadowBox.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_shadowRBox.shader
-
0/Runtime/Resources/shaders/UIWidgets_canvas_strokeAlpha.shader
|
|||
#import <UIKit/UIKit.h> |
|||
#import "UIWidgetsDevice.h" |
|||
int IOSDeviceScaleFactor() |
|||
float IOSDeviceScaleFactor() |
|||
return [[UIScreen mainScreen] scale]; |
|||
float scale = [[UIScreen mainScreen] scale] * 1.0; |
|||
if ([UIWidgetsDevice NeedScreenDownSample]) { |
|||
scale *= 0.8696; |
|||
} |
|||
return scale; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: db2eb33ed6fce4c999c8481059ee7e6c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 88f2ad2c8ab504c5d95b1f70539f8d86 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace Unity.UIWidgets.ui { |
|||
enum InitStage { |
|||
NotPrepared, |
|||
Prepared, |
|||
Ready |
|||
} |
|||
|
|||
static partial class CanvasShader { |
|||
static InitStage initStage = InitStage.NotPrepared; |
|||
static int initialFrameCount; |
|||
static Shader testShader; |
|||
const string testShaderName = "UIWidgets/canvas_convexFill_cb"; |
|||
|
|||
static bool OnNotPrepared() { |
|||
initStage = InitStage.Prepared; |
|||
|
|||
initialFrameCount = Time.frameCount; |
|||
testShader = GetShader(testShaderName); |
|||
var material = new Material(testShader); |
|||
//for Unity 2018 or below, shader is compiled after Shader.Find() call immediately,
|
|||
//therefore we can just skip the manually preload if the compilation fails
|
|||
if (!material.shader.isSupported) { |
|||
ObjectUtils.SafeDestroy(material); |
|||
return OnPrepared(true); |
|||
} |
|||
|
|||
using (var cmdBuf = new CommandBuffer()) { |
|||
var renderTarget = new RenderTexture(1, 1, 1); |
|||
cmdBuf.SetRenderTarget(renderTarget); |
|||
|
|||
var mesh = new Mesh { |
|||
vertices = new[] {new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 1, 0)}, |
|||
uv = new[] {new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1)}, |
|||
triangles = new[] {0, 1, 2} |
|||
}; |
|||
cmdBuf.DrawMesh(mesh, Matrix4x4.identity, material); |
|||
cmdBuf.DisableScissorRect(); |
|||
Graphics.ExecuteCommandBuffer(cmdBuf); |
|||
|
|||
ObjectUtils.SafeDestroy(renderTarget); |
|||
ObjectUtils.SafeDestroy(mesh); |
|||
} |
|||
|
|||
ObjectUtils.SafeDestroy(material); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
static bool OnPrepared(bool forceReady = false) { |
|||
D.assert(initStage == InitStage.Prepared); |
|||
if (!forceReady && initialFrameCount >= Time.frameCount) { |
|||
return false; |
|||
} |
|||
|
|||
initStage = InitStage.Ready; |
|||
DoPrepare(); |
|||
return true; |
|||
} |
|||
|
|||
static void DoPrepare() { |
|||
D.assert(testShader != null); |
|||
var isShaderSupported = testShader.isSupported; |
|||
testShader = null; |
|||
supportComputeBuffer = enableComputeBuffer && SystemInfo.supportsComputeShaders && isShaderSupported; |
|||
|
|||
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 convexFillShaderCompute = GetShader("UIWidgets/canvas_convexFill_cb"); |
|||
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(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 bool isReady() { |
|||
switch (initStage) { |
|||
case InitStage.NotPrepared: |
|||
return OnNotPrepared(); |
|||
case InitStage.Prepared: |
|||
return OnPrepared(); |
|||
case InitStage.Ready: |
|||
return true; |
|||
default: |
|||
throw new ArgumentOutOfRangeException(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2ac77d972b29f49709bc66afaa7ca199 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: f592638352fff481487dec316e583967 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3434943ef6cfa4c80b424b818d1ccd46 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 12533dde17d054c58aa5aef1f8df7067 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4ad4bfab828614fd090399d0cd793b1a |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 104c51408606c4531bd029a900ff26b3 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cccc75413df09406bad8aab430428aec |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 080129d418c1c442985d3aba354d88ca |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e3e75e0dcee5243e2b95bc639eea758e |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cc9374790071e4da883a3319cda6cb20 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 57f3d43bd5ba648cda816d05ceb3b643 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3072a3ddd64a34c8cb3aa713b9705d72 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c5ba00af1b3a24619b8572f17b98917a |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 72c25fdac75cf4041bf9ef313a342a28 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9b0b3e1e797834f3abaefee47bce19df |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ad6fc8c9236144ca78ce73afd7a87833 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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; |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 703259d9f57a14f58a79e9bb2de8195f |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1b5261459dc1b4070bf275274cb5dcdc |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8d1dce436d5e143c0a2f90e25210070a |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 609f86cb483334c4396d574a338c7921 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2c7a9c90ab5af4b02875f760080b1c51 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 6c8a50e3adb8349e0a98bd0de080c7e5 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 813531ada8c4e40c597b19027ac7fc87 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5bde36357cad4438faa8e580cd85f2cd |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b6b3fce2866044f15aa7571d9d983a93 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e87b6538afcca45d5af06b744d26e3bb |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 444296b3078c944388a1f81cf1821808 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4037f8954a4124abf93d3ff663baa78d |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
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 |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ea02b3553b38477c85b9ca45949cc85c |
|||
timeCreated: 1544158153 |
|
|||
fileFormatVersion: 2 |
|||
guid: 43b4ae1d316ca415589f96e49cc0fcab |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 6565922d18a5e4ee29fa183d2600eccc |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e75e9debfc1ad4e1687365932de72aa0 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7dbfb4eecc7a84ddc90c53891aa77e0b |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 756de2a3eb91745ba853728245a033d9 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b4673a8cf87214fdb8643b32e0ec3316 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7e33032771e1e46a6b5eda923148503f |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ee8a29ca6a09f4510bbf6e3b70922edc |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1702a648d08de40d9aacd9bbab1188b3 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: da4e74e0b377e41699f5c3ed2c7c69e4 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 105f52491741049d88708e718c749e34 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 77c8565b9b449434490473ef8f7f0e91 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c57ed8e638931f946a7b5e26a54725d8 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue