1
0
Fork 0

add texture options (filtering broken for now)

This commit is contained in:
Sen 2025-08-29 13:37:01 +02:00
parent 937fd4bfb7
commit 1bf4578ad8
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
8 changed files with 92 additions and 31 deletions

View file

@ -72,6 +72,7 @@ import client.renderer.entity.RenderManager;
import client.renderer.texture.EntityTexManager;
import client.renderer.texture.TextureManager;
import client.renderer.texture.TextureMap;
import client.renderer.texture.TextureUtil;
import client.util.FileUtils;
import client.util.Message;
import client.util.PerfSection;
@ -177,9 +178,11 @@ import common.util.IntHashMap;
import common.util.LongHashMap;
import common.util.ParticleType;
import common.util.Color;
import common.util.Displayable;
import common.util.Util;
import common.util.Var;
import common.util.HitPosition.ObjectType;
import common.util.Identifyable;
import common.vars.Vars;
import common.world.Chunk;
import common.world.State;
@ -208,6 +211,28 @@ import common.world.World;
*/
public class Client implements IThreadListener {
public static enum MipmapType implements Identifyable, Displayable {
NONE("off", "Keine"),
NEAREST("nearest", "Nächster nachbar"),
LINEAR("linear", "Linear interpoliert");
private final String name;
private final String display;
private MipmapType(String name, String display) {
this.name = name;
this.display = display;
}
public String getName() {
return this.name;
}
public String getDisplay() {
return this.display;
}
}
public static class SyncFunction implements IntFunction {
public void apply(IntVar cv, int value) {
Client.CLIENT.sync(value);
@ -293,6 +318,24 @@ public class Client implements IThreadListener {
}
}
public static class TextureBoolFunction implements BoolFunction {
public void apply(BoolVar cv, boolean value) {
Client.CLIENT.updateTexture();
}
}
public static class TextureFloatFunction implements FloatFunction {
public void apply(FloatVar cv, float value) {
Client.CLIENT.updateTexture();
}
}
public static class MipmapFunction implements EnumFunction<MipmapType> {
public void apply(EnumVar cv, MipmapType value) {
Client.CLIENT.updateTexture();
}
}
private interface DebugRunner {
void execute(Keysym key);
}
@ -497,6 +540,7 @@ public class Client implements IThreadListener {
private long tick_update;
private long syncLimit;
private float anisotropyMax;
private float deltaX;
private float deltaY;
private float framerate;
@ -672,20 +716,12 @@ public class Client implements IThreadListener {
public int lightMaximum = 64;
@Variable(name = "gl_dynlight_chunkrange", category = CVarCategory.RENDER, min = 0, max = 64, display = "Lichtq. Sichtweite")
public int lightDistance = 8;
// int ldist_chunk_xz;
// int ldist_chunk_y;
// "gl_tex_filter", "Texturfilterung", tex_filter, true
// "gl_tex_mipmaps", "Mipmaps", tex_miptype, MIP_NONE, MIP_NEAREST, MIP_LINEAR, "off", "nearest", "linear", "Keine", "Nächster nachbar", "Linear interpoliert", MIP_LINEAR
// "gl_tex_anisotropic", "Anisotrope Filterung", tex_aniso, 1.0f (1.0f - 16.0f)
// float aniso_max;
// float tex_aniso;
//
// byte tex_miptype;
// byte tex_miplevel;
// byte tex_filter;
@Variable(name = "gl_tex_anisotropic", category = CVarCategory.RENDER, min = 1.0f, max = 16.0f, precision = 1, display = "Anisotrope Filterung", callback = TextureFloatFunction.class)
private float anisotopicFiltering = 16.0f;
@Variable(name = "gl_tex_mipmaps", category = CVarCategory.RENDER, display = "Mipmaps", callback = MipmapFunction.class)
private MipmapType mipmapType = MipmapType.LINEAR;
@Variable(name = "gl_tex_filter", category = CVarCategory.RENDER, display = "Texturfilterung", callback = TextureBoolFunction.class)
private boolean textureFiltering = true;
public static final Client CLIENT = new Client();
@ -837,6 +873,7 @@ public class Client implements IThreadListener {
this.textureManager = new TextureManager();
this.textureManager.onReload();
this.soundManager = new SoundManager(this);
this.anisotropyMax = GL46.glGetFloat(GL46.GL_MAX_TEXTURE_MAX_ANISOTROPY);
GlState.enableTexture2D();
GlState.shadeModel(GL46.GL_SMOOTH);
GL46.glClearDepth(1.0D);
@ -851,9 +888,7 @@ public class Client implements IThreadListener {
GL46.glMatrixMode(GL46.GL_MODELVIEW);
this.textureMap = new TextureMap();
this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap);
this.textureManager.bindTexture(TextureMap.BLOCKS);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_NEAREST);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_NEAREST);
this.updateTexture();
this.modelManager = new ModelManager(this.textureMap);
this.modelManager.onReload();
this.renderItem = new RenderItem(this.textureManager, this.modelManager);
@ -3817,6 +3852,11 @@ public class Client implements IThreadListener {
// light_calc(win->world);
// }
}
public void updateTexture() {
this.textureManager.bindTexture(TextureMap.BLOCKS);
TextureUtil.setParams(this.textureFiltering, this.mipmapType != MipmapType.NONE, this.mipmapType == MipmapType.LINEAR, Math.min(this.anisotopicFiltering, this.anisotropyMax));
}
private static byte[] genTriwave(int w, int h, int color1, int color2, int color3, int color4, int color5, int color6) {
byte[] data = new byte[w * h * 4];