1
0
Fork 0

implement material roughness

This commit is contained in:
Sen 2025-08-29 11:22:33 +02:00
parent 1e79613f2b
commit 401f9dbe34
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
12 changed files with 73 additions and 60 deletions

View file

@ -3468,6 +3468,7 @@ public class Renderer {
boolean up = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP);
boolean down = blockliquid.canRender(blockAccess, blockPosIn.down(), Facing.DOWN);
boolean[] aboolean = new boolean[] {blockliquid.canRender(blockAccess, blockPosIn.north(), Facing.NORTH), blockliquid.canRender(blockAccess, blockPosIn.south(), Facing.SOUTH), blockliquid.canRender(blockAccess, blockPosIn.west(), Facing.WEST), blockliquid.canRender(blockAccess, blockPosIn.east(), Facing.EAST)};
float shine = (blockliquid.getShinyness() / 32.0f) * 0.5f;
if (!up && !down && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3])
{
@ -3538,17 +3539,17 @@ public class Renderer {
int k2 = getLightmapValueLiquid(blockAccess, blockPosIn);
int l2 = k2 >> 16 & 65535;
int i3 = k2 & 65535;
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up()))
{
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
}
}
@ -3561,10 +3562,10 @@ public class Renderer {
int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down());
int i2 = l1 >> 16 & 65535;
int j2 = l1 & 65535;
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
rendered = true;
}
@ -3653,15 +3654,14 @@ public class Renderer {
int l = j & 65535;
float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f);
float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f);
float br = np < 2 ? 0.4f : 0.3f;
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
}
}

View file

@ -23,7 +23,7 @@ import common.util.Vector3f;
import common.util.Vector4f;
public enum Shader {
WORLD("world", "world", context -> {context.integer("tex", 0); context.integer("lightmap", 1); /* GL46.glUniformBlockBinding(context.getProgram(), GL46.glGetUniformBlockIndex(context.getProgram(), "light_block"), 0); */}, context -> {
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);
@ -51,8 +51,6 @@ public enum Shader {
context.integer("n_lights", 0);
context.color3("specular", 0xffffff);
context.vec("shine", 1.0f);
// context.vec("density", density);
GlState.setActiveTexture(GL46.GL_TEXTURE0);
// glBindBufferBase(GL_UNIFORM_BUFFER, 0, world->light_buf);

View file

@ -73,9 +73,9 @@ public class FaceBakery
FACINGS[Constants.EAST_INDEX] = EnumFaceDirection.EAST;
}
public BakedQuad makeBakedQuad(Vector3f posFrom, Vector3f posTo, BlockPartFace face, Sprite sprite, Facing facing, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade)
public BakedQuad makeBakedQuad(Vector3f posFrom, Vector3f posTo, BlockPartFace face, Sprite sprite, Facing facing, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine)
{
int[] aint = this.makeQuadVertexData(face, sprite, facing, this.getPositionsDiv16(posFrom, posTo), modelRotationIn, partRotation, uvLocked, shade);
int[] aint = this.makeQuadVertexData(face, sprite, facing, this.getPositionsDiv16(posFrom, posTo), modelRotationIn, partRotation, uvLocked, shade, shine);
Facing enumfacing = getFacingFromVertexData(aint);
if (uvLocked)
@ -91,13 +91,13 @@ public class FaceBakery
return new BakedQuad(aint, face.tint, enumfacing);
}
private int[] makeQuadVertexData(BlockPartFace partFace, Sprite sprite, Facing facing, float[] p_178405_4_, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade)
private int[] makeQuadVertexData(BlockPartFace partFace, Sprite sprite, Facing facing, float[] p_178405_4_, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine)
{
int[] aint = new int[28];
for (int i = 0; i < 4; ++i)
{
this.fillVertexData(aint, i, facing, partFace, p_178405_4_, sprite, modelRotationIn, partRotation, uvLocked, shade);
this.fillVertexData(aint, i, facing, partFace, p_178405_4_, sprite, modelRotationIn, partRotation, uvLocked, shade, shine);
}
return aint;
@ -105,7 +105,7 @@ public class FaceBakery
private int getFaceShadeColor(Facing facing)
{
return this.getFaceBrightness(facing) << 24 | this.getFaceNormal(facing);
return this.getFaceNormal(facing);
}
private int getFaceNormal(Facing facing)
@ -128,29 +128,6 @@ public class FaceBakery
}
}
private int getFaceBrightness(Facing facing)
{
switch (facing)
{
case DOWN:
return 0x3f;
case UP:
return 0x7f;
case NORTH:
case SOUTH:
return 0x65;
case WEST:
case EAST:
return 0x4c;
default:
return 0x7f;
}
}
private float[] getPositionsDiv16(Vector3f pos1, Vector3f pos2)
{
float[] afloat = new float[Facing.values().length];
@ -163,10 +140,10 @@ public class FaceBakery
return afloat;
}
private void fillVertexData(int[] faceData, int vertexIndex, Facing facing, BlockPartFace partFace, float[] p_178402_5_, Sprite sprite, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade)
private void fillVertexData(int[] faceData, int vertexIndex, Facing facing, BlockPartFace partFace, float[] p_178402_5_, Sprite sprite, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine)
{
Facing enumfacing = modelRotationIn.rotateFace(facing);
int i = shade ? this.getFaceShadeColor(enumfacing) : 0x7f000000;
int i = (int)((shine / 32.0f) * 127.0f) << 24 | (shade ? this.getFaceShadeColor(enumfacing) : 0x000000);
VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.getFacing(facing).getVertexInformation(vertexIndex);
Vector3f vector3f = new Vector3f(p_178402_5_[enumfacedirection$vertexinformation.xIndex], p_178402_5_[enumfacedirection$vertexinformation.yIndex], p_178402_5_[enumfacedirection$vertexinformation.zIndex]);
this.rotatePart(vector3f, partRotation);

View file

@ -61,6 +61,7 @@ public abstract class ModelBakery
for(Entry<State, String> entry : map.entrySet()) {
ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(provider, BlockRegistry.getName(entry.getKey().getBlock())
.toString(), entry.getKey());
model.setShinyness(entry.getKey().getBlock().getShinyness());
models.put(entry.getValue(), model);
variants.add(entry.getValue());
}
@ -231,9 +232,9 @@ public abstract class ModelBakery
sprite = sprite == null ? fallback : sprite;
if (face.cull == null)
builder.addGeneralQuad(faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade));
builder.addGeneralQuad(faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade, modelBlockIn.getShinyness()));
else
builder.addFaceQuad(modelRotationIn.rotateFace(face.cull), faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade));
builder.addFaceQuad(modelRotationIn.rotateFace(face.cull), faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade, modelBlockIn.getShinyness()));
}
}
return builder.makeBakedModel();

View file

@ -21,6 +21,7 @@ public class ModelBlock extends Model {
private ModelRotation rotation;
private boolean uvLock;
private GuiPosition transform;
private float shinyness;
private BlockPart lastPart;
private BlockPartFace[] last;
@ -159,4 +160,12 @@ public class ModelBlock extends Model {
public boolean isUvLocked() {
return this.uvLock;
}
public void setShinyness(float shinyness) {
this.shinyness = shinyness;
}
public float getShinyness() {
return this.shinyness;
}
}