diff --git a/bin/data/config.json b/bin/data/config.json index e17c2117..2fc42594 100644 --- a/bin/data/config.json +++ b/bin/data/config.json @@ -117,9 +117,9 @@ "pipelines": { "deferred": true, "gui": true, - "vsync": true, // vsync on vulkan side rather than engine-side + "vsync": false, // vsync on vulkan side rather than engine-side "hdr": true, - "vxgi": true, // to-do: fix issues + "vxgi": false, // to-do: fix issues "culling": false, "bloom": true, "dof": false, diff --git a/bin/data/scenes/scene.json b/bin/data/scenes/scene.json index d8ece647..dd219ad7 100644 --- a/bin/data/scenes/scene.json +++ b/bin/data/scenes/scene.json @@ -18,7 +18,7 @@ [ 0, 0, 0, 0 ] ], "shader": { - "mode": 10, + "mode": 0, "scalar": 16, "parameters": [ 0, 0, 0, "time" ] } diff --git a/bin/data/shaders/common/macros.h b/bin/data/shaders/common/macros.h index 0fc8b6a4..5a7a079c 100644 --- a/bin/data/shaders/common/macros.h +++ b/bin/data/shaders/common/macros.h @@ -3,7 +3,6 @@ // enable if shaderNonUniform is not supported // Nvidia hardware does not require nonuniformEXT, but AMD does #endif - // implicit variables #ifndef MULTISAMPLING #define MULTISAMPLING 1 @@ -20,8 +19,11 @@ #ifndef MAX_SHADOWS #define MAX_SHADOWS ubo.settings.lighting.maxShadows #endif +#ifndef USE_CAMERA_VIEWPORT + #define USE_CAMERA_VIEWPORT 0 +#endif #ifndef VIEW_MATRIX -#if VXGI +#if VXGI || !USE_CAMERA_VIEWPORT #define VIEW_MATRIX ubo.eyes[surface.pass].view #else #define VIEW_MATRIX camera.viewport[surface.pass].view @@ -80,7 +82,7 @@ #endif #if BARYCENTRIC #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #ifndef BUFFER_REFERENCE #define BUFFER_REFERENCE 1 diff --git a/bin/data/shaders/display/deferred/comp/comp.h b/bin/data/shaders/display/deferred/comp/comp.h index a0e62ede..4c78f656 100644 --- a/bin/data/shaders/display/deferred/comp/comp.h +++ b/bin/data/shaders/display/deferred/comp/comp.h @@ -199,10 +199,15 @@ void populateSurface() { { vec2 inUv = (vec2(gl_GlobalInvocationID.xy) / vec2(renderSize)) * 2.0f - 1.0f; + #if USE_CAMERA_VIEWPORT const mat4 iProjection = inverse( camera.viewport[surface.pass].projection ); const mat4 iView = inverse( camera.viewport[surface.pass].view ); - const mat4 iProjectionView = inverse( camera.viewport[surface.pass].projection * mat4(mat3(camera.viewport[surface.pass].view)) ); - + const mat4 iProjectionView = /*iProjection * iView;*/ inverse( camera.viewport[surface.pass].projection * mat4(mat3(camera.viewport[surface.pass].view)) ); + #else + const mat4 iView = ubo.eyes[surface.pass].iView; + const mat4 iProjection = ubo.eyes[surface.pass].iProjection; + const mat4 iProjectionView = /*iProjection * iView;*/ inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) ); + #endif const vec4 near4 = iProjectionView * (vec4(inUv, -1.0, 1.0)); const vec4 far4 = iProjectionView * (vec4(inUv, 1.0, 1.0)); const vec3 near3 = near4.xyz / near4.w; diff --git a/engine/src/ext/vulkan/rendermodes/deferred.cpp b/engine/src/ext/vulkan/rendermodes/deferred.cpp index 1dae5e5b..72c07634 100644 --- a/engine/src/ext/vulkan/rendermodes/deferred.cpp +++ b/engine/src/ext/vulkan/rendermodes/deferred.cpp @@ -21,7 +21,7 @@ #if BARYCENTRIC // 0 keeps a buffer for barycentric coordinates, 1 will reconstruct in the deferred pass #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #endif diff --git a/engine/src/utils/math/collider.cpp b/engine/src/utils/math/collider.cpp deleted file mode 100644 index 7e6133a5..00000000 --- a/engine/src/utils/math/collider.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#if UF_USE_UNUSED -#include -#include -#include -#include -#include -#include -#include - -uf::Collider::~Collider() { - this->clear(); -} -void uf::Collider::clear() { - for ( pod::Collider* pointer : this->m_container ) delete pointer; - this->m_container.clear(); -} - -void uf::Collider::add( pod::Collider* pointer ) { - this->m_container.push_back(pointer); -} -uf::Collider::container_t& uf::Collider::getContainer() { - return this->m_container; -} -const uf::Collider::container_t& uf::Collider::getContainer() const { - return this->m_container; -} - -std::size_t uf::Collider::getSize() const { - return this->m_container.size(); -} - -uf::stl::vector uf::Collider::intersects( const uf::Collider& body, bool smart ) const { - uf::stl::vector manifolds; - manifolds.reserve( this->m_container.size() * body.m_container.size() ); - for ( const pod::Collider* pointer : body.m_container ) { - uf::stl::vector result = this->intersects( *pointer, smart ); - manifolds.insert( manifolds.end(), result.begin(), result.end() ); - } - return manifolds; -} - -uf::stl::vector uf::Collider::intersects( const pod::Collider& body, bool smart ) const { - // smart = false; - uf::stl::vector manifolds; - for ( const pod::Collider* pointer : this->m_container ) { - pod::Collider::Manifold& manifold = manifolds.emplace_back(); - if ( !pointer ) continue; - if ( smart && pointer->type() == body.type() ) { - if ( pointer->type() == "BoundingBox" ) { - const uf::BoundingBox& a = *((const uf::BoundingBox*) pointer); - const uf::BoundingBox& b = *((const uf::BoundingBox*) &body); - manifold = a.intersects(b); - } else if ( pointer->type() == "Sphere" ) { - const uf::SphereCollider& a = *((const uf::SphereCollider*) pointer); - const uf::SphereCollider& b = *((const uf::SphereCollider*) &body); - manifold = a.intersects(b); - } - else - manifold = pointer->intersects( body ); - } else manifold = pointer->intersects( body ); - } - return manifolds; -} -#endif \ No newline at end of file diff --git a/engine/src/utils/math/physics/common.cpp b/engine/src/utils/math/physics/common.cpp index 73218653..9b35fc3c 100644 --- a/engine/src/utils/math/physics/common.cpp +++ b/engine/src/utils/math/physics/common.cpp @@ -1,5 +1,14 @@ #include +namespace impl { + void updateStaticBody( pod::PhysicsBody& body ) { + if ( !body.isStatic ) return; + + body.bounds = impl::computeAABB( body ); + if ( body.world ) body.world->staticBvh.dirty = true; + } +} + // create ID from pointers uint64_t impl::makePairKey( const pod::PhysicsBody& a, const pod::PhysicsBody& b ) { uint64_t lhs = reinterpret_cast(&a); @@ -19,6 +28,7 @@ void impl::wakeBody( pod::PhysicsBody& body ) { } body.activity.awake = true; + if ( body.isStatic ) impl::updateStaticBody( body ); } void impl::sleepBody( pod::PhysicsBody& body ) { bool wasAsleep = !body.activity.awake; @@ -718,11 +728,13 @@ pod::AABB impl::computeAABB( const pod::PhysicsBody& body ) { const auto transform = impl::getTransform( body ); switch ( body.collider.type ) { case pod::ShapeType::AABB: { - // return impl::transformAabbToWorld( body.collider.aabb, *body.transform ); + return impl::transformAabbToWorld( body.collider.aabb, *body.transform ); + /* return { transform.position + body.collider.aabb.min, transform.position + body.collider.aabb.max, }; + */ } break; case pod::ShapeType::SPHERE: { return { @@ -737,10 +749,7 @@ pod::AABB impl::computeAABB( const pod::PhysicsBody& body ) { case pod::ShapeType::MESH: case pod::ShapeType::CONVEX_HULL: { if ( body.collider.mesh.bvh && !body.collider.mesh.bvh->bounds.empty() ) - return { - transform.position + body.collider.mesh.bvh->bounds[0].min, - transform.position + body.collider.mesh.bvh->bounds[0].max, - }; + return impl::transformAabbToWorld( body.collider.mesh.bvh->bounds[0], *body.transform ); const auto& meshData = *body.collider.mesh.mesh; pod::AABB bounds = { { FLT_MAX, FLT_MAX, FLT_MAX }, { -FLT_MAX, -FLT_MAX, -FLT_MAX } }; for ( const auto& view : meshData.buffer_views ) impl::computeConvexHullAABB( view, view["position"], bounds );