@thenick775/mgba-wasm 2.5.0-beta.1 → 2.5.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mgba.data +82 -116
- package/dist/mgba.js +1 -1
- package/dist/mgba.wasm +0 -0
- package/dist/mgba.wasm.map +1 -1
- package/package.json +1 -1
package/dist/mgba.data
CHANGED
|
@@ -684,27 +684,34 @@ uniform vec2 ReflectionDistance;
|
|
|
684
684
|
|
|
685
685
|
#define M_PI 3.1415926535897932384626433832795
|
|
686
686
|
|
|
687
|
+
const vec2 CENTER = vec2(0.5, 0.5);
|
|
688
|
+
const float INV_SQRT_HALF = 1.4142135623730951; // 1.0 / sqrt(0.5)
|
|
689
|
+
|
|
687
690
|
/**
|
|
688
691
|
* Helper to compute backlight bleed intensity
|
|
689
692
|
* for a texCoord input.
|
|
690
693
|
*/
|
|
691
694
|
float getLightIntensity(vec2 coord) {
|
|
692
|
-
vec2 coordCentered = coord -
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
);
|
|
695
|
+
vec2 coordCentered = coord - CENTER;
|
|
696
|
+
|
|
697
|
+
// length(coordCentered) / sqrt(0.5) == length(coordCentered) * (1/sqrt(0.5))
|
|
698
|
+
float coordDistCenter = length(coordCentered) * INV_SQRT_HALF;
|
|
699
|
+
|
|
696
700
|
vec2 coordQuadrant = vec2(
|
|
697
701
|
1.0 - (1.5 * min(coord.x, 1.0 - coord.x)),
|
|
698
702
|
1.0 - (1.5 * min(coord.y, 1.0 - coord.y))
|
|
699
703
|
);
|
|
704
|
+
|
|
700
705
|
float lightIntensityEdges = (
|
|
701
706
|
pow(coordQuadrant.x, 5.0) +
|
|
702
707
|
pow(coordQuadrant.y, 5.0)
|
|
703
708
|
);
|
|
709
|
+
|
|
704
710
|
float lightIntensity = (
|
|
705
711
|
(1.0 - LightSoftness) * lightIntensityEdges +
|
|
706
712
|
LightSoftness * coordDistCenter
|
|
707
713
|
);
|
|
714
|
+
|
|
708
715
|
return clamp(lightIntensity, 0.0, 1.0);
|
|
709
716
|
}
|
|
710
717
|
|
|
@@ -717,12 +724,17 @@ float getLightIntensity(vec2 coord) {
|
|
|
717
724
|
*/
|
|
718
725
|
vec3 getWhiteVector(float intensity) {
|
|
719
726
|
const float DeformAmount = 0.0025;
|
|
720
|
-
|
|
727
|
+
|
|
728
|
+
vec2 texCoordCentered = texCoord - CENTER;
|
|
721
729
|
float radians = atan(texCoordCentered.y, texCoordCentered.x);
|
|
722
|
-
|
|
730
|
+
|
|
731
|
+
float ring = floor(6.0 * length(texCoordCentered));
|
|
732
|
+
float rot = pow(2.0, 4.0 + ring);
|
|
733
|
+
|
|
723
734
|
float deformRed = cos(rot * radians + (2.0 / 3.0 * M_PI));
|
|
724
735
|
float deformGreen = cos(rot * radians);
|
|
725
736
|
float deformBlue = cos(rot * radians + (4.0 / 3.0 * M_PI));
|
|
737
|
+
|
|
726
738
|
return clamp(vec3(
|
|
727
739
|
intensity + (deformRed * DeformAmount),
|
|
728
740
|
intensity + (deformGreen * DeformAmount),
|
|
@@ -877,9 +889,11 @@ uniform float SubpixelTabHeight;
|
|
|
877
889
|
* G: #C1D650 (0.75, 0.84, 0.31)
|
|
878
890
|
* B: #3BCEFF (0.23, 0.81, 1.00)
|
|
879
891
|
*/
|
|
880
|
-
uniform vec3 SubpixelColorRed;
|
|
892
|
+
uniform vec3 SubpixelColorRed; // vec3(1.00, 0.38, 0.22);
|
|
881
893
|
uniform vec3 SubpixelColorGreen; // vec3(0.60, 0.88, 0.30);
|
|
882
|
-
uniform vec3 SubpixelColorBlue;
|
|
894
|
+
uniform vec3 SubpixelColorBlue; // vec3(0.23, 0.65, 1.00);
|
|
895
|
+
|
|
896
|
+
const vec3 ONE = vec3(1.0, 1.0, 1.0);
|
|
883
897
|
|
|
884
898
|
/**
|
|
885
899
|
* Helper to get luminosity of an RGB color.
|
|
@@ -901,13 +915,15 @@ vec3 convertRgbToHcl(in vec3 rgb) {
|
|
|
901
915
|
float xMax = max(rgb.r, max(rgb.g, rgb.b));
|
|
902
916
|
float c = xMax - xMin;
|
|
903
917
|
float l = getColorLumosity(rgb);
|
|
918
|
+
|
|
904
919
|
float h = mod((
|
|
905
|
-
c == 0 ? 0.0 :
|
|
920
|
+
c == 0.0 ? 0.0 :
|
|
906
921
|
xMax == rgb.r ? ((rgb.g - rgb.b) / c) :
|
|
907
922
|
xMax == rgb.g ? ((rgb.b - rgb.r) / c) + 2.0 :
|
|
908
923
|
xMax == rgb.b ? ((rgb.r - rgb.g) / c) + 4.0 :
|
|
909
924
|
0.0
|
|
910
925
|
), 6.0);
|
|
926
|
+
|
|
911
927
|
return vec3(h, c, l);
|
|
912
928
|
}
|
|
913
929
|
|
|
@@ -920,26 +936,24 @@ vec3 convertHclToRgb(in vec3 hcl) {
|
|
|
920
936
|
float c = hcl.y;
|
|
921
937
|
float l = hcl.z;
|
|
922
938
|
float x = c * (1.0 - abs(mod(h, 2.0) - 1.0));
|
|
923
|
-
|
|
939
|
+
|
|
940
|
+
if (h <= 1.0) {
|
|
924
941
|
rgb = vec3(c, x, 0.0);
|
|
925
|
-
}
|
|
926
|
-
else if(h <= 2.0) {
|
|
942
|
+
} else if (h <= 2.0) {
|
|
927
943
|
rgb = vec3(x, c, 0.0);
|
|
928
|
-
}
|
|
929
|
-
else if(h <= 3.0) {
|
|
944
|
+
} else if (h <= 3.0) {
|
|
930
945
|
rgb = vec3(0.0, c, x);
|
|
931
|
-
}
|
|
932
|
-
else if(h <= 4.0) {
|
|
946
|
+
} else if (h <= 4.0) {
|
|
933
947
|
rgb = vec3(0.0, x, c);
|
|
934
|
-
}
|
|
935
|
-
else if(h <= 5.0) {
|
|
948
|
+
} else if (h <= 5.0) {
|
|
936
949
|
rgb = vec3(x, 0.0, c);
|
|
937
|
-
}
|
|
938
|
-
else {
|
|
950
|
+
} else {
|
|
939
951
|
rgb = vec3(c, 0.0, x);
|
|
940
952
|
}
|
|
953
|
+
|
|
941
954
|
float lRgb = getColorLumosity(rgb);
|
|
942
955
|
float m = l - lRgb;
|
|
956
|
+
|
|
943
957
|
return clamp(vec3(m, m, m) + rgb, 0.0, 1.0);
|
|
944
958
|
}
|
|
945
959
|
|
|
@@ -947,11 +961,7 @@ vec3 convertHclToRgb(in vec3 hcl) {
|
|
|
947
961
|
* Helper to check if a point is contained within
|
|
948
962
|
* a rectangular area.
|
|
949
963
|
*/
|
|
950
|
-
bool getPointInRect(
|
|
951
|
-
vec2 point,
|
|
952
|
-
vec2 rectTopLeft,
|
|
953
|
-
vec2 rectBottomRight
|
|
954
|
-
) {
|
|
964
|
+
bool getPointInRect(vec2 point, vec2 rectTopLeft, vec2 rectBottomRight) {
|
|
955
965
|
return (
|
|
956
966
|
point.x >= rectTopLeft.x &&
|
|
957
967
|
point.y >= rectTopLeft.y &&
|
|
@@ -967,22 +977,14 @@ bool getPointInRect(
|
|
|
967
977
|
* distance from the point to the line segment.)
|
|
968
978
|
* Thank you to https://stackoverflow.com/a/1501725
|
|
969
979
|
*/
|
|
970
|
-
vec2 getPointLineDistance(
|
|
971
|
-
vec2 point,
|
|
972
|
-
vec2 line0,
|
|
973
|
-
vec2 line1
|
|
974
|
-
) {
|
|
980
|
+
vec2 getPointLineDistance(vec2 point, vec2 line0, vec2 line1) {
|
|
975
981
|
vec2 lineDelta = line0 - line1;
|
|
976
982
|
float lineLengthSq = dot(lineDelta, lineDelta);
|
|
977
|
-
if(lineLengthSq <= 0) {
|
|
983
|
+
if (lineLengthSq <= 0.0) {
|
|
978
984
|
return line0 - point;
|
|
979
985
|
}
|
|
980
|
-
float t = (
|
|
981
|
-
|
|
982
|
-
);
|
|
983
|
-
vec2 projection = (
|
|
984
|
-
line0 + clamp(t, 0.0, 1.0) * (line1 - line0)
|
|
985
|
-
);
|
|
986
|
+
float t = dot(point - line0, line1 - line0) / lineLengthSq;
|
|
987
|
+
vec2 projection = line0 + clamp(t, 0.0, 1.0) * (line1 - line0);
|
|
986
988
|
return projection - point;
|
|
987
989
|
}
|
|
988
990
|
|
|
@@ -991,40 +993,30 @@ vec2 getPointLineDistance(
|
|
|
991
993
|
* point to a rectangle.
|
|
992
994
|
* Returns (0, 0) for points within the rectangle.
|
|
993
995
|
*/
|
|
994
|
-
vec2 getPointRectDistance(
|
|
995
|
-
|
|
996
|
-
vec2 rectTopLeft,
|
|
997
|
-
vec2 rectBottomRight
|
|
998
|
-
) {
|
|
999
|
-
if(getPointInRect(point, rectTopLeft, rectBottomRight)) {
|
|
996
|
+
vec2 getPointRectDistance(vec2 point, vec2 rectTopLeft, vec2 rectBottomRight) {
|
|
997
|
+
if (getPointInRect(point, rectTopLeft, rectBottomRight)) {
|
|
1000
998
|
return vec2(0.0, 0.0);
|
|
1001
999
|
}
|
|
1000
|
+
|
|
1002
1001
|
vec2 rectTopRight = vec2(rectBottomRight.x, rectTopLeft.y);
|
|
1003
1002
|
vec2 rectBottomLeft = vec2(rectTopLeft.x, rectBottomRight.y);
|
|
1003
|
+
|
|
1004
1004
|
vec2 v0 = getPointLineDistance(point, rectTopLeft, rectTopRight);
|
|
1005
1005
|
vec2 v1 = getPointLineDistance(point, rectBottomLeft, rectBottomRight);
|
|
1006
1006
|
vec2 v2 = getPointLineDistance(point, rectTopLeft, rectBottomLeft);
|
|
1007
1007
|
vec2 v3 = getPointLineDistance(point, rectTopRight, rectBottomRight);
|
|
1008
|
+
|
|
1008
1009
|
float v0LengthSq = dot(v0, v0);
|
|
1009
1010
|
float v1LengthSq = dot(v1, v1);
|
|
1010
1011
|
float v2LengthSq = dot(v2, v2);
|
|
1011
1012
|
float v3LengthSq = dot(v3, v3);
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
);
|
|
1016
|
-
if(minLengthSq ==
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
else if(minLengthSq == v1LengthSq) {
|
|
1020
|
-
return v1;
|
|
1021
|
-
}
|
|
1022
|
-
else if(minLengthSq == v2LengthSq) {
|
|
1023
|
-
return v2;
|
|
1024
|
-
}
|
|
1025
|
-
else {
|
|
1026
|
-
return v3;
|
|
1027
|
-
}
|
|
1013
|
+
|
|
1014
|
+
float minLengthSq = min(min(v0LengthSq, v1LengthSq), min(v2LengthSq, v3LengthSq));
|
|
1015
|
+
|
|
1016
|
+
if (minLengthSq == v0LengthSq) return v0;
|
|
1017
|
+
if (minLengthSq == v1LengthSq) return v1;
|
|
1018
|
+
if (minLengthSq == v2LengthSq) return v2;
|
|
1019
|
+
return v3;
|
|
1028
1020
|
}
|
|
1029
1021
|
|
|
1030
1022
|
/**
|
|
@@ -1035,33 +1027,28 @@ vec2 getPointRectDistance(
|
|
|
1035
1027
|
* corner.
|
|
1036
1028
|
* Returns (0, 0) for points within the subpixel.
|
|
1037
1029
|
*/
|
|
1038
|
-
vec2 getPointSubpixelDistance(
|
|
1039
|
-
vec2 point,
|
|
1040
|
-
vec2 subpixelCenter,
|
|
1041
|
-
vec2 subpixelSizeHalf
|
|
1042
|
-
) {
|
|
1030
|
+
vec2 getPointSubpixelDistance(vec2 point, vec2 subpixelCenter, vec2 subpixelSizeHalf) {
|
|
1043
1031
|
float rectLeft = subpixelCenter.x - subpixelSizeHalf.x;
|
|
1044
1032
|
float rectRight = subpixelCenter.x + subpixelSizeHalf.x;
|
|
1045
1033
|
float rectTop = subpixelCenter.y - subpixelSizeHalf.y;
|
|
1046
1034
|
float rectBottom = subpixelCenter.y + subpixelSizeHalf.y;
|
|
1035
|
+
|
|
1047
1036
|
vec2 offsetLeft = getPointRectDistance(
|
|
1048
1037
|
point,
|
|
1049
1038
|
vec2(rectLeft, rectTop + SubpixelTabHeight),
|
|
1050
1039
|
vec2(subpixelCenter.x, rectBottom)
|
|
1051
1040
|
);
|
|
1041
|
+
|
|
1052
1042
|
vec2 offsetRight = getPointRectDistance(
|
|
1053
1043
|
point,
|
|
1054
1044
|
vec2(subpixelCenter.x, rectTop),
|
|
1055
1045
|
vec2(rectRight, rectBottom)
|
|
1056
1046
|
);
|
|
1047
|
+
|
|
1057
1048
|
float offsetLeftLengthSq = dot(offsetLeft, offsetLeft);
|
|
1058
1049
|
float offsetRightLengthSq = dot(offsetRight, offsetRight);
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
else {
|
|
1063
|
-
return offsetRight;
|
|
1064
|
-
}
|
|
1050
|
+
|
|
1051
|
+
return (offsetLeftLengthSq <= offsetRightLengthSq) ? offsetLeft : offsetRight;
|
|
1065
1052
|
}
|
|
1066
1053
|
|
|
1067
1054
|
/**
|
|
@@ -1072,33 +1059,23 @@ vec2 getPointSubpixelDistance(
|
|
|
1072
1059
|
* Spread represents the subpixel's horizontal
|
|
1073
1060
|
* position within the pixel.
|
|
1074
1061
|
*/
|
|
1075
|
-
float getSubpixelIntensity(
|
|
1076
|
-
vec2 pixelPosition,
|
|
1077
|
-
float spread
|
|
1078
|
-
) {
|
|
1062
|
+
float getSubpixelIntensity(vec2 pixelPosition, float spread) {
|
|
1079
1063
|
vec2 subpixelCenter = vec2(
|
|
1080
1064
|
0.5 + (spread * SubpixelSpread),
|
|
1081
1065
|
1.0 - SubpixelVerticalOffset
|
|
1082
1066
|
);
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
);
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
subpixelSizeHalf
|
|
1091
|
-
);
|
|
1092
|
-
if(SubpixelLightGlow <= 0) {
|
|
1093
|
-
return dot(offset, offset) <= 0.0 ? 1.0 : 0.0;
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
float dist = length(offset);
|
|
1097
|
-
float glow = max(0.0,
|
|
1098
|
-
1.0 - (dist / SubpixelLightGlow)
|
|
1099
|
-
);
|
|
1100
|
-
return glow;
|
|
1067
|
+
|
|
1068
|
+
vec2 subpixelSizeHalf = 0.5 * vec2(SubpixelLightWidth, SubpixelLightHeight);
|
|
1069
|
+
|
|
1070
|
+
vec2 offset = getPointSubpixelDistance(pixelPosition, subpixelCenter, subpixelSizeHalf);
|
|
1071
|
+
|
|
1072
|
+
if (SubpixelLightGlow <= 0.0) {
|
|
1073
|
+
return (dot(offset, offset) <= 0.0) ? 1.0 : 0.0;
|
|
1101
1074
|
}
|
|
1075
|
+
|
|
1076
|
+
float dist = length(offset);
|
|
1077
|
+
float glow = max(0.0, 1.0 - (dist / SubpixelLightGlow));
|
|
1078
|
+
return glow;
|
|
1102
1079
|
}
|
|
1103
1080
|
|
|
1104
1081
|
/**
|
|
@@ -1108,10 +1085,7 @@ float getSubpixelIntensity(
|
|
|
1108
1085
|
* more strongly coerced to more accurately represent
|
|
1109
1086
|
* the underlying pixel color.
|
|
1110
1087
|
*/
|
|
1111
|
-
float applySubpixelBleed(
|
|
1112
|
-
float subpixelIntensity,
|
|
1113
|
-
float colorSourceChannel
|
|
1114
|
-
) {
|
|
1088
|
+
float applySubpixelBleed(float subpixelIntensity, float colorSourceChannel) {
|
|
1115
1089
|
return subpixelIntensity * (
|
|
1116
1090
|
SubpixelColorBleed +
|
|
1117
1091
|
((1.0 - SubpixelColorBleed) * colorSourceChannel)
|
|
@@ -1130,19 +1104,17 @@ void main() {
|
|
|
1130
1104
|
));
|
|
1131
1105
|
// Determine how much each subpixel's light should
|
|
1132
1106
|
// affect this fragment.
|
|
1133
|
-
vec2 pixelPosition = (
|
|
1134
|
-
mod(texCoord * texSize * SubpixelScale, 1.0)
|
|
1135
|
-
);
|
|
1107
|
+
vec2 pixelPosition = mod(texCoord * texSize * SubpixelScale, 1.0);
|
|
1136
1108
|
float subpixelIntensityRed = applySubpixelBleed(
|
|
1137
1109
|
getSubpixelIntensity(pixelPosition, -1.0),
|
|
1138
1110
|
colorSourceAdjusted.r
|
|
1139
1111
|
);
|
|
1140
1112
|
float subpixelIntensityGreen = applySubpixelBleed(
|
|
1141
|
-
getSubpixelIntensity(pixelPosition,
|
|
1113
|
+
getSubpixelIntensity(pixelPosition, 0.0),
|
|
1142
1114
|
colorSourceAdjusted.g
|
|
1143
1115
|
);
|
|
1144
1116
|
float subpixelIntensityBlue = applySubpixelBleed(
|
|
1145
|
-
getSubpixelIntensity(pixelPosition,
|
|
1117
|
+
getSubpixelIntensity(pixelPosition, 1.0),
|
|
1146
1118
|
colorSourceAdjusted.b
|
|
1147
1119
|
);
|
|
1148
1120
|
vec3 subpixelLightColor = SubpixelGamma * (
|
|
@@ -1151,22 +1123,16 @@ void main() {
|
|
|
1151
1123
|
(subpixelIntensityBlue * SubpixelColorBlue)
|
|
1152
1124
|
);
|
|
1153
1125
|
// Compute final color
|
|
1154
|
-
vec3 colorResult = clamp(
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
vec3 colorResultBlended = (
|
|
1126
|
+
vec3 colorResult = clamp(subpixelLightColor * colorSourceAdjusted, 0.0, 1.0);
|
|
1127
|
+
|
|
1128
|
+
vec3 colorResultBlended =
|
|
1158
1129
|
((1.0 - SubpixelBlendAmount) * colorSourceAdjusted) +
|
|
1159
|
-
(SubpixelBlendAmount * colorResult)
|
|
1160
|
-
|
|
1161
|
-
colorResultBlended = BaseColor + (
|
|
1162
|
-
|
|
1163
|
-
);
|
|
1164
|
-
|
|
1165
|
-
colorResultBlended,
|
|
1166
|
-
1.0
|
|
1167
|
-
);
|
|
1168
|
-
}
|
|
1169
|
-
This is free and unencumbered software released into the public domain.
|
|
1130
|
+
(SubpixelBlendAmount * colorResult);
|
|
1131
|
+
|
|
1132
|
+
colorResultBlended = BaseColor + (colorResultBlended * (ONE - BaseColor));
|
|
1133
|
+
|
|
1134
|
+
gl_FragColor = vec4(colorResultBlended, 1.0);
|
|
1135
|
+
}This is free and unencumbered software released into the public domain.
|
|
1170
1136
|
|
|
1171
1137
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
1172
1138
|
distribute this software, either in source code form or as a compiled
|