mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Forgot palette
This commit is contained in:
parent
e04a4fad02
commit
c0a704dc56
@ -68,7 +68,7 @@ public final class OpenGLRendering {
|
||||
private static int boxTexture;
|
||||
|
||||
static void init() {
|
||||
// GLUtil.setupDebugMessageCallback();
|
||||
GLUtil.setupDebugMessageCallback();
|
||||
|
||||
paletteTexture = loadTexture("palette");
|
||||
boxTexture = loadTexture("box");
|
||||
|
@ -12,13 +12,13 @@ import java.util.Map;
|
||||
public class PaletteGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<Byte, Integer> colors = new HashMap<>();
|
||||
Map<Integer, Integer> colors = new HashMap<>();
|
||||
int highestIndex = 0;
|
||||
for(MapColors c : MapColors.values()) {
|
||||
for(MapColors.Multiplier m : MapColors.Multiplier.values()) {
|
||||
byte index = m.apply(c);
|
||||
if(((int)index & 0xFF) > highestIndex) {
|
||||
highestIndex = ((int)index) & 0xFF;
|
||||
int index = ((int)m.apply(c)) & 0xFF;
|
||||
if(index > highestIndex) {
|
||||
highestIndex = index;
|
||||
}
|
||||
int rgb = MapColors.PreciseMapColor.toRGB(c, m);
|
||||
colors.put(index, rgb);
|
||||
@ -27,8 +27,8 @@ public class PaletteGenerator {
|
||||
|
||||
BufferedImage paletteTexture = new BufferedImage(highestIndex+1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
for (int i = 0; i <= highestIndex; i++) {
|
||||
int rgb = colors.getOrDefault((byte)i, 0);
|
||||
int argb = (0xFF << 24) | rgb;
|
||||
int rgb = colors.getOrDefault(i, 0);
|
||||
int argb = (0xFF << 24) | (rgb & 0xFFFFFF);
|
||||
paletteTexture.setRGB(i, 0, argb);
|
||||
}
|
||||
|
||||
|
@ -14,16 +14,16 @@ void main() {
|
||||
|
||||
// render in map colors
|
||||
int closest = 0;
|
||||
float distance = 1.0f/0.0f;
|
||||
uint closestDistance = uint(2147483647);
|
||||
for(int i = 1; i < paletteSize; i++) {
|
||||
vec3 mapColor = texture(palette, vec2(i/paletteSize, 0.0)).rgb;
|
||||
float dr = mapColor.r - vertexColor.r;
|
||||
float dg = mapColor.g - vertexColor.g;
|
||||
float db = mapColor.b - vertexColor.b;
|
||||
int dr = int((mapColor.r - vertexColor.r)*255);
|
||||
int dg = int((mapColor.g - vertexColor.g)*255);
|
||||
int db = int((mapColor.b - vertexColor.b)*255);
|
||||
|
||||
float d = dr*dr+dg*dg+db*db;
|
||||
if(d < distance) {
|
||||
distance = d;
|
||||
uint d = uint(dr*dr)+uint(dg*dg)+uint(db*db);
|
||||
if(d < closestDistance) {
|
||||
closestDistance = d;
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
|
BIN
src/lwjgl/resources/textures/palette.png
Normal file
BIN
src/lwjgl/resources/textures/palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 876 B |
Loading…
Reference in New Issue
Block a user