diff --git a/libraries/wgpuEngine b/libraries/wgpuEngine index bf8cabb..84b9400 160000 --- a/libraries/wgpuEngine +++ b/libraries/wgpuEngine @@ -1 +1 @@ -Subproject commit bf8cabb17d8bf4ec1a80787c72a9b4bf006c5b67 +Subproject commit 84b94007b4fce06a39b95bf00fc402d2ceca881f diff --git a/src/engine/sample_engine.cpp b/src/engine/sample_engine.cpp index ceb8a62..a6b529c 100644 --- a/src/engine/sample_engine.cpp +++ b/src/engine/sample_engine.cpp @@ -833,18 +833,19 @@ void SampleEngine::load_tracer_scene() MeshInstance3D* mesh_instance = new MeshInstance3D(); Surface* surface = new Surface(); - std::vector interleaved; - interleaved.resize(vpet_mesh->vertex_array.size()); - - for (uint32_t i = 0u; i < interleaved.size(); ++i) { - interleaved[i].position = vpet_mesh->vertex_array[i]; - interleaved[i].position.z = -interleaved[i].position.z; - interleaved[i].normal = vpet_mesh->normal_array[i]; - interleaved[i].normal.z = -interleaved[i].normal.z; - interleaved[i].uv = vpet_mesh->uv_array[i]; + sSurfaceData surface_data; + + surface_data.resize(vpet_mesh->vertex_array.size()); + + for (uint32_t i = 0u; i < surface_data.size(); ++i) { + surface_data.vertices[i] = vpet_mesh->vertex_array[i]; + surface_data.vertices[i].z = -surface_data.vertices[i].z; + surface_data.normals[i]= vpet_mesh->normal_array[i]; + surface_data.normals[i].z = -surface_data.normals[i].z; + surface_data.uvs[i] = vpet_mesh->uv_array[i]; } - surface->create_vertex_buffer(interleaved); + surface->create_surface_data(surface_data); std::vector indices; indices.resize(vpet_mesh->index_array.size()); @@ -875,7 +876,7 @@ void SampleEngine::load_tracer_scene() }*/ } - geo_material->set_shader(RendererStorage::get_shader_from_source(shaders::mesh_forward::source, shaders::mesh_forward::path, geo_material)); + geo_material->set_shader(RendererStorage::get_shader_from_source(shaders::mesh_forward::source, shaders::mesh_forward::path, shaders::mesh_forward::libraries, geo_material)); mesh_instance->set_surface_material_override(surface, geo_material); } diff --git a/src/vpet/scene_distribution.cpp b/src/vpet/scene_distribution.cpp index 248de6b..a8533e6 100644 --- a/src/vpet/scene_distribution.cpp +++ b/src/vpet/scene_distribution.cpp @@ -94,14 +94,14 @@ uint32_t process_material(sVPETContext& vpet, Surface* surface) std::string generate_mesh_identifier(Surface* surface) { - sSurfaceData* surface_data = surface->get_surface_data(); - return "Mesh_" + surface->get_name() + "_" + std::to_string(surface_data->vertices.size());; + sSurfaceData& surface_data = surface->get_surface_data(); + return "Mesh_" + surface->get_name() + "_" + std::to_string(surface_data.vertices.size()); } uint32_t process_geo(sVPETContext& vpet, Surface* surface) { - sSurfaceData* surface_data = surface->get_surface_data(); - if (!surface_data) { + sSurfaceData& surface_data = surface->get_surface_data(); + if (surface_data.size() == 0u) { assert(0); return -1; } @@ -121,31 +121,31 @@ uint32_t process_geo(sVPETContext& vpet, Surface* surface) vpet_mesh->name = name; // Transform to unity coordinate system - vpet_mesh->vertex_array.resize(surface_data->vertices.size()); - for (uint32_t idx = 0; idx < surface_data->vertices.size(); ++idx) { - vpet_mesh->vertex_array[idx] = surface_data->vertices[idx]; + vpet_mesh->vertex_array.resize(surface_data.vertices.size()); + for (uint32_t idx = 0; idx < surface_data.vertices.size(); ++idx) { + vpet_mesh->vertex_array[idx] = surface_data.vertices[idx]; vpet_mesh->vertex_array[idx].z = -vpet_mesh->vertex_array[idx].z; } vpet.geos_byte_size += sizeof(uint32_t) + vpet_mesh->vertex_array.size() * sizeof(glm::vec3); - vpet_mesh->uv_array = surface_data->uvs; + vpet_mesh->uv_array = surface_data.uvs; vpet.geos_byte_size += sizeof(uint32_t) + vpet_mesh->uv_array.size() * sizeof(glm::vec2); // Transform to unity coordinate system - vpet_mesh->normal_array.resize(surface_data->normals.size()); - for (uint32_t idx = 0; idx < surface_data->normals.size(); ++idx) { - vpet_mesh->normal_array[idx] = surface_data->normals[idx]; + vpet_mesh->normal_array.resize(surface_data.normals.size()); + for (uint32_t idx = 0; idx < surface_data.normals.size(); ++idx) { + vpet_mesh->normal_array[idx] = surface_data.normals[idx]; vpet_mesh->normal_array[idx].z = -vpet_mesh->normal_array[idx].z; } vpet.geos_byte_size += sizeof(uint32_t) + vpet_mesh->normal_array.size() * sizeof(glm::vec3); // Transform triangle winding after vertex transform - vpet_mesh->index_array.resize(surface_data->indices.size()); + vpet_mesh->index_array.resize(surface_data.indices.size()); uint32_t add_idx = 0; - for (uint32_t idx = surface_data->indices.size(); idx > 0; --idx) { - vpet_mesh->index_array[add_idx] = surface_data->indices[idx - 1]; + for (uint32_t idx = surface_data.indices.size(); idx > 0; --idx) { + vpet_mesh->index_array[add_idx] = surface_data.indices[idx - 1]; add_idx++; }