fix block colors
This commit is contained in:
parent
2f010b35c9
commit
1e79613f2b
3 changed files with 26 additions and 26 deletions
|
@ -2600,7 +2600,7 @@ public class Renderer {
|
|||
GL46.glEnableVertexAttribArray(1);
|
||||
GL46.glVertexAttribPointer(2, 2, GL46.GL_FLOAT, false, 28, 16L);
|
||||
GL46.glEnableVertexAttribArray(2);
|
||||
GL46.glVertexAttribPointer(3, 2, GL46.GL_UNSIGNED_SHORT, true, 28, 24L);
|
||||
GL46.glVertexAttribPointer(3, 4, GL46.GL_UNSIGNED_BYTE, true, 28, 24L);
|
||||
GL46.glEnableVertexAttribArray(3);
|
||||
|
||||
vertexbuffer.drawArrays(GL46.GL_QUADS);
|
||||
|
@ -3338,34 +3338,35 @@ public class Renderer {
|
|||
}
|
||||
List<BakedQuad> list = model.getQuads();
|
||||
if(list.size() > 0) {
|
||||
this.renderModelStandardQuads(world, block, pos, null, -1, true, rb, list, bounds);
|
||||
this.renderModelStandardQuads(world, block, pos, null, 0xffffffff, true, rb, list, bounds);
|
||||
rendered = true;
|
||||
}
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private int getLightColor(int light) {
|
||||
return light << 24 | (int)(this.blockColorBlue * (float)light) << 16 | (int)(this.blockColorGreen * (float)light) << 8 | (int)(this.blockColorRed * (float)light);
|
||||
}
|
||||
|
||||
private static final int getLightmapValue(IWorldAccess world, BlockPos pos) {
|
||||
private int getLightmapValue(IWorldAccess world, BlockPos pos) {
|
||||
Block block = world.getState(pos).getBlock();
|
||||
int light = world.getCombinedLight(pos, block.getLight());
|
||||
int light = world.getCombinedLight(pos, block.getLight()) & 0xff;
|
||||
if(light == 0 && block instanceof BlockSlab) {
|
||||
pos = pos.down();
|
||||
block = world.getState(pos).getBlock();
|
||||
return world.getCombinedLight(pos, block.getLight());
|
||||
light = world.getCombinedLight(pos, block.getLight()) & 0xff;
|
||||
}
|
||||
return light;
|
||||
return this.getLightColor(light);
|
||||
}
|
||||
|
||||
private static final int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) {
|
||||
int i = world.getCombinedLight(pos, 0);
|
||||
int j = world.getCombinedLight(pos.up(), 0);
|
||||
int k = i & 255;
|
||||
int l = j & 255;
|
||||
int i1 = i >> 16 & 255;
|
||||
int j1 = j >> 16 & 255;
|
||||
return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
|
||||
private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) {
|
||||
int light = world.getCombinedLight(pos, 0) & 0xff;
|
||||
int up = world.getCombinedLight(pos.up(), 0) & 0xff;
|
||||
light = light > up ? light : up;
|
||||
return this.getLightColor(light);
|
||||
}
|
||||
|
||||
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int brightnessIn, boolean ownBrightness, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
|
||||
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int light, boolean ownLight, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
|
||||
{
|
||||
double d0 = (double)blockPosIn.getX();
|
||||
double d1 = (double)blockPosIn.getY();
|
||||
|
@ -3373,14 +3374,14 @@ public class Renderer {
|
|||
|
||||
for (BakedQuad bakedquad : listQuadsIn)
|
||||
{
|
||||
if (ownBrightness)
|
||||
if (ownLight)
|
||||
{
|
||||
this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags);
|
||||
brightnessIn = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : getLightmapValue(blockAccessIn, blockPosIn);
|
||||
light = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : getLightmapValue(blockAccessIn, blockPosIn);
|
||||
}
|
||||
|
||||
worldRendererIn.addVertexData(bakedquad.getVertexData());
|
||||
worldRendererIn.putBrightness4(brightnessIn, brightnessIn, brightnessIn, brightnessIn);
|
||||
worldRendererIn.putBrightness4(light, light, light, light);
|
||||
worldRendererIn.putPosition(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,11 @@ struct light_t {
|
|||
in vec3 vertex;
|
||||
in vec3 normal;
|
||||
in vec2 tex_coord;
|
||||
in vec2 lm_coord;
|
||||
in vec4 light_color;
|
||||
in float brightness;
|
||||
|
||||
uniform vec3 cam_pos;
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D lightmap;
|
||||
uniform vec3 specular;
|
||||
uniform float shine;
|
||||
uniform float max_vert_dist;
|
||||
|
@ -77,10 +76,10 @@ void main() {
|
|||
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;
|
||||
float block = clamp(0.03125 + lm_coord.x * 256.0, 0.0, 1.0);
|
||||
vec3 lm = block * block_ambient;
|
||||
// float block = clamp(0.03125 + lm_coord.x * 256.0, 0.0, 1.0);
|
||||
// vec3 lm = block * block_ambient;
|
||||
vec3 rgb = texel.rgb; // * brightness;
|
||||
vec3 result = rgb * lm + calc_dir_light(norm, dir, rgb * sky * (1.0 - block));
|
||||
vec3 result = rgb * light_color.rgb + calc_dir_light(norm, dir, rgb * sky * (1.0 - light_color.a * 0.5));
|
||||
// int l = 0;
|
||||
for(int z = 0; z < n_lights; z++) {
|
||||
// if(lights[z].enabled) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
layout (location = 0) in vec3 pos;
|
||||
layout (location = 1) in vec4 norm;
|
||||
layout (location = 2) in vec2 coord;
|
||||
layout (location = 3) in vec2 light;
|
||||
layout (location = 3) in vec4 light;
|
||||
|
||||
out vec3 vertex;
|
||||
out vec3 normal;
|
||||
out vec2 tex_coord;
|
||||
out vec2 lm_coord;
|
||||
out vec4 light_color;
|
||||
out float brightness;
|
||||
|
||||
uniform mat4 model;
|
||||
|
@ -23,6 +23,6 @@ void main() {
|
|||
normal = mat3(transpose(inverse(model))) * norm.rgb;
|
||||
brightness = norm.a;
|
||||
tex_coord = coord;
|
||||
lm_coord = light;
|
||||
light_color = light;
|
||||
gl_Position = projection * view * vec4(offset + nvertex, 1.0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue