Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gents83/INOX
Browse files Browse the repository at this point in the history
  • Loading branch information
gents83 committed Mar 10, 2024
2 parents c483c94 + 9a63392 commit 42a6dc7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions crates/blender/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::exporter::Exporter;
use inox_resources::Singleton;
use inox_serialize::inox_serializable::SerializableRegistryRc;
use pyo3::{prelude::PyAnyMethods, pyclass, pymethods, PyResult, Python};
use pyo3::{pyclass, pymethods, PyResult, Python};

use inox_binarizer::Binarizer;
use inox_core::App;
Expand Down Expand Up @@ -196,7 +196,7 @@ fn add_node_in_blender(
let description = node.description();
let serialized_class = node.serialize_node(serializable_registry.clone());

py.import_bound("INOX")
py.import("INOX")
.unwrap()
.getattr("node_tree")
.unwrap()
Expand Down
30 changes: 16 additions & 14 deletions crates/blender/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
};

use pyo3::{
prelude::PyAnyMethods,
types::{PyDict, PyList},
PyObject, PyResult, Python, ToPyObject,
};
Expand Down Expand Up @@ -41,14 +40,11 @@ impl Exporter {

if create_dir_all(self.export_dir.as_path()).is_ok() {
// Blender data import
let export_scene = py
.import_bound("bpy")?
.getattr("ops")?
.getattr("export_scene")?;
let export_scene = py.import("bpy")?.getattr("ops")?.getattr("export_scene")?;
let scene_path = self.export_dir.join(format!("{}.{}", scene_name, "gltf"));
let scene_path = scene_path.to_str().unwrap_or_default().to_string();

let kwargs = PyDict::new_bound(py);
let kwargs = PyDict::new(py);
kwargs.set_item("filepath", scene_path.clone())?;
kwargs.set_item("check_existing", true)?;
kwargs.set_item("export_format", "GLTF_SEPARATE")?;
Expand All @@ -59,7 +55,7 @@ impl Exporter {
kwargs.set_item("export_lights", true)?;
kwargs.set_item("export_extras", true)?;
kwargs.set_item("export_texture_dir", "./textures/")?;
export_scene.call_method("gltf", (), Some(&kwargs))?;
export_scene.call_method("gltf", (), Some(kwargs))?;

self.export_custom_data(py, self.export_dir.as_path())?;

Expand All @@ -72,18 +68,24 @@ impl Exporter {
}

fn export_custom_data(&self, py: Python, export_dir: &Path) -> PyResult<bool> {
let data = py.import_bound("bpy")?.getattr("data")?;
let data = py.import("bpy")?.getattr("data")?;

// For every Blender scene
let scenes = data.getattr("scenes")?.call_method("values", (), None)?;
let scenes = scenes.downcast::<PyList>()?;
if let Ok(scene) = scenes.iter() {
let objects = scene.getattr("objects")?.call_method("values", (), None)?;
let objects = objects.downcast::<PyList>()?;
if let Ok(object) = objects.iter() {
self.process_object_properties(py, &object.to_object(py), export_dir)?;
scenes.iter().for_each(|scene| {
let objects = scene
.getattr("objects")
.unwrap()
.call_method("values", (), None)
.unwrap();
if let Ok(objects) = objects.downcast::<PyList>() {
objects.iter().for_each(|object| {
self.process_object_properties(py, &object.to_object(py), export_dir)
.ok();
});
}
}
});
Ok(true)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/graphics/src/passes/compute_culling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Pass for CullingPass {
}

let num_meshlets = self.meshlets.read().unwrap().item_count();
let lods_array = vec![MeshletLodLevel(0); num_meshlets];
let lods_array = vec![MeshletLodLevel(1u32); num_meshlets];
*self.meshlets_lod_level.write().unwrap() = lods_array;

if self.update_meshes {
Expand Down
1 change: 0 additions & 1 deletion crates/render/src/platform/pc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn required_gpu_features() -> wgpu::Features {
| wgpu::Features::SHADER_PRIMITIVE_INDEX
| wgpu::Features::PIPELINE_STATISTICS_QUERY
| wgpu::Features::TIMESTAMP_QUERY
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES
| wgpu::Features::PUSH_CONSTANTS
| wgpu::Features::DEPTH32FLOAT_STENCIL8
Expand Down
2 changes: 1 addition & 1 deletion data_raw/shaders/wgsl/compute_commands.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main(
let meshlet = meshlets.data[global_invocation_id.x];
let meshlet_lod_level = meshlet.mesh_index_and_lod_level & 7u;
let desired_lod_level = meshlets_lod_level[meshlet_id];
if(meshlet_lod_level != desired_lod_level) {
if(desired_lod_level != 0u) {
return;
}
let mesh_id = meshlet.mesh_index_and_lod_level >> 3u;
Expand Down
34 changes: 18 additions & 16 deletions data_raw/shaders/wgsl/compute_culling.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ fn main(

let meshlet = meshlets.data[meshlet_id];
let mesh_id = meshlet.mesh_index_and_lod_level >> 3u;
let mesh = meshes.data[mesh_id];
let meshlet_lod_level = meshlet.mesh_index_and_lod_level & 7u;
var mesh = meshes.data[mesh_id];
let flags = (mesh.flags_and_vertices_attribute_layout & 0xFFFF0000u) >> 16u;
if (flags != culling_data.mesh_flags) {
atomicStore(&meshlets_lod_level[meshlet_id], MAX_LOD_LEVELS);
return;
}

Expand All @@ -86,7 +86,6 @@ fn main(
frustum[2] = normalize_plane(row3 + row1);
frustum[3] = normalize_plane(row3 - row1);
if !is_box_inside_frustum(min, max, frustum) {
atomicStore(&meshlets_lod_level[meshlet_id], MAX_LOD_LEVELS);
return;
}

Expand All @@ -113,19 +112,22 @@ fn main(
if (constant_data.forced_lod_level >= 0) {
desired_lod_level = MAX_LOD_LEVELS - 1u - u32(constant_data.forced_lod_level);
}

atomicMax(&meshlets_lod_level[meshlet_id], desired_lod_level);

if(meshlet.child_meshlets.x >= 0) {
atomicMax(&meshlets_lod_level[meshlet.child_meshlets.x], desired_lod_level);
}
if(meshlet.child_meshlets.y >= 0) {
atomicMax(&meshlets_lod_level[meshlet.child_meshlets.y], desired_lod_level);
}
if(meshlet.child_meshlets.z >= 0) {
atomicMax(&meshlets_lod_level[meshlet.child_meshlets.z], desired_lod_level);

if(meshlet_lod_level == desired_lod_level) {
atomicAnd(&meshlets_lod_level[meshlet_id], 0u);
}
if(meshlet.child_meshlets.w >= 0) {
atomicMax(&meshlets_lod_level[meshlet.child_meshlets.w], desired_lod_level);
else if(desired_lod_level == (meshlet_lod_level + 1u)) {
if(meshlet.child_meshlets.x >= 0) {
atomicAnd(&meshlets_lod_level[meshlet.child_meshlets.x], 0u);
}
if(meshlet.child_meshlets.y >= 0) {
atomicAnd(&meshlets_lod_level[meshlet.child_meshlets.y], 0u);
}
if(meshlet.child_meshlets.z >= 0) {
atomicAnd(&meshlets_lod_level[meshlet.child_meshlets.z], 0u);
}
if(meshlet.child_meshlets.w >= 0) {
atomicAnd(&meshlets_lod_level[meshlet.child_meshlets.w], 0u);
}
}
}

0 comments on commit 42a6dc7

Please sign in to comment.