restore custom meshes

This commit is contained in:
Zack Buhman 2026-03-19 15:08:46 -05:00
parent 50a747934d
commit 8283bc2974
22 changed files with 4165 additions and 21 deletions

View File

@ -12,9 +12,9 @@ struct {
short offset;
short count;
} index_buffer_custom_offsets[] = {
{1152, 12}, // tallgrass.obj
{1164, 36}, // fence.obj
{1200, 36}, // torch.obj
{1236, 24}, // wheat.obj
{1260, 1584}, // custom-mushroom.obj
{1152, 3180}, // candle.obj
{4332, 1584}, // custom_mushroom.obj
{5916, 36}, // fence.obj
{5952, 12}, // tall_grass.obj
{5964, 2082}, // wall_torch.obj
};

View File

@ -215,7 +215,7 @@ function love.run()
test.update_mouse(x, y)
end
nico_draw()
--nico_draw()
love.graphics.present()
love.timer.sleep(0.001)

Binary file not shown.

2633
minecraft/gen/candle.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -116,8 +116,8 @@ def build_block_instances(blocks):
if block_ids.is_light_source(block_id, block_data):
light_sources.append((position, block_id, block_data))
if not block_ids.is_cube_block(block_id, block_data):
#custom_mesh_index = block_ids.get_custom_mesh_index(block_id, block_data)
#non_cube_blocks[custom_mesh_index].append((position, block_id, block_data))
custom_mesh_index = block_ids.get_custom_mesh_index(block_id, block_data)
non_cube_blocks[custom_mesh_index].append((position, block_id, block_data))
continue
configuration = normal_indices_as_block_configuration(normal_indices)
by_configuration[configuration].append((position, block_id, block_data))

View File

@ -5,6 +5,8 @@ import obj_state
import obj_write
import sys
import block_ids
normals = [
(-1.0, 0.0, 0.0),
(0.0, -1.0, 0.0),
@ -49,11 +51,10 @@ def main():
build_configuration_index_buffers(cube_faces_by_normal, index_buffer)
# check mc.py `custom_blocks` for model order
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "tallgrass.obj")
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "fence.obj")
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "torch.obj")
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "wheat.obj")
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "custom-mushroom.obj")
mesh_order = block_ids.sorted_custom_mesh
for mesh_name in mesh_order:
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, f"{mesh_name}.obj")
with open("../configuration.idx", "wb") as f:
obj_write.write_indices(f, "<H", index_buffer)

1507
minecraft/gen/wall_torch.obj Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -38,6 +38,9 @@ void main()
vec3 light_direction = normalize(Eye.xyz - position.xyz);
float diffuse = max(dot(normal.xyz, light_direction), 0.0);
if (normal.w > 1.0)
diffuse = 1.0;
out_color = color.xyz * diffuse;
Color = vec4(out_color, 1.0);
}

View File

@ -11,7 +11,7 @@ in VS_OUT {
} fs_in;
layout (location = 0) out vec3 Position;
layout (location = 1) out vec3 Normal;
layout (location = 1) out vec4 Normal;
layout (location = 2) out vec3 Color;
layout (location = 3) out vec3 Block;
@ -40,12 +40,14 @@ void main()
vec4 texture_color = texelFetch(TerrainSampler, coord, 0);
if (texture_color.w != 1.0) {
//discard;
//return;
discard;
return;
}
float two_sided = float(fs_in.BlockID == 31 || fs_in.BlockID == 37 || fs_in.BlockID == 38 || fs_in.BlockID == 39);
Position = fs_in.BlockPosition.xzy;
Normal = normalize(fs_in.Normal.xzy);
Normal = vec4(normalize(fs_in.Normal.xzy), two_sided * 2.0);
Color = texture_color.xyz;
Block = vec3(fs_in.BlockID, fs_in.Data, fs_in.TextureID);
}

View File

@ -7,12 +7,12 @@ in VS_OUT {
} fs_in;
layout (location = 0) out vec3 Position;
layout (location = 1) out vec3 Normal;
layout (location = 1) out vec4 Normal;
layout (location = 2) out vec3 Color;
void main()
{
Position = fs_in.Position;
Normal = normalize(fs_in.Normal);
Normal = vec4(normalize(fs_in.Normal), 0.0);
Color = vec3(0, 1, 1);
}

View File

@ -312,7 +312,6 @@ namespace minecraft {
//////////////////////////////////////////////////////////////////////
// custom blocks
//////////////////////////////////////////////////////////////////////
/*
for (int i = 0; i < world::custom_block_types; i++) {
int element_count = index_buffer_custom_offsets[i].count;
const void * indices = (void *)(2 * (ptrdiff_t)index_buffer_custom_offsets[i].offset);
@ -322,7 +321,6 @@ namespace minecraft {
continue;
glDrawElementsInstancedBaseInstance(GL_TRIANGLES, element_count, GL_UNSIGNED_SHORT, indices, instance_count, base_instance);
}
*/
}
}
}