From 4012eb97ba7cd56796f53136272c03a7ddcaf839 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Wed, 8 Mar 2023 21:23:03 +0800 Subject: [PATCH 1/3] Auto stash before merge of "SP3-1-Rendering" and "origin/main" Solved shadow bugs and WIP trajectory --- Assets/Scenes/Level2.shade | 139 +++++++++++++++++- Assets/Scenes/Scene2.shade | 56 ++++++- Assets/Shaders/DeferredComposite_CS.glsl | 24 ++- Assets/Shaders/DeferredComposite_CS.shshaderb | Bin 11109 -> 11569 bytes .../GlobalData/SHGraphicsPredefinedData.cpp | 2 +- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 3 +- .../MiddleEnd/Lights/SHLightComponent.cpp | 20 +-- .../MiddleEnd/Lights/SHLightingSubSystem.cpp | 4 +- .../SHTrajectoryRenderableComponent.h | 4 + .../SHTrajectoryRenderingSubSystem.cpp | 20 ++- .../Graphics/Pipeline/SHVkPipelineLayout.cpp | 4 +- .../RenderGraph/SHRenderGraphNodeCompute.cpp | 2 +- 12 files changed, 240 insertions(+), 38 deletions(-) diff --git a/Assets/Scenes/Level2.shade b/Assets/Scenes/Level2.shade index d068f3ca..dadf7bf0 100644 --- a/Assets/Scenes/Level2.shade +++ b/Assets/Scenes/Level2.shade @@ -21,6 +21,7 @@ Color: {x: 1, y: 1, z: 1, w: 1} Layer: 4294967295 Strength: 1 + Casting Shadows: false IsActive: true Scripts: ~ - EID: 5 @@ -35,6 +36,7 @@ Color: {x: 0.901608765, y: 0.867841423, z: 1, w: 1} Layer: 4294967295 Strength: 0.699999988 + Casting Shadows: false IsActive: true Scripts: ~ - EID: 65674 @@ -54,6 +56,7 @@ Color: {x: 0, y: 0, z: 0, w: 1} Layer: 4294967295 Strength: 1 + Casting Shadows: true IsActive: true Scripts: ~ - EID: 240 @@ -80,6 +83,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -131,6 +135,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -182,6 +187,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -233,6 +239,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -284,6 +291,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -335,6 +343,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -386,6 +395,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -437,6 +447,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -494,6 +505,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -535,6 +547,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -576,6 +589,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -617,6 +631,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -658,6 +673,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -709,6 +725,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -760,6 +777,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -811,6 +829,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -862,6 +881,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -913,6 +933,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -964,6 +985,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1015,6 +1037,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1066,6 +1089,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1117,6 +1141,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1168,6 +1193,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1219,6 +1245,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1270,6 +1297,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1321,6 +1349,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1372,6 +1401,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1423,6 +1453,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1474,6 +1505,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1525,6 +1557,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1576,6 +1609,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1627,6 +1661,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1684,6 +1719,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1735,6 +1771,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1786,6 +1823,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1837,6 +1875,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1888,6 +1927,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1939,6 +1979,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -1996,6 +2037,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2047,6 +2089,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2098,6 +2141,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2149,6 +2193,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2200,6 +2245,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2251,6 +2297,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2308,6 +2355,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2349,6 +2397,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2390,6 +2439,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2431,6 +2481,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2472,6 +2523,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2529,6 +2581,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2570,6 +2623,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2611,6 +2665,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2652,6 +2707,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -2695,6 +2751,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: true Sleeping Enabled: true @@ -2757,6 +2814,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: true Sleeping Enabled: true @@ -2999,6 +3057,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: false Interpolate: false Sleeping Enabled: true @@ -3180,6 +3239,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3227,6 +3287,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3268,6 +3329,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3309,6 +3371,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3350,6 +3413,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3391,6 +3455,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3438,6 +3503,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3479,6 +3545,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3520,6 +3587,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3561,6 +3629,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3602,6 +3671,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3649,6 +3719,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3690,6 +3761,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3731,6 +3803,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3772,6 +3845,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3813,6 +3887,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3860,6 +3935,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3901,6 +3977,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3942,6 +4019,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -3983,6 +4061,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4024,6 +4103,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4071,6 +4151,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4112,6 +4193,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4153,6 +4235,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4194,6 +4277,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4235,6 +4319,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4282,6 +4367,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4323,6 +4409,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4364,6 +4451,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4405,6 +4493,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4446,6 +4535,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4493,6 +4583,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4534,6 +4625,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4575,6 +4667,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4616,6 +4709,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4657,6 +4751,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4704,6 +4799,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4745,6 +4841,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4786,6 +4883,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4827,6 +4925,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4868,6 +4967,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4915,6 +5015,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4956,6 +5057,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -4997,6 +5099,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5038,6 +5141,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5079,6 +5183,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5126,6 +5231,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5167,6 +5273,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5208,6 +5315,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5249,6 +5357,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -5373,6 +5482,7 @@ Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 + Gravity Scale: 1 Use Gravity: true Interpolate: false Sleeping Enabled: true @@ -7421,7 +7531,7 @@ Components: Transform Component: Translate: {x: 2, y: 0, z: 0} - Rotate: {x: -0, y: 0, z: 0} + Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true Renderable Component: @@ -14149,4 +14259,31 @@ Perspective: true FOV: 90 IsActive: true + Scripts: ~ +- EID: 537 + Name: ShadowFixRoof + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -0.0146873593, y: 2.83242893, z: 0} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 5.15999985, y: 5.15999985, z: 5.15999985} + IsActive: true + Renderable Component: + Mesh: 142812576 + Material: 127069936 + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 0 + Type: Box + Half Extents: {x: 2, y: 0.0500000007, z: 2} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: -0.00999999978, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/Scene2.shade b/Assets/Scenes/Scene2.shade index 891c9664..c45d8b51 100644 --- a/Assets/Scenes/Scene2.shade +++ b/Assets/Scenes/Scene2.shade @@ -26,7 +26,7 @@ NumberOfChildren: 1 Components: Transform Component: - Translate: {x: 0, y: 0.189419448, z: 0} + Translate: {x: 0, y: 0.201105013, z: 0} Rotate: {x: 0.00523597933, y: -2.96353412, z: -6.40293041e-10} Scale: {x: 1.00000191, y: 1, z: 1.00000191} IsActive: true @@ -41,9 +41,9 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0.006237939, y: -0.000393368304, z: 0} - Rotate: {x: -0, y: 2.79945588, z: 0} - Scale: {x: 1.0000881, y: 1, z: 1.0000881} + Translate: {x: 0.00623797067, y: -0.000395311916, z: -2.03726813e-08} + Rotate: {x: 1.35041773e-08, y: 2.79945588, z: -9.6043955e-09} + Scale: {x: 1.00008798, y: 1, z: 1.0000881} IsActive: true Renderable Component: Mesh: 144838771 @@ -67,6 +67,7 @@ Color: {x: 1, y: 1, z: 1, w: 1} Layer: 4294967295 Strength: 0 + Casting Shadows: false IsActive: true Scripts: ~ - EID: 4 @@ -81,6 +82,7 @@ Color: {x: 1, y: 1, z: 1, w: 1} Layer: 4294967295 Strength: 0.600000024 + Casting Shadows: false IsActive: true Scripts: ~ - EID: 5 @@ -97,4 +99,50 @@ Mesh: 141771688 Material: 124370424 IsActive: true + Scripts: ~ +- EID: 6 + Name: TrajectoryTest + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -3.39616156, y: 3.66783714, z: -0.722039163} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + RigidBody Component: + Type: Dynamic + Drag: 0.00999999978 + Angular Drag: 0.100000001 + Gravity Scale: 1 + Use Gravity: true + Interpolate: true + Sleeping Enabled: false + Freeze Position X: false + Freeze Position Y: false + Freeze Position Z: false + Freeze Rotation X: false + Freeze Rotation Y: false + Freeze Rotation Z: false + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 0 + Type: Sphere + Radius: 1 + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true + Trajectory Renderer Component: + Mesh: 134305891 + Start Color: {x: 1, y: 0.951541781, z: 0} + Start Alpha: 1 + End Color: {x: 0, y: 1, z: 0.748898745} + End Alpha: 1 + "Color Eval Rate ": 0.192000002 + IsActive: true Scripts: ~ \ No newline at end of file diff --git a/Assets/Shaders/DeferredComposite_CS.glsl b/Assets/Shaders/DeferredComposite_CS.glsl index 18f53de4..e9f9eb0c 100644 --- a/Assets/Shaders/DeferredComposite_CS.glsl +++ b/Assets/Shaders/DeferredComposite_CS.glsl @@ -1,4 +1,5 @@ #version 450 +#extension GL_EXT_nonuniform_qualifier : require struct DirectionalLightStruct { @@ -63,8 +64,6 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV // Perform perspective division and convert to 0 to 1 range vec3 converted = (fragPosLightPOV.xyz / fragPosLightPOV.w) * vec3(0.5f) + vec3(0.5f); - // float sampledDepth = texture(shadowMap, converted.xy).r; - // float sampledDepth = texture(shadowMap, converted.xy).z; vec2 moments = texture(shadowMap, converted.xy).xy; if (converted.x < 0.0f || converted.x > 1.0f || converted.y < 0.0f || converted.y > 1.0f) @@ -121,18 +120,21 @@ void main() // light layer index uint lightLayer = lightLayerAndNormal.x; + // Normals are stored in 2 32-bit uints (only first 48 bits are used) where they can be unpacked in 3 floats so we unpack them here. vec3 worldNormal = vec3 (unpackHalf2x16 (lightLayerAndNormal.y).xy, unpackHalf2x16 (lightLayerAndNormal.z).x); vec3 fragColor = vec3 (0.0f); vec4 shadowMapColor = vec4 (1.0f); + // Shadow multiplier + float shadowValue = 1.0f; + for (int i = 0; i < lightCounts.ambientLights; ++i) { if ((lightLayer & AmbLightData.aLightData[i].cullingMask) != 0) { // Just do some add - //fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (0.5f); fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (AmbLightData.aLightData[i].strength); } } @@ -153,12 +155,16 @@ void main() // If the shadow map is enabled (test the bit) if ((DirLightData.dLightData[i].shadowData & uint(1)) == 1) { - // calculate shadow map here - fragColor.rgb *= CalcShadowValue (shadowMaps[0], positionWorld, DirLightData.dLightData[i].pvMatrix, worldNormal, DirLightData.dLightData[i].directionWorld.xyz).xxx; + uint shadowMapIndex = (DirLightData.dLightData[i].shadowData >> 8); + shadowValue = min (shadowValue, CalcShadowValue (shadowMaps[nonuniformEXT(shadowMapIndex)], positionWorld, DirLightData.dLightData[i].pvMatrix, worldNormal, DirLightData.dLightData[i].directionWorld.xyz)); } } } + // calculate shadow map here + if (shadowValue != 0.0f) + fragColor.rgb *= shadowValue; + float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r; fragColor *= ssaoVal; @@ -167,12 +173,4 @@ void main() // store result into result image imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f)); - - // vec2 normTexCoords = vec2 (gl_GlobalInvocationID.xy) / vec2 (1024.0f); - // vec4 shadowMapVal = texture(shadowMaps[0], normTexCoords); - // if (normTexCoords.x > 1.0f || normTexCoords.y > 1.0f) - // shadowMapVal = vec4(0.0f); - - // imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), shadowMapVal.xxxx); - } \ No newline at end of file diff --git a/Assets/Shaders/DeferredComposite_CS.shshaderb b/Assets/Shaders/DeferredComposite_CS.shshaderb index 57401b13063ae5536870be4281bf45663baf213c..1ec2bcf0d56aa6c9634e82958dec3fd7f3f954af 100644 GIT binary patch literal 11569 zcmZ{o37lM2m4{!FUP1^<2umOk(?OCr1V~6&Vjv+TAw&}rYz%R2s=KQ@1=Uqeb#*61 zki>|hU<8fe!X~03pfez-qce^$Bg{TJ%;M~Em>HaX7105m?|XGm|6c0nT>5bS=YP&U z_uTEhSDC-~tSoQSrk>uNWmB>l*-_aqPHAzovZ*jxre2oxQ^&XLuO$5q^o(qJ*1K(c z--aDm^$nKC1{#&oX1&o@sSTEQS8BuAky%%sXXEDH&1a7_2hUz{-cm<6I-91-ea8^f z3GP5fN|l=YSCM1k(-5%H}nmRj`oc;Z>X00s+C%~Z?MuR4>T(i<;grLu2LJQjt>?CI>}V5uQTh; zW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W>T*+U7kE zF~<9Q4tgDOUJ_J3hb!>89_J(WH^zB+=Az$vuztnn+#TODpfA?oLa^ic?Pm?1xw+; zsOxgDV_U27juCZT0oHF_SE6m!CI3o9&bq`=*Q>zobzKD~AM15BST5Ep@~ES(SA!kf zT8(!M>$nDOvkqgnBiA6-A@a=zIf$LpXtL#Ft;fM9BMl_R zdJR}UVwzy@Px-D)V9UpTw7~Y0x1K4q&3g1rB68Lvj@&!Jj$eKjU5_mvxo-f=IakkM z*m*MZyD;TAagh}i{hUx!=a%s2t zGQ|G+-A~^s`XbjGa(@52cN?61#Jn-Zl-K=sIQfXV<9Eco2~OVUa~Jx}i2dZ_o8T>A z$I}Is6XAfE~&f&da z#}4})ZT35{?GyfYB|GN*Zfs-ZZ%u3Q9iR>l`ycinfsKiE|6_2hyRrJC-ai5B_wGjgpMs4)3DIv& zjyr(X7vuaHSkAjI_RM?sV~;)nZr{fb!pXpF}zP7M%%nk`W{B)%q@1TMah=; PzIq4stK-?~cj0dVKJ1B) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index a15687cb..91ec0cea 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -186,7 +186,7 @@ namespace SHADE .flags = vk::DescriptorBindingFlagBits::eVariableDescriptorCount, }; - // For global data (generic data and textures) + // For global data (generic data and textures). NOT USED. Handle shadowMapDescLayout = logicalDevice->CreateDescriptorSetLayout({ shadowMapBinding }); SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, shadowMapDescLayout->GetVkHandle(), "[Descriptor Set Layout] Shadow Maps"); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index bf2f1ec2..397edf74 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -942,7 +942,8 @@ namespace SHADE else { // get the shadow map node - renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName)->SetDynamicActive(false); + if (auto node = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName)) + node->SetDynamicActive(false); } return eventPtr->handle; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp index f8578647..de930596 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp @@ -120,21 +120,17 @@ namespace SHADE { lightData.castShadows = flag; - // If the flag is true - if (flag) - { - // Create new event and broadcast it - SHLightShadowEvent newEvent; - newEvent.lightEntity = GetEID(); + // Create new event and broadcast it + SHLightShadowEvent newEvent; + newEvent.lightEntity = GetEID(); - // If shadow map index is invalid, that means light is enabling shadow for the first time. - newEvent.firstEnable = (lightData.shadowMapIndex == SHLightData::INVALID_SHADOW_MAP_INDEX); + // If shadow map index is invalid, that means light is enabling shadow for the first time. + newEvent.firstEnable = (lightData.shadowMapIndex == SHLightData::INVALID_SHADOW_MAP_INDEX); - // pass the flag to the event - newEvent.enableShadow = flag; + // pass the flag to the event + newEvent.enableShadow = flag; - SHEventManager::BroadcastEvent(newEvent, SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT); - } + SHEventManager::BroadcastEvent(newEvent, SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT); } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp index 27685d69..a2b9cc0a 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp @@ -526,7 +526,7 @@ namespace SHADE if (auto renderer = light.GetRenderer()) { //SHMatrix orthoMatrix = SHMatrix::OrthographicRH() - renderer->UpdateDataManual(frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(15.0f, 15.0f, 1.0f, 80.0f)); + renderer->UpdateDataManual(frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(20.0f, 20.0f, 1.0f, 80.0f)); } auto enumValue = SHUtilities::ConvertEnum(light.GetLightData().type); @@ -636,7 +636,7 @@ namespace SHADE shadowMapImageSamplers.emplace_back(NEW_IMAGE_VIEW, shadowMapSampler, vk::ImageLayout::eShaderReadOnlyOptimal); // Add to container of shadow maps - shadowMapIndexing.emplace(lightEntity, static_cast (shadowMaps.size())); + shadowMapIndexing.emplace(lightEntity, static_cast (shadowMaps.size() - 1u)); usedIndex = static_cast(shadowMapImageSamplers.size()) - 1u; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h index f3744d83..fd3d8b02 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h @@ -35,6 +35,9 @@ namespace SHADE //! evolving rate of the color float colorEvolveRate; + //! Entity to simulate trajectory of + //EntityID + public: /*-----------------------------------------------------------------------*/ /* PRIVATE MEMBER FUNCTIONS */ @@ -61,6 +64,7 @@ namespace SHADE void ClearPositions(void) noexcept; bool HasPositions(void) const noexcept; + void SimulateTrajectory (EntityID eid) noexcept; RTTR_ENABLE() diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp index cbf593d4..3ff7c1ec 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp @@ -11,6 +11,8 @@ #include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h" +#include "Physics/System/SHPhysicsSystem.h" +#include "ECS_Base/Managers/SHSystemManager.h" namespace SHADE { @@ -74,6 +76,8 @@ namespace SHADE void SHTrajectoryRenderingSubSystem::Run(uint32_t frameIndex) noexcept { + auto* physicsSystem = SHSystemManager::GetSystem(); + auto& comps = SHComponentManager::GetDense(); for (auto& comp : comps) { @@ -86,7 +90,21 @@ namespace SHADE // x += 0.5f; //} - //comp.SetPositions (test); + std::vector positions{}; + std::vector quats{}; + physicsSystem->SimulateBody + (positions, quats, + SHPhysicsSystem::SimulateBodyInfo + { + .bodyEID = comp.GetEID(), + .force = SHVec3 {30.0f, 100.0f, 30.0f}, + .continuousForce = false, + .timeStep = 0.1f, + .maxSteps = 100, + } + ); + + comp.SetPositions(positions); // If has positions, feed data to buffer. if (comp.HasPositions()) { diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp index d1c37e3a..166b3c6e 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp +++ b/SHADE_Engine/src/Graphics/Pipeline/SHVkPipelineLayout.cpp @@ -194,9 +194,9 @@ namespace SHADE // In reality, the check for variable descriptor sets do not exists in spirv-reflect. Fortunately, when a shader // defines a boundless descriptor binding in the shader, the information reflected makes the array dimensions - // contain a 1 element of value 1. Knowing that having an array [1] doesn't make sense, we can use this to + // contain a 1 element of value 0. Knowing that having an array [1] doesn't make sense, we can use this to // signify a variable sized binding. - if (reflectedBinding->array.dims[0] == 1) + if (reflectedBinding->array.dims_count == 1 && reflectedBinding->array.dims[0] == 0) { // variable binding has to be the last in the set if (i == set->binding_count - 1) diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp index ef1b6b03..72176f4e 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNodeCompute.cpp @@ -118,7 +118,7 @@ namespace SHADE if (layouts.size() == descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1) { Handle computeResourceLayout = {}; - computeResourceLayout = layouts[descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; + computeResourceLayout = layouts[descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; // create compute resources computeResource = graphStorage->resourceHub->Create(); -- 2.40.1 From e3a552f983340890ab5f6e73c10f18be5a464ea1 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Thu, 9 Mar 2023 10:45:57 +0800 Subject: [PATCH 2/3] Wrote scripting interface for trajectory rendering --- .../SHTrajectoryRenderableComponent.cpp | 35 ++-- .../SHTrajectoryRenderableComponent.h | 41 +++-- .../SHTrajectoryRenderingSubSystem.cpp | 151 ++++++++---------- .../src/Components/TrajectoryRenderable.cxx | 5 + .../src/Components/TrajectoryRenderable.hxx | 3 + 5 files changed, 128 insertions(+), 107 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.cpp index 91c11e60..41678935 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.cpp @@ -22,19 +22,32 @@ namespace SHADE } - void SHTrajectoryRenderableComponent::ClearPositions(void) noexcept + void SHTrajectoryRenderableComponent::SimulateTrajectory(EntityID eid, SHVec3 force, float timestep, uint32_t maxSteps) noexcept { - positions.clear(); + entityToSimulate = eid; + simulationForce = force; + simulationTimestep = timestep; + simulationMaxSteps = maxSteps; } - bool SHTrajectoryRenderableComponent::HasPositions(void) const noexcept + float SHTrajectoryRenderableComponent::GetSimulationTimestep(void) const noexcept { - return !positions.empty(); + return simulationTimestep; } - std::vector SHTrajectoryRenderableComponent::GetPositions(void) const noexcept + void SHTrajectoryRenderableComponent::ResetSimulationInfo(void) noexcept { - return positions; + entityToSimulate = MAX_EID; + } + + uint32_t SHTrajectoryRenderableComponent::GetSimulationMaxSteps(void) const noexcept + { + return simulationMaxSteps; + } + + SHVec3 SHTrajectoryRenderableComponent::GetSimulationForce(void) const noexcept + { + return simulationForce; } Handle SHTrajectoryRenderableComponent::GetMesh(void) const noexcept @@ -67,16 +80,16 @@ namespace SHADE return colorEvolveRate; } + EntityID SHTrajectoryRenderableComponent::GetEntityToSimulate(void) const noexcept + { + return entityToSimulate; + } + void SHTrajectoryRenderableComponent::SetMesh(Handle newMesh) noexcept { mesh = newMesh; } - void SHTrajectoryRenderableComponent::SetPositions(std::vector const& inPositions) noexcept - { - positions = inPositions; - } - void SHTrajectoryRenderableComponent::SetStartColor(SHVec3 color) noexcept { startColor = color; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h index fd3d8b02..95d40af1 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h @@ -17,9 +17,6 @@ namespace SHADE //! Mesh used to render the trajectory Handle mesh; - //! positions to plot for rendering. Will be cleared every frame. - std::vector positions; - //! Starting color of the trajectory SHVec3 startColor; @@ -35,36 +32,48 @@ namespace SHADE //! evolving rate of the color float colorEvolveRate; + //! Used for the trajectory simulation. Indicates the time to pass before + //! plotting a point in the simulation + float simulationTimestep; + //! Entity to simulate trajectory of - //EntityID + EntityID entityToSimulate; + + //! Force to use during simulation of + SHVec3 simulationForce; + + //! max points to be plotted in the simulation before stopping. + //! Note that the plotting might still be halted if the simulation + //! detects a raycast hit with a collider. + uint32_t simulationMaxSteps; public: /*-----------------------------------------------------------------------*/ /* PRIVATE MEMBER FUNCTIONS */ /*-----------------------------------------------------------------------*/ void SetMesh(Handle newMesh) noexcept; - void SetPositions (std::vector const& inPositions) noexcept; void SetStartColor(SHVec3 startColor) noexcept; void SetEndColor (SHVec3 endColor) noexcept; void SetStartAlpha(float a) noexcept; void SetEndAlpha (float a) noexcept; void SetColorEvolveRate(float rate) noexcept; - std::vector GetPositions (void) const noexcept; - Handle GetMesh (void) const noexcept; - SHVec3 const& GetStartColor (void) const noexcept; - SHVec3 const& GetEndColor (void) const noexcept; - float GetStartAlpha (void) const noexcept; - float GetEndAlpha (void) const noexcept; - float GetColorEvolveRate (void) const noexcept; + Handle GetMesh (void) const noexcept; + SHVec3 const& GetStartColor (void) const noexcept; + SHVec3 const& GetEndColor (void) const noexcept; + float GetStartAlpha (void) const noexcept; + float GetEndAlpha (void) const noexcept; + float GetColorEvolveRate (void) const noexcept; + EntityID GetEntityToSimulate (void) const noexcept; + SHVec3 GetSimulationForce (void) const noexcept; + uint32_t GetSimulationMaxSteps (void) const noexcept; + float GetSimulationTimestep (void) const noexcept; + void ResetSimulationInfo (void) noexcept; void OnCreate(void) override final; void OnDestroy(void) override final; - void ClearPositions(void) noexcept; - bool HasPositions(void) const noexcept; - - void SimulateTrajectory (EntityID eid) noexcept; + void SimulateTrajectory (EntityID eid, SHVec3 force, float timestep, uint32_t maxSteps) noexcept; RTTR_ENABLE() diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp index 3ff7c1ec..f923add4 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp @@ -81,94 +81,85 @@ namespace SHADE auto& comps = SHComponentManager::GetDense(); for (auto& comp : comps) { - //std::vector test{}; - //test.resize(10); - //float x = 0.0f; - //for (auto& vec : test) - //{ - // vec = SHVec3(x, 5.0f, 0.0f); - // x += 0.5f; - //} - - std::vector positions{}; - std::vector quats{}; - physicsSystem->SimulateBody - (positions, quats, - SHPhysicsSystem::SimulateBodyInfo - { - .bodyEID = comp.GetEID(), - .force = SHVec3 {30.0f, 100.0f, 30.0f}, - .continuousForce = false, - .timeStep = 0.1f, - .maxSteps = 100, - } - ); - - comp.SetPositions(positions); - // If has positions, feed data to buffer. - if (comp.HasPositions()) + if (EntityID entityToSimulate = comp.GetEntityToSimulate(); entityToSimulate != MAX_EID) { - auto meshHandle = comp.GetMesh(); - - // dont do anything if no mesh - if (!meshHandle) - continue; - - SHTransformComponent* transform = SHComponentManager::GetComponent_s(comp.GetEID()); - if (transform) - { - // convenient variable - SHVec3 const& startColor = comp.GetStartColor(); - SHVec3 const& endColor = comp.GetEndColor(); - float colorEvolveRate = comp.GetColorEvolveRate(); - - // trs to be reused - SHMatrix trs = transform->GetTRS(); - - // starting color of trajectory - SHVec4 currentColor = comp.GetStartColor(); - - // Start from 0 and slowly evolve to 1 - float lerpValue = 0.0f; - - // Will be used for baseInstance later - uint32_t oldTransformDataSize = transformData.size(); - - - auto const& positions = comp.GetPositions(); - for (auto& pos : positions) + std::vector positions{}; + std::vector quats{}; + physicsSystem->SimulateBody + (positions, quats, + SHPhysicsSystem::SimulateBodyInfo { - // modify position and reuse matrix - trs.m[3][0] = pos.x; - trs.m[3][1] = pos.y; - trs.m[3][2] = pos.z; - - transformData.push_back(trs); - colorData.push_back(currentColor); - - // evolve lerp value and clamp to 1 - lerpValue = std::min (1.0f, lerpValue + colorEvolveRate); - - // evolve color - currentColor = SHVec3::Lerp(startColor, endColor, lerpValue); - currentColor.w = SHMath::Lerp (comp.GetStartAlpha(), comp.GetEndAlpha(), lerpValue); - + .bodyEID = entityToSimulate, + .force = comp.GetSimulationForce(), + .continuousForce = false, + .timeStep = comp.GetSimulationTimestep(), + .maxSteps = static_cast(comp.GetSimulationMaxSteps()), } + ); - // add draw data for this trajectory - drawData.push_back(vk::DrawIndexedIndirectCommand + comp.ResetSimulationInfo(); + + // If has positions, feed data to buffer. + if (!positions.empty()) + { + auto meshHandle = comp.GetMesh(); + + // dont do anything if no mesh + if (!meshHandle) + continue; + + SHTransformComponent* transform = SHComponentManager::GetComponent_s(comp.GetEID()); + if (transform) + { + // convenient variable + SHVec3 const& startColor = comp.GetStartColor(); + SHVec3 const& endColor = comp.GetEndColor(); + float colorEvolveRate = comp.GetColorEvolveRate(); + + // trs to be reused + SHMatrix trs = transform->GetTRS(); + + // starting color of trajectory + SHVec4 currentColor = comp.GetStartColor(); + + // Start from 0 and slowly evolve to 1 + float lerpValue = 0.0f; + + // Will be used for baseInstance later + uint32_t oldTransformDataSize = transformData.size(); + + for (auto& pos : positions) { - .indexCount = meshHandle->IndexCount, - .instanceCount = static_cast(transformData.size()) - oldTransformDataSize, - .firstIndex = meshHandle->FirstIndex, - .vertexOffset = meshHandle->FirstVertex, - .firstInstance = oldTransformDataSize - }); + // modify position and reuse matrix + trs.m[3][0] = pos.x; + trs.m[3][1] = pos.y; + trs.m[3][2] = pos.z; + + transformData.push_back(trs); + colorData.push_back(currentColor); + + // evolve lerp value and clamp to 1 + lerpValue = std::min(1.0f, lerpValue + colorEvolveRate); + + // evolve color + currentColor = SHVec3::Lerp(startColor, endColor, lerpValue); + currentColor.w = SHMath::Lerp(comp.GetStartAlpha(), comp.GetEndAlpha(), lerpValue); + + } + + // add draw data for this trajectory + drawData.push_back(vk::DrawIndexedIndirectCommand + { + .indexCount = meshHandle->IndexCount, + .instanceCount = static_cast(transformData.size()) - oldTransformDataSize, + .firstIndex = meshHandle->FirstIndex, + .vertexOffset = meshHandle->FirstVertex, + .firstInstance = oldTransformDataSize + }); + } } } - // clear at the end of every frame since data is already in buffers - comp.ClearPositions(); } if (!transformData.empty()) diff --git a/SHADE_Managed/src/Components/TrajectoryRenderable.cxx b/SHADE_Managed/src/Components/TrajectoryRenderable.cxx index 4b762338..9eace4ab 100644 --- a/SHADE_Managed/src/Components/TrajectoryRenderable.cxx +++ b/SHADE_Managed/src/Components/TrajectoryRenderable.cxx @@ -13,6 +13,11 @@ namespace SHADE } + void TrajectoryRenderable::SimulateTrajectory(EntityID eid, Vector3 force, float timestep, uint32_t maxSteps) + { + GetNativeComponent()->SimulateTrajectory(eid, Convert::ToNative(force), timestep, maxSteps); + } + MeshAsset TrajectoryRenderable::Mesh::get() { auto mesh = GetNativeComponent()->GetMesh(); diff --git a/SHADE_Managed/src/Components/TrajectoryRenderable.hxx b/SHADE_Managed/src/Components/TrajectoryRenderable.hxx index 37a350ad..78e3c0f1 100644 --- a/SHADE_Managed/src/Components/TrajectoryRenderable.hxx +++ b/SHADE_Managed/src/Components/TrajectoryRenderable.hxx @@ -82,6 +82,9 @@ namespace SHADE float get(); void set(float val); } + + void SimulateTrajectory(EntityID eid, Vector3 force, float timestep, uint32_t maxSteps); + }; } -- 2.40.1 From bf08be045ac023437f61fa2b267495255567e9c7 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Thu, 9 Mar 2023 14:56:03 +0800 Subject: [PATCH 3/3] Solved bugs with shadows Switching a scene causes a crash from shadows. --- Assets/Scenes/Level2.shade | 4 +-- Assets/Shaders/DeferredComposite_CS.glsl | 6 +++- Assets/Shaders/DeferredComposite_CS.shshaderb | Bin 11569 -> 11569 bytes Assets/Shaders/ShinyHighlight_FS.glsl | 2 +- Assets/Shaders/ShinyHighlight_FS.shshaderb | Bin 5733 -> 5921 bytes .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 28 ++++++++++-------- .../MiddleEnd/Lights/SHLightingSubSystem.cpp | 10 +++---- .../Graphics/RenderGraph/SHRenderGraph.cpp | 6 ++-- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Assets/Scenes/Level2.shade b/Assets/Scenes/Level2.shade index dadf7bf0..ef197542 100644 --- a/Assets/Scenes/Level2.shade +++ b/Assets/Scenes/Level2.shade @@ -45,14 +45,14 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0.242245644, y: 1.56757355, z: -6.07086945} + Translate: {x: 0.236000001, y: 1.56757355, z: -6.07086945} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true Light Component: Position: {x: 2, y: 1.5, z: -5.5999999} Type: Directional - Direction: {x: 0, y: 0, z: -1} + Direction: {x: -0.0780000016, y: 0.159999996, z: -1} Color: {x: 0, y: 0, z: 0, w: 1} Layer: 4294967295 Strength: 1 diff --git a/Assets/Shaders/DeferredComposite_CS.glsl b/Assets/Shaders/DeferredComposite_CS.glsl index e9f9eb0c..2839e106 100644 --- a/Assets/Shaders/DeferredComposite_CS.glsl +++ b/Assets/Shaders/DeferredComposite_CS.glsl @@ -73,9 +73,12 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV float worldNormalDotLight = dot (normalize (worldNormal), normalize(lightDir)); - if (worldNormalDotLight < 0.0f) + if (worldNormalDotLight <= 0.0f) return 0.7f; + // if (worldNormalDotLight <= 0.01f) + // return 0.7f; + if (fragPosLightPOV.z > moments.x && fragPosLightPOV.w > 0.0f) { float p = step (fragPosLightPOV.z, moments.x); @@ -94,6 +97,7 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV return 0.0f; } + // return min (worldNormalDotLight + 0.7f, 1.0f); return 1.0f; } diff --git a/Assets/Shaders/DeferredComposite_CS.shshaderb b/Assets/Shaders/DeferredComposite_CS.shshaderb index 1ec2bcf0d56aa6c9634e82958dec3fd7f3f954af..a48a176f5d45e271183945cd393248c18c43ea5f 100644 GIT binary patch delta 14 VcmdlOwJ~Z#ss`hp&1o8^SpYG;1|a|d delta 14 VcmdlOwJ~Z#ss`hZ&1o8^SpYGm1|0wZ diff --git a/Assets/Shaders/ShinyHighlight_FS.glsl b/Assets/Shaders/ShinyHighlight_FS.glsl index 18f979fe..b2a2e940 100644 --- a/Assets/Shaders/ShinyHighlight_FS.glsl +++ b/Assets/Shaders/ShinyHighlight_FS.glsl @@ -77,7 +77,7 @@ void main() worldSpacePosition = In.worldPos; outEntityID = In2.eid; - lightLayerIndices = uvec4 (In2.lightLayerIndex, 0, 0, 1); + lightLayerIndices = uvec4 (In2.lightLayerIndex, packHalf2x16 (In.worldNormal.xy), packHalf2x16 (vec2 (In.worldNormal.z, 1.0f)), 1); // float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition; // bring the frame of reference to the object's screen space pos diff --git a/Assets/Shaders/ShinyHighlight_FS.shshaderb b/Assets/Shaders/ShinyHighlight_FS.shshaderb index a3a6230df5e550a976d687e26fd3bab001c76575..7bbcb950f9afcf7c089937860865cd4c234a5f2a 100644 GIT binary patch literal 5921 zcmZ9Oi+@~I5yx-IZqlYtq)-rzNeeAntWe9#N+G4`CK5;>wXM(PcK0T^bhCH4dpBu) z(Sk@7Ux-?Hs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jmuccs*Y}PP) zpD=?xTK^`5$;tdrdc4{D+1Gwa5Init`g=fDvHzd;HuDdAoY$S({C*LS{}E}{!p~j$ ztjBg2KPQ{moG%5~RnJi`^NvUuX4izR{z$k_!hUUkv%-H@0PDxX#Ii4J{n_IBgKhav zdk!1^j3fx&-Lp}VF9^{G?j_$5a#`FeA#n%}RtWaDGbU!_+{;8-8~ZO`4VyNZt|FI z0*^3ONVpFVYEG~8l!O?DaSsZ^5o_E-o@4HmPJ{KP9VR9S@N=i>AKzen*6)MD)XulU z`h7?ko_M|~*u?XV_>AM1_sYG0bcyeAzwy`>|Cli6W9LbHD0xgmt$a`F61XE?YSOG- zmBt62k)D-|sxy2m9(R0RH}TX?&yFtndfZ#VrWWqXyrlcCG(A76S`y)w#O?|{J5zE$ z;r%E5TB+xnvbj5L2^_UxXA<~-x)92174e>Ug1F#Ku7 zP}k=r@Nz>Nly9sUlN8Rj`{fDtZyeBf91P*QXIVX?Ub5$X*kRKoG^Pb z`)k6)*g9VqCI+7Q&q~8t{5OP)^S>#Z`PRR02@?a){O6_N=pT3W+mf@A;ywM2=WUJe z%4Xfmn)8D6_awx?|5G`CAkFxX?hU^0OW^pu0NYwW6z*Q@N8;dZtse_h<0Ze=PlSnq z|F`m4Ui3foE~w|H64otCh-XdedQqA|UBvuM@@ENkf$7IN>6au{cc&qW3 z!t~tE=vTtTzz^uwbFY3aSs^J&@Y~$q2(v%4e=A(f^*hF-$T_`PJEggne=9`VF6m;DoC_548?Za}{S%>Sc=eQcB9V}0`5-v8un z;w&GW<$Fz-eD>{sT^Oz?%)2NKA7}icG-t$FneS4Uj~LGEvh78bwp=SrE_^ocy~5OP_I1L=wcjV382B^3FV_o`3*RZvy84-+|3h5!Hn diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 397edf74..bc50d0a7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -865,32 +865,30 @@ namespace SHADE std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity); std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity); std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity); - Handle gBufferWriteSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS); - Handle gBufferWriteVfxSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_VFX_SUBPASS); + + // we need to wait for the device to finish using the graph first + device->WaitIdle(); + if (EVENT_DATA->enableShadow) { // When the light first enables shadow rendering, we need to prepare the relevant objects to render shadows; namely renderpasses and subpasses, pipelines and descriptor sets if (EVENT_DATA->firstEnable) { - // we need to wait for the device to finish using the graph first - device->WaitIdle(); + Handle gBufferWriteSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS); + Handle gBufferWriteVfxSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_VFX_SUBPASS); + // Create new renderer for the light component and give it to the light component Handle newRenderer = resourceManager.Create(device, swapchain->GetNumImages(), descPool, SHRenderer::PROJECTION_TYPE::ORTHOGRAPHIC); lightComp->SetRenderer(newRenderer); - // assign shadow map index to light component - lightComp->SetShadowMapIndex(lightingSubSystem->GetNumShadowMaps()); - - // Add the shadow map resource to the graph renderGraph->AddResource(depthResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eD32Sfloat); renderGraph->AddResource(shadowMapResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eR32G32B32A32Sfloat); renderGraph->AddResource(shadowMapBlurredResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eR32G32B32A32Sfloat); - // link resource to node. This means linking the resource and regenerating the node's renderpass and framebuffer. auto shadowMapNode = renderGraph->AddNodeAfter(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, { depthResourceName.c_str(), shadowMapResourceName.c_str(), shadowMapBlurredResourceName.c_str() }, SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data()); @@ -929,6 +927,10 @@ namespace SHADE // add the shadow map and the blurred version to the lighting system uint32_t const NEW_SHADOW_MAP_INDEX = lightingSubSystem->AddShadowMap(renderGraph->GetRenderGraphResource(shadowMapBlurredResourceName), EVENT_DATA->lightEntity); + // assign shadow map index to light component + lightComp->SetShadowMapIndex(NEW_SHADOW_MAP_INDEX); + + // Get deferred composite node compute and modify descriptor set auto nodeCompute = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data())->GetNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data()); nodeCompute->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetBindings::SHADOW_MAP_IMAGE_SAMPLER_DATA, lightingSubSystem->GetViewSamplerLayout(NEW_SHADOW_MAP_INDEX), NEW_SHADOW_MAP_INDEX); @@ -964,12 +966,12 @@ namespace SHADE std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity); // Remove render graph node - //renderGraph->RemoveNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName); + renderGraph->RemoveNode(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName); // Remove render graph resource - //renderGraph->RemoveResource(depthResourceName); - //renderGraph->RemoveResource(shadowMapResourceName); - //renderGraph->RemoveResource(shadowMapBlurredResourceName); + renderGraph->RemoveResource(depthResourceName); + renderGraph->RemoveResource(shadowMapResourceName); + renderGraph->RemoveResource(shadowMapBlurredResourceName); // Register light component shadow map index into light system as recyclable lightingSubSystem->RemoveShadowMap (EVENT_DATA->lightEntity); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp index a2b9cc0a..b17964e4 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp @@ -62,15 +62,13 @@ namespace SHADE // write view projection matrix if renderer is available auto lightRenderer = lightComp->GetRenderer(); if (lightRenderer) - { lightPtr->pvMatrix = lightRenderer->GetCPUCameraData().viewProjectionMatrix; - // Boolean to cast shadows in first 8 bits (1 byte) - lightPtr->shadowData = lightData.castShadows; + // Boolean to cast shadows in first 8 bits (1 byte) + lightPtr->shadowData = lightData.castShadows; - // Next 24 bits for shadow map index - lightPtr->shadowData |= (lightData.shadowMapIndex << 8); - } + // Next 24 bits for shadow map index + lightPtr->shadowData |= (lightData.shadowMapIndex << 8); break; } case SH_LIGHT_TYPE::POINT: diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index 34206e5b..c44c9464 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -111,7 +111,6 @@ namespace SHADE renderGraphStorage->graphResources->at(resourceName).Free(); renderGraphStorage->graphResources->erase (resourceName); - resourceHdl.Free (); /* * IMPORTANT NOTES * @@ -134,8 +133,11 @@ namespace SHADE // Get handle to node since it exists auto nodeHdl = nodes[nodeIndexing[nodeName]]; + nodes.erase(nodes.begin() + nodeIndexing[nodeName]); + nodeHdl.Free(); - nodeIndexing.erase(nodeName); + + ReindexNodes(); } } -- 2.40.1