added Linux arm64 SDK
This commit is contained in:
@@ -1,587 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
static const std::string shader_fill_frag1 = R"(
|
||||
#version 150
|
||||
|
||||
// Program Uniforms
|
||||
uniform vec4 State;
|
||||
uniform mat4 Transform;
|
||||
uniform vec4 Scalar4[2];
|
||||
uniform vec4 Vector[8];
|
||||
uniform uint ClipSize;
|
||||
uniform mat4 Clip[8];
|
||||
|
||||
// Uniform Accessor Functions
|
||||
float Scalar(uint i) { if (i < 4u) return Scalar4[0][i]; else return Scalar4[1][i - 4u]; }
|
||||
|
||||
// Texture Units
|
||||
uniform sampler2D Texture1;
|
||||
uniform sampler2D Texture2;
|
||||
uniform sampler2D Texture3;
|
||||
|
||||
// Vertex Attributes
|
||||
in vec4 ex_Color;
|
||||
in vec2 ex_TexCoord;
|
||||
in vec2 ex_ObjectCoord;
|
||||
in vec2 ex_ScreenCoord;
|
||||
in vec4 ex_Data0;
|
||||
in vec4 ex_Data1;
|
||||
in vec4 ex_Data2;
|
||||
in vec4 ex_Data3;
|
||||
in vec4 ex_Data4;
|
||||
in vec4 ex_Data5;
|
||||
in vec4 ex_Data6;
|
||||
|
||||
// Out Params
|
||||
out vec4 out_Color;
|
||||
|
||||
uint FillType() { return uint(ex_Data0.x + 0.5); }
|
||||
vec4 TileRectUV() { return Vector[0]; }
|
||||
vec2 TileSize() { return Vector[1].zw; }
|
||||
vec2 PatternTransformA() { return Vector[2].xy; }
|
||||
vec2 PatternTransformB() { return Vector[2].zw; }
|
||||
vec2 PatternTransformC() { return Vector[3].xy; }
|
||||
uint Gradient_NumStops() { return uint(ex_Data0.y + 0.5); }
|
||||
bool Gradient_IsRadial() { return bool(uint(ex_Data0.z + 0.5)); }
|
||||
float Gradient_R0() { return ex_Data1.x; }
|
||||
float Gradient_R1() { return ex_Data1.y; }
|
||||
vec2 Gradient_P0() { return ex_Data1.xy; }
|
||||
vec2 Gradient_P1() { return ex_Data1.zw; }
|
||||
float SDFMaxDistance() { return ex_Data0.y; }
|
||||
|
||||
struct GradientStop { float percent; vec4 color; };
|
||||
|
||||
GradientStop GetGradientStop(uint offset) {
|
||||
GradientStop result;
|
||||
if (offset < 4u) {
|
||||
result.percent = ex_Data2[offset];
|
||||
if (offset == 0u)
|
||||
result.color = ex_Data3;
|
||||
else if (offset == 1u)
|
||||
result.color = ex_Data4;
|
||||
else if (offset == 2u)
|
||||
result.color = ex_Data5;
|
||||
else if (offset == 3u)
|
||||
result.color = ex_Data6;
|
||||
} else {
|
||||
result.percent = Scalar(offset - 4u);
|
||||
result.color = Vector[offset - 4u];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define AA_WIDTH 0.354
|
||||
|
||||
float antialias(in float d, in float width, in float median) {
|
||||
return smoothstep(median - width, median + width, d);
|
||||
}
|
||||
|
||||
float sdRect(vec2 p, vec2 size) {
|
||||
vec2 d = abs(p) - size;
|
||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
||||
}
|
||||
|
||||
// The below function "sdEllipse" is MIT licensed with following text:
|
||||
//
|
||||
// The MIT License
|
||||
// Copyright 2013 Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions: The above copyright
|
||||
// notice and this permission notice shall be included in all copies or substantial
|
||||
// portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
float sdEllipse( vec2 p, in vec2 ab ) {
|
||||
if (abs(ab.x - ab.y) < 0.1)
|
||||
return length(p) - ab.x;
|
||||
|
||||
p = abs(p); if (p.x > p.y) { p=p.yx; ab=ab.yx; }
|
||||
|
||||
float l = ab.y*ab.y - ab.x*ab.x;
|
||||
|
||||
float m = ab.x*p.x/l;
|
||||
float n = ab.y*p.y/l;
|
||||
float m2 = m*m;
|
||||
float n2 = n*n;
|
||||
|
||||
float c = (m2 + n2 - 1.0)/3.0;
|
||||
float c3 = c*c*c;
|
||||
|
||||
float q = c3 + m2*n2*2.0;
|
||||
float d = c3 + m2*n2;
|
||||
float g = m + m*n2;
|
||||
|
||||
float co;
|
||||
|
||||
if (d < 0.0)
|
||||
{
|
||||
float p = acos(q/c3)/3.0;
|
||||
float s = cos(p);
|
||||
float t = sin(p)*sqrt(3.0);
|
||||
float rx = sqrt( -c*(s + t + 2.0) + m2 );
|
||||
float ry = sqrt( -c*(s - t + 2.0) + m2 );
|
||||
co = ( ry + sign(l)*rx + abs(g)/(rx*ry) - m)/2.0;
|
||||
} else {
|
||||
float h = 2.0*m*n*sqrt( d );
|
||||
float s = sign(q+h)*pow( abs(q+h), 1.0/3.0 );
|
||||
float u = sign(q-h)*pow( abs(q-h), 1.0/3.0 );
|
||||
float rx = -s - u - c*4.0 + 2.0*m2;
|
||||
float ry = (s - u)*sqrt(3.0);
|
||||
float rm = sqrt( rx*rx + ry*ry );
|
||||
float p = ry/sqrt(rm-rx);
|
||||
co = (p + 2.0*g/rm - m)/2.0;
|
||||
}
|
||||
|
||||
float si = sqrt(1.0 - co*co);
|
||||
|
||||
vec2 r = vec2(ab.x*co, ab.y*si);
|
||||
|
||||
return length(r - p) * sign(p.y-r.y);
|
||||
}
|
||||
|
||||
float sdRoundRect(vec2 p, vec2 size, vec4 rx, vec4 ry) {
|
||||
size *= 0.5;
|
||||
vec2 corner;
|
||||
|
||||
corner = vec2(-size.x+rx.x, -size.y+ry.x); // Top-Left
|
||||
vec2 local = p - corner;
|
||||
if (dot(rx.x, ry.x) > 0.0 && p.x < corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, vec2(rx.x, ry.x));
|
||||
|
||||
corner = vec2(size.x-rx.y, -size.y+ry.y); // Top-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.y, ry.y) > 0.0 && p.x >= corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, vec2(rx.y, ry.y));
|
||||
|
||||
corner = vec2(size.x-rx.z, size.y-ry.z); // Bottom-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.z, ry.z) > 0.0 && p.x >= corner.x && p.y >= corner.y)
|
||||
return sdEllipse(local, vec2(rx.z, ry.z));
|
||||
|
||||
corner = vec2(-size.x+rx.w, size.y-ry.w); // Bottom-Left
|
||||
local = p - corner;
|
||||
if (dot(rx.w, ry.w) > 0.0 && p.x < corner.x && p.y > corner.y)
|
||||
return sdEllipse(local, vec2(rx.w, ry.w));
|
||||
|
||||
return sdRect(p, size);
|
||||
}
|
||||
|
||||
void fillSolid() {
|
||||
out_Color = ex_Color;
|
||||
}
|
||||
|
||||
void fillImage(vec2 uv) {
|
||||
out_Color = texture(Texture1, uv) * ex_Color;
|
||||
}
|
||||
|
||||
vec2 transformAffine(vec2 val, vec2 a, vec2 b, vec2 c) {
|
||||
return val.x * a + val.y * b + c;
|
||||
}
|
||||
|
||||
void fillPatternImage() {
|
||||
vec4 tile_rect_uv = TileRectUV();
|
||||
vec2 tile_size = TileSize();
|
||||
|
||||
vec2 p = ex_ObjectCoord;
|
||||
|
||||
// Apply the affine matrix
|
||||
vec2 transformed_coords = transformAffine(p,
|
||||
PatternTransformA(), PatternTransformB(), PatternTransformC());
|
||||
|
||||
// Convert back to uv coordinate space
|
||||
transformed_coords /= tile_size;
|
||||
|
||||
// Wrap UVs to [0.0, 1.0] so texture repeats properly
|
||||
vec2 uv = fract(transformed_coords);
|
||||
|
||||
// Clip to tile-rect UV
|
||||
uv *= tile_rect_uv.zw - tile_rect_uv.xy;
|
||||
uv += tile_rect_uv.xy;
|
||||
|
||||
fillImage(uv);
|
||||
}
|
||||
|
||||
// Gradient noise from Jorge Jimenez's presentation:
|
||||
// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
||||
float gradientNoise(in vec2 uv)
|
||||
{
|
||||
const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
|
||||
float ramp(in float inMin, in float inMax, in float val)
|
||||
{
|
||||
return clamp((val - inMin) / (inMax - inMin), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void fillPatternGradient() {
|
||||
int num_stops = int(Gradient_NumStops());
|
||||
bool is_radial = Gradient_IsRadial();
|
||||
vec2 p0 = Gradient_P0();
|
||||
vec2 p1 = Gradient_P1();
|
||||
|
||||
float t = 0.0;
|
||||
if (is_radial) {
|
||||
float r0 = p1.x;
|
||||
float r1 = p1.y;
|
||||
t = distance(ex_TexCoord, p0);
|
||||
float rDelta = r1 - r0;
|
||||
t = clamp((t / rDelta) - (r0 / rDelta), 0.0, 1.0);
|
||||
} else {
|
||||
vec2 V = p1 - p0;
|
||||
t = clamp(dot(ex_TexCoord - p0, V) / dot(V, V), 0.0, 1.0);
|
||||
}
|
||||
|
||||
GradientStop stop0 = GetGradientStop(0u);
|
||||
GradientStop stop1 = GetGradientStop(1u);
|
||||
|
||||
out_Color = mix(stop0.color, stop1.color, ramp(stop0.percent, stop1.percent, t));
|
||||
if (num_stops > 2) {
|
||||
GradientStop stop2 = GetGradientStop(2u);
|
||||
out_Color = mix(out_Color, stop2.color, ramp(stop1.percent, stop2.percent, t));
|
||||
if (num_stops > 3) {
|
||||
GradientStop stop3 = GetGradientStop(3u);
|
||||
out_Color = mix(out_Color, stop3.color, ramp(stop2.percent, stop3.percent, t));
|
||||
if (num_stops > 4) {
|
||||
GradientStop stop4 = GetGradientStop(4u);
|
||||
out_Color = mix(out_Color, stop4.color, ramp(stop3.percent, stop4.percent, t));
|
||||
if (num_stops > 5) {
|
||||
GradientStop stop5 = GetGradientStop(5u);
|
||||
out_Color = mix(out_Color, stop5.color, ramp(stop4.percent, stop5.percent, t));
|
||||
if (num_stops > 6) {
|
||||
GradientStop stop6 = GetGradientStop(6u);
|
||||
out_Color = mix(out_Color, stop6.color, ramp(stop5.percent, stop6.percent, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add gradient noise to reduce banding (+4/-4 gradations)
|
||||
//out_Color += (8.0/255.0) * gradientNoise(gl_FragCoord.xy) - (4.0/255.0);
|
||||
}
|
||||
|
||||
void Unpack(vec4 x, out vec4 a, out vec4 b) {
|
||||
const float s = 65536.0;
|
||||
a = floor(x / s);
|
||||
b = floor(x - a * s);
|
||||
}
|
||||
|
||||
const float epsilon = AA_WIDTH;
|
||||
|
||||
float antialias2 (float d) {
|
||||
return smoothstep (-epsilon, +epsilon, d);
|
||||
}
|
||||
|
||||
// Returns two values:
|
||||
// [0] = distance of p to line segment.
|
||||
// [1] = closest t on line segment, clamped to [0, 1]
|
||||
vec2 sdSegment(in vec2 p, in vec2 a, in vec2 b)
|
||||
{
|
||||
vec2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return vec2(length(pa - ba * t), t);
|
||||
}
|
||||
|
||||
float testCross(vec2 a, vec2 b, vec2 p) {
|
||||
return (b.y - a.y) * (p.x - a.x) - (b.x - a.x) * (p.y - a.y);
|
||||
}
|
||||
|
||||
float sdLine(in vec2 a, in vec2 b, in vec2 p)
|
||||
{
|
||||
vec2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return length(pa - ba*t) * sign(testCross(a, b, p));
|
||||
}
|
||||
|
||||
vec4 blend(vec4 src, vec4 dest) {
|
||||
vec4 result;
|
||||
result.rgb = src.rgb + dest.rgb * (1.0 - src.a);
|
||||
result.a = src.a + dest.a * (1.0 - src.a);
|
||||
return result;
|
||||
}
|
||||
|
||||
)";
|
||||
|
||||
static const std::string shader_fill_frag2 = R"(
|
||||
|
||||
float innerStroke(float stroke_width, float d) {
|
||||
return min(antialias(-d, AA_WIDTH, 0.0), 1.0 - antialias(-d, AA_WIDTH, stroke_width));
|
||||
}
|
||||
|
||||
void fillRoundedRect() {
|
||||
vec2 p = ex_TexCoord;
|
||||
vec2 size = ex_Data0.zw;
|
||||
p = (p - 0.5) * size;
|
||||
float d = sdRoundRect(p, size, ex_Data1, ex_Data2);
|
||||
|
||||
// Fill background
|
||||
float alpha = antialias(-d, AA_WIDTH, 0.0);
|
||||
out_Color = ex_Color * alpha;
|
||||
|
||||
// Draw stroke
|
||||
float stroke_width = ex_Data3.x;
|
||||
vec4 stroke_color = ex_Data4;
|
||||
|
||||
if (stroke_width > 0.0) {
|
||||
alpha = innerStroke(stroke_width, d);
|
||||
vec4 stroke = stroke_color * alpha;
|
||||
out_Color = blend(stroke, out_Color);
|
||||
}
|
||||
}
|
||||
|
||||
void fillBoxShadow() {
|
||||
vec2 p = ex_ObjectCoord;
|
||||
bool inset = bool(uint(ex_Data0.y + 0.5));
|
||||
float radius = ex_Data0.z;
|
||||
vec2 origin = ex_Data1.xy;
|
||||
vec2 size = ex_Data1.zw;
|
||||
vec2 clip_origin = ex_Data4.xy;
|
||||
vec2 clip_size = ex_Data4.zw;
|
||||
|
||||
float sdClip = sdRoundRect(p - clip_origin, clip_size, ex_Data5, ex_Data6);
|
||||
float sdRect = sdRoundRect(p - origin, size, ex_Data2, ex_Data3);
|
||||
|
||||
float clip = inset ? -sdRect : sdClip;
|
||||
float d = inset ? -sdClip : sdRect;
|
||||
|
||||
if (clip < 0.0) {
|
||||
discard;
|
||||
out_Color = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
float alpha = radius >= 1.0? pow(antialias(-d, radius * 2 + 0.2, 0.0), 1.9) * 3.3 / pow(radius * 1.2, 0.15) :
|
||||
antialias(-d, AA_WIDTH, inset ? -1.0 : 1.0);
|
||||
alpha = clamp(alpha, 0.0, 1.0) * ex_Color.a;
|
||||
out_Color = vec4(ex_Color.rgb * alpha, alpha);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 blendOverlay(vec3 src, vec3 dest) {
|
||||
vec3 col;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 blendColorDodge(vec3 src, vec3 dest) {
|
||||
vec3 col;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 1.0) ? src[i] : min(dest[i] / (1.0 - src[i]), 1.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 blendColorBurn(vec3 src, vec3 dest) {
|
||||
vec3 col;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 0.0) ? src[i] : max((1.0 - ((1.0 - dest[i]) / src[i])), 0.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 blendHardLight(vec3 src, vec3 dest) {
|
||||
vec3 col;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 blendSoftLight(vec3 src, vec3 dest) {
|
||||
vec3 col;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] < 0.5) ? (2.0 * dest[i] * src[i] + dest[i] * dest[i] * (1.0 - 2.0 * src[i])) : (sqrt(dest[i]) * (2.0 * src[i] - 1.0) + 2.0 * dest[i] * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 rgb2hsl( vec3 col )
|
||||
{
|
||||
const float eps = 0.0000001;
|
||||
float minc = min( col.r, min(col.g, col.b) );
|
||||
float maxc = max( col.r, max(col.g, col.b) );
|
||||
vec3 mask = step(col.grr,col.rgb) * step(col.bbg,col.rgb);
|
||||
vec3 h = mask * (vec3(0.0,2.0,4.0) + (col.gbr-col.brg)/(maxc-minc + eps)) / 6.0;
|
||||
return vec3(fract(1.0 + h.x + h.y + h.z ), // H
|
||||
(maxc-minc)/(1.0-abs(minc+maxc-1.0) + eps), // S
|
||||
(minc+maxc)*0.5 ); // L
|
||||
}
|
||||
|
||||
vec3 hsl2rgb( vec3 c )
|
||||
{
|
||||
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
|
||||
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
|
||||
}
|
||||
|
||||
vec3 blendHue(vec3 src, vec3 dest) {
|
||||
vec3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(vec3(rgb2hsl(src).r, baseHSL.g, baseHSL.b));
|
||||
}
|
||||
|
||||
vec3 blendSaturation(vec3 src, vec3 dest) {
|
||||
vec3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(vec3(baseHSL.r, rgb2hsl(src).g, baseHSL.b));
|
||||
}
|
||||
|
||||
vec3 blendColor(vec3 src, vec3 dest) {
|
||||
vec3 blendHSL = rgb2hsl(src);
|
||||
return hsl2rgb(vec3(blendHSL.r, blendHSL.g, rgb2hsl(dest).b));
|
||||
}
|
||||
|
||||
vec3 blendLuminosity(vec3 src, vec3 dest) {
|
||||
vec3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(vec3(baseHSL.r, baseHSL.g, rgb2hsl(src).b));
|
||||
}
|
||||
|
||||
vec4 saturate(vec4 val) {
|
||||
return clamp(val, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec4 calcBlend() {
|
||||
const uint BlendOp_Clear = 0u;
|
||||
const uint BlendOp_Source = 1u;
|
||||
const uint BlendOp_Over = 2u;
|
||||
const uint BlendOp_In = 3u;
|
||||
const uint BlendOp_Out = 4u;
|
||||
const uint BlendOp_Atop = 5u;
|
||||
const uint BlendOp_DestOver = 6u;
|
||||
const uint BlendOp_DestIn = 7u;
|
||||
const uint BlendOp_DestOut = 8u;
|
||||
const uint BlendOp_DestAtop = 9u;
|
||||
const uint BlendOp_XOR = 10u;
|
||||
const uint BlendOp_Darken = 11u;
|
||||
const uint BlendOp_Add = 12u;
|
||||
const uint BlendOp_Difference = 13u;
|
||||
const uint BlendOp_Multiply = 14u;
|
||||
const uint BlendOp_Screen = 15u;
|
||||
const uint BlendOp_Overlay = 16u;
|
||||
const uint BlendOp_Lighten = 17u;
|
||||
const uint BlendOp_ColorDodge = 18u;
|
||||
const uint BlendOp_ColorBurn = 19u;
|
||||
const uint BlendOp_HardLight = 20u;
|
||||
const uint BlendOp_SoftLight = 21u;
|
||||
const uint BlendOp_Exclusion = 22u;
|
||||
const uint BlendOp_Hue = 23u;
|
||||
const uint BlendOp_Saturation = 24u;
|
||||
const uint BlendOp_Color = 25u;
|
||||
const uint BlendOp_Luminosity = 26u;
|
||||
|
||||
fillImage(ex_TexCoord);
|
||||
vec4 src = out_Color;
|
||||
vec4 dest = texture(Texture2, ex_ObjectCoord);
|
||||
|
||||
switch(uint(ex_Data0.y + 0.5))
|
||||
{
|
||||
case BlendOp_Clear: return vec4(0.0, 0.0, 0.0, 0.0);
|
||||
case BlendOp_Source: return src;
|
||||
case BlendOp_Over: return src + dest * (1.0 - src.a);
|
||||
case BlendOp_In: return src * dest.a;
|
||||
case BlendOp_Out: return src * (1.0 - dest.a);
|
||||
case BlendOp_Atop: return src * dest.a + dest * (1.0 - src.a);
|
||||
case BlendOp_DestOver: return src * (1.0 - dest.a) + dest;
|
||||
case BlendOp_DestIn: return dest * src.a;
|
||||
case BlendOp_DestOut: return dest * (1.0 - src.a);
|
||||
case BlendOp_DestAtop: return src * (1.0 - dest.a) + dest * src.a;
|
||||
case BlendOp_XOR: return saturate(src * (1.0 - dest.a) + dest * (1.0 - src.a));
|
||||
case BlendOp_Darken: return vec4(min(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Add: return saturate(src + dest);
|
||||
case BlendOp_Difference: return vec4(abs(dest.rgb - src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Multiply: return vec4(src.rgb * dest.rgb * src.a, dest.a * src.a);
|
||||
case BlendOp_Screen: return vec4((1.0 - ((1.0 - dest.rgb) * (1.0 - src.rgb))) * src.a, dest.a * src.a);
|
||||
case BlendOp_Overlay: return vec4(blendOverlay(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Lighten: return vec4(max(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorDodge: return vec4(blendColorDodge(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorBurn: return vec4(blendColorBurn(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_HardLight: return vec4(blendOverlay(dest.rgb, src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_SoftLight: return vec4(blendSoftLight(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Exclusion: return vec4((dest.rgb + src.rgb - 2.0 * dest.rgb * src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Hue: return vec4(blendHue(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Saturation: return vec4(blendSaturation(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Color: return vec4(blendColor(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Luminosity: return vec4(blendLuminosity(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
void fillBlend() {
|
||||
out_Color = calcBlend();
|
||||
}
|
||||
|
||||
void fillMask() {
|
||||
fillImage(ex_TexCoord);
|
||||
float alpha = texture(Texture2, ex_ObjectCoord).a;
|
||||
out_Color *= alpha;
|
||||
}
|
||||
|
||||
void fillGlyph(vec2 uv) {
|
||||
float alpha = texture(Texture1, uv).r * ex_Color.a;
|
||||
alpha = clamp(alpha, 0.0, 1.0);
|
||||
float fill_color_luma = ex_Data0.y;
|
||||
float corrected_alpha = texture(Texture2, vec2(alpha, fill_color_luma)).r;
|
||||
//float corrected_alpha = alpha;
|
||||
out_Color = vec4(ex_Color.rgb * corrected_alpha, corrected_alpha);
|
||||
}
|
||||
|
||||
void applyClip() {
|
||||
for (uint i = 0u; i < ClipSize; i++) {
|
||||
mat4 data = Clip[i];
|
||||
vec2 origin = data[0].xy;
|
||||
vec2 size = data[0].zw;
|
||||
vec4 radii_x, radii_y;
|
||||
Unpack(data[1], radii_x, radii_y);
|
||||
bool inverse = bool(data[3].z);
|
||||
|
||||
vec2 p = ex_ObjectCoord;
|
||||
p = transformAffine(p, data[2].xy, data[2].zw, data[3].xy);
|
||||
p -= origin;
|
||||
|
||||
float d_clip = sdRoundRect(p, size, radii_x, radii_y) * (inverse? -1.0 : 1.0);
|
||||
float alpha = antialias2(-d_clip);
|
||||
out_Color = vec4(out_Color.rgb * alpha, out_Color.a * alpha);
|
||||
|
||||
//if (abs(d_clip) < 2.0)
|
||||
// out_Color = vec4(0.9, 1.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
const uint FillType_Solid = 0u;
|
||||
const uint FillType_Image = 1u;
|
||||
const uint FillType_Pattern_Image = 2u;
|
||||
const uint FillType_Pattern_Gradient = 3u;
|
||||
const uint FillType_RESERVED_1 = 4u;
|
||||
const uint FillType_RESERVED_2 = 5u;
|
||||
const uint FillType_RESERVED_3 = 6u;
|
||||
const uint FillType_Rounded_Rect = 7u;
|
||||
const uint FillType_Box_Shadow = 8u;
|
||||
const uint FillType_Blend = 9u;
|
||||
const uint FillType_Mask = 10u;
|
||||
const uint FillType_Glyph = 11u;
|
||||
|
||||
switch (FillType())
|
||||
{
|
||||
case FillType_Solid: fillSolid(); break;
|
||||
case FillType_Image: fillImage(ex_TexCoord); break;
|
||||
case FillType_Pattern_Image: fillPatternImage(); break;
|
||||
case FillType_Pattern_Gradient: fillPatternGradient(); break;
|
||||
case FillType_Rounded_Rect: fillRoundedRect(); break;
|
||||
case FillType_Box_Shadow: fillBoxShadow(); break;
|
||||
case FillType_Blend: fillBlend(); break;
|
||||
case FillType_Mask: fillMask(); break;
|
||||
case FillType_Glyph: fillGlyph(ex_TexCoord); break;
|
||||
}
|
||||
|
||||
applyClip();
|
||||
}
|
||||
|
||||
)";
|
||||
|
||||
static std::string shader_fill_frag() { return shader_fill_frag1 + shader_fill_frag2; }
|
||||
@@ -1,172 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
static std::string shader_fill_path_frag() {
|
||||
return R"(#version 150
|
||||
|
||||
// Program Uniforms
|
||||
uniform vec4 State;
|
||||
uniform mat4 Transform;
|
||||
uniform vec4 Scalar4[2];
|
||||
uniform vec4 Vector[8];
|
||||
uniform uint ClipSize;
|
||||
uniform mat4 Clip[8];
|
||||
|
||||
// Uniform Accessor Functions
|
||||
float Time() { return State[0]; }
|
||||
float ScreenWidth() { return State[1]; }
|
||||
float ScreenHeight() { return State[2]; }
|
||||
float ScreenScale() { return State[3]; }
|
||||
float Scalar(uint i) { if (i < 4u) return Scalar4[0][i]; else return Scalar4[1][i - 4u]; }
|
||||
|
||||
// Vertex Attributes
|
||||
in vec4 ex_Color;
|
||||
in vec2 ex_ObjectCoord;
|
||||
in vec2 ex_ScreenCoord;
|
||||
|
||||
// Out Params
|
||||
out vec4 out_Color;
|
||||
|
||||
float sdRect(vec2 p, vec2 size) {
|
||||
vec2 d = abs(p) - size;
|
||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
||||
}
|
||||
|
||||
// The below function "sdEllipse" is MIT licensed with following text:
|
||||
//
|
||||
// The MIT License
|
||||
// Copyright 2013 Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions: The above copyright
|
||||
// notice and this permission notice shall be included in all copies or substantial
|
||||
// portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
float sdEllipse( vec2 p, in vec2 ab ) {
|
||||
if (abs(ab.x - ab.y) < 0.1)
|
||||
return length(p) - ab.x;
|
||||
|
||||
p = abs(p); if (p.x > p.y) { p=p.yx; ab=ab.yx; }
|
||||
|
||||
float l = ab.y*ab.y - ab.x*ab.x;
|
||||
|
||||
float m = ab.x*p.x/l;
|
||||
float n = ab.y*p.y/l;
|
||||
float m2 = m*m;
|
||||
float n2 = n*n;
|
||||
|
||||
float c = (m2 + n2 - 1.0)/3.0;
|
||||
float c3 = c*c*c;
|
||||
|
||||
float q = c3 + m2*n2*2.0;
|
||||
float d = c3 + m2*n2;
|
||||
float g = m + m*n2;
|
||||
|
||||
float co;
|
||||
|
||||
if (d < 0.0)
|
||||
{
|
||||
float p = acos(q/c3)/3.0;
|
||||
float s = cos(p);
|
||||
float t = sin(p)*sqrt(3.0);
|
||||
float rx = sqrt( -c*(s + t + 2.0) + m2 );
|
||||
float ry = sqrt( -c*(s - t + 2.0) + m2 );
|
||||
co = ( ry + sign(l)*rx + abs(g)/(rx*ry) - m)/2.0;
|
||||
} else {
|
||||
float h = 2.0*m*n*sqrt( d );
|
||||
float s = sign(q+h)*pow( abs(q+h), 1.0/3.0 );
|
||||
float u = sign(q-h)*pow( abs(q-h), 1.0/3.0 );
|
||||
float rx = -s - u - c*4.0 + 2.0*m2;
|
||||
float ry = (s - u)*sqrt(3.0);
|
||||
float rm = sqrt( rx*rx + ry*ry );
|
||||
float p = ry/sqrt(rm-rx);
|
||||
co = (p + 2.0*g/rm - m)/2.0;
|
||||
}
|
||||
|
||||
float si = sqrt(1.0 - co*co);
|
||||
|
||||
vec2 r = vec2(ab.x*co, ab.y*si);
|
||||
|
||||
return length(r - p) * sign(p.y-r.y);
|
||||
}
|
||||
|
||||
float sdRoundRect(vec2 p, vec2 size, vec4 rx, vec4 ry) {
|
||||
size *= 0.5;
|
||||
vec2 corner;
|
||||
|
||||
corner = vec2(-size.x+rx.x, -size.y+ry.x); // Top-Left
|
||||
vec2 local = p - corner;
|
||||
if (dot(rx.x, ry.x) > 0.0 && p.x < corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, vec2(rx.x, ry.x));
|
||||
|
||||
corner = vec2(size.x-rx.y, -size.y+ry.y); // Top-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.y, ry.y) > 0.0 && p.x >= corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, vec2(rx.y, ry.y));
|
||||
|
||||
corner = vec2(size.x-rx.z, size.y-ry.z); // Bottom-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.z, ry.z) > 0.0 && p.x >= corner.x && p.y >= corner.y)
|
||||
return sdEllipse(local, vec2(rx.z, ry.z));
|
||||
|
||||
corner = vec2(-size.x+rx.w, size.y-ry.w); // Bottom-Left
|
||||
local = p - corner;
|
||||
if (dot(rx.w, ry.w) > 0.0 && p.x < corner.x && p.y > corner.y)
|
||||
return sdEllipse(local, vec2(rx.w, ry.w));
|
||||
|
||||
return sdRect(p, size);
|
||||
}
|
||||
|
||||
vec2 transformAffine(vec2 val, vec2 a, vec2 b, vec2 c) {
|
||||
return val.x * a + val.y * b + c;
|
||||
}
|
||||
|
||||
void Unpack(vec4 x, out vec4 a, out vec4 b) {
|
||||
const float s = 65536.0;
|
||||
a = floor(x / s);
|
||||
b = floor(x - a * s);
|
||||
}
|
||||
|
||||
#define AA_WIDTH 0.354
|
||||
|
||||
float antialias(in float d, in float width, in float median) {
|
||||
return smoothstep(median - width, median + width, d);
|
||||
}
|
||||
|
||||
void applyClip() {
|
||||
for (uint i = 0u; i < ClipSize; i++) {
|
||||
mat4 data = Clip[i];
|
||||
vec2 origin = data[0].xy;
|
||||
vec2 size = data[0].zw;
|
||||
vec4 radii_x, radii_y;
|
||||
Unpack(data[1], radii_x, radii_y);
|
||||
bool inverse = bool(data[3].z);
|
||||
|
||||
vec2 p = ex_ObjectCoord;
|
||||
p = transformAffine(p, data[2].xy, data[2].zw, data[3].xy);
|
||||
p -= origin;
|
||||
|
||||
float d_clip = sdRoundRect(p, size, radii_x, radii_y) * (inverse? -1.0 : 1.0);
|
||||
float alpha = antialias(-d_clip, AA_WIDTH, 0.0);
|
||||
out_Color = vec4(out_Color.rgb * alpha, out_Color.a * alpha);
|
||||
|
||||
//if (abs(d_clip) < 2.0)
|
||||
// out_Color = vec4(0.9, 1.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
out_Color = ex_Color;
|
||||
applyClip();
|
||||
}
|
||||
|
||||
)";
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
static std::string shader_v2f_c4f_t2f_t2f_d28f_vert() {
|
||||
return R"(#version 150
|
||||
|
||||
// Program Uniforms
|
||||
uniform vec4 State;
|
||||
uniform mat4 Transform;
|
||||
uniform vec4 Scalar4[2];
|
||||
uniform vec4 Vector[8];
|
||||
uniform uint ClipSize;
|
||||
uniform mat4 Clip[8];
|
||||
|
||||
// Uniform Accessor Functions
|
||||
float Time() { return State[0]; }
|
||||
float ScreenWidth() { return State[1]; }
|
||||
float ScreenHeight() { return State[2]; }
|
||||
float ScreenScale() { return State[3]; }
|
||||
float Scalar(uint i) { if (i < 4u) return Scalar4[0][i]; else return Scalar4[1][i - 4u]; }
|
||||
vec4 sRGBToLinear(vec4 val) { return vec4(val.xyz * (val.xyz * (val.xyz * 0.305306011 + 0.682171111) + 0.012522878), val.w); }
|
||||
|
||||
// Vertex Attributes
|
||||
in vec2 in_Position;
|
||||
in vec4 in_Color;
|
||||
in vec2 in_TexCoord;
|
||||
in vec2 in_ObjCoord;
|
||||
in vec4 in_Data0;
|
||||
in vec4 in_Data1;
|
||||
in vec4 in_Data2;
|
||||
in vec4 in_Data3;
|
||||
in vec4 in_Data4;
|
||||
in vec4 in_Data5;
|
||||
in vec4 in_Data6;
|
||||
|
||||
// Out Params
|
||||
out vec4 ex_Color;
|
||||
out vec2 ex_TexCoord;
|
||||
out vec4 ex_Data0;
|
||||
out vec4 ex_Data1;
|
||||
out vec4 ex_Data2;
|
||||
out vec4 ex_Data3;
|
||||
out vec4 ex_Data4;
|
||||
out vec4 ex_Data5;
|
||||
out vec4 ex_Data6;
|
||||
out vec2 ex_ObjectCoord;
|
||||
out vec2 ex_ScreenCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ex_ObjectCoord = in_ObjCoord;
|
||||
gl_Position = Transform * vec4(in_Position, 0.0, 1.0);
|
||||
ex_Color = in_Color;
|
||||
ex_TexCoord = in_TexCoord;
|
||||
ex_Data0 = in_Data0;
|
||||
ex_Data1 = in_Data1;
|
||||
ex_Data2 = in_Data2;
|
||||
ex_Data3 = in_Data3;
|
||||
ex_Data4 = in_Data4;
|
||||
ex_Data5 = in_Data5;
|
||||
ex_Data6 = in_Data6;
|
||||
}
|
||||
|
||||
)";
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
static std::string shader_v2f_c4f_t2f_vert() {
|
||||
return R"(#version 150
|
||||
|
||||
// Program Uniforms
|
||||
uniform vec4 State;
|
||||
uniform mat4 Transform;
|
||||
uniform vec4 Scalar4[2];
|
||||
uniform vec4 Vector[8];
|
||||
uniform uint ClipSize;
|
||||
uniform mat4 Clip[8];
|
||||
|
||||
// Uniform Accessor Functions
|
||||
float Time() { return State[0]; }
|
||||
float ScreenWidth() { return State[1]; }
|
||||
float ScreenHeight() { return State[2]; }
|
||||
float ScreenScale() { return State[3]; }
|
||||
float Scalar(uint i) { if (i < 4u) return Scalar4[0][i]; else return Scalar4[1][i - 4u]; }
|
||||
vec4 sRGBToLinear(vec4 val) { return vec4(val.xyz * (val.xyz * (val.xyz * 0.305306011 + 0.682171111) + 0.012522878), val.w); }
|
||||
|
||||
// Vertex Attributes
|
||||
in vec2 in_Position;
|
||||
in vec4 in_Color;
|
||||
in vec2 in_TexCoord;
|
||||
|
||||
// Out Params
|
||||
out vec4 ex_Color;
|
||||
out vec2 ex_ObjectCoord;
|
||||
out vec2 ex_ScreenCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ex_ObjectCoord = in_TexCoord;
|
||||
gl_Position = Transform * vec4(in_Position, 0.0, 1.0);
|
||||
ex_Color = in_Color;
|
||||
}
|
||||
|
||||
)";
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,99 +0,0 @@
|
||||
unsigned char v2f_c4f_t2f_fxc[] = {
|
||||
0x44, 0x58, 0x42, 0x43, 0xCC, 0x19, 0x9C, 0x90, 0x85, 0xC8, 0x48, 0xEF,
|
||||
0xC5, 0x7D, 0xF4, 0x1E, 0x15, 0x9C, 0xDC, 0x13, 0x01, 0x00, 0x00, 0x00,
|
||||
0x7C, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
|
||||
0xEC, 0x01, 0x00, 0x00, 0x5C, 0x02, 0x00, 0x00, 0xD0, 0x02, 0x00, 0x00,
|
||||
0x00, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xB0, 0x01, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFE, 0xFF, 0x00, 0x01, 0x00, 0x00,
|
||||
0x88, 0x01, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x55, 0x6E, 0x69, 0x66, 0x6F, 0x72, 0x6D, 0x73, 0x00, 0xAB, 0xAB, 0xAB,
|
||||
0x3C, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3C, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x54, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x70, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0xAB, 0xAB, 0x01, 0x00, 0x03, 0x00,
|
||||
0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0xAB, 0xAB,
|
||||
0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x53, 0x63, 0x61, 0x6C, 0x61, 0x72, 0x34, 0x00,
|
||||
0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x56, 0x65, 0x63, 0x74, 0x6F, 0x72, 0x00, 0xAB,
|
||||
0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x43, 0x6C, 0x69, 0x70, 0x53, 0x69, 0x7A, 0x65,
|
||||
0x00, 0xAB, 0xAB, 0xAB, 0x00, 0x00, 0x13, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6C, 0x69, 0x70,
|
||||
0x00, 0xAB, 0xAB, 0xAB, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x69, 0x63, 0x72,
|
||||
0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4C,
|
||||
0x53, 0x4C, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6F,
|
||||
0x6D, 0x70, 0x69, 0x6C, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x00,
|
||||
0x49, 0x53, 0x47, 0x4E, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x03, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x03, 0x03, 0x00, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E,
|
||||
0x00, 0x43, 0x4F, 0x4C, 0x4F, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4F,
|
||||
0x4F, 0x52, 0x44, 0x00, 0x4F, 0x53, 0x47, 0x4E, 0x6C, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x50,
|
||||
0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E, 0x00, 0x43, 0x4F, 0x4C, 0x4F,
|
||||
0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4F, 0x4F, 0x52, 0x44, 0x00, 0xAB,
|
||||
0x53, 0x48, 0x44, 0x52, 0x28, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00,
|
||||
0x4A, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8E, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08,
|
||||
0xF2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0A, 0xF2, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x46, 0x0E, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0E, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0xF2, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x38, 0x00, 0x00, 0x0A, 0xF2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x46, 0x0E, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
|
||||
0x81, 0x80, 0x80, 0x3B, 0x81, 0x80, 0x80, 0x3B, 0x81, 0x80, 0x80, 0x3B,
|
||||
0x81, 0x80, 0x80, 0x3B, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
unsigned int v2f_c4f_t2f_fxc_len = 1148;
|
||||
@@ -1,161 +0,0 @@
|
||||
unsigned char v2f_c4f_t2f_t2f_d28f_fxc[] = {
|
||||
0x44, 0x58, 0x42, 0x43, 0x0C, 0xAE, 0xC8, 0x0A, 0xD9, 0x88, 0x3C, 0xBA,
|
||||
0x2F, 0xEC, 0x7E, 0x7A, 0x0D, 0xB8, 0xB3, 0xFF, 0x01, 0x00, 0x00, 0x00,
|
||||
0x5C, 0x07, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
|
||||
0xEC, 0x01, 0x00, 0x00, 0x1C, 0x03, 0x00, 0x00, 0x50, 0x04, 0x00, 0x00,
|
||||
0xE0, 0x06, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xB0, 0x01, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFE, 0xFF, 0x00, 0x01, 0x00, 0x00,
|
||||
0x88, 0x01, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x55, 0x6E, 0x69, 0x66, 0x6F, 0x72, 0x6D, 0x73, 0x00, 0xAB, 0xAB, 0xAB,
|
||||
0x3C, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x24, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3C, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x54, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x70, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0xAB, 0xAB, 0x01, 0x00, 0x03, 0x00,
|
||||
0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0xAB, 0xAB,
|
||||
0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x53, 0x63, 0x61, 0x6C, 0x61, 0x72, 0x34, 0x00,
|
||||
0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x56, 0x65, 0x63, 0x74, 0x6F, 0x72, 0x00, 0xAB,
|
||||
0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x43, 0x6C, 0x69, 0x70, 0x53, 0x69, 0x7A, 0x65,
|
||||
0x00, 0xAB, 0xAB, 0xAB, 0x00, 0x00, 0x13, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6C, 0x69, 0x70,
|
||||
0x00, 0xAB, 0xAB, 0xAB, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x69, 0x63, 0x72,
|
||||
0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4C,
|
||||
0x53, 0x4C, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6F,
|
||||
0x6D, 0x70, 0x69, 0x6C, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2E, 0x31, 0x00,
|
||||
0x49, 0x53, 0x47, 0x4E, 0x28, 0x01, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x03, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x03, 0x03, 0x00, 0x00, 0x1F, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x03, 0x03, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E,
|
||||
0x00, 0x43, 0x4F, 0x4C, 0x4F, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4F,
|
||||
0x4F, 0x52, 0x44, 0x00, 0x4F, 0x53, 0x47, 0x4E, 0x2C, 0x01, 0x00, 0x00,
|
||||
0x0B, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x22, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x00, 0x00, 0x22, 0x01, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x0C, 0x03, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x05, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x09, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5F, 0x50,
|
||||
0x4F, 0x53, 0x49, 0x54, 0x49, 0x4F, 0x4E, 0x00, 0x43, 0x4F, 0x4C, 0x4F,
|
||||
0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4F, 0x4F, 0x52, 0x44, 0x00, 0xAB,
|
||||
0x53, 0x48, 0x44, 0x52, 0x88, 0x02, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00,
|
||||
0xA2, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8E, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x03,
|
||||
0xF2, 0x10, 0x10, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xC2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x65, 0x00, 0x00, 0x03, 0xF2, 0x20, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08,
|
||||
0xF2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0A, 0xF2, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x46, 0x0E, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0E, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x8E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0xF2, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x38, 0x00, 0x00, 0x0A, 0xF2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x46, 0x0E, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
|
||||
0x81, 0x80, 0x80, 0x3B, 0x81, 0x80, 0x80, 0x3B, 0x81, 0x80, 0x80, 0x3B,
|
||||
0x81, 0x80, 0x80, 0x3B, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x36, 0x00, 0x00, 0x05, 0xC2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x06, 0x14, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xF2, 0x20, 0x10, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x36, 0x00, 0x00, 0x05, 0xF2, 0x20, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x46, 0x1E, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xF2, 0x20, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x36, 0x00, 0x00, 0x05, 0xF2, 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x46, 0x1E, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
|
||||
0xF2, 0x20, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x1E, 0x10, 0x00,
|
||||
0x0A, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54,
|
||||
0x74, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
};
|
||||
unsigned int v2f_c4f_t2f_t2f_d28f_fxc_len = 1884;
|
||||
@@ -1,574 +0,0 @@
|
||||
cbuffer Uniforms : register(b0)
|
||||
{
|
||||
float4 State;
|
||||
matrix Transform;
|
||||
float4 Scalar4[2];
|
||||
float4 Vector[8];
|
||||
uint ClipSize;
|
||||
matrix Clip[8];
|
||||
};
|
||||
|
||||
float Scalar(int i) { if (i < 4) return Scalar4[0][i]; else return Scalar4[1][i - 4]; }
|
||||
|
||||
Texture2D texture0 : register(t0);
|
||||
Texture2D texture1 : register(t1);
|
||||
SamplerState sampler0 : register(s0);
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
float4 Data0 : COLOR1;
|
||||
float4 Data1 : COLOR2;
|
||||
float4 Data2 : COLOR3;
|
||||
float4 Data3 : COLOR4;
|
||||
float4 Data4 : COLOR5;
|
||||
float4 Data5 : COLOR6;
|
||||
float4 Data6 : COLOR7;
|
||||
float2 ObjectCoord : TEXCOORD1;
|
||||
};
|
||||
|
||||
uint FillType(VS_OUTPUT input) { return uint(input.Data0.x + 0.5); }
|
||||
float4 TileRectUV() { return Vector[0]; }
|
||||
float2 TileSize() { return Vector[1].zw; }
|
||||
float2 PatternTransformA() { return Vector[2].xy; }
|
||||
float2 PatternTransformB() { return Vector[2].zw; }
|
||||
float2 PatternTransformC() { return Vector[3].xy; }
|
||||
uint Gradient_NumStops(VS_OUTPUT input) { return uint(input.Data0.y + 0.5); }
|
||||
bool Gradient_IsRadial(VS_OUTPUT input) { return bool(uint(input.Data0.z + 0.5)); }
|
||||
float Gradient_R0(VS_OUTPUT input) { return input.Data1.x; }
|
||||
float Gradient_R1(VS_OUTPUT input) { return input.Data1.y; }
|
||||
float2 Gradient_P0(VS_OUTPUT input) { return input.Data1.xy; }
|
||||
float2 Gradient_P1(VS_OUTPUT input) { return input.Data1.zw; }
|
||||
float SDFMaxDistance(VS_OUTPUT input) { return input.Data0.y; }
|
||||
|
||||
struct GradientStop { float percent; float4 color; };
|
||||
|
||||
GradientStop GetGradientStop(VS_OUTPUT input, uint offset) {
|
||||
GradientStop result;
|
||||
if (offset < 4) {
|
||||
result.percent = input.Data2[offset];
|
||||
if (offset == 0)
|
||||
result.color = input.Data3;
|
||||
else if (offset == 1)
|
||||
result.color = input.Data4;
|
||||
else if (offset == 2)
|
||||
result.color = input.Data5;
|
||||
else if (offset == 3)
|
||||
result.color = input.Data6;
|
||||
} else {
|
||||
result.percent = Scalar(offset - 4);
|
||||
result.color = Vector[offset - 4];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define AA_WIDTH 0.354
|
||||
|
||||
float antialias(in float d, in float width, in float median) {
|
||||
return smoothstep(median - width, median + width, d);
|
||||
}
|
||||
|
||||
float sdRect(float2 p, float2 size) {
|
||||
float2 d = abs(p) - size;
|
||||
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
|
||||
}
|
||||
|
||||
// The below function "sdEllipse" is MIT licensed with following text:
|
||||
//
|
||||
// The MIT License
|
||||
// Copyright 2013 Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions: The above copyright
|
||||
// notice and this permission notice shall be included in all copies or substantial
|
||||
// portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
float sdEllipse(float2 p, float2 ab) {
|
||||
if (abs(ab.x - ab.y) < 0.1)
|
||||
return length(p) - ab.x;
|
||||
|
||||
p = abs(p); if (p.x > p.y) { p = p.yx; ab = ab.yx; }
|
||||
|
||||
float l = ab.y*ab.y - ab.x*ab.x;
|
||||
|
||||
float m = ab.x*p.x / l;
|
||||
float n = ab.y*p.y / l;
|
||||
float m2 = m*m;
|
||||
float n2 = n*n;
|
||||
|
||||
float c = (m2 + n2 - 1.0) / 3.0;
|
||||
float c3 = c*c*c;
|
||||
|
||||
float q = c3 + m2*n2*2.0;
|
||||
float d = c3 + m2*n2;
|
||||
float g = m + m*n2;
|
||||
|
||||
float co;
|
||||
|
||||
if (d < 0.0) {
|
||||
float p = acos(q / c3) / 3.0;
|
||||
float s = cos(p);
|
||||
float t = sin(p)*sqrt(3.0);
|
||||
float rx = sqrt(-c*(s + t + 2.0) + m2);
|
||||
float ry = sqrt(-c*(s - t + 2.0) + m2);
|
||||
co = (ry + sign(l)*rx + abs(g) / (rx*ry) - m) / 2.0;
|
||||
} else {
|
||||
float h = 2.0*m*n*sqrt(d);
|
||||
float s = sign(q + h)*pow(abs(q + h), 1.0 / 3.0);
|
||||
float u = sign(q - h)*pow(abs(q - h), 1.0 / 3.0);
|
||||
float rx = -s - u - c*4.0 + 2.0*m2;
|
||||
float ry = (s - u)*sqrt(3.0);
|
||||
float rm = sqrt(rx*rx + ry*ry);
|
||||
float p = ry / sqrt(rm - rx);
|
||||
co = (p + 2.0*g / rm - m) / 2.0;
|
||||
}
|
||||
|
||||
float si = sqrt(1.0 - co*co);
|
||||
|
||||
float2 r = float2(ab.x*co, ab.y*si);
|
||||
|
||||
return length(r - p) * sign(p.y - r.y);
|
||||
}
|
||||
|
||||
float sdRoundRect(float2 p, float2 size, float4 rx, float4 ry) {
|
||||
size *= 0.5;
|
||||
float2 corner;
|
||||
|
||||
corner = float2(-size.x + rx.x, -size.y + ry.x); // Top-Left
|
||||
float2 local = p - corner;
|
||||
if (dot(rx.x, ry.x) > 0.0 && p.x < corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.x, ry.x));
|
||||
|
||||
corner = float2(size.x - rx.y, -size.y + ry.y); // Top-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.y, ry.y) > 0.0 && p.x >= corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.y, ry.y));
|
||||
|
||||
corner = float2(size.x - rx.z, size.y - ry.z); // Bottom-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.z, ry.z) > 0.0 && p.x >= corner.x && p.y >= corner.y)
|
||||
return sdEllipse(local, float2(rx.z, ry.z));
|
||||
|
||||
corner = float2(-size.x + rx.w, size.y - ry.w); // Bottom-Left
|
||||
local = p - corner;
|
||||
if (dot(rx.w, ry.w) > 0.0 && p.x < corner.x && p.y > corner.y)
|
||||
return sdEllipse(local, float2(rx.w, ry.w));
|
||||
|
||||
return sdRect(p, size);
|
||||
}
|
||||
|
||||
float4 fillSolid(VS_OUTPUT input) {
|
||||
return input.Color;
|
||||
}
|
||||
|
||||
float4 fillImage(VS_OUTPUT input) {
|
||||
return texture0.Sample(sampler0, input.TexCoord) * input.Color;
|
||||
}
|
||||
|
||||
float2 transformAffine(float2 val, float2 a, float2 b, float2 c) {
|
||||
return val.x * a + val.y * b + c;
|
||||
}
|
||||
|
||||
float4 fillPatternImage(VS_OUTPUT input) {
|
||||
float4 tile_rect_uv = TileRectUV();
|
||||
float2 tile_size = TileSize();
|
||||
|
||||
float2 p = input.ObjectCoord;
|
||||
|
||||
// Apply the affine matrix
|
||||
float2 transformed_coords = transformAffine(p,
|
||||
PatternTransformA(), PatternTransformB(), PatternTransformC());
|
||||
|
||||
// Convert back to uv coordinate space
|
||||
transformed_coords /= tile_size;
|
||||
|
||||
// Wrap UVs to [0.0, 1.0] so texture repeats properly
|
||||
float2 uv = frac(transformed_coords);
|
||||
|
||||
// Clip to tile-rect UV
|
||||
uv *= tile_rect_uv.zw - tile_rect_uv.xy;
|
||||
uv += tile_rect_uv.xy;
|
||||
|
||||
return texture0.Sample(sampler0, uv) * input.Color;
|
||||
}
|
||||
|
||||
// Gradient noise from Jorge Jimenez's presentation:
|
||||
// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
||||
float gradientNoise(in float2 uv)
|
||||
{
|
||||
const float3 magic = float3(0.06711056, 0.00583715, 52.9829189);
|
||||
return frac(magic.z * frac(dot(uv, magic.xy)));
|
||||
}
|
||||
|
||||
float ramp(in float inMin, in float inMax, in float val)
|
||||
{
|
||||
return clamp((val - inMin) / (inMax - inMin), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float4 fillPatternGradient(VS_OUTPUT input) {
|
||||
float num_stops = Gradient_NumStops(input);
|
||||
bool is_radial = Gradient_IsRadial(input);
|
||||
float2 p0 = Gradient_P0(input);
|
||||
float2 p1 = Gradient_P1(input);
|
||||
float4 out_Color = float4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
float t = 0.0;
|
||||
if (is_radial) {
|
||||
float r0 = p1.x;
|
||||
float r1 = p1.y;
|
||||
t = distance(input.TexCoord, p0);
|
||||
float rDelta = r1 - r0;
|
||||
t = saturate((t / rDelta) - (r0 / rDelta));
|
||||
} else {
|
||||
float2 V = p1 - p0;
|
||||
t = saturate(dot(input.TexCoord - p0, V) / dot(V, V));
|
||||
}
|
||||
|
||||
GradientStop stop0 = GetGradientStop(input, 0u);
|
||||
GradientStop stop1 = GetGradientStop(input, 1u);
|
||||
|
||||
out_Color = lerp(stop0.color, stop1.color, ramp(stop0.percent, stop1.percent, t));
|
||||
if (num_stops > 2) {
|
||||
GradientStop stop2 = GetGradientStop(input, 2u);
|
||||
out_Color = lerp(out_Color, stop2.color, ramp(stop1.percent, stop2.percent, t));
|
||||
if (num_stops > 3) {
|
||||
GradientStop stop3 = GetGradientStop(input, 3u);
|
||||
out_Color = lerp(out_Color, stop3.color, ramp(stop2.percent, stop3.percent, t));
|
||||
if (num_stops > 4) {
|
||||
GradientStop stop4 = GetGradientStop(input, 4u);
|
||||
out_Color = lerp(out_Color, stop4.color, ramp(stop3.percent, stop4.percent, t));
|
||||
if (num_stops > 5) {
|
||||
GradientStop stop5 = GetGradientStop(input, 5u);
|
||||
out_Color = lerp(out_Color, stop5.color, ramp(stop4.percent, stop5.percent, t));
|
||||
if (num_stops > 6) {
|
||||
GradientStop stop6 = GetGradientStop(input, 6u);
|
||||
out_Color = lerp(out_Color, stop6.color, ramp(stop5.percent, stop6.percent, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return float4(out_Color.rgb, out_Color.a);
|
||||
}
|
||||
|
||||
void Unpack(float4 x, out float4 a, out float4 b) {
|
||||
const float s = 65536.0;
|
||||
a = floor(x / s);
|
||||
b = floor(x - a * s);
|
||||
}
|
||||
|
||||
float antialias2(float d) {
|
||||
return smoothstep(-0.6180469, 0.6180469, d/fwidth(d));
|
||||
}
|
||||
|
||||
// Returns two values:
|
||||
// [0] = distance of p to line segment.
|
||||
// [1] = closest t on line segment, clamped to [0, 1]
|
||||
float2 sdSegment(in float2 p, in float2 a, in float2 b)
|
||||
{
|
||||
float2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return float2(length(pa - ba * t), t);
|
||||
}
|
||||
|
||||
float testCross(float2 a, float2 b, float2 p) {
|
||||
return (b.y - a.y) * (p.x - a.x) - (b.x - a.x) * (p.y - a.y);
|
||||
}
|
||||
|
||||
float sdLine(in float2 a, in float2 b, in float2 p)
|
||||
{
|
||||
float2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return length(pa - ba*t) * sign(testCross(a, b, p));
|
||||
}
|
||||
|
||||
|
||||
float4 blend(float4 src, float4 dest) {
|
||||
float4 result;
|
||||
result.rgb = src.rgb + dest.rgb * (1.0 - src.a);
|
||||
result.a = src.a + dest.a * (1.0 - src.a);
|
||||
return result;
|
||||
}
|
||||
|
||||
float innerStroke(float stroke_width, float d) {
|
||||
return min(antialias(-d, AA_WIDTH, 0.0), 1.0 - antialias(-d, AA_WIDTH, stroke_width));
|
||||
}
|
||||
|
||||
float4 fillRoundedRect(VS_OUTPUT input) {
|
||||
float2 p = input.TexCoord;
|
||||
float2 size = input.Data0.zw;
|
||||
p = (p - 0.5) * size;
|
||||
float d = sdRoundRect(p, size, input.Data1, input.Data2);
|
||||
|
||||
// Fill background
|
||||
float alpha = antialias(-d, AA_WIDTH, 0.0) * input.Color.a;
|
||||
float4 outColor = float4(input.Color.rgb * alpha, alpha);
|
||||
|
||||
// Draw stroke
|
||||
float stroke_width = input.Data3.x;
|
||||
float4 stroke_color = input.Data4;
|
||||
|
||||
if (stroke_width > 0.0) {
|
||||
alpha = innerStroke(stroke_width, d);
|
||||
alpha *= stroke_color.a;
|
||||
float4 stroke = float4(stroke_color.rgb * alpha, alpha);
|
||||
outColor = blend(stroke, outColor);
|
||||
}
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
float4 fillBoxShadow(VS_OUTPUT input) {
|
||||
float2 p = input.ObjectCoord;
|
||||
bool inset = bool(uint(input.Data0.y + 0.5));
|
||||
float radius = input.Data0.z;
|
||||
float2 origin = input.Data1.xy;
|
||||
float2 size = input.Data1.zw;
|
||||
float2 clip_origin = input.Data4.xy;
|
||||
float2 clip_size = input.Data4.zw;
|
||||
|
||||
float sdClip = sdRoundRect(p - clip_origin, clip_size, input.Data5, input.Data6);
|
||||
float sdRect = sdRoundRect(p - origin, size, input.Data2, input.Data3);
|
||||
|
||||
float clip = inset ? -sdRect : sdClip;
|
||||
float d = inset ? -sdClip : sdRect;
|
||||
|
||||
if (clip < 0.0) {
|
||||
discard;
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float alpha = radius >= 1.0? pow(antialias(-d, radius * 2 + 0.2, 0.0), 1.9) * 3.3 / pow(radius * 1.2, 0.15) :
|
||||
antialias(-d, AA_WIDTH, inset ? -1.0 : 1.0);
|
||||
|
||||
alpha = clamp(alpha, 0.0, 1.0) * input.Color.a;
|
||||
return float4(input.Color.rgb * alpha, alpha);
|
||||
}
|
||||
|
||||
float3 blendOverlay(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendColorDodge(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 1.0) ? src[i] : min(dest[i] / (1.0 - src[i]), 1.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendColorBurn(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 0.0) ? src[i] : max((1.0 - ((1.0 - dest[i]) / src[i])), 0.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendHardLight(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendSoftLight(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] < 0.5) ? (2.0 * dest[i] * src[i] + dest[i] * dest[i] * (1.0 - 2.0 * src[i])) : (sqrt(dest[i]) * (2.0 * src[i] - 1.0) + 2.0 * dest[i] * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 rgb2hsl( float3 col )
|
||||
{
|
||||
const float eps = 0.0000001;
|
||||
float minc = min( col.r, min(col.g, col.b) );
|
||||
float maxc = max( col.r, max(col.g, col.b) );
|
||||
float3 mask = step(col.grr,col.rgb) * step(col.bbg,col.rgb);
|
||||
float3 h = mask * (float3(0.0,2.0,4.0) + (col.gbr-col.brg)/(maxc-minc + eps)) / 6.0;
|
||||
return float3(frac( 1.0 + h.x + h.y + h.z ), // H
|
||||
(maxc-minc)/(1.0-abs(minc+maxc-1.0) + eps), // S
|
||||
(minc+maxc)*0.5 ); // L
|
||||
}
|
||||
|
||||
float3 hsl2rgb( float3 c )
|
||||
{
|
||||
float3 rgb = clamp( abs(fmod(c.x*6.0+float3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
|
||||
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
|
||||
}
|
||||
|
||||
float3 blendHue(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(rgb2hsl(src).r, baseHSL.g, baseHSL.b));
|
||||
}
|
||||
|
||||
float3 blendSaturation(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(baseHSL.r, rgb2hsl(src).g, baseHSL.b));
|
||||
}
|
||||
|
||||
float3 blendColor(float3 src, float3 dest) {
|
||||
float3 blendHSL = rgb2hsl(src);
|
||||
return hsl2rgb(float3(blendHSL.r, blendHSL.g, rgb2hsl(dest).b));
|
||||
}
|
||||
|
||||
float3 blendLuminosity(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(baseHSL.r, baseHSL.g, rgb2hsl(src).b));
|
||||
}
|
||||
|
||||
float4 fillBlend(VS_OUTPUT input) {
|
||||
const uint BlendOp_Clear = 0u;
|
||||
const uint BlendOp_Source = 1u;
|
||||
const uint BlendOp_Over = 2u;
|
||||
const uint BlendOp_In = 3u;
|
||||
const uint BlendOp_Out = 4u;
|
||||
const uint BlendOp_Atop = 5u;
|
||||
const uint BlendOp_DestOver = 6u;
|
||||
const uint BlendOp_DestIn = 7u;
|
||||
const uint BlendOp_DestOut = 8u;
|
||||
const uint BlendOp_DestAtop = 9u;
|
||||
const uint BlendOp_XOR = 10u;
|
||||
const uint BlendOp_Darken = 11u;
|
||||
const uint BlendOp_Add = 12u;
|
||||
const uint BlendOp_Difference = 13u;
|
||||
const uint BlendOp_Multiply = 14u;
|
||||
const uint BlendOp_Screen = 15u;
|
||||
const uint BlendOp_Overlay = 16u;
|
||||
const uint BlendOp_Lighten = 17u;
|
||||
const uint BlendOp_ColorDodge = 18u;
|
||||
const uint BlendOp_ColorBurn = 19u;
|
||||
const uint BlendOp_HardLight = 20u;
|
||||
const uint BlendOp_SoftLight = 21u;
|
||||
const uint BlendOp_Exclusion = 22u;
|
||||
const uint BlendOp_Hue = 23u;
|
||||
const uint BlendOp_Saturation = 24u;
|
||||
const uint BlendOp_Color = 25u;
|
||||
const uint BlendOp_Luminosity = 26u;
|
||||
|
||||
float4 src = fillImage(input);
|
||||
float4 dest = texture1.Sample(sampler0, input.ObjectCoord);
|
||||
|
||||
switch(uint(input.Data0.y + 0.5))
|
||||
{
|
||||
case BlendOp_Clear: return float4(0.0, 0.0, 0.0, 0.0);
|
||||
case BlendOp_Source: return src;
|
||||
case BlendOp_Over: return src + dest * (1.0 - src.a);
|
||||
case BlendOp_In: return src * dest.a;
|
||||
case BlendOp_Out: return src * (1.0 - dest.a);
|
||||
case BlendOp_Atop: return src * dest.a + dest * (1.0 - src.a);
|
||||
case BlendOp_DestOver: return src * (1.0 - dest.a) + dest;
|
||||
case BlendOp_DestIn: return dest * src.a;
|
||||
case BlendOp_DestOut: return dest * (1.0 - src.a);
|
||||
case BlendOp_DestAtop: return src * (1.0 - dest.a) + dest * src.a;
|
||||
case BlendOp_XOR: return saturate(src * (1.0 - dest.a) + dest * (1.0 - src.a));
|
||||
case BlendOp_Darken: return float4(min(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Add: return saturate(src + dest);
|
||||
case BlendOp_Difference: return float4(abs(dest.rgb - src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Multiply: return float4(src.rgb * dest.rgb * src.a, dest.a * src.a);
|
||||
case BlendOp_Screen: return float4((1.0 - ((1.0 - dest.rgb) * (1.0 - src.rgb))) * src.a, dest.a * src.a);
|
||||
case BlendOp_Overlay: return float4(blendOverlay(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Lighten: return float4(max(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorDodge: return float4(blendColorDodge(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorBurn: return float4(blendColorBurn(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_HardLight: return float4(blendOverlay(dest.rgb, src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_SoftLight: return float4(blendSoftLight(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Exclusion: return float4((dest.rgb + src.rgb - 2.0 * dest.rgb * src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Hue: return float4(blendHue(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Saturation: return float4(blendSaturation(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Color: return float4(blendColor(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Luminosity: return float4(blendLuminosity(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
float4 fillMask(VS_OUTPUT input) {
|
||||
float4 col = fillImage(input);
|
||||
float alpha = texture1.Sample(sampler0, input.ObjectCoord).a;
|
||||
return float4(col.rgb * alpha, col.a * alpha);
|
||||
}
|
||||
|
||||
float4 GetCol(in matrix m, uint i) { return float4(m[0][i], m[1][i], m[2][i], m[3][i]); }
|
||||
|
||||
#define VISUALIZE_CLIP 0
|
||||
|
||||
void applyClip(VS_OUTPUT input, inout float4 outColor) {
|
||||
for (uint i = 0; i < ClipSize; i++) {
|
||||
matrix data = Clip[i];
|
||||
float2 origin = GetCol(data, 0).xy;
|
||||
float2 size = GetCol(data, 0).zw;
|
||||
float4 radii_x, radii_y;
|
||||
Unpack(GetCol(data, 1), radii_x, radii_y);
|
||||
bool inverse = bool(GetCol(data, 3).z);
|
||||
|
||||
float2 p = input.ObjectCoord;
|
||||
p = transformAffine(p, GetCol(data, 2).xy, GetCol(data, 2).zw, GetCol(data, 3).xy);
|
||||
p -= origin;
|
||||
float d_clip = sdRoundRect(p, size, radii_x, radii_y) * (inverse ? -1.0 : 1.0);
|
||||
|
||||
#if VISUALIZE_CLIP
|
||||
if (abs(d_clip) < 3.0)
|
||||
outColor = float4(0.9, 1.0, 0.0, 1.0);
|
||||
#else
|
||||
float alpha = antialias2(-d_clip);
|
||||
outColor = float4(outColor.rgb * alpha, outColor.a * alpha);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
float4 fillGlyph(VS_OUTPUT input) {
|
||||
float alpha = texture0.Sample(sampler0, input.TexCoord).a * input.Color.a;
|
||||
float fill_color_luma = input.Data0.y;
|
||||
float corrected_alpha = texture1.Sample(sampler0, float2(alpha, fill_color_luma)).a;
|
||||
|
||||
return float4(input.Color.rgb * corrected_alpha, corrected_alpha);
|
||||
}
|
||||
|
||||
float4 PS(VS_OUTPUT input) : SV_Target
|
||||
{
|
||||
const uint FillType_Solid = 0u;
|
||||
const uint FillType_Image = 1u;
|
||||
const uint FillType_Pattern_Image = 2u;
|
||||
const uint FillType_Pattern_Gradient = 3u;
|
||||
const uint FillType_RESERVED_1 = 4u;
|
||||
const uint FillType_RESERVED_2 = 5u;
|
||||
const uint FillType_RESERVED_3 = 6u;
|
||||
const uint FillType_Rounded_Rect = 7u;
|
||||
const uint FillType_Box_Shadow = 8u;
|
||||
const uint FillType_Blend = 9u;
|
||||
const uint FillType_Mask = 10u;
|
||||
const uint FillType_Glyph = 11u;
|
||||
|
||||
float4 outColor = input.Color;
|
||||
|
||||
switch (FillType(input))
|
||||
{
|
||||
case FillType_Solid: outColor = fillSolid(input); break;
|
||||
case FillType_Image: outColor = fillImage(input); break;
|
||||
case FillType_Pattern_Image: outColor = fillPatternImage(input); break;
|
||||
case FillType_Pattern_Gradient: outColor = fillPatternGradient(input); break;
|
||||
case FillType_Rounded_Rect: outColor = fillRoundedRect(input); break;
|
||||
case FillType_Box_Shadow: outColor = fillBoxShadow(input); break;
|
||||
case FillType_Blend: outColor = fillBlend(input); break;
|
||||
case FillType_Mask: outColor = fillMask(input); break;
|
||||
case FillType_Glyph: outColor = fillGlyph(input); break;
|
||||
}
|
||||
|
||||
applyClip(input, outColor);
|
||||
|
||||
return outColor;
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
cbuffer Uniforms : register(b0)
|
||||
{
|
||||
float4 State;
|
||||
matrix Transform;
|
||||
float4 Scalar4[2];
|
||||
float4 Vector[8];
|
||||
uint ClipSize;
|
||||
matrix Clip[8];
|
||||
};
|
||||
|
||||
float Time() { return State[0]; }
|
||||
float ScreenWidth() { return State[1]; }
|
||||
float ScreenHeight() { return State[2]; }
|
||||
float ScreenScale() { return State[3]; }
|
||||
float Scalar(int i) { if (i < 4) return Scalar4[0][i]; else return Scalar4[1][i - 4]; }
|
||||
|
||||
Texture2D texture0 : register(t0);
|
||||
SamplerState sampler0 : register(s0);
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 ObjectCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float sdRect(float2 p, float2 size) {
|
||||
float2 d = abs(p) - size;
|
||||
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
|
||||
}
|
||||
|
||||
// The below function "sdEllipse" is MIT licensed with following text:
|
||||
//
|
||||
// The MIT License
|
||||
// Copyright 2013 Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions: The above copyright
|
||||
// notice and this permission notice shall be included in all copies or substantial
|
||||
// portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
float sdEllipse(float2 p, float2 ab) {
|
||||
if (abs(ab.x - ab.y) < 0.1)
|
||||
return length(p) - ab.x;
|
||||
|
||||
p = abs(p); if (p.x > p.y) { p = p.yx; ab = ab.yx; }
|
||||
|
||||
float l = ab.y*ab.y - ab.x*ab.x;
|
||||
|
||||
float m = ab.x*p.x / l;
|
||||
float n = ab.y*p.y / l;
|
||||
float m2 = m*m;
|
||||
float n2 = n*n;
|
||||
|
||||
float c = (m2 + n2 - 1.0) / 3.0;
|
||||
float c3 = c*c*c;
|
||||
|
||||
float q = c3 + m2*n2*2.0;
|
||||
float d = c3 + m2*n2;
|
||||
float g = m + m*n2;
|
||||
|
||||
float co;
|
||||
|
||||
if (d < 0.0) {
|
||||
float p = acos(q / c3) / 3.0;
|
||||
float s = cos(p);
|
||||
float t = sin(p)*sqrt(3.0);
|
||||
float rx = sqrt(-c*(s + t + 2.0) + m2);
|
||||
float ry = sqrt(-c*(s - t + 2.0) + m2);
|
||||
co = (ry + sign(l)*rx + abs(g) / (rx*ry) - m) / 2.0;
|
||||
} else {
|
||||
float h = 2.0*m*n*sqrt(d);
|
||||
float s = sign(q + h)*pow(abs(q + h), 1.0 / 3.0);
|
||||
float u = sign(q - h)*pow(abs(q - h), 1.0 / 3.0);
|
||||
float rx = -s - u - c*4.0 + 2.0*m2;
|
||||
float ry = (s - u)*sqrt(3.0);
|
||||
float rm = sqrt(rx*rx + ry*ry);
|
||||
float p = ry / sqrt(rm - rx);
|
||||
co = (p + 2.0*g / rm - m) / 2.0;
|
||||
}
|
||||
|
||||
float si = sqrt(1.0 - co*co);
|
||||
|
||||
float2 r = float2(ab.x*co, ab.y*si);
|
||||
|
||||
return length(r - p) * sign(p.y - r.y);
|
||||
}
|
||||
|
||||
// 1.0 = No softening, 0.1 = Max softening
|
||||
#define SOFTEN_ELLIPSE 1.0
|
||||
|
||||
float sdRoundRect(float2 p, float2 size, float4 rx, float4 ry) {
|
||||
size *= 0.5;
|
||||
float2 corner;
|
||||
|
||||
corner = float2(-size.x + rx.x, -size.y + ry.x); // Top-Left
|
||||
float2 local = p - corner;
|
||||
if (dot(rx.x, ry.x) > 0.0 && p.x < corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.x, ry.x)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(size.x - rx.y, -size.y + ry.y); // Top-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.y, ry.y) > 0.0 && p.x >= corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.y, ry.y)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(size.x - rx.z, size.y - ry.z); // Bottom-Right
|
||||
local = p - corner;
|
||||
if (dot(rx.z, ry.z) > 0.0 && p.x >= corner.x && p.y >= corner.y)
|
||||
return sdEllipse(local, float2(rx.z, ry.z)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(-size.x + rx.w, size.y - ry.w); // Bottom-Left
|
||||
local = p - corner;
|
||||
if (dot(rx.w, ry.w) > 0.0 && p.x < corner.x && p.y > corner.y)
|
||||
return sdEllipse(local, float2(rx.w, ry.w)) * SOFTEN_ELLIPSE;
|
||||
|
||||
return sdRect(p, size);
|
||||
}
|
||||
|
||||
float2 transformAffine(float2 val, float2 a, float2 b, float2 c) {
|
||||
return val.x * a + val.y * b + c;
|
||||
}
|
||||
|
||||
void Unpack(float4 x, out float4 a, out float4 b) {
|
||||
const float s = 65536.0;
|
||||
a = floor(x / s);
|
||||
b = floor(x - a * s);
|
||||
}
|
||||
|
||||
float antialias2(float d) {
|
||||
return smoothstep(-0.6180469, 0.6180469, d/fwidth(d));
|
||||
}
|
||||
|
||||
float4 GetCol(in matrix m, uint i) { return float4(m[0][i], m[1][i], m[2][i], m[3][i]); }
|
||||
|
||||
#define VISUALIZE_CLIP 0
|
||||
|
||||
void applyClip(VS_OUTPUT input, inout float4 outColor) {
|
||||
for (uint i = 0; i < ClipSize; i++) {
|
||||
matrix data = Clip[i];
|
||||
float2 origin = GetCol(data, 0).xy;
|
||||
float2 size = GetCol(data, 0).zw;
|
||||
float4 radii_x, radii_y;
|
||||
Unpack(GetCol(data, 1), radii_x, radii_y);
|
||||
bool inverse = bool(GetCol(data, 3).z);
|
||||
|
||||
float2 p = input.ObjectCoord;
|
||||
p = transformAffine(p, GetCol(data, 2).xy, GetCol(data, 2).zw, GetCol(data, 3).xy);
|
||||
p -= origin;
|
||||
float d_clip = sdRoundRect(p, size, radii_x, radii_y) * (inverse ? -1.0 : 1.0);
|
||||
|
||||
#if VISUALIZE_CLIP
|
||||
if (abs(d_clip) < 3.0)
|
||||
outColor = float4(0.9, 1.0, 0.0, 1.0);
|
||||
#else
|
||||
float alpha = antialias2(-d_clip);
|
||||
outColor = float4(outColor.rgb * alpha, outColor.a * alpha);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
float4 PS(VS_OUTPUT input) : SV_Target
|
||||
{
|
||||
float4 outColor = input.Color;
|
||||
applyClip(input, outColor);
|
||||
|
||||
return outColor;
|
||||
}
|
||||
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
set PATH=%PATH%;%CD%
|
||||
cd ../bin
|
||||
del *.h
|
||||
fxc /T ps_4_0 /Fo fill.fxc ../ps/fill.hlsl /E PS
|
||||
fxc /T ps_4_0 /Fo fill_path.fxc ../ps/fill_path.hlsl /E PS
|
||||
fxc /T vs_4_0 /Fo v2f_c4f_t2f.fxc ../vs/v2f_c4f_t2f.hlsl /E VS
|
||||
fxc /T vs_4_0 /Fo v2f_c4f_t2f_t2f_d28f.fxc ../vs/v2f_c4f_t2f_t2f_d28f.hlsl /E VS
|
||||
bin2header fill.fxc
|
||||
bin2header fill_path.fxc
|
||||
bin2header v2f_c4f_t2f.fxc
|
||||
bin2header v2f_c4f_t2f_t2f_d28f.fxc
|
||||
del *.fxc
|
||||
Binary file not shown.
@@ -1,32 +0,0 @@
|
||||
cbuffer Uniforms : register(b0)
|
||||
{
|
||||
float4 State;
|
||||
matrix Transform;
|
||||
float4 Scalar4[2];
|
||||
float4 Vector[8];
|
||||
uint ClipSize;
|
||||
matrix Clip[8];
|
||||
};
|
||||
|
||||
float ScreenWidth() { return State[1]; }
|
||||
float ScreenHeight() { return State[2]; }
|
||||
float Scalar(int i) { if (i < 4) return Scalar4[0][i]; else return Scalar4[1][i - 4]; }
|
||||
float4 sRGBToLinear(float4 val) { return float4(val.xyz * (val.xyz * (val.xyz * 0.305306011 + 0.682171111) + 0.012522878), val.w); }
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 ObjectCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VS_OUTPUT VS(float2 Position : POSITION,
|
||||
uint4 Color : COLOR0,
|
||||
float2 ObjCoord : TEXCOORD0)
|
||||
{
|
||||
VS_OUTPUT output;
|
||||
output.Position = mul(Transform, float4(Position, 0.0, 1.0));
|
||||
output.Color = float4(Color) / 255.0;
|
||||
output.ObjectCoord = ObjCoord;
|
||||
return output;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
cbuffer Uniforms : register(b0)
|
||||
{
|
||||
float4 State;
|
||||
matrix Transform;
|
||||
float4 Scalar4[2];
|
||||
float4 Vector[8];
|
||||
uint ClipSize;
|
||||
matrix Clip[8];
|
||||
};
|
||||
|
||||
float4 sRGBToLinear(float4 val) { return float4(val.xyz * (val.xyz * (val.xyz * 0.305306011 + 0.682171111) + 0.012522878), val.w); }
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
float4 Data0 : COLOR1;
|
||||
float4 Data1 : COLOR2;
|
||||
float4 Data2 : COLOR3;
|
||||
float4 Data3 : COLOR4;
|
||||
float4 Data4 : COLOR5;
|
||||
float4 Data5 : COLOR6;
|
||||
float4 Data6 : COLOR7;
|
||||
float2 ObjectCoord : TEXCOORD1;
|
||||
};
|
||||
|
||||
VS_OUTPUT VS(float2 Position : POSITION,
|
||||
uint4 Color : COLOR0,
|
||||
float2 TexCoord : TEXCOORD0,
|
||||
float2 ObjCoord : TEXCOORD1,
|
||||
float4 Data0 : COLOR1,
|
||||
float4 Data1 : COLOR2,
|
||||
float4 Data2 : COLOR3,
|
||||
float4 Data3 : COLOR4,
|
||||
float4 Data4 : COLOR5,
|
||||
float4 Data5 : COLOR6,
|
||||
float4 Data6 : COLOR7)
|
||||
{
|
||||
VS_OUTPUT output;
|
||||
output.ObjectCoord = ObjCoord;
|
||||
output.Position = mul(Transform, float4(Position, 0.0, 1.0));
|
||||
output.Color = float4(Color) / 255.0;
|
||||
output.TexCoord = TexCoord;
|
||||
output.Data0 = Data0;
|
||||
output.Data1 = Data1;
|
||||
output.Data2 = Data2;
|
||||
output.Data3 = Data3;
|
||||
output.Data4 = Data4;
|
||||
output.Data5 = Data5;
|
||||
output.Data6 = Data6;
|
||||
return output;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,52 +0,0 @@
|
||||
#ifndef ShaderTypes_h
|
||||
#define ShaderTypes_h
|
||||
|
||||
#include <simd/simd.h>
|
||||
|
||||
typedef enum VertexIndex
|
||||
{
|
||||
VertexIndex_Vertices = 0,
|
||||
VertexIndex_Uniforms = 1,
|
||||
} VertexInputIndex;
|
||||
|
||||
typedef enum FragmentIndex
|
||||
{
|
||||
FragmentIndex_Uniforms = 0,
|
||||
} FragmentIndex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simd::float4 State;
|
||||
simd::float4x4 Transform;
|
||||
simd::float4 Scalar4[2];
|
||||
simd::float4 Vector[8];
|
||||
unsigned int ClipSize;
|
||||
simd::float4x4 Clip[8];
|
||||
} Uniforms;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
simd::float2 Position;
|
||||
simd::uchar4 Color;
|
||||
simd::float2 TexCoord;
|
||||
simd::float2 ObjCoord;
|
||||
simd::float4 Data0;
|
||||
simd::float4 Data1;
|
||||
simd::float4 Data2;
|
||||
simd::float4 Data3;
|
||||
simd::float4 Data4;
|
||||
simd::float4 Data5;
|
||||
simd::float4 Data6;
|
||||
} Vertex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simd::float2 Position;
|
||||
simd::uchar4 Color;
|
||||
simd::float2 ObjCoord;
|
||||
} PathVertex;
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif /* ShaderTypes_h */
|
||||
@@ -1,730 +0,0 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
// Include header shared between this Metal shader code and C code executing Metal API commands
|
||||
#ifndef ShaderTypes_h
|
||||
#define ShaderTypes_h
|
||||
|
||||
typedef enum VertexIndex
|
||||
{
|
||||
VertexIndex_Vertices = 0,
|
||||
VertexIndex_Uniforms = 1,
|
||||
} VertexInputIndex;
|
||||
|
||||
typedef enum FragmentIndex
|
||||
{
|
||||
FragmentIndex_Uniforms = 0,
|
||||
} FragmentIndex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simd::float4 State;
|
||||
simd::float4x4 Transform;
|
||||
simd::float4 Scalar4[2];
|
||||
simd::float4 Vector[8];
|
||||
unsigned int ClipSize;
|
||||
simd::float4x4 Clip[8];
|
||||
} Uniforms;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
simd::float2 Position;
|
||||
simd::uchar4 Color;
|
||||
simd::float2 TexCoord;
|
||||
simd::float2 ObjCoord;
|
||||
simd::float4 Data0;
|
||||
simd::float4 Data1;
|
||||
simd::float4 Data2;
|
||||
simd::float4 Data3;
|
||||
simd::float4 Data4;
|
||||
simd::float4 Data5;
|
||||
simd::float4 Data6;
|
||||
} Vertex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simd::float2 Position;
|
||||
simd::uchar4 Color;
|
||||
simd::float2 ObjCoord;
|
||||
} PathVertex;
|
||||
#pragma pack(pop)
|
||||
#endif /* ShaderTypes_h */
|
||||
|
||||
// Vertex shader outputs and fragment shader inputs
|
||||
typedef struct
|
||||
{
|
||||
float4 Position [[position]];
|
||||
float4 Color;
|
||||
float2 TexCoord;
|
||||
float4 Data0;
|
||||
float4 Data1;
|
||||
float4 Data2;
|
||||
float4 Data3;
|
||||
float4 Data4;
|
||||
float4 Data5;
|
||||
float4 Data6;
|
||||
float2 ObjectCoord;
|
||||
float2 ScreenCoord;
|
||||
} FragmentInput;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float4 Position [[position]];
|
||||
float4 Color;
|
||||
float2 ObjectCoord;
|
||||
float2 ScreenCoord;
|
||||
} PathFragmentInput;
|
||||
|
||||
// Uniform Accessor Functions
|
||||
bool SnapEnabled(constant Uniforms& u) { return bool(uint(u.State[0])); }
|
||||
float ScreenWidth(constant Uniforms& u) { return u.State[1]; }
|
||||
float ScreenHeight(constant Uniforms& u) { return u.State[2]; }
|
||||
float ScreenScale(constant Uniforms& u) { return u.State[3]; }
|
||||
float Scalar(constant Uniforms& u, uint i) { if (i < 4u) return u.Scalar4[0][i]; else return u.Scalar4[1][i - 4u]; }
|
||||
float4 sRGBToLinear(float4 val) { return float4(val.xyz * (val.xyz * (val.xyz * 0.305306011 + 0.682171111) + 0.012522878), val.w); }
|
||||
|
||||
float4 SnapToScreen(float4 pos, constant Uniforms& u)
|
||||
{
|
||||
pos.xy += 1.0;
|
||||
pos.xy /= 2.0;
|
||||
pos.xy *= float2(ScreenWidth(u), ScreenHeight(u));
|
||||
pos.x = round(pos.x);
|
||||
pos.y = round(pos.y);
|
||||
pos.xy /= float2(ScreenWidth(u), ScreenHeight(u));
|
||||
pos.xy *= 2.0;
|
||||
pos.xy -= 1.0;
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Vertex function
|
||||
vertex FragmentInput
|
||||
vertexShader(uint vertexID [[vertex_id]],
|
||||
device Vertex *vertices [[buffer(VertexIndex_Vertices)]],
|
||||
constant Uniforms &uniforms [[buffer(VertexIndex_Uniforms)]])
|
||||
{
|
||||
FragmentInput out;
|
||||
|
||||
out.ObjectCoord = vertices[vertexID].ObjCoord;
|
||||
out.Position = uniforms.Transform * float4(vertices[vertexID].Position.xy, 0.0, 1.0);
|
||||
if (SnapEnabled(uniforms))
|
||||
out.Position = SnapToScreen(out.Position, uniforms);
|
||||
out.Color = float4(vertices[vertexID].Color) / 255.0f;
|
||||
out.TexCoord = vertices[vertexID].TexCoord;
|
||||
out.Data0 = vertices[vertexID].Data0;
|
||||
out.Data1 = vertices[vertexID].Data1;
|
||||
out.Data2 = vertices[vertexID].Data2;
|
||||
out.Data3 = vertices[vertexID].Data3;
|
||||
out.Data4 = vertices[vertexID].Data4;
|
||||
out.Data5 = vertices[vertexID].Data5;
|
||||
out.Data6 = vertices[vertexID].Data6;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
vertex PathFragmentInput
|
||||
pathVertexShader(uint vertexID [[vertex_id]],
|
||||
device PathVertex *vertices [[buffer(VertexIndex_Vertices)]],
|
||||
constant Uniforms &uniforms [[buffer(VertexIndex_Uniforms)]])
|
||||
{
|
||||
PathFragmentInput out;
|
||||
|
||||
out.ObjectCoord = vertices[vertexID].ObjCoord;
|
||||
out.Position = uniforms.Transform * float4(vertices[vertexID].Position.xy, 0.0, 1.0);
|
||||
out.Color = float4(vertices[vertexID].Color) / 255.0f;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr sampler texSampler(mag_filter::linear, min_filter::linear);
|
||||
|
||||
uint FillType(thread FragmentInput& input) { return uint(input.Data0.x + 0.5); }
|
||||
float4 TileRectUV(constant Uniforms& u) { return u.Vector[0]; }
|
||||
float2 TileSize(constant Uniforms& u) { return u.Vector[1].zw; }
|
||||
float2 PatternTransformA(constant Uniforms& u) { return u.Vector[2].xy; }
|
||||
float2 PatternTransformB(constant Uniforms& u) { return u.Vector[2].zw; }
|
||||
float2 PatternTransformC(constant Uniforms& u) { return u.Vector[3].xy; }
|
||||
uint Gradient_NumStops(thread FragmentInput& input) { return uint(input.Data0.y + 0.5); }
|
||||
bool Gradient_IsRadial(thread FragmentInput& input) { return bool(uint(input.Data0.z + 0.5)); }
|
||||
float Gradient_R0(thread FragmentInput& input) { return input.Data1.x; }
|
||||
float Gradient_R1(thread FragmentInput& input) { return input.Data1.y; }
|
||||
float2 Gradient_P0(thread FragmentInput& input) { return input.Data1.xy; }
|
||||
float2 Gradient_P1(thread FragmentInput& input) { return input.Data1.zw; }
|
||||
float SDFMaxDistance(thread FragmentInput& input) { return input.Data0.y; }
|
||||
|
||||
struct GradientStop { float percent; float4 color; };
|
||||
|
||||
GradientStop GetGradientStop(thread FragmentInput& input, constant Uniforms& u, uint offset)
|
||||
{
|
||||
GradientStop result;
|
||||
if (offset < 4) {
|
||||
result.percent = input.Data2[offset];
|
||||
if (offset == 0)
|
||||
result.color = input.Data3;
|
||||
else if (offset == 1)
|
||||
result.color = input.Data4;
|
||||
else if (offset == 2)
|
||||
result.color = input.Data5;
|
||||
else if (offset == 3)
|
||||
result.color = input.Data6;
|
||||
} else {
|
||||
result.percent = Scalar(u, offset - 4);
|
||||
result.color = u.Vector[offset - 4];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define AA_WIDTH 0.354
|
||||
|
||||
float antialias(float d, float width, float median) {
|
||||
return smoothstep(median - width, median + width, d);
|
||||
}
|
||||
|
||||
float sdRect(float2 p, float2 size) {
|
||||
float2 d = abs(p) - size;
|
||||
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
|
||||
}
|
||||
|
||||
|
||||
// The below function "sdEllipse" is MIT licensed with following text:
|
||||
//
|
||||
// The MIT License
|
||||
// Copyright 2013 Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions: The above copyright
|
||||
// notice and this permission notice shall be included in all copies or substantial
|
||||
// portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
float sdEllipse(float2 p, float2 ab) {
|
||||
if (abs(ab.x - ab.y) < 0.1)
|
||||
return length(p) - ab.x;
|
||||
|
||||
p = abs(p); if (p.x > p.y) { p = p.yx; ab = ab.yx; }
|
||||
|
||||
float l = ab.y*ab.y - ab.x*ab.x;
|
||||
|
||||
float m = ab.x*p.x / l;
|
||||
float n = ab.y*p.y / l;
|
||||
float m2 = m*m;
|
||||
float n2 = n*n;
|
||||
|
||||
float c = (m2 + n2 - 1.0) / 3.0;
|
||||
float c3 = c*c*c;
|
||||
|
||||
float q = c3 + m2*n2*2.0;
|
||||
float d = c3 + m2*n2;
|
||||
float g = m + m*n2;
|
||||
|
||||
float co;
|
||||
|
||||
if (d < 0.0) {
|
||||
float p = acos(q / c3) / 3.0;
|
||||
float s = cos(p);
|
||||
float t = sin(p)*sqrt(3.0);
|
||||
float rx = sqrt(-c*(s + t + 2.0) + m2);
|
||||
float ry = sqrt(-c*(s - t + 2.0) + m2);
|
||||
co = (ry + sign(l)*rx + abs(g) / (rx*ry) - m) / 2.0;
|
||||
} else {
|
||||
float h = 2.0*m*n*sqrt(d);
|
||||
float s = sign(q + h)*pow(abs(q + h), 1.0 / 3.0);
|
||||
float u = sign(q - h)*pow(abs(q - h), 1.0 / 3.0);
|
||||
float rx = -s - u - c*4.0 + 2.0*m2;
|
||||
float ry = (s - u)*sqrt(3.0);
|
||||
float rm = sqrt(rx*rx + ry*ry);
|
||||
float p = ry / sqrt(rm - rx);
|
||||
co = (p + 2.0*g / rm - m) / 2.0;
|
||||
}
|
||||
|
||||
float si = sqrt(1.0 - co*co);
|
||||
|
||||
float2 r = float2(ab.x*co, ab.y*si);
|
||||
|
||||
return length(r - p) * sign(p.y - r.y);
|
||||
}
|
||||
|
||||
// 1.0 = No softening, 0.1 = Max softening
|
||||
#define SOFTEN_ELLIPSE 1.0
|
||||
|
||||
float sdRoundRect(float2 p, float2 size, float4 rx, float4 ry) {
|
||||
size *= 0.5;
|
||||
float2 corner;
|
||||
|
||||
corner = float2(-size.x + rx.x, -size.y + ry.x); // Top-Left
|
||||
float2 local = p - corner;
|
||||
if (rx.x * ry.x > 0.0 && p.x < corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.x, ry.x)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(size.x - rx.y, -size.y + ry.y); // Top-Right
|
||||
local = p - corner;
|
||||
if (rx.y * ry.y > 0.0 && p.x >= corner.x && p.y <= corner.y)
|
||||
return sdEllipse(local, float2(rx.y, ry.y)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(size.x - rx.z, size.y - ry.z); // Bottom-Right
|
||||
local = p - corner;
|
||||
if (rx.z * ry.z > 0.0 && p.x >= corner.x && p.y >= corner.y)
|
||||
return sdEllipse(local, float2(rx.z, ry.z)) * SOFTEN_ELLIPSE;
|
||||
|
||||
corner = float2(-size.x + rx.w, size.y - ry.w); // Bottom-Left
|
||||
local = p - corner;
|
||||
if (rx.w * ry.w > 0.0 && p.x < corner.x && p.y > corner.y)
|
||||
return sdEllipse(local, float2(rx.w, ry.w)) * SOFTEN_ELLIPSE;
|
||||
|
||||
return sdRect(p, size);
|
||||
}
|
||||
|
||||
float4 fillSolid(thread FragmentInput& input) {
|
||||
return input.Color;
|
||||
}
|
||||
|
||||
float4 fillImage(thread FragmentInput& input, thread texture2d<half>& tex) {
|
||||
return float4(tex.sample(texSampler, input.TexCoord)) * input.Color;
|
||||
}
|
||||
|
||||
float2 transformAffine(float2 val, float2 a, float2 b, float2 c) {
|
||||
return val.x * a + val.y * b + c;
|
||||
}
|
||||
|
||||
float4 fillPatternImage(thread FragmentInput& input, constant Uniforms& u, thread texture2d<half>& tex) {
|
||||
float4 tile_rect_uv = TileRectUV(u);
|
||||
float2 tile_size = TileSize(u);
|
||||
|
||||
float2 p = input.ObjectCoord;
|
||||
|
||||
// Apply the affine matrix
|
||||
float2 transformed_coords = transformAffine(p, PatternTransformA(u), PatternTransformB(u), PatternTransformC(u));
|
||||
|
||||
// Convert back to uv coordinate space
|
||||
transformed_coords /= tile_size;
|
||||
|
||||
// Wrap UVs to [0.0, 1.0] so texture repeats properly
|
||||
float2 uv = fract(transformed_coords);
|
||||
|
||||
// Clip to tile-rect UV
|
||||
uv *= tile_rect_uv.zw - tile_rect_uv.xy;
|
||||
uv += tile_rect_uv.xy;
|
||||
|
||||
return float4(tex.sample(texSampler, uv)) * input.Color;
|
||||
}
|
||||
|
||||
float ramp(float inMin, float inMax, float val)
|
||||
{
|
||||
return clamp((val - inMin) / (inMax - inMin), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float4 fillPatternGradient(thread FragmentInput& input, constant Uniforms& u) {
|
||||
uint num_stops = Gradient_NumStops(input);
|
||||
bool is_radial = Gradient_IsRadial(input);
|
||||
float2 p0 = Gradient_P0(input);
|
||||
float2 p1 = Gradient_P1(input);
|
||||
|
||||
float4 col = input.Color;
|
||||
|
||||
float t = 0.0;
|
||||
if (is_radial) {
|
||||
float r0 = p1.x;
|
||||
float r1 = p1.y;
|
||||
t = distance(input.TexCoord, p0);
|
||||
float rDelta = r1 - r0;
|
||||
t = saturate((t / rDelta) - (r0 / rDelta));
|
||||
} else {
|
||||
float2 V = p1 - p0;
|
||||
t = saturate(dot(input.TexCoord - p0, V) / dot(V, V));
|
||||
}
|
||||
|
||||
GradientStop stop0 = GetGradientStop(input, u, 0u);
|
||||
GradientStop stop1 = GetGradientStop(input, u, 1u);
|
||||
|
||||
col = mix(stop0.color, stop1.color, ramp(stop0.percent, stop1.percent, t));
|
||||
if (num_stops > 2u) {
|
||||
GradientStop stop2 = GetGradientStop(input, u, 2u);
|
||||
col = mix(col, stop2.color, ramp(stop1.percent, stop2.percent, t));
|
||||
if (num_stops > 3u) {
|
||||
GradientStop stop3 = GetGradientStop(input, u, 3u);
|
||||
col = mix(col, stop3.color, ramp(stop2.percent, stop3.percent, t));
|
||||
if (num_stops > 4u) {
|
||||
GradientStop stop4 = GetGradientStop(input, u, 4u);
|
||||
col = mix(col, stop4.color, ramp(stop3.percent, stop4.percent, t));
|
||||
if (num_stops > 5u) {
|
||||
GradientStop stop5 = GetGradientStop(input, u, 5u);
|
||||
col = mix(col, stop5.color, ramp(stop4.percent, stop5.percent, t));
|
||||
if (num_stops > 6u) {
|
||||
GradientStop stop6 = GetGradientStop(input, u, 6u);
|
||||
col = mix(col, stop6.color, ramp(stop5.percent, stop6.percent, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return float4(col.rgb, col.a);
|
||||
}
|
||||
|
||||
float stroke(float d, float s, float a) {
|
||||
if (d <= s)
|
||||
return 1.0;
|
||||
return 1.0 - smoothstep(s, s + a, d);
|
||||
}
|
||||
|
||||
float samp(thread texture2d<half>& tex, float2 uv, float width, float median) {
|
||||
return antialias(tex.sample(texSampler, uv).a, width, median);
|
||||
}
|
||||
|
||||
#define SHARPENING 0.9 // 0 = No sharpening, 0.9 = Max sharpening.
|
||||
#define SHARPEN_MORE 1
|
||||
|
||||
float supersample(thread texture2d<half>& tex, float2 uv) {
|
||||
float dist = tex.sample(texSampler, uv).a;
|
||||
float width = fwidth(dist) * (1.0 - SHARPENING);
|
||||
const float median = 0.5;
|
||||
float alpha = antialias(dist, width, median);
|
||||
float2 dscale = float2(0.354, 0.354); // half of 1/sqrt2
|
||||
float2 duv = (dfdx(uv) + dfdy(uv)) * dscale;
|
||||
float4 box = float4(uv - duv, uv + duv);
|
||||
|
||||
float asum = samp(tex, box.xy, width, median)
|
||||
+ samp(tex, box.zw, width, median)
|
||||
+ samp(tex, box.xw, width, median)
|
||||
+ samp(tex, box.zy, width, median);
|
||||
#if SHARPEN_MORE
|
||||
alpha = (alpha + 0.4 * asum) * 0.39;
|
||||
#else
|
||||
alpha = (alpha + 0.5 * asum) / 3.0;
|
||||
#endif
|
||||
return alpha;
|
||||
}
|
||||
|
||||
float samp_stroke(thread texture2d<half>& tex, float2 uv, float w, float m, float max_d) {
|
||||
float d = abs(((tex.sample(texSampler, uv).r * 2.0) - 1.0) * max_d);
|
||||
return antialias(d, w, m);
|
||||
}
|
||||
|
||||
void Unpack(float4 x, thread float4& a, thread float4& b) {
|
||||
const float s = 65536.0;
|
||||
a = floor(x / s);
|
||||
b = floor(x - a * s);
|
||||
}
|
||||
|
||||
// Returns two values:
|
||||
// [0] = distance of p to line segment.
|
||||
// [1] = closest t on line segment, clamped to [0, 1]
|
||||
float2 sdSegment(float2 p, float2 a, float2 b)
|
||||
{
|
||||
float2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return float2(length(pa - ba * t), t);
|
||||
}
|
||||
|
||||
float testCross(float2 a, float2 b, float2 p) {
|
||||
return (b.y - a.y) * (p.x - a.x) - (b.x - a.x) * (p.y - a.y);
|
||||
}
|
||||
|
||||
float sdLine(float2 a, float2 b, float2 p)
|
||||
{
|
||||
float2 pa = p - a, ba = b - a;
|
||||
float t = dot(pa, ba) / dot(ba, ba);
|
||||
return length(pa - ba*t) * sign(testCross(a, b, p));
|
||||
}
|
||||
|
||||
float4 blend(float4 src, float4 dest) {
|
||||
float4 result;
|
||||
result.rgb = src.rgb + dest.rgb * (1.0 - src.a);
|
||||
result.a = src.a + dest.a * (1.0 - src.a);
|
||||
return result;
|
||||
}
|
||||
|
||||
float innerStroke(float stroke_width, float d, float aa_width) {
|
||||
return min(antialias(-d, aa_width, 0.0), 1.0 - antialias(-d, aa_width, stroke_width));
|
||||
}
|
||||
|
||||
float4 fillRoundedRect(thread FragmentInput& input, constant Uniforms& u) {
|
||||
float2 p = input.TexCoord;
|
||||
float2 size = input.Data0.zw;
|
||||
p = (p - 0.5) * size;
|
||||
float d = sdRoundRect(p, size, input.Data1, input.Data2);
|
||||
|
||||
// Fill background
|
||||
float alpha = antialias(-d, AA_WIDTH, 0.0);
|
||||
float4 outColor = input.Color * alpha;
|
||||
|
||||
// Draw stroke
|
||||
float stroke_width = input.Data3.x;
|
||||
float4 stroke_color = input.Data4;
|
||||
|
||||
if (stroke_width > 0.0) {
|
||||
alpha = innerStroke(stroke_width, d, AA_WIDTH);
|
||||
float4 stroke = stroke_color * alpha;
|
||||
outColor = blend(stroke, outColor);
|
||||
}
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
float4 fillBoxShadow(thread FragmentInput& input) {
|
||||
float2 p = input.ObjectCoord;
|
||||
bool inset = bool(uint(input.Data0.y + 0.5));
|
||||
float radius = input.Data0.z;
|
||||
float2 origin = input.Data1.xy;
|
||||
float2 size = input.Data1.zw;
|
||||
float2 clip_origin = input.Data4.xy;
|
||||
float2 clip_size = input.Data4.zw;
|
||||
|
||||
float sdClip = sdRoundRect(p - clip_origin, clip_size, input.Data5, input.Data6);
|
||||
float sdRect = sdRoundRect(p - origin, size, input.Data2, input.Data3);
|
||||
|
||||
float clip = inset ? -sdRect : sdClip;
|
||||
float d = inset ? -sdClip : sdRect;
|
||||
|
||||
if (clip < 0.0) {
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float alpha = radius >= 1.0? pow(antialias(-d, radius * 2 + 0.2, 0.0), 1.9) * 2.3 / pow(radius * 1.2, 0.15) :
|
||||
antialias(-d, AA_WIDTH, inset ? -1.0 : 1.0);
|
||||
alpha = clamp(alpha, 0.0, 1.0);
|
||||
return input.Color * alpha;
|
||||
}
|
||||
|
||||
float3 blendOverlay(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendColorDodge(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 1.0) ? src[i] : min(dest[i] / (1.0 - src[i]), 1.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendColorBurn(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] == 0.0) ? src[i] : max((1.0 - ((1.0 - dest[i]) / src[i])), 0.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendHardLight(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = dest[i] < 0.5 ? (2.0 * dest[i] * src[i]) : (1.0 - 2.0 * (1.0 - dest[i]) * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blendSoftLight(float3 src, float3 dest) {
|
||||
float3 col;
|
||||
for (uint i = 0; i < 3; ++i)
|
||||
col[i] = (src[i] < 0.5) ? (2.0 * dest[i] * src[i] + dest[i] * dest[i] * (1.0 - 2.0 * src[i])) : (sqrt(dest[i]) * (2.0 * src[i] - 1.0) + 2.0 * dest[i] * (1.0 - src[i]));
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 rgb2hsl( float3 col )
|
||||
{
|
||||
const float eps = 0.0000001;
|
||||
float minc = min( col.r, min(col.g, col.b) );
|
||||
float maxc = max( col.r, max(col.g, col.b) );
|
||||
float3 mask = step(col.grr,col.rgb) * step(col.bbg,col.rgb);
|
||||
float3 h = mask * (float3(0.0,2.0,4.0) + (col.gbr-col.brg)/(maxc-minc + eps)) / 6.0;
|
||||
return float3(fract( 1.0 + h.x + h.y + h.z ), // H
|
||||
(maxc-minc)/(1.0-abs(minc+maxc-1.0) + eps), // S
|
||||
(minc+maxc)*0.5 ); // L
|
||||
}
|
||||
|
||||
float3 hsl2rgb( float3 c )
|
||||
{
|
||||
float3 rgb = clamp( abs(fmod(c.x*6.0+float3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
|
||||
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
|
||||
}
|
||||
|
||||
float3 blendHue(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(rgb2hsl(src).r, baseHSL.g, baseHSL.b));
|
||||
}
|
||||
|
||||
float3 blendSaturation(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(baseHSL.r, rgb2hsl(src).g, baseHSL.b));
|
||||
}
|
||||
|
||||
float3 blendColor(float3 src, float3 dest) {
|
||||
float3 blendHSL = rgb2hsl(src);
|
||||
return hsl2rgb(float3(blendHSL.r, blendHSL.g, rgb2hsl(dest).b));
|
||||
}
|
||||
|
||||
float3 blendLuminosity(float3 src, float3 dest) {
|
||||
float3 baseHSL = rgb2hsl(dest);
|
||||
return hsl2rgb(float3(baseHSL.r, baseHSL.g, rgb2hsl(src).b));
|
||||
}
|
||||
|
||||
float4 fillBlend(thread FragmentInput& input, thread texture2d<half>& tex0, thread texture2d<half>& tex1) {
|
||||
const uint BlendOp_Clear = 0u;
|
||||
const uint BlendOp_Source = 1u;
|
||||
const uint BlendOp_Over = 2u;
|
||||
const uint BlendOp_In = 3u;
|
||||
const uint BlendOp_Out = 4u;
|
||||
const uint BlendOp_Atop = 5u;
|
||||
const uint BlendOp_DestOver = 6u;
|
||||
const uint BlendOp_DestIn = 7u;
|
||||
const uint BlendOp_DestOut = 8u;
|
||||
const uint BlendOp_DestAtop = 9u;
|
||||
const uint BlendOp_XOR = 10u;
|
||||
const uint BlendOp_Darken = 11u;
|
||||
const uint BlendOp_Add = 12u;
|
||||
const uint BlendOp_Difference = 13u;
|
||||
const uint BlendOp_Multiply = 14u;
|
||||
const uint BlendOp_Screen = 15u;
|
||||
const uint BlendOp_Overlay = 16u;
|
||||
const uint BlendOp_Lighten = 17u;
|
||||
const uint BlendOp_ColorDodge = 18u;
|
||||
const uint BlendOp_ColorBurn = 19u;
|
||||
const uint BlendOp_HardLight = 20u;
|
||||
const uint BlendOp_SoftLight = 21u;
|
||||
const uint BlendOp_Exclusion = 22u;
|
||||
const uint BlendOp_Hue = 23u;
|
||||
const uint BlendOp_Saturation = 24u;
|
||||
const uint BlendOp_Color = 25u;
|
||||
const uint BlendOp_Luminosity = 26u;
|
||||
|
||||
float4 src = fillImage(input, tex0);
|
||||
float4 dest = float4(tex1.sample(texSampler, input.ObjectCoord));
|
||||
|
||||
switch(uint(input.Data0.y + 0.5))
|
||||
{
|
||||
case BlendOp_Clear: return float4(0.0, 0.0, 0.0, 0.0);
|
||||
case BlendOp_Source: return src;
|
||||
case BlendOp_Over: return src + dest * (1.0 - src.a);
|
||||
case BlendOp_In: return src * dest.a;
|
||||
case BlendOp_Out: return src * (1.0 - dest.a);
|
||||
case BlendOp_Atop: return src * dest.a + dest * (1.0 - src.a);
|
||||
case BlendOp_DestOver: return src * (1.0 - dest.a) + dest;
|
||||
case BlendOp_DestIn: return dest * src.a;
|
||||
case BlendOp_DestOut: return dest * (1.0 - src.a);
|
||||
case BlendOp_DestAtop: return src * (1.0 - dest.a) + dest * src.a;
|
||||
case BlendOp_XOR: return saturate(src * (1.0 - dest.a) + dest * (1.0 - src.a));
|
||||
case BlendOp_Darken: return float4(min(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Add: return saturate(src + dest);
|
||||
case BlendOp_Difference: return float4(abs(dest.rgb - src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Multiply: return float4(src.rgb * dest.rgb * src.a, dest.a * src.a);
|
||||
case BlendOp_Screen: return float4((1.0 - ((1.0 - dest.rgb) * (1.0 - src.rgb))) * src.a, dest.a * src.a);
|
||||
case BlendOp_Overlay: return float4(blendOverlay(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Lighten: return float4(max(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorDodge: return float4(blendColorDodge(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_ColorBurn: return float4(blendColorBurn(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_HardLight: return float4(blendOverlay(dest.rgb, src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_SoftLight: return float4(blendSoftLight(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Exclusion: return float4((dest.rgb + src.rgb - 2.0 * dest.rgb * src.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Hue: return float4(blendHue(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Saturation: return float4(blendSaturation(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Color: return float4(blendColor(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
case BlendOp_Luminosity: return float4(blendLuminosity(src.rgb, dest.rgb) * src.a, dest.a * src.a);
|
||||
}
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
float4 fillMask(thread FragmentInput& input, thread texture2d<half>& tex0, thread texture2d<half>& tex1) {
|
||||
float4 col = fillImage(input, tex0);
|
||||
float alpha = float4(tex1.sample(texSampler, input.ObjectCoord)).a;
|
||||
return col * alpha;
|
||||
}
|
||||
|
||||
float4 fillGlyph(thread FragmentInput& input, thread texture2d<half>& tex0, thread texture2d<half>& tex1) {
|
||||
float alpha = tex0.sample(texSampler, input.TexCoord).a * input.Color.a;
|
||||
float fill_color_luma = input.Data0.y;
|
||||
float corrected_alpha = tex1.sample(texSampler, float2(alpha, fill_color_luma)).a;
|
||||
|
||||
return float4(input.Color.rgb * corrected_alpha, corrected_alpha);
|
||||
}
|
||||
|
||||
//float4 GetCol(float4x4 m, uint i) { return float4(m[0][i], m[1][i], m[2][i], m[3][i]); }
|
||||
|
||||
#define VISUALIZE_CLIP 0
|
||||
|
||||
void applyClip(float2 objCoord, constant Uniforms& u, thread float4& outColor) {
|
||||
for (uint i = 0; i < u.ClipSize; i++) {
|
||||
float4x4 data = u.Clip[i];
|
||||
float2 origin = data[0].xy;
|
||||
float2 size = data[0].zw;
|
||||
float4 radii_x, radii_y;
|
||||
Unpack(data[1], radii_x, radii_y);
|
||||
bool inverse = bool(uint(data[3].z + 0.5));
|
||||
|
||||
float2 p = objCoord;
|
||||
p = transformAffine(p, data[2].xy, data[2].zw, data[3].xy);
|
||||
p -= origin;
|
||||
float d_clip = sdRoundRect(p, size, radii_x, radii_y) * (inverse ? -1.0 : 1.0);
|
||||
|
||||
#if VISUALIZE_CLIP
|
||||
if (abs(d_clip) < 1.0)
|
||||
outColor = float4(0.9, 1.0, 0.0, 1.0);
|
||||
#else
|
||||
float alpha = antialias(-d_clip, AA_WIDTH, 0.0);
|
||||
outColor = float4(outColor.rgb * alpha, outColor.a * alpha);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Fragment function
|
||||
fragment float4 fragmentShader(FragmentInput input [[stage_in]],
|
||||
constant Uniforms &uniforms [[buffer(FragmentIndex_Uniforms)]],
|
||||
texture2d<half> tex0 [[texture(0)]],
|
||||
texture2d<half> tex1 [[texture(1)]])
|
||||
{
|
||||
const uint FillType_Solid = 0u;
|
||||
const uint FillType_Image = 1u;
|
||||
const uint FillType_Pattern_Image = 2u;
|
||||
const uint FillType_Pattern_Gradient = 3u;
|
||||
const uint FillType_RESERVED_1 = 4u;
|
||||
const uint FillType_RESERVED_2 = 5u;
|
||||
const uint FillType_RESERVED_3 = 6u;
|
||||
const uint FillType_Rounded_Rect = 7u;
|
||||
const uint FillType_Box_Shadow = 8u;
|
||||
const uint FillType_Blend = 9u;
|
||||
const uint FillType_Mask = 10u;
|
||||
const uint FillType_Glyph = 11u;
|
||||
|
||||
float4 outColor = input.Color;
|
||||
|
||||
switch (FillType(input))
|
||||
{
|
||||
case FillType_Solid: outColor = fillSolid(input); break;
|
||||
case FillType_Image: outColor = fillImage(input, tex0); break;
|
||||
case FillType_Pattern_Image: outColor = fillPatternImage(input, uniforms, tex0); break;
|
||||
case FillType_Pattern_Gradient: outColor = fillPatternGradient(input, uniforms); break;
|
||||
case FillType_RESERVED_1: break;
|
||||
case FillType_RESERVED_2: break;
|
||||
case FillType_RESERVED_3: break;
|
||||
case FillType_Rounded_Rect: outColor = fillRoundedRect(input, uniforms); break;
|
||||
case FillType_Box_Shadow: outColor = fillBoxShadow(input); break;
|
||||
case FillType_Blend: outColor = fillBlend(input, tex0, tex1); break;
|
||||
case FillType_Mask: outColor = fillMask(input, tex0, tex1); break;
|
||||
case FillType_Glyph: outColor = fillGlyph(input, tex0, tex1); break;
|
||||
}
|
||||
|
||||
applyClip(input.ObjectCoord, uniforms, outColor);
|
||||
|
||||
return outColor;
|
||||
}
|
||||
|
||||
fragment float4 pathFragmentShader(PathFragmentInput input [[stage_in]],
|
||||
constant Uniforms &uniforms [[buffer(FragmentIndex_Uniforms)]])
|
||||
{
|
||||
float4 outColor = input.Color;
|
||||
|
||||
applyClip(input.ObjectCoord, uniforms, outColor);
|
||||
|
||||
return outColor;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd ../bin
|
||||
rm -f metal_shader.h
|
||||
rm -f metal_shader
|
||||
rm -f obj.air
|
||||
|
||||
# Compile metal shader to intermediate IR (air)
|
||||
xcrun -sdk macosx metal -mmacosx-version-min=10.12 -std=osx-metal1.2 -c ../src/Shaders.metal -o obj.air
|
||||
|
||||
# Archive air file into metallib format
|
||||
xcrun -sdk macosx metallib obj.air -o metal_shader
|
||||
|
||||
# Convert metallib binary to C header
|
||||
xxd -i metal_shader > metal_shader.h
|
||||
|
||||
# Clean up
|
||||
rm -f metal_shader
|
||||
rm -f obj.air
|
||||
Reference in New Issue
Block a user