1
0
Fork 0

add visuals

This commit is contained in:
Sen 2025-08-29 15:35:11 +02:00
parent 1bf4578ad8
commit 220a8432ef
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
13 changed files with 81 additions and 93 deletions

View file

@ -707,9 +707,9 @@ public class Client implements IThreadListener {
@Variable(name = "gl_light_blend", category = CVarCategory.RENDER, min = 0.0f, max = 1.0f, precision = 2, unit = "%", display = "Lichtüberdeckung")
public float lightBlend = 0.5f;
@Variable(name = "gl_dynlight_maxdist", category = CVarCategory.RENDER, min = 1.0f, max = 10000.0f, display = "Entfernung Lichtq. -> Mitte")
@Variable(name = "gl_dynlight_maxdist", category = CVarCategory.RENDER, min = 1.0f, max = 10000.0f, display = "Entfernung Lichtquelle")
public float lightDistVert = 128.0f;
@Variable(name = "gl_dynlight_viewdist", category = CVarCategory.RENDER, min = 1.0f, max = 10000.0f, display = "Entfernung Lichtq. -> Kamera")
@Variable(name = "gl_dynlight_viewdist", category = CVarCategory.RENDER, min = 1.0f, max = 10000.0f, display = "Entfernung Licht Kamera")
public float lightDistCam = 256.0f;
@Variable(name = "gl_dynlight_max", category = CVarCategory.RENDER, min = 0, max = 112, display = "Max. Dyn. Lichtquellen", callback = MaxLightFunction.class)
@ -864,6 +864,7 @@ public class Client implements IThreadListener {
this.renderItem.onReload();
this.renderer.cacheSprites();
EntityTexManager.loadNpcTextures();
this.updateTexture();
this.renderer.loadRenderers();
this.logFeed("Texturen wurden neu geladen");
}

View file

@ -29,6 +29,7 @@ public enum Shader {
context.vec("screen", (float)Client.CLIENT.fbRawX, (float)Client.CLIENT.fbRawY);
context.matrix("view", MatrixState.getModelView());
context.matrix("projection", MatrixState.getProjection());
context.vec("time", (float)Util.ftime());
float angle = -90.0f + Client.CLIENT.world.getCelestialAngle(Client.CLIENT.getTickFraction());
@ -64,15 +65,6 @@ public enum Shader {
VIS("vis", "vis", null, context -> {
context.matrix("view", MatrixState.getModelView());
context.matrix("projection", MatrixState.getProjection());
}),
GRID("grid", "grid", null, context -> {
context.vec("clip_near", Client.CLIENT.renderer.getNearPlane());
context.vec("clip_far", Client.CLIENT.renderer.getFarPlane());
context.vec("screen", (float)Client.CLIENT.fbRawX, (float)Client.CLIENT.fbRawY);
context.matrix("view", MatrixState.getModelView());
context.matrix("projection", MatrixState.getProjection());
context.vec("time", (float)Util.ftime());
});
// BLIT("blit", "blit", context -> context.integer("tex", 0), context -> {

View file

@ -112,20 +112,14 @@ public class TextureUtil
return img;
}
static
{
int i = -16777216;
int j = -524040;
int[] aint = new int[] { -524040, -524040, -524040, -524040, -524040, -524040, -524040, -524040};
int[] aint1 = new int[] { -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216};
int k = aint.length;
for (int l = 0; l < 16; ++l)
{
System.arraycopy(l < k ? aint : aint1, 0, MISSING_DATA, 16 * l, k);
System.arraycopy(l < k ? aint1 : aint, 0, MISSING_DATA, 16 * l + k, k);
}
MISSING.updateTexture();
}
static {
int color1 = 0xff000000;
int color2 = 0xffff00ff;
for(int x = 0; x < 16; x++) {
for(int y = 0; y < 16; y++) {
MISSING_DATA[y * 16 + x] = ((x >> 1 & 1) ^ (y >> 1 & 1)) == 0 ? color1 : color2;
}
}
MISSING.updateTexture();
}
}

View file

@ -1,39 +0,0 @@
out vec4 FragColor;
in vec3 vertex;
in vec2 tex_coord;
uniform float time;
#define GLM_PI 3.14159265358979323846264338327950288
#define GLM_SQRT2 1.41421356237309504880168872420969808
#define vis_div 24.0
float v2rand(vec2 uv) {
return fract(sin(dot(uv, vec2(12.9898,78.233))) * 43758.5453123);
}
float avg(vec4 v) {
return ((v.r + v.g + v.b) / 3.0) * v.a;
}
float gauss(float v, float b, float c) {
return (1.0 / (c * sqrt(2.0 * GLM_PI))) * exp(-(pow(v - b, 2.0) / (2.0 * pow(c, 2.0))));
}
float dgauss(float v, float b, float c) {
return b + v * c;
}
float inside(vec2 vec, vec2 offs, float a, float b, float scale, float x1, float x2, float y1, float y2) {
vec2 cscaled = (mod(vec + offs + 1.0, 1.0)) * scale;
return (x2 < x1 ? (cscaled.x >= x1 || cscaled.x <= x2) : (cscaled.x >= x1 && cscaled.x <= x2)) || (y2 < y1 ? (cscaled.y >= y1 || cscaled.y <= y2) : (cscaled.y >= y1 && cscaled.y <= y2)) || (abs(cscaled.y - (cscaled.x - (x2 < x1 ? (x1 - x2) : (x2 - x1)) * GLM_SQRT2 * (x2 < x1 ? 0.0 : (x1 < scale / 2.0 ? x1 : (x2 - scale))))) < GLM_SQRT2) ? b : a;
}
void main() {
vec2 coord = vec2(vertex.x, vertex.z) * 16.0f;
vec2 shift = vec2(v2rand(coord + fract(time)) * 2.0 - 1.0, v2rand(coord + 0.5 + fract(time)) * 2.0 - 1.0);
shift = vec2(dgauss(shift.x, 0.0, 1.0), dgauss(shift.y, 0.0, 1.0)) * 0.015;
vec3 cl = vec3(inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 1.0, 3.0, 1.0, 3.0), inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 63.0, 1.0, 63.0, 1.0), inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 61.0, 63.0, 61.0, 63.0));
FragColor = vec4(mix(vec3(0.0, 0.0, clamp(0.1 + 0.2 * (vertex.y + 64.0) / 128.0, 0.0, 1.0)), cl, clamp(cl.x + cl.y + cl.z, 0.0, 1.0)), 1.0);
}

View file

@ -1,18 +0,0 @@
layout (location = 0) in vec3 pos;
layout (location = 1) in vec4 color;
layout (location = 2) in vec2 coord;
layout (location = 3) in vec2 light;
out vec3 vertex;
out vec2 tex_coord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform vec3 offset;
void main() {
vertex = vec3(model * vec4(pos, 1.0));
tex_coord = coord;
gl_Position = projection * view * vec4(offset + vertex, 1.0);
}

View file

@ -1,3 +1,7 @@
#define GLM_PI 3.14159265358979323846264338327950288
#define GLM_SQRT2 1.41421356237309504880168872420969808
#define vis_div 24.0
out vec4 FragColor;
struct light_t {
@ -27,10 +31,32 @@ uniform vec3 moon_ambient;
uniform int n_lights;
uniform bool sky_light;
uniform bool moon_light;
uniform float time;
uniform light_block {
light_t lights[MAX_LIGHTS];
};
float v2rand(vec2 uv) {
return fract(sin(dot(uv, vec2(12.9898,78.233))) * 43758.5453123);
}
float avg(vec4 v) {
return ((v.r + v.g + v.b) / 3.0) * v.a;
}
float gauss(float v, float b, float c) {
return (1.0 / (c * sqrt(2.0 * GLM_PI))) * exp(-(pow(v - b, 2.0) / (2.0 * pow(c, 2.0))));
}
float dgauss(float v, float b, float c) {
return b + v * c;
}
float inside(vec2 vec, vec2 offs, float a, float b, float scale, float x1, float x2, float y1, float y2) {
vec2 cscaled = (mod(vec + offs + 1.0, 1.0)) * scale;
return (x2 < x1 ? (cscaled.x >= x1 || cscaled.x <= x2) : (cscaled.x >= x1 && cscaled.x <= x2)) || (y2 < y1 ? (cscaled.y >= y1 || cscaled.y <= y2) : (cscaled.y >= y1 && cscaled.y <= y2)) || (abs(cscaled.y - (cscaled.x - (x2 < x1 ? (x1 - x2) : (x2 - x1)) * GLM_SQRT2 * (x2 < x1 ? 0.0 : (x1 < scale / 2.0 ? x1 : (x2 - scale))))) < GLM_SQRT2) ? b : a;
}
/*
vec4 pcf_sample(sampler2D stex, vec2 pos) {
vec4 avg = vec4(0.0);
@ -73,12 +99,21 @@ vec3 calc_point_light(light_t light, vec3 norm, vec3 dir, vec3 rgb) {
}
void main() {
if(shine <= 0.0) {
vec2 coord = fract(tex_coord * 2.0) * vis_div; // vertex.xz + vec2(0.25, 0.5)) * 24.0 / 2.0;
vec2 shift = vec2(v2rand(coord + fract(time)) * 2.0 - 1.0, v2rand(coord + 0.5 + fract(time)) * 2.0 - 1.0);
shift = vec2(dgauss(shift.x, 0.0, 1.0), dgauss(shift.y, 0.0, 1.0)) * 0.015;
vec3 cl = vec3(inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 1.0, 3.0, 1.0, 3.0), inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 63.0, 1.0, 63.0, 1.0), inside(coord / vis_div, shift, 0.0, 1.0, 64.0, 61.0, 63.0, 61.0, 63.0));
FragColor = vec4(mix(vec3(0.0, 0.0, clamp(0.1 + 0.2 * (vertex.y + 64.0) / 128.0, 0.0, 1.0)), cl, clamp(cl.x + cl.y + cl.z, 0.0, 1.0)), 1.0);
return;
}
vec3 norm = normalize(normal);
vec3 dir = normalize(cam_pos - vertex);
vec4 texel = texture(tex, tex_coord);
float sky = sky_light ? vertex.y < 0.0 ? 0.0 : (vertex.y < 64.0 ? vertex.y / 64.0 : 1.0) : 1.0;
vec3 rgb = texel.rgb;
vec3 direct = rgb * sky * (1.0 - light_color.a * 0.5);
vec3 direct = rgb * sky * (1.0 - light_color.a * light_factor);
vec3 result = rgb * light_color.rgb + calc_dir_light(norm, dir, direct, sun_direction, sun_ambient);
if(moon_light)
result += calc_dir_light(norm, dir, direct, moon_direction, moon_ambient);

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB