1
+ #version 450
2
+
3
+ layout (push_constant) uniform Push
4
+ {
5
+ vec4 SourceSize;
6
+ vec4 OriginalSize;
7
+ vec4 OutputSize;
8
+ uint FrameCount;
9
+ uint Rotation;
10
+ #ifdef _HAS_ORIGINALASPECT_UNIFORMS
11
+ float OriginalAspect;
12
+ float OriginalAspectRotated;
13
+ #endif
14
+
15
+
16
+
17
+ } params;
18
+
19
+ layout (std140, set = 0 , binding = 0 ) uniform UBO
20
+ {
21
+ mat4 MVP;
22
+ } global;
23
+
24
+ #pragma stage vertex
25
+ layout (location = 0 ) in vec4 Position;
26
+ layout (location = 1 ) in vec2 TexCoord;
27
+ layout (location = 0 ) out vec2 vTexCoord;
28
+
29
+ void main()
30
+ {
31
+ gl_Position = global .MVP * Position;
32
+ vTexCoord = TexCoord;
33
+ }
34
+
35
+ #pragma stage fragment
36
+ layout (location = 0 ) in vec2 vTexCoord;
37
+ layout (location = 0 ) out vec4 FragColor;
38
+
39
+ float DigitBin( const int x )
40
+ {
41
+ return x== 0 ? 480599 . 0 : x== 1 ? 139810 . 0 : x== 2 ? 476951 . 0 : x== 3 ? 476999 . 0 : x== 4 ? 350020 . 0 : x== 5 ? 464711 . 0 : x== 6 ? 464727 . 0 : x== 7 ? 476228 . 0 : x== 8 ? 481111 . 0 : x== 9 ? 481095 . 0 : 0 . 0 ;
42
+ }
43
+
44
+ float PrintValue( vec2 vStringCoords, float fValue, float fMaxDigits, float fDecimalPlaces )
45
+ {
46
+ if ((vStringCoords .y < 0 . 0 ) || (vStringCoords .y >= 1 . 0 )) return 0 . 0 ;
47
+
48
+ bool bNeg = ( fValue < 0 . 0 );
49
+ fValue = abs(fValue);
50
+
51
+ float fLog10Value = log2(abs(fValue)) / log2(10 . 0 );
52
+ float fBiggestIndex = max(floor(fLog10Value), 0 . 0 );
53
+ float fDigitIndex = fMaxDigits - floor(vStringCoords .x );
54
+ float fCharBin = 0 . 0 ;
55
+ if (fDigitIndex > (- fDecimalPlaces - 1 . 01 )) {
56
+ if (fDigitIndex > fBiggestIndex) {
57
+ if ((bNeg) && (fDigitIndex < (fBiggestIndex+ 1 . 5 ))) fCharBin = 1792 . 0 ;
58
+ } else {
59
+ if (fDigitIndex == - 1 . 0 ) {
60
+ if (fDecimalPlaces > 0 . 0 ) fCharBin = 2 . 0 ;
61
+ } else {
62
+ float fReducedRangeValue = fValue;
63
+ if (fDigitIndex < 0 . 0 ) { fReducedRangeValue = fract( fValue ); fDigitIndex += 1 . 0 ; }
64
+ float fDigitValue = (abs(fReducedRangeValue / (pow(10 . 0 , fDigitIndex))));
65
+ fCharBin = DigitBin(int (floor(mod(fDigitValue, 10 . 0 ))));
66
+ }
67
+ }
68
+ }
69
+ return floor(mod((fCharBin / pow(2 . 0 , floor(fract(vStringCoords .x ) * 4 . 0 ) + (floor(vStringCoords .y * 5 . 0 ) * 4 . 0 ))), 2 . 0 ));
70
+ }
71
+
72
+ vec3 PrintValueVec3( vec2 vStringCoords, vec2 FragCoord, float fValue, float fMaxDigits, float fDecimalPlaces ) {
73
+ vec3 vColour = vec3(0 . 0 );
74
+ vec2 vFontSize = vec2(8 . 0 , 15 . 0 );
75
+ vec2 vPixelCoord1 = vStringCoords;
76
+ FragCoord .y = (vFontSize .y * 2 . 0 ) - FragCoord .y ;
77
+ float customDigit = PrintValue( ( FragCoord - vPixelCoord1 ) / vFontSize, fValue, fMaxDigits, fDecimalPlaces);
78
+ vColour = mix( vColour, vec3(0 . 0 , 1 . 0 , 1 . 0 ), customDigit);
79
+ return vColour;
80
+ }
81
+
82
+
83
+ void main() {
84
+ vec2 FragCoord = vTexCoord * params .OutputSize .xy ;
85
+ float f0 = float (params .Rotation );
86
+ float f1 = - 1 ;
87
+ float f2 = - 1 ;
88
+ #ifdef _HAS_ORIGINALASPECT_UNIFORMS
89
+ f1 = params .OriginalAspect ;
90
+ f2 = params .OriginalAspectRotated ;
91
+ #endif
92
+ vec3 v0 = PrintValueVec3( vec2(50 , - 10 ) , FragCoord, f0, 3 , 3 );
93
+ vec3 v1 = PrintValueVec3( vec2(100 , - 10 ), FragCoord, f1, 3 , 3 );
94
+ vec3 v2 = PrintValueVec3( vec2(150 , - 10 ), FragCoord, f2, 3 , 3 );
95
+ FragColor .rgb = v0+ v1+ v2;
96
+ }
0 commit comments