Search in sources :

Example 1 with ModelQuadViewMutable

use of me.jellysquid.mods.sodium.client.render.quad.ModelQuadViewMutable in project sodium-fabric by CaffeineMC.

the class ChunkBlockRenderPipeline method renderQuad.

private void renderQuad(BlockRenderView world, BlockState state, BlockPos pos, VertexConsumer builder, Vector3f translation, ModelQuadView quad, float[] brightnesses, int[] lights) {
    int color = this.getQuadColor(quad, world, state, pos);
    float r, g, b;
    if (color != Integer.MIN_VALUE) {
        r = ColorUtil.normalize(ColorUtil.unpackColorR(color));
        g = ColorUtil.normalize(ColorUtil.unpackColorG(color));
        b = ColorUtil.normalize(ColorUtil.unpackColorB(color));
    } else {
        r = 1.0f;
        g = 1.0f;
        b = 1.0f;
    }
    ModelQuadOrder order = ModelQuadOrder.orderOf(brightnesses);
    ModelQuadViewMutable copy = this.cachedQuad;
    int norm = QuadUtil.getNormal(quad.getFacing());
    for (int i = 0; i < 4; i++) {
        int o = order.getVertexIndex(i);
        copy.setX(i, quad.getX(o) + translation.getX());
        copy.setY(i, quad.getY(o) + translation.getY());
        copy.setZ(i, quad.getZ(o) + translation.getZ());
        float br = brightnesses[o];
        if (color != Integer.MIN_VALUE) {
            copy.setColor(i, ColorUtil.mulPackedRGB(quad.getColor(o), r * br, g * br, b * br));
        } else {
            copy.setColor(i, ColorUtil.mulPacked(quad.getColor(o), br));
        }
        copy.setTexU(i, quad.getTexU(o));
        copy.setTexV(i, quad.getTexV(o));
        copy.setLight(i, lights[o]);
        copy.setNormal(i, norm);
    }
    ((ChunkMeshBuilder) builder).write(copy);
}
Also used : ModelQuadViewMutable(me.jellysquid.mods.sodium.client.render.quad.ModelQuadViewMutable) ChunkMeshBuilder(me.jellysquid.mods.sodium.client.render.mesh.ChunkMeshBuilder) ModelQuadOrder(me.jellysquid.mods.sodium.client.render.quad.ModelQuadOrder)

Aggregations

ChunkMeshBuilder (me.jellysquid.mods.sodium.client.render.mesh.ChunkMeshBuilder)1 ModelQuadOrder (me.jellysquid.mods.sodium.client.render.quad.ModelQuadOrder)1 ModelQuadViewMutable (me.jellysquid.mods.sodium.client.render.quad.ModelQuadViewMutable)1