1
0
Fork 0

revert some improved rendering

This commit is contained in:
Sen 2025-08-31 11:23:30 +02:00
parent 0e003971bc
commit 9d31588d8d
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
88 changed files with 735 additions and 608 deletions

View file

@ -311,12 +311,6 @@ public class Client implements IThreadListener {
Client.CLIENT.setMidiDebug();
}
}
public static class MaxLightFunction implements IntFunction {
public void apply(IntVar cv, int value) {
Client.CLIENT.lightSetup();
}
}
public static class TextureBoolFunction implements BoolFunction {
public void apply(BoolVar cv, boolean value) {
@ -727,7 +721,7 @@ public class Client implements IThreadListener {
@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)
@Variable(name = "gl_dynlight_max", category = CVarCategory.RENDER, min = 0, max = 112, display = "Max. Dyn. Lichtquellen")
public int lightMaximum = 64;
@Variable(name = "gl_dynlight_chunkrange", category = CVarCategory.RENDER, min = 0, max = 64, display = "Lichtq. Sichtweite")
public int lightDistance = 8;
@ -741,6 +735,8 @@ public class Client implements IThreadListener {
public boolean specularColors = true;
@Variable(name = "gl_flat_shading", category = CVarCategory.RENDER, display = "Flaches Shading")
public boolean flatShading = false;
@Variable(name = "gl_use_shader", category = CVarCategory.RENDER, display = "Shader verwenden")
public boolean useShader = true;
public static final Client CLIENT = new Client();
@ -3875,14 +3871,6 @@ public class Client implements IThreadListener {
return this.tiles;
}
public void lightSetup() {
Shader.WORLD.update();
// if(win->world) {
// glNamedBufferData(win->world->light_buf, LIGHT_SSIZE * gdr.light_max, NULL, GL_DYNAMIC_DRAW);
// 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));

View file

@ -27,11 +27,12 @@ public class GuiGraphics extends GuiOptions {
this.addSelector("gl_dynlight_viewdist", 0, 200, 240, 0);
this.addSelector("gl_dynlight_maxdist", 242, 200, 240, 0);
this.addSelector("gl_light_blend", 0, 220, 240, 0);
this.addSelector("gl_specular", 242, 220, 240, 0);
this.addSelector("gl_flat_shading", 0, 240, 240, 0);
this.addSelector("gl_use_shader", 0, 220, 240, 0);
this.addSelector("gl_light_blend", 242, 220, 240, 0);
this.addSelector("gl_specular", 0, 240, 240, 0);
this.addSelector("gl_flat_shading", 242, 240, 240, 0);
this.addSelector("gl_tex_filter", 0, 260, 240, 0);
this.addSelector("gl_tex_mipmaps", 242, 260, 240, 0);

View file

@ -24,9 +24,9 @@ public class DefaultVertexFormats
static
{
BLOCK.addElement(POSITION_3F);
BLOCK.addElement(NORMAL_4B);
BLOCK.addElement(TEX_2F);
BLOCK.addElement(COLOR_4UB);
BLOCK.addElement(TEX_2F);
BLOCK.addElement(TEX_2S);
ITEM.addElement(POSITION_3F);
ITEM.addElement(COLOR_4UB);
ITEM.addElement(TEX_2F);

View file

@ -169,6 +169,11 @@ public class RenderBuffer
return this;
}
public RenderBuffer lightmap(int light)
{
return this.lightmap(light >> 16 & 65535, light & 65535);
}
public void putBrightness4(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_)
{
int i = (this.vertexCount - 4) * this.vertexFormat.getIntegerSize() + this.vertexFormat.getUvOffsetById(1) / 4;
@ -251,11 +256,6 @@ public class RenderBuffer
return this.color(color >> 16 & 255, color >> 8 & 255, color & 255, color >> 24 & 255);
}
public RenderBuffer lightColor(int light)
{
return this.color(light & 255, light >> 8 & 255, light >> 16 & 255, light >> 24 & 255);
}
public RenderBuffer lightNormal(int data)
{
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
@ -328,6 +328,15 @@ public class RenderBuffer
this.vertexCount += vertexData.length / this.vertexFormat.getIntegerSize();
}
public void addVertexData(int[] vertexData, int len)
{
this.growBuffer(len);
this.rawIntBuffer.position(this.getBufferSize());
this.rawIntBuffer.put(vertexData);
this.vertexCount += len / this.vertexFormat.getIntegerSize();
this.rawIntBuffer.position(this.getBufferSize());
}
public void endVertex()
{
++this.vertexCount;

View file

@ -41,7 +41,6 @@ import common.block.artificial.BlockSlab;
import common.block.liquid.BlockDynamicLiquid;
import common.block.liquid.BlockLiquid;
import common.block.liquid.BlockStaticLiquid;
import common.block.tech.BlockAnvil;
import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
@ -62,7 +61,6 @@ import common.sound.Sound;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Clientside;
import common.util.ExtMath;
import common.util.Facing;
import common.util.HitPosition;
@ -74,7 +72,6 @@ import common.util.ParticleType;
import common.util.Vec3;
import common.util.Vec3i;
import common.util.Vector3f;
import common.world.Chunk;
import common.world.IBlockAccess;
import common.world.IWorldAccess;
import common.world.State;
@ -2547,7 +2544,7 @@ public class Renderer {
private int renderChunks()
{
ItemRenderer.disableStandardItemLighting();
ItemRenderer.disableStandardItemLighting();
int l = 0;
int i = this.renderInfos.size();
for (int j = 0; j < i; j++)
@ -2559,66 +2556,144 @@ public class Renderer {
this.renderChunks.add(renderchunk);
}
}
GlState.setActiveTexture(GL46.GL_TEXTURE1);
GL46.glMatrixMode(GL46.GL_TEXTURE);
GL46.glLoadIdentity();
GL46.glMatrixMode(GL46.GL_MODELVIEW);
this.gm.getTextureManager().bindTexture(TEX_LIGHTMAP);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_LINEAR);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_LINEAR);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_CLAMP);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_CLAMP);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GlState.enableTexture2D();
GlState.setActiveTexture(GL46.GL_TEXTURE0);
if (this.initialized)
{
ShaderContext context = Shader.WORLD.use();
context.bool("sky_light", this.skyLight);
context.bool("moon_light", this.moonLight);
for (RenderChunk renderchunk : this.renderChunks)
if(this.gm.useShader && this.gm.dimensionName.equals("cyberspace")) {
GlState.setActiveTexture(GL46.GL_TEXTURE1);
GL46.glMatrixMode(GL46.GL_TEXTURE);
GL46.glLoadIdentity();
GL46.glMatrixMode(GL46.GL_MODELVIEW);
this.gm.getTextureManager().bindTexture(TEX_LIGHTMAP);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_LINEAR);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_LINEAR);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_CLAMP);
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_CLAMP);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GlState.enableTexture2D();
GlState.setActiveTexture(GL46.GL_TEXTURE0);
if (this.initialized)
{
VertexBuffer vertexbuffer = renderchunk.getVertexBuffer();
BlockPos blockpos = renderchunk.getPosition();
context.vec("offset", (float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ));
// Vec3 cam = MatrixState.project(Client.CLIENT.getRenderViewEntity(), Client.CLIENT.getTickFraction());
context.vec("cam_pos", (float)this.viewEntityX, (float)this.viewEntityY + this.gm.player.getEyeHeight(), (float)this.viewEntityZ);
context.matrix("model", renderchunk.getModelviewMatrix());
context.integer("chunk_x", blockpos.getX());
context.integer("chunk_y", blockpos.getY());
context.integer("chunk_z", blockpos.getZ());
vertexbuffer.bindBuffer();
ShaderContext context = Shader.GRID.use();
for (RenderChunk renderchunk : this.renderChunks)
{
VertexBuffer vertexbuffer = renderchunk.getVertexBuffer();
BlockPos blockpos = renderchunk.getPosition();
context.vec("offset", (float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ));
context.matrix("model", renderchunk.getModelviewMatrix());
context.integer("chunk_x", blockpos.getX());
context.integer("chunk_y", blockpos.getY());
context.integer("chunk_z", blockpos.getZ());
vertexbuffer.bindBuffer();
GL46.glVertexAttribPointer(0, 3, GL46.GL_FLOAT, false, 28, 0L);
GL46.glEnableVertexAttribArray(0);
GL46.glVertexAttribPointer(1, 4, GL46.GL_BYTE, true, 28, 12L);
GL46.glEnableVertexAttribArray(1);
GL46.glVertexAttribPointer(2, 2, GL46.GL_FLOAT, false, 28, 16L);
GL46.glEnableVertexAttribArray(2);
GL46.glVertexAttribPointer(3, 4, GL46.GL_UNSIGNED_BYTE, true, 28, 24L);
GL46.glEnableVertexAttribArray(3);
vertexbuffer.drawArrays(GL46.GL_QUADS);
GL46.glVertexAttribPointer(0, 3, GL46.GL_FLOAT, false, 28, 0L);
GL46.glEnableVertexAttribArray(0);
GL46.glVertexAttribPointer(1, 4, GL46.GL_BYTE, true, 28, 12L);
GL46.glEnableVertexAttribArray(1);
GL46.glVertexAttribPointer(2, 2, GL46.GL_FLOAT, false, 28, 16L);
GL46.glEnableVertexAttribArray(2);
GL46.glVertexAttribPointer(3, 4, GL46.GL_UNSIGNED_BYTE, true, 28, 24L);
GL46.glEnableVertexAttribArray(3);
vertexbuffer.drawArrays(GL46.GL_QUADS);
GL46.glDisableVertexAttribArray(0);
GL46.glDisableVertexAttribArray(1);
GL46.glDisableVertexAttribArray(2);
GL46.glDisableVertexAttribArray(3);
GL46.glDisableVertexAttribArray(0);
GL46.glDisableVertexAttribArray(1);
GL46.glDisableVertexAttribArray(2);
GL46.glDisableVertexAttribArray(3);
}
context.finish();
GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0);
GlState.resetColor();
this.renderChunks.clear();
}
context.finish();
}
else {
this.gm.renderer.enableLightmap();
GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0);
GlState.resetColor();
this.renderChunks.clear();
GL46.glEnableClientState(GL46.GL_VERTEX_ARRAY);
GL46.glClientActiveTexture(GL46.GL_TEXTURE0);
GL46.glEnableClientState(GL46.GL_TEXTURE_COORD_ARRAY);
GL46.glClientActiveTexture(GL46.GL_TEXTURE1);
GL46.glEnableClientState(GL46.GL_TEXTURE_COORD_ARRAY);
GL46.glClientActiveTexture(GL46.GL_TEXTURE0);
GL46.glEnableClientState(GL46.GL_COLOR_ARRAY);
if (this.initialized)
{
for (RenderChunk renderchunk : this.renderChunks)
{
VertexBuffer vertexbuffer = renderchunk.getVertexBuffer();
GL46.glPushMatrix();
this.preRenderChunk(renderchunk);
GL46.glMultMatrixf(renderchunk.getModelviewMatrix());
vertexbuffer.bindBuffer();
this.setupArrayPointers();
vertexbuffer.drawArrays(GL46.GL_QUADS);
GL46.glPopMatrix();
}
GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0);
GlState.resetColor();
this.renderChunks.clear();
}
for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements())
{
VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage();
int s = vertexformatelement.index();
switch (vertexformatelement$enumusage)
{
case POSITION:
GL46.glDisableClientState(GL46.GL_VERTEX_ARRAY);
break;
case UV:
GL46.glClientActiveTexture(GL46.GL_TEXTURE0 + s);
GL46.glDisableClientState(GL46.GL_TEXTURE_COORD_ARRAY);
GL46.glClientActiveTexture(GL46.GL_TEXTURE0);
break;
case COLOR:
GL46.glDisableClientState(GL46.GL_COLOR_ARRAY);
GlState.resetColor();
}
}
}
this.gm.renderer.disableLightmap();
return l;
}
// private void setupArrayPointers()
// {
// GL46.nglVertexPointer(3, GL46.GL_FLOAT, 32, 0L);
// GL46.glTexCoordPointer(2, GL46.GL_FLOAT, 32, 16L);
// GL46.nglColorPointer(4, GL46.GL_UNSIGNED_BYTE, 32, 24L);
// GL46.glClientActiveTexture(GL46.GL_TEXTURE1);
// GL46.glTexCoordPointer(2, GL46.GL_SHORT, 32, 28L);
// GL46.glClientActiveTexture(GL46.GL_TEXTURE0);
// }
private void setupArrayPointers()
{
GL46.nglVertexPointer(3, GL46.GL_FLOAT, 28, 0L);
GL46.nglColorPointer(4, GL46.GL_UNSIGNED_BYTE, 28, 12L);
GL46.glTexCoordPointer(2, GL46.GL_FLOAT, 28, 16L);
GL46.glClientActiveTexture(GL46.GL_TEXTURE1);
GL46.glTexCoordPointer(2, GL46.GL_SHORT, 28, 24L);
GL46.glClientActiveTexture(GL46.GL_TEXTURE0);
}
private void preRenderChunk(RenderChunk renderChunkIn)
{
BlockPos blockpos = renderChunkIn.getPosition();
GL46.glTranslatef((float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ));
}
private void renderSkyBox(String texture)
{
GlState.disableFog();
@ -3285,6 +3360,26 @@ public class Renderer {
}
return 0xff000000 | (int)(Math.min(directR, 1.0f) * 255.0f) << 16 | (int)(Math.min(directG, 1.0f) * 255.0f) << 8 | (int)(Math.min(directB, 1.0f) * 255.0f);
}
public int getWorldColor(BlockPos pos, Facing side, int light, boolean flip) {
float sky = this.skyLight ? pos.getY() < 0 ? 0.0f : (pos.getY() < 64 ? (float)pos.getY() / 64.0f : 1.0f) : 1.0f;
float shading = side == null ? 1.0f : FaceBakery.getFaceBrightness(side);
float max = (float)Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) / 255.0f;
max = sky * (1.0f - max * this.gm.lightBlend);
float directR = ((float)(light >> 16 & 0xff) / 255.0f + max) * shading;
float directG = ((float)(light >> 8 & 0xff) / 255.0f + max) * shading;
float directB = ((float)(light & 0xff) / 255.0f + max) * shading;
return 0xff000000 | (int)(Math.min(flip ? directB : directR, 1.0f) * 255.0f) << 16 | (int)(Math.min(directG, 1.0f) * 255.0f) << 8 | (int)(Math.min(flip ? directR : directB, 1.0f) * 255.0f);
}
public int getSkyBrightness(BlockPos pos) {
int light = this.getCombinedLight(pos);
float sky = this.skyLight ? pos.getY() < 0 ? 0.0f : (pos.getY() < 64 ? (float)pos.getY() / 64.0f : 1.0f) : 1.0f;
float max = (float)Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) / 255.0f;
max = sky * (1.0f - max * this.gm.lightBlend);
light = (int)(max * 255.0f) / 16;
return light << 20 | 1 << 4;
}
public int getCombinedBrightness(BlockPos pos) {
int light = this.getLightColor(pos, null);
@ -3320,29 +3415,26 @@ public class Renderer {
if(!list.isEmpty()) {
BlockPos bpos = pos.offset(side);
if(!checkSides || block.canRender(world, bpos, side)) {
int light = getLightmapValue(world, bpos);
this.renderModelStandardQuads(world, block, pos, side, light, false, rb, list, bounds);
int light = this.getLightmapValue(world, bpos, side);
int sky = this.getSkyBrightness(bpos);
this.renderModelStandardQuads(world, block, pos, side, light, sky, false, rb, list, bounds);
rendered = true;
}
}
}
List<BakedQuad> list = model.getQuads();
if(list.size() > 0) {
this.renderModelStandardQuads(world, block, pos, null, 0xffffffff, true, rb, list, bounds);
this.renderModelStandardQuads(world, block, pos, null, 0xffffffff, 0xffffffff, true, rb, list, bounds);
rendered = true;
}
return rendered;
}
public static int getLightColor(int light) {
return Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) << 24 | (light & 0x00ff00) | ((light >> 16) & 0xff) | ((light & 0xff) << 16);
}
public static int componentMax(int lightA, int lightB) {
return Math.max((lightA >> 16) & 0xff, (lightB >> 16) & 0xff) << 16 | Math.max((lightA >> 8) & 0xff, (lightB >> 8) & 0xff) << 8 | Math.max(lightA & 0xff, lightB & 0xff);
}
private int getLightmapValue(IWorldAccess world, BlockPos pos) {
private int getLightmapValue(IWorldAccess world, BlockPos pos, Facing side) {
Block block = world.getState(pos).getBlock();
int light = componentMax(world.getCombinedLight(pos), block.getLight());
if(light == 0 && block instanceof BlockSlab) {
@ -3350,16 +3442,16 @@ public class Renderer {
block = world.getState(pos).getBlock();
light = componentMax(world.getCombinedLight(pos), block.getLight());
}
return getLightColor(light);
return getWorldColor(pos, side, light, true);
}
private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) {
private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos, Facing side) {
int light = world.getCombinedLight(pos);
int up = world.getCombinedLight(pos.up());
return getLightColor(componentMax(light, up));
return getWorldColor(pos, side, componentMax(light, up), false);
}
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int light, boolean ownLight, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int light, int sky, boolean ownLight, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
{
double d0 = (double)blockPosIn.getX();
double d1 = (double)blockPosIn.getY();
@ -3370,11 +3462,13 @@ public class Renderer {
if (ownLight)
{
this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags);
light = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : getLightmapValue(blockAccessIn, blockPosIn);
light = boundsFlags.get(0) ? this.getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace()), bakedquad.getFace()) : this.getLightmapValue(blockAccessIn, blockPosIn, bakedquad.getFace());
sky = this.getSkyBrightness(boundsFlags.get(0) ? blockPosIn.offset(bakedquad.getFace()) : blockPosIn);
}
worldRendererIn.addVertexData(bakedquad.getVertexData());
worldRendererIn.putColor4Light(light, light, light, light);
worldRendererIn.putBrightness4(sky, sky, sky, sky);
worldRendererIn.putPosition(d0, d1, d2);
}
}
@ -3529,19 +3623,19 @@ public class Renderer {
f20 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 - f21) * 16.0F));
}
int light = getLightmapValueLiquid(blockAccess, blockPosIn);
int norm = FaceBakery.getFaceNormal(shine, Facing.UP);
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).lightNormal(norm).tex((double)f13, (double)f17).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).lightNormal(norm).tex((double)f14, (double)f18).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).lightNormal(norm).tex((double)f15, (double)f19).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).lightNormal(norm).tex((double)f16, (double)f20).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockPosIn, Facing.UP);
int sky = this.getSkyBrightness(blockPosIn);
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(light).tex((double)f13, (double)f17).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(light).tex((double)f14, (double)f18).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(light).tex((double)f15, (double)f19).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(light).tex((double)f16, (double)f20).lightmap(sky).endVertex();
if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up()))
{
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).lightNormal(norm).tex((double)f13, (double)f17).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).lightNormal(norm).tex((double)f16, (double)f20).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).lightNormal(norm).tex((double)f15, (double)f19).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).lightNormal(norm).tex((double)f14, (double)f18).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(light).tex((double)f13, (double)f17).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(light).tex((double)f16, (double)f20).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(light).tex((double)f15, (double)f19).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(light).tex((double)f14, (double)f18).lightmap(sky).endVertex();
}
}
@ -3551,12 +3645,12 @@ public class Renderer {
float f36 = atextureatlassprite[0].getMaxU();
float f37 = atextureatlassprite[0].getMinV();
float f38 = atextureatlassprite[0].getMaxV();
int light = getLightmapValueLiquid(blockAccess, blockPosIn.down());
int norm = FaceBakery.getFaceNormal(shine, Facing.DOWN);
worldRendererIn.pos(d0, d1, d2 + 1.0D).lightNormal(norm).tex((double)f35, (double)f38).lightColor(light).endVertex();
worldRendererIn.pos(d0, d1, d2).lightNormal(norm).tex((double)f35, (double)f37).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).lightNormal(norm).tex((double)f36, (double)f37).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).lightNormal(norm).tex((double)f36, (double)f38).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockPosIn.down(), Facing.DOWN);
int sky = this.getSkyBrightness(blockPosIn.down());
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(light).tex((double)f35, (double)f38).lightmap(sky).endVertex();
worldRendererIn.pos(d0, d1, d2).color(light).tex((double)f35, (double)f37).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(light).tex((double)f36, (double)f37).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(light).tex((double)f36, (double)f38).lightmap(sky).endVertex();
rendered = true;
}
@ -3640,16 +3734,16 @@ public class Renderer {
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F));
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F * 0.5F));
float f30 = textureatlassprite1.getInterpolatedV(8.0D);
int light = getLightmapValueLiquid(blockAccess, blockpos);
int norm = FaceBakery.getFaceNormal(shine, np == 0 ? Facing.NORTH : (np == 1 ? Facing.SOUTH : (np == 2 ? Facing.WEST : Facing.EAST)));
worldRendererIn.pos(d3, d1 + (double)f39, d4).lightNormal(norm).tex((double)f41, (double)f28).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).lightNormal(norm).tex((double)f27, (double)f29).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).lightNormal(norm).tex((double)f27, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).lightNormal(norm).tex((double)f41, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).lightNormal(norm).tex((double)f41, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).lightNormal(norm).tex((double)f27, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).lightNormal(norm).tex((double)f27, (double)f29).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).lightNormal(norm).tex((double)f41, (double)f28).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockpos, np == 0 ? Facing.NORTH : (np == 1 ? Facing.SOUTH : (np == 2 ? Facing.WEST : Facing.EAST)));
int sky = this.getSkyBrightness(blockpos);
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(light).tex((double)f41, (double)f28).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(light).tex((double)f27, (double)f29).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(light).tex((double)f27, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(light).tex((double)f41, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(light).tex((double)f41, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(light).tex((double)f27, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(light).tex((double)f27, (double)f29).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(light).tex((double)f41, (double)f28).lightmap(sky).endVertex();
}
}
@ -3752,12 +3846,12 @@ public class Renderer {
f16 = f15;
f20 = f17;
int light = getLightmapValueLiquid(blockAccess, blockPosIn);
int norm = FaceBakery.getFaceNormal(shine, Facing.UP);
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).lightNormal(norm).tex((double)f13, (double)f17).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).lightNormal(norm).tex((double)f14, (double)f18).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).lightNormal(norm).tex((double)f15, (double)f19).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).lightNormal(norm).tex((double)f16, (double)f20).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockPosIn, Facing.UP);
int sky = this.getSkyBrightness(blockPosIn);
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(light).tex((double)f13, (double)f17).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(light).tex((double)f14, (double)f18).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(light).tex((double)f15, (double)f19).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(light).tex((double)f16, (double)f20).lightmap(sky).endVertex();
//
// if (block.shouldRenderSides(blockAccess, blockPosIn.up()))
// {
@ -3774,12 +3868,12 @@ public class Renderer {
float f36 = textureatlassprite.getMaxU();
float f37 = textureatlassprite.getMinV();
float f38 = textureatlassprite.getMaxV();
int light = getLightmapValueLiquid(blockAccess, blockPosIn.down());
int norm = FaceBakery.getFaceNormal(shine, Facing.DOWN);
worldRendererIn.pos(d0, d1, d2 + 1.0D).lightNormal(norm).tex((double)f35, (double)f38).lightColor(light).endVertex();
worldRendererIn.pos(d0, d1, d2).lightNormal(norm).tex((double)f35, (double)f37).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).lightNormal(norm).tex((double)f36, (double)f37).lightColor(light).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).lightNormal(norm).tex((double)f36, (double)f38).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockPosIn.down(), Facing.DOWN);
int sky = this.getSkyBrightness(blockPosIn.down());
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(light).tex((double)f35, (double)f38).lightmap(sky).endVertex();
worldRendererIn.pos(d0, d1, d2).color(light).tex((double)f35, (double)f37).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(light).tex((double)f36, (double)f37).lightmap(sky).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(light).tex((double)f36, (double)f38).lightmap(sky).endVertex();
rendered = true;
}
@ -3863,16 +3957,16 @@ public class Renderer {
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F));
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F));
float f30 = textureatlassprite1.getInterpolatedV(16.0D);
int light = getLightmapValueLiquid(blockAccess, blockpos);
int norm = FaceBakery.getFaceNormal(shine, np == 0 ? Facing.NORTH : (np == 1 ? Facing.SOUTH : (np == 2 ? Facing.WEST : Facing.EAST)));
worldRendererIn.pos(d3, d1 + (double)f39, d4).lightNormal(norm).tex((double)f41, (double)f28).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).lightNormal(norm).tex((double)f27, (double)f29).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).lightNormal(norm).tex((double)f27, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).lightNormal(norm).tex((double)f41, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).lightNormal(norm).tex((double)f41, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).lightNormal(norm).tex((double)f27, (double)f30).lightColor(light).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).lightNormal(norm).tex((double)f27, (double)f29).lightColor(light).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).lightNormal(norm).tex((double)f41, (double)f28).lightColor(light).endVertex();
int light = this.getLightmapValueLiquid(blockAccess, blockpos, np == 0 ? Facing.NORTH : (np == 1 ? Facing.SOUTH : (np == 2 ? Facing.WEST : Facing.EAST)));
int sky = this.getSkyBrightness(blockpos);
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(light).tex((double)f41, (double)f28).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(light).tex((double)f27, (double)f29).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(light).tex((double)f27, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(light).tex((double)f41, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(light).tex((double)f41, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(light).tex((double)f27, (double)f30).lightmap(sky).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(light).tex((double)f27, (double)f29).lightmap(sky).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(light).tex((double)f41, (double)f28).lightmap(sky).endVertex();
}
}
@ -3906,7 +4000,7 @@ public class Renderer {
if (!material.isNonBlock()) // material != block
{
if (!material.canConnectNonBlock())
if (material == Blocks.air)
{
++a;
f += 4;

View file

@ -15,7 +15,6 @@ import client.Client;
import client.util.FileUtils;
import common.collect.Maps;
import common.log.Log;
import common.util.ExtMath;
import common.util.Matrix4f;
import common.util.Util;
import common.util.Vec3;
@ -23,56 +22,18 @@ import common.util.Vector3f;
import common.util.Vector4f;
public enum Shader {
WORLD("world", "world", context -> {context.integer("tex", 0); /* GL46.glUniformBlockBinding(context.getProgram(), GL46.glGetUniformBlockIndex(context.getProgram(), "light_block"), 0); */}, 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);
GRID("grid", "grid", context -> {context.integer("tex", 0);}, context -> {
context.matrix("view", MatrixState.getModelView());
context.matrix("projection", MatrixState.getProjection());
context.vec("time", (float)Util.ftime());
float angle = -90.0f + Client.CLIENT.renderer.getCelestialAngle(Client.CLIENT.getTickFraction());
float sunX = !Client.CLIENT.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos(angle / 180.0f * (float)Math.PI);
float sunY = !Client.CLIENT.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin(angle / 180.0f * (float)Math.PI);
context.vec("sun_direction", sunX, sunY, 0.0f);
float moonX = !Client.CLIENT.world.dimension.hasDaylight() ? 0.0f : ExtMath.cos((180.0f + angle) / 180.0f * (float)Math.PI);
float moonY = !Client.CLIENT.world.dimension.hasDaylight() ? -1.0f : ExtMath.sin((180.0f + angle) / 180.0f * (float)Math.PI);
context.vec("moon_direction", moonX, moonY, 0.0f);
float sunRed = Client.CLIENT.renderer.getSunColorRed();
float sunGreen = Client.CLIENT.renderer.getSunColorGreen();
float sunBlue = Client.CLIENT.renderer.getSunColorBlue();
context.vec("sun_ambient", sunRed, sunGreen, sunBlue);
float moonRed = Client.CLIENT.renderer.getMoonColorRed();
float moonGreen = Client.CLIENT.renderer.getMoonColorGreen();
float moonBlue = Client.CLIENT.renderer.getMoonColorBlue();
context.vec("moon_ambient", moonRed, moonGreen, moonBlue);
context.vec("light_factor", Client.CLIENT.lightBlend);
context.vec("max_vert_dist", Client.CLIENT.lightDistVert);
context.vec("max_cam_dist", Client.CLIENT.lightDistCam);
context.integer("n_lights", 0);
context.color3("specular", Client.CLIENT.specularColors && !Client.CLIENT.setGamma && !Client.CLIENT.xrayActive ? 0xffffff : 0x000000);
context.bool("shade", Client.CLIENT.flatShading || Client.CLIENT.setGamma || Client.CLIENT.xrayActive);
GlState.setActiveTexture(GL46.GL_TEXTURE0);
// glBindBufferBase(GL_UNIFORM_BUFFER, 0, world->light_buf);
}, "MAX_LIGHTS", (Supplier<Integer>)() -> Client.CLIENT.lightMaximum),
context.vec("tex_mul", (float)Client.CLIENT.getTextureMapBlocks().getWidth() / 16.0f, (float)Client.CLIENT.getTextureMapBlocks().getHeight() / 16.0f);
}),
VIS("vis", "vis", null, context -> {
context.matrix("view", MatrixState.getModelView());
context.matrix("projection", MatrixState.getProjection());
});
// BLIT("blit", "blit", context -> context.integer("tex", 0), context -> {
// GL46.glBindVertexArray(QUAD);
// GlState.setActiveTexture(GL46.GL_TEXTURE0);
// });
public class ShaderContext {
private final int program;
@ -314,13 +275,4 @@ public enum Shader {
if(this.program != 0 && !this.load())
Log.RENDER.error("Konnte Shader-Programm '%s' nicht neu laden", this.name());
}
// void shd_setint(int *pos, const char *vardef, int value) {
// *pos += sprintf(&gdr.shd_include[*pos], "#define %s %d\n", vardef, value);
// }
//
// void shd_setvars() {
// int pos = 0;
// shd_setint(&pos, "MAX_LIGHTS", gdr.light_max < 1 ? 1 : gdr.light_max);
// }
}

View file

@ -33,6 +33,9 @@ public class TextureMap extends Texture
private final Map<String, TextureCreator> tickedTextures;
private final Map<String, Integer> animTextures;
private final Sprite missingImage;
private int width;
private int height;
public TextureMap()
{
@ -62,6 +65,14 @@ public class TextureMap extends Texture
map.clear();
anim.clear();
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
private void initMissingImage()
{
@ -146,7 +157,7 @@ public class TextureMap extends Texture
}
Log.RENDER.info("Textur-Atlas in Größe " + stitcher.getCurrentWidth() + "x" + stitcher.getCurrentHeight() + " erstellt");
TextureUtil.allocateTexture(this.getGlTextureId(), stitcher.getCurrentWidth(), stitcher.getCurrentHeight());
TextureUtil.allocateTexture(this.getGlTextureId(), this.width = stitcher.getCurrentWidth(), this.height = stitcher.getCurrentHeight());
Map<String, Sprite> map = Maps.<String, Sprite>newHashMap(this.mapRegisteredSprites);
for (Sprite textureatlassprite2 : stitcher.getStichSlots())