Skip to content

Commit

Permalink
Update engine
Browse files Browse the repository at this point in the history
  • Loading branch information
jxarco committed Dec 16, 2024
1 parent ba18b7f commit 8315e7d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion libraries/wgpuEngine
Submodule wgpuEngine updated 42 files
+3 −0 .gitmodules
+12 −0 CMakeLists.txt
+29 −15 data/shaders/brdf_lut_gen.wgsl
+1 −1 data/shaders/gaussian_splatting/gs_render.wgsl
+11 −0 data/shaders/math.wgsl
+4 −1 data/shaders/mesh_forward.wgsl
+6 −6 data/shaders/mesh_includes.wgsl
+15 −17 data/shaders/pbr_functions.wgsl
+12 −7 data/shaders/pbr_light.wgsl
+1 −1 data/shaders/prefilter_env.wgsl
+11 −2 glsl_builder.py
+1 −1 libraries/easyVDB
+1 −0 libraries/mikktspace
+1 −1 src/engine/engine.cpp
+2 −2 src/framework/nodes/button_2d.cpp
+3 −3 src/framework/nodes/container_2d.cpp
+1 −1 src/framework/nodes/directional_light_3d.cpp
+1 −1 src/framework/nodes/environment_3d.cpp
+9 −8 src/framework/nodes/gs_node.cpp
+2 −2 src/framework/nodes/joint_3d.cpp
+1 −1 src/framework/nodes/omni_light_3d.cpp
+5 −5 src/framework/nodes/panel_2d.cpp
+10 −8 src/framework/nodes/skeleton_helper_3d.cpp
+2 −2 src/framework/nodes/slider_2d.cpp
+1 −1 src/framework/nodes/spot_light_3d.cpp
+6 −10 src/framework/nodes/text.cpp
+1 −1 src/framework/nodes/text.h
+178 −157 src/framework/parsers/parse_gltf.cpp
+1 −1 src/framework/parsers/parse_gltf.h
+25 −40 src/framework/parsers/parse_obj.cpp
+3 −1 src/framework/parsers/parse_vdb.cpp
+11 −11 src/framework/ui/gizmo_3d.cpp
+1 −1 src/graphics/kernels/prefix_sum_kernel.cpp
+2 −2 src/graphics/kernels/radix_sort_kernel.cpp
+14 −12 src/graphics/renderer.cpp
+24 −10 src/graphics/renderer_storage.cpp
+4 −1 src/graphics/renderer_storage.h
+41 −11 src/graphics/shader.cpp
+10 −3 src/graphics/shader.h
+469 −226 src/graphics/surface.cpp
+29 −11 src/graphics/surface.h
+5 −5 src/graphics/webgpu_context.cpp
23 changes: 12 additions & 11 deletions src/engine/sample_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,19 @@ void SampleEngine::load_tracer_scene()
MeshInstance3D* mesh_instance = new MeshInstance3D();
Surface* surface = new Surface();

std::vector<sInterleavedData> 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<uint32_t> indices;
indices.resize(vpet_mesh->index_array.size());
Expand Down Expand Up @@ -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);
}

Expand Down
28 changes: 14 additions & 14 deletions src/vpet/scene_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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++;
}

Expand Down

0 comments on commit 8315e7d

Please sign in to comment.