Skip to content

Commit 47717a2

Browse files
Implement Texture::crispBlend (#46)
* Texture::crispBlend * Make Texture::crispBlend match
1 parent 1d375a3 commit 47717a2

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

data/mcswitch_functions.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44987,7 +44987,7 @@ Address,Quality,Size,Name
4498744987
0x000000710074ec04,U,000012,_ZN7Texture7getDataEj
4498844988
0x000000710074ec10,U,000008,_ZN7Texture9getHeightEv
4498944989
0x000000710074ec18,U,000008,_ZN7Texture8getWidthEv
44990-
0x000000710074ec20,U,000136,_ZN7Texture10crispBlendEii
44990+
0x000000710074ec20,O,000136,_ZN7Texture10crispBlendEii
4499144991
0x000000710074eca8,U,000008,_ZN7Texture12getManagerIdEv
4499244992
0x000000710074ecb0,U,000008,
4499344993
0x000000710074ecb8,U,000076,_ZN7Texture4bindEi
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "net/minecraft/client/renderer/texture/Texture.h"
2+
3+
int Texture::crispBlend(int c0, int c1) {
4+
int a0 = c0 >> 24 & 255;
5+
int a1 = c1 >> 24 & 255;
6+
int a = 255;
7+
if (a0 + a1 < 255) {
8+
a0 = 1;
9+
a1 = 1;
10+
a = 0;
11+
} else if (a0 > a1) {
12+
a0 = 255;
13+
a1 = 1;
14+
} else {
15+
a0 = 1;
16+
a1 = 255;
17+
}
18+
19+
int r0 = (c0 >> 16 & 255) * a0;
20+
int g0 = (c0 >> 8 & 255) * a0;
21+
int b0 = (c0 & 255) * a0;
22+
int r1 = (c1 >> 16 & 255) * a1;
23+
int g1 = (c1 >> 8 & 255) * a1;
24+
int b1 = (c1 & 255) * a1;
25+
int r = (r0 + r1) / (a0 + a1);
26+
int g = (g0 + g1) / (a0 + a1);
27+
int b = (b0 + b1) / (a0 + a1);
28+
return a << 24 | r << 16 | g << 8 | b;
29+
}

src/Minecraft.Client/net/minecraft/client/renderer/texture/Texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Texture {
1818
void getData(u32);
1919
void getHeight();
2020
void getWidth();
21-
static void crispBlend(int, int);
21+
static int crispBlend(int c0, int c1);
2222
void getManagerId();
2323
void bind(int);
2424

0 commit comments

Comments
 (0)