diff --git a/ecs/component.h b/ecs/component.h index effc92c6..324b46d4 100644 --- a/ecs/component.h +++ b/ecs/component.h @@ -45,6 +45,7 @@ u32 ecs_componentmanager__internal_get_pool_capacity(const ecs_component_type ty switch(type) { case ECS_CMP_CAMERA: return 10; + case ECS_CMP_MATERIAL: return 128; default: return ECS_ENTITY_MAX_COUNT / 2; } } @@ -190,7 +191,8 @@ void ecs_componentmanager_add(ecs_componentmanager_t * const self, const u32 ent cmp_idx_buffer[cmp_idx_count] = pool->len; const u16 cmp_size = ecs_component__internal_get_componenttype_size(cmp_type); - buffer(WORD) buf = {0}; + //NOTE: buffer sized for largest component (ecs_component_material_t ~2.3KB + header) + buffer(KB * 3) buf = {0}; //NOTE: sets the entity id memcpy(buf.raw_data, &entity_id, sizeof(entity_id)); diff --git a/ecs/component/types.h b/ecs/component/types.h index 0f24e931..03c46fad 100644 --- a/ecs/component/types.h +++ b/ecs/component/types.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #define ECS_CMP_INVALID_IDX -1 @@ -98,8 +100,11 @@ struct ecs_component_input_t { typedef struct ecs_component_material_t ecs_component_material_t; struct ecs_component_material_t { - u32 texture_asset_id; - u32 shader_asset_id; + gltexturelist_t textures; + struct { + u32 asset_id; + gluniforms_t uniforms; + } shader; }; /* =========================== CAMERA ================================== */ diff --git a/ecs/serialization.h b/ecs/serialization.h index 5adc7974..2e805cdc 100644 --- a/ecs/serialization.h +++ b/ecs/serialization.h @@ -104,10 +104,9 @@ static const ecs_cmp_field_map_t ecs_deserializer__internal_cmp_field_maps[ECS_C } }, [ECS_CMP_MATERIAL_IDX] = { - .field_count = 2, + .field_count = 1, .fields = { - CMP_FLD_DESC("\ttexture_asset_id:", "\ttexture_asset_id:%u", ecs_component_material_t, texture_asset_id, ECS_CMP_FLD_U32), - CMP_FLD_DESC("\tshader_asset_id:", "\tshader_asset_id:%u", ecs_component_material_t, shader_asset_id, ECS_CMP_FLD_U32), + CMP_FLD_DESC("\tshader_asset_id:", "\tshader_asset_id:%u", ecs_component_material_t, shader.asset_id, ECS_CMP_FLD_U32), } }, [ECS_CMP_CAMERA_IDX] = { @@ -210,7 +209,7 @@ INTERNAL void ecs_serializer__internal_entity_cmp_data(file_t *const file, const case ECS_CMP_TRANSFORM: total_members = 5; bytesize = sizeof(ecs_component_transform_t); break; case ECS_CMP_MODEL: total_members = 2; bytesize = sizeof(ecs_component_model_t); break; case ECS_CMP_INPUT: total_members = 3; bytesize = sizeof(ecs_component_input_t); break; - case ECS_CMP_MATERIAL: total_members = 2; bytesize = sizeof(ecs_component_material_t); break; + case ECS_CMP_MATERIAL: total_members = 1; bytesize = sizeof(ecs_component_material_t); break; case ECS_CMP_CAMERA: total_members = 3; bytesize = sizeof(ecs_component_camera_t); break; case ECS_CMP_COLLIDER: total_members = 5; bytesize = sizeof(ecs_component_collider_t); break; case ECS_CMP_MESH: total_members = 2; bytesize = sizeof(ecs_component_mesh_t); break; @@ -379,8 +378,7 @@ INTERNAL void ecs_deserializer__internal_remap_entity_assets(ecs_componentbundle } break; case ECS_CMP_MATERIAL: { ecs_component_material_t *mat = &bundle->component[cmp_idx].material; - if (mat->texture_asset_id) mat->texture_asset_id = ecs_deserializer__internal_ensure_asset_loaded(assets, mat->texture_asset_id, assets_parsed); - if (mat->shader_asset_id) mat->shader_asset_id = ecs_deserializer__internal_ensure_asset_loaded(assets, mat->shader_asset_id, assets_parsed); + if (mat->shader.asset_id) mat->shader.asset_id = ecs_deserializer__internal_ensure_asset_loaded(assets, mat->shader.asset_id, assets_parsed); } break; } } diff --git a/ecs/system.h b/ecs/system.h index 14e7bf30..19cbfa39 100644 --- a/ecs/system.h +++ b/ecs/system.h @@ -7,6 +7,7 @@ #include "poglib/ecs/systems/mesh.h" #include "poglib/ecs/systems/model.h" #include "poglib/ecs/systems/transform.h" +#include "poglib/ecs/systems/uniform_resolve.h" void ecs_add_system(ecs_t *const self, const ecs_system_t system) { @@ -49,6 +50,13 @@ void ecs_add_all_core_systems(ecs_t *const self) } ); + ecs_add_system( + self, + (ecs_system_t) { + .callback = ecs_system_uniform_resolve + } + ); + ecs_add_system( self, (ecs_system_t) { diff --git a/ecs/systems/mesh.h b/ecs/systems/mesh.h index 7e88ceb3..a111e7c3 100644 --- a/ecs/systems/mesh.h +++ b/ecs/systems/mesh.h @@ -38,7 +38,7 @@ void ecs_system_render_mesh(ecs_componentmanager_t *const cmp_manager, const ecs ECS_CMP_MATERIAL | ECS_CMP_TRANSFORM); const ecs_component_material_t *material = view.entity_cmp_data[ECS_CMP_MATERIAL_IDX]; const ecs_component_transform_t *transform = view.entity_cmp_data[ECS_CMP_TRANSFORM_IDX]; - const glshader_t *shader = assetmanager_get_assetresource(&global_engine->systems.assets, ASSET_TYPE_GLSL_SHADER, material->shader_asset_id); + const glshader_t *shader = assetmanager_get_assetresource(&global_engine->systems.assets, ASSET_TYPE_GLSL_SHADER, material->shader.asset_id); ASSERT(material); ASSERT(shader); @@ -47,15 +47,8 @@ void ecs_system_render_mesh(ecs_componentmanager_t *const cmp_manager, const ecs spriteatlas_t *atlas = (spriteatlas_t *)assetmanager_get_assetresource( &global_engine->systems.assets, ASSET_TYPE_TEXTURE_SPRITE_ATLAS, global_workbench->primitives.atlas_id); - const matrix4f_t perspective_projection = glms_perspective( - radians(45), - global_engine->handle.app->window.aspect_ratio, - 1.0f, 1000.0f - ); - const bool is_editor_selected = global_workbench->editor.current_selected_entity_id == entry->entity_id; - rendercommand_t command = { .mesh = gpu_loaded_asset->meshes.data, .draw_mode = RENDER_COMMAND_DRAW_MODE_TRIANGLE, @@ -71,31 +64,22 @@ void ecs_system_render_mesh(ecs_componentmanager_t *const cmp_manager, const ecs .size = sizeof(rendercommand_instance_primitive_mesh_t) }, .material = { - .textures = { + .texture = { .count = 1, - .ids = { - [0] = atlas->texture.id, + .items = { + [0] = (gltextureitem_t){ + .type = GL_TEXTURE_TYPE_NORMAL, + .source = { .normal_texture = &atlas->texture } + } } }, .shader = { .data = shader, - .uniforms = { - .count = 2, - .data = { - [0] = { - .name = str("projection"), - .value = perspective_projection - }, - [1] = { - .name = str("view"), - .value = glcamera_getview(ctx.active_camera), - } - } - } + .uniforms = material->shader.uniforms, } } }; + renderqueue_pass_command(&global_engine->systems.renderqueue, command); } } - diff --git a/ecs/systems/model.h b/ecs/systems/model.h index 17af86d9..4d1c6cbb 100644 --- a/ecs/systems/model.h +++ b/ecs/systems/model.h @@ -11,8 +11,6 @@ #include "poglib/poggen.h" #include "poglib/util/asset.h" #include "poglib/util/assetmanager.h" -#include "poglib/util/glcamera.h" -#include "poglib/util/workbench/common.h" void ecs_system_render_model(ecs_componentmanager_t *const cmp_manager, const ecs_system_ctx_t ctx) { @@ -28,111 +26,79 @@ void ecs_system_render_model(ecs_componentmanager_t *const cmp_manager, const ec if (!cmp_model->internal.model) { cmp_model->internal.model = (glmodel_t *)assetmanager_get_assetresource( - &global_engine->systems.assets, + &global_engine->systems.assets, ASSET_TYPE_MODEL, (cmp_model)->asset_id ); } - - if (!cmp_model->internal.model) { - continue; - } + if (!cmp_model->internal.model) continue; const gpu_asset_t *gpu_loaded_asset = (gpu_asset_t *)assetmanager_get_gpu_loaded_asset_async( - &global_engine->systems.assets, + &global_engine->systems.assets, cmp_model->asset_id ); - if (!gpu_loaded_asset) { - continue; - } + if (!gpu_loaded_asset) continue; const u32 entity_id = entry->entity_id; const ecs_entity_query_t view = ecs_componentmanager__internal_query_components( - cmp_manager, - entity_id, + cmp_manager, + entity_id, ECS_CMP_MATERIAL | ECS_CMP_TRANSFORM); const ecs_component_material_t *material = view.entity_cmp_data[ECS_CMP_MATERIAL_IDX]; const ecs_component_transform_t *transform = view.entity_cmp_data[ECS_CMP_TRANSFORM_IDX]; - const glshader_t *shader = assetmanager_get_assetresource(&global_engine->systems.assets, ASSET_TYPE_GLSL_SHADER, material->shader_asset_id); + const glshader_t *shader = assetmanager_get_assetresource(&global_engine->systems.assets, ASSET_TYPE_GLSL_SHADER, material->shader.asset_id); ASSERT(material); ASSERT(shader); ASSERT(transform); - const matrix4f_t perspective_projection = glms_perspective( - radians(45), - global_engine->handle.app->window.aspect_ratio, - 1.0f, 1000.0f - ); - const glmodel_t *model = cmp_model->internal.model; + gltexturelist_t model_textures = glmodel_get_texuturelist(model); + ASSERT(gpu_loaded_asset->meshes.count == model->meshes.len); for (u8 idx = 0; idx < model->meshes.len; idx++) { - //printf("[RENDER] mesh=%i bones=%f data=%p\n", idx, model->transforms[idx].len, model->transforms[idx].data); - renderqueue_pass_command( - &global_engine->systems.renderqueue, - (rendercommand_t) { - .mesh = &gpu_loaded_asset->meshes.data[idx], - .draw_mode = RENDER_COMMAND_DRAW_MODE_TRIANGLE, - .enable_wireframe = false, - .instance = {0}, - .material = { - .textures = {0}, - .shader = { - .data = shader, - .uniforms = { - .count = 8, - .data = { - [0] = { - .name = str_lit("view"), - .value = glcamera_getview(ctx.active_camera), - }, - [1] = { - .name = str_lit("projection"), - .value = perspective_projection - }, - [2] = { - .name = str_lit("transform"), - .value = glms_mat4_mul( - glms_translate_make(transform->position), - glms_mat4_mul( - glms_quat_mat4(transform->orientation), - glms_scale_make(transform->scale) - ) - ) - }, - [3] = { - .name = str_lit("material.color"), - .value.vec4 = *(vec4f_t *)list_get_value(&model->colors, idx) - }, - [4] = { - .name = str_lit("uBones"), - .value.mat4s = { - .count = model->transforms[idx].len, - .data = (matrix4f_t *)model->transforms[idx].data - } - }, - [5] = { - .name = str_lit("light.color"), - .value.vec4 = global_workbench->editor.current_selected_entity_id == entry->entity_id ? COLOR_RED : COLOR_WHITE - }, - [6] = { - .name = str_lit("light.ambient"), - .value.f32 = 1.0f - }, - [7] = { - .name = str_lit("light.position"), - .value.vec3 = vec3f(1.0f) - } - } - } - } + const vec4f_t mesh_color = *(vec4f_t *)list_get_value(&model->colors, idx); + const u32 bone_count = model->transforms[idx].len; + matrix4f_t *bone_data = (matrix4f_t *)model->transforms[idx].data; + + rendercommand_t cmd = { + .mesh = &gpu_loaded_asset->meshes.data[idx], + .draw_mode = RENDER_COMMAND_DRAW_MODE_TRIANGLE, + .enable_wireframe = false, + .instance = {0}, + .material = { + .texture = model_textures, + .shader = { + .data = shader, + .uniforms = material->shader.uniforms, } } - ); + }; + + if (material->textures.count) { + for (u8 t = 0; t < material->textures.count; t++) { + if (cmd.material.texture.count < MAX_SUPPORTED_TEXTURE_COUNT_PER_DRAW_CALL) { + cmd.material.texture.items[cmd.material.texture.count++] = material->textures.items[t]; + } + } + } + + gluniforms_t *u = &cmd.material.shader.uniforms; + + u->data[u->count].name = str("material.color"); + u->data[u->count].value.vec4 = mesh_color; + u->count++; + + if (bone_count) { + u->data[u->count].name = str("uBones"); + u->data[u->count].value.mat4s.count = bone_count; + u->data[u->count].value.mat4s.data = bone_data; + u->count++; + } + + renderqueue_pass_command(&global_engine->systems.renderqueue, cmd); } } } - diff --git a/ecs/systems/uniform_resolve.h b/ecs/systems/uniform_resolve.h new file mode 100644 index 00000000..6fcb8f04 --- /dev/null +++ b/ecs/systems/uniform_resolve.h @@ -0,0 +1,21 @@ +#pragma once +#include "poglib/ecs/common.h" +#include "poglib/ecs/component.h" +#include "poglib/ecs/component/types.h" +#include "poglib/ecs/uniform_registry.h" + +void ecs_system_uniform_resolve(ecs_componentmanager_t *const cmp_manager, const ecs_system_ctx_t ctx) +{ + slot_t *primary_pool = slot_get_value(&cmp_manager->componentpool_slots, ECS_CMP_MATERIAL_IDX); + + slot_iterator(primary_pool, ITER) + { + const ecs_component_poolentry_t *const entry = ITER; + ecs_component_material_t *material = (ecs_component_material_t *)entry->entity_cmpdata; + + if (!material->shader.asset_id) continue; + + uniform_registry_resolve_material_uniforms( + material, cmp_manager, entry->entity_id, ctx.active_camera); + } +} diff --git a/ecs/uniform_registry.h b/ecs/uniform_registry.h new file mode 100644 index 00000000..487ab786 --- /dev/null +++ b/ecs/uniform_registry.h @@ -0,0 +1,61 @@ +#pragma once +#include "poglib/ecs/component/types.h" +#include "poglib/ecs/common.h" +#include "poglib/gfx/gl/shader.h" +#include "poglib/poggen.h" +#include +#include +#include + +INTERNAL void uniform_registry_resolve_material_uniforms( + ecs_component_material_t *material, + const ecs_componentmanager_t *cmp_manager, + u32 entity_id, + const glcamera_t *active_camera) +{ + const glshader_t *shader = (glshader_t *)assetmanager_get_assetresource( + &global_engine->systems.assets, ASSET_TYPE_GLSL_SHADER, material->shader.asset_id); + if (!shader) return; + + const ecs_entity_query_t view = ecs_componentmanager__internal_query_components( + (ecs_componentmanager_t *)cmp_manager, entity_id, ECS_CMP_TRANSFORM); + const ecs_component_transform_t *transform = view.entity_cmp_data[ECS_CMP_TRANSFORM_IDX]; + if (!transform) return; + + const matrix4f_t proj = glms_perspective( + radians(45), global_engine->handle.app->window.aspect_ratio, 1.0f, 1000.0f); + const matrix4f_t view_mat = glcamera_getview(active_camera); + const matrix4f_t model_mat = glms_mat4_mul( + glms_translate_make(transform->position), + glms_mat4_mul(glms_quat_mat4(transform->orientation), glms_scale_make(transform->scale))); + + hashtable_iterator(&shader->internal.uniformlocs, loc_entry) + { + const hashtable_entry_t *he = loc_entry; + const str_t uniform_name = he->key.str; + + bool already_set = false; + for (u8 i = 0; i < material->shader.uniforms.count; i++) { + if (str_cmp(material->shader.uniforms.data[i].name, uniform_name)) { + already_set = true; + break; + } + } + if (already_set) continue; + + gluniform_value_t value = {0}; + if (str_cmp(uniform_name, str("view"))) + value.mat4 = view_mat; + else if (str_cmp(uniform_name, str("projection"))) + value.mat4 = proj; + else if (str_cmp(uniform_name, str("transform"))) + value.mat4 = model_mat; + else + continue; + + ASSERT(material->shader.uniforms.count < MAX_UNIFORMS_ALLOWED_IN_SHADER); + material->shader.uniforms.data[material->shader.uniforms.count].name = uniform_name; + material->shader.uniforms.data[material->shader.uniforms.count].value = value; + material->shader.uniforms.count++; + } +} diff --git a/pipeline/render/render_command.h b/pipeline/render/render_command.h index a58c1925..c765ecd2 100644 --- a/pipeline/render/render_command.h +++ b/pipeline/render/render_command.h @@ -34,10 +34,7 @@ struct rendercommand_t { gluniforms_t uniforms; const glshader_t *data; } shader; - struct { - u16 count; - u16 ids[MAX_TEXTURES_ALLOWED_PER_RENDER]; - } textures; + gltexturelist_t texture; } material; buffer_t instance; @@ -51,12 +48,15 @@ bool rendercommand__internal_compare_textures_ids(const rendercommand_t *const r { ASSERT(rc1 && rc2); - if (rc1->material.textures.count != rc2->material.textures.count) + if (rc1->material.texture.count != rc2->material.texture.count) return false; - for (u8 tex_idx = 0; tex_idx < rc1->material.textures.count; tex_idx++) - if(rc1->material.textures.ids[tex_idx] != rc2->material.textures.ids[tex_idx]) - return false; + for (u8 tex_idx = 0; tex_idx < rc1->material.texture.count; tex_idx++) { + const gltextureitem_t *a = &rc1->material.texture.items[tex_idx]; + const gltextureitem_t *b = &rc2->material.texture.items[tex_idx]; + if (a->type != b->type) return false; + if (a->source.normal_texture->id != b->source.normal_texture->id) return false; + } return true; diff --git a/pipeline/render/render_queue.h b/pipeline/render/render_queue.h index ae2f8a3d..144966e7 100644 --- a/pipeline/render/render_queue.h +++ b/pipeline/render/render_queue.h @@ -247,9 +247,18 @@ void renderqueue_dispatch(renderqueue_t *const self) } //NOTE: bind textures - for(u8 tex_idx = 0; tex_idx < first_command->material.textures.count; tex_idx++) { - GL_CHECK(glActiveTexture(GL_TEXTURE0 + tex_idx)); - GL_CHECK(glBindTexture(GL_TEXTURE_2D, first_command->material.textures.ids[tex_idx])); + for(u8 tex_idx = 0; tex_idx < first_command->material.texture.count; tex_idx++) { + const gltextureitem_t *item = &first_command->material.texture.items[tex_idx]; + switch (item->type) { + case GL_TEXTURE_TYPE_CUBEMAP: + GL_CHECK(glDepthMask(false)); + GL_CHECK(glDepthFunc(GL_LEQUAL)); + glcubemap_bind(item->source.cubemap); + break; + default: + gltexture2d_bind(item->source.normal_texture, tex_idx); + break; + } } //NOTE: Use instance if configured diff --git a/test/ecs/save_load/build.sh b/test/ecs/save_load/build.sh index 2ae91dea..1d8af080 100755 --- a/test/ecs/save_load/build.sh +++ b/test/ecs/save_load/build.sh @@ -3,13 +3,14 @@ SRC_PATH="./src/main.c" EXE_NAME="ecs_save_load_test" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -POGLIB_DIR="$(cd "$SCRIPT_DIR/../../../.." && pwd)" -JOLT_DIR="$POGLIB_DIR/poglib/external/joltc/lib/linux/debug" +POGLIB_DIR="$(cd "$SCRIPT_DIR/../../.." && pwd)" +PARENT_DIR="$(dirname "$POGLIB_DIR")" +JOLT_DIR="$POGLIB_DIR/external/joltc/lib/linux/debug" CC="clang" FLAGS="-std=c11 -g -O0 -DDEBUG -W -Wall -Wextra -Wno-missing-braces -Wincompatible-pointer-types-discards-qualifiers -Wno-variadic-macros" LINKERS="-lfreetype -lSDL2 -lGLEW -lGLU -lGL -lm -lassimp -pthread -ldl -L$JOLT_DIR -ljoltcd -lJoltd -lstdc++" -INCLUDES="-I/usr/include/freetype2 -I$POGLIB_DIR -I/usr/include/SDL2" +INCLUDES="-I/usr/include/freetype2 -I$PARENT_DIR -I/usr/include/SDL2" red=$(tput setaf 1) green=$(tput bold; tput setaf 2) diff --git a/test/ecs/save_load/src/main.c b/test/ecs/save_load/src/main.c index 57613c02..83484013 100644 --- a/test/ecs/save_load/src/main.c +++ b/test/ecs/save_load/src/main.c @@ -66,7 +66,7 @@ static void test_all_component_types(void) .component = { [ECS_CMP_TRANSFORM_IDX].transform = (ecs_component_transform_t){ .scale = {1,1,1}, .source = ECS_CMP_TRANSFORM_SOURCE_NONE }, [ECS_CMP_MESH_IDX].mesh = (ecs_component_mesh_t){ .asset_id = 2, .prototype_sprite_type = 20 }, - [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .texture_asset_id = 6, .shader_asset_id = 7 }, + [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .shader = { .asset_id = 7 } }, } }); /* entity 3: input */ @@ -116,7 +116,7 @@ static void test_all_component_types(void) .component = { [ECS_CMP_TRANSFORM_IDX].transform = (ecs_component_transform_t){ .scale = {1,1,1}, .source = ECS_CMP_TRANSFORM_SOURCE_NONE }, [ECS_CMP_MODEL_IDX].model = (ecs_component_model_t){ .asset_id = 9 }, - [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .texture_asset_id = 0, .shader_asset_id = 10 }, + [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .shader = { .asset_id = 10 } }, } }); /* entities 7-9: multiple same type for multi-entity test */ @@ -155,8 +155,7 @@ static void test_all_component_types(void) TEST_ASSERT(m->asset_id == 2, "mesh: asset_id"); TEST_ASSERT(m->prototype_sprite_type == 20, "mesh: sprite_type"); TEST_ASSERT(mat, "material: present"); - TEST_ASSERT(mat->texture_asset_id == 6, "material: texture_id"); - TEST_ASSERT(mat->shader_asset_id == 7, "material: shader_id"); } + TEST_ASSERT(mat->shader.asset_id == 7, "material: shader_id"); } /* entity 3: input */ { const ecs_entity_query_t q = ecs_entity_query_components(ecs2, 3, ECS_CMP_INPUT); @@ -232,7 +231,7 @@ static void test_asset_loading_from_save(void) .component = { [ECS_CMP_TRANSFORM_IDX].transform = (ecs_component_transform_t){ .scale={1,1,1}, .source=ECS_CMP_TRANSFORM_SOURCE_NONE }, [ECS_CMP_MODEL_IDX].model = (ecs_component_model_t){ .asset_id = model_id }, - [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .texture_asset_id=0, .shader_asset_id=0 }, + [ECS_CMP_MATERIAL_IDX].material = (ecs_component_material_t){ .shader = { .asset_id = 0 } }, } }); SAVE_AND_DESTROY(ecs); diff --git a/test/ecs/save_load/test_corruption.ecs b/test/ecs/save_load/test_corruption.ecs index 7645a13a..8ca01e4e 100644 --- a/test/ecs/save_load/test_corruption.ecs +++ b/test/ecs/save_load/test_corruption.ecs @@ -15,8 +15,7 @@ input:{totalmembers:3,bytesize:80} state.orientation:[0.000000,0.000000,0.000000,1.000000] state.front:[-0.185430,-0.268920,-0.945144] state.right:[0.981293,0.000000,-0.192522] -material:{totalmembers:2,bytesize:8} - texture_asset_id:0 +material:{totalmembers:1,bytesize:2344} shader_asset_id:10 collider:{totalmembers:5,bytesize:96} shape_type:1 @@ -33,8 +32,7 @@ transform:{totalmembers:5,bytesize:64} scale:[1.000000,1.000000,1.000000] velocity:[0.000000,0.000000,0.000000] source:0 -material:{totalmembers:2,bytesize:8} - texture_asset_id:6 +material:{totalmembers:1,bytesize:2344} shader_asset_id:7 collider:{totalmembers:5,bytesize:96} shape_type:3 @@ -54,8 +52,7 @@ transform:{totalmembers:5,bytesize:64} scale:[1.000000,2.500000,1.000000] velocity:[0.000000,0.000000,0.000000] source:0 -material:{totalmembers:2,bytesize:8} - texture_asset_id:6 +material:{totalmembers:1,bytesize:2344} shader_asset_id:7 collider:{totalmembers:5,bytesize:96} shape_type:3 diff --git a/test/ecs/save_load/test_save.ecs b/test/ecs/save_load/test_save.ecs index 636f5801..289582bc 100644 --- a/test/ecs/save_load/test_save.ecs +++ b/test/ecs/save_load/test_save.ecs @@ -7,8 +7,7 @@ transform:{totalmembers:5,bytesize:64} scale:[1.000000,1.000000,1.000000] velocity:[0.000000,0.000000,0.000000] source:0 -material:{totalmembers:2,bytesize:8} - texture_asset_id:6 +material:{totalmembers:1,bytesize:2344} shader_asset_id:7 mesh:{totalmembers:2,bytesize:8} asset_id:2 @@ -76,8 +75,7 @@ transform:{totalmembers:5,bytesize:64} source:0 model:{totalmembers:2,bytesize:16} asset_id:9 -material:{totalmembers:2,bytesize:8} - texture_asset_id:0 +material:{totalmembers:1,bytesize:2344} shader_asset_id:10 entity:7 component_signature:1 diff --git a/util/workbench.h b/util/workbench.h index 97d9dbf1..a930368b 100644 --- a/util/workbench.h +++ b/util/workbench.h @@ -524,7 +524,7 @@ void workbench_render_camera( .size = sizeof(rendercommand_instance_primitive_mesh_t) }, .material = { - .textures = {0}, + .texture = {0}, .shader = { .data = assetmanager_get_assetresource(assetmanager, ASSET_TYPE_GLSL_SHADER, global_workbench->primitives.mesh_shader_id), .uniforms = { @@ -588,10 +588,13 @@ void workbench_render_marker( .size = sizeof(rendercommand_instance_primitive_mesh_t) }, .material = { - .textures = { + .texture = { .count = 1, - .ids = { - atlas->texture.id + .items = { + [0] = (gltextureitem_t){ + .type = GL_TEXTURE_TYPE_NORMAL, + .source = { .normal_texture = &atlas->texture } + } } }, .shader = {