Skip to content

Commit

Permalink
Improved physics integration and editor improvements (#49)
Browse files Browse the repository at this point in the history
* Fixed some issues

* Expanded physics integration

* Some improvements

* Added camera component to editor UI

* Started work on actual player component

* More changes

* Implemented notification system

* Some fixes

* Moved to seperate physics body object

* Added profile window

* Reset some previous changes

* Smaller changes + added default scene

* Bunch of code smell fixes + make resource manager paths relative to assert directory

* Smaller changes

* Finished player implementation for now

* Smaller improvements

* Final fixes
  • Loading branch information
tippesi authored Feb 15, 2024
1 parent bb69679 commit 4beec4b
Show file tree
Hide file tree
Showing 108 changed files with 3,047 additions and 657 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ jobs:
!**/CMakeFiles
macos-build:
runs-on: macos-12
runs-on: macos-13
name: Build on MacOS
# Run both builds in parallel and don't cancel if one fails
strategy:
Expand Down Expand Up @@ -405,6 +405,7 @@ jobs:
LICENSE.md
THIRDPARTY.md
${{ github.workspace }}/bin/**/AtlasEngineDemo
${{ github.workspace }}/bin/**/AtlasEngineEditor
${{ github.workspace }}/bin/**/*.dylib*
!${{ github.workspace }}/bin/tests
!**/CMakeFiles
122 changes: 122 additions & 0 deletions data/capsule.gltf

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data/scenes/sponza.aescene
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"aabb":{"max":{"x":128.0,"y":128.0,"z":128.0},"min":{"x":-128.0,"y":-128.0,"z":-128.0}},"ao":{"enable":false,"opacityCheck":false,"radius":3.0,"rt":true,"sampleCount":16,"strength":1.0},"depth":5.0,"entities":[{"entities":[{"id":1,"light":{"color":{"x":1.0,"y":0.9254902005195618,"z":0.8196078538894653},"intensity":10.0,"isMain":true,"mobility":0,"properties":{"direction":{"x":0.0,"y":-1.0,"z":0.2800000011920929}},"shadow":{"allowDynamicActors":false,"allowTerrain":true,"bias":3.0,"cascadeBlendDistance":2.5,"center":{"x":0.0,"y":0.0,"z":0.0},"distance":200.0,"isCascaded":false,"longRange":false,"longRangeDistance":1024.0,"resolution":4096,"splitCorrection":0.0,"useCubemap":false,"viewCount":1,"views":[{"farDistance":200.0,"frustumMatrix":{"j0":{"w":0.0,"x":0.009999999776482582,"y":0.0,"z":0.0},"j1":{"w":0.0,"x":0.0,"y":-0.010526316240429878,"z":0.0},"j2":{"w":0.0,"x":0.0,"y":0.0,"z":-0.004166666883975267},"j3":{"w":1.0,"x":0.0,"y":0.2631579041481018,"z":0.5}},"nearDistance":0.0,"projectionMatrix":{"j0":{"w":0.0,"x":0.009999999776482582,"y":0.0,"z":0.0},"j1":{"w":0.0,"x":0.0,"y":-0.010526316240429878,"z":0.0},"j2":{"w":0.0,"x":0.0,"y":0.0,"z":-0.004166666883975267},"j3":{"w":1.0,"x":0.0,"y":0.2631579041481018,"z":0.5}},"terrainFrustumMatrix":{"j0":{"w":0.0,"x":0.009999999776482582,"y":0.0,"z":0.0},"j1":{"w":0.0,"x":0.0,"y":-0.010526316240429878,"z":0.0},"j2":{"w":0.0,"x":0.0,"y":0.0,"z":-0.004166666883975267},"j3":{"w":1.0,"x":0.0,"y":0.2631579041481018,"z":0.5}},"viewMatrix":{"j0":{"w":0.0,"x":-1.0,"y":0.0,"z":-0.0},"j1":{"w":0.0,"x":0.0,"y":0.26962992548942566,"z":0.9629640579223633},"j2":{"w":0.0,"x":0.0,"y":0.9629640579223633,"z":-0.26962992548942566},"j3":{"w":1.0,"x":-0.0,"y":-0.0,"z":0.0}}}]},"type":0,"volumetric":true},"name":{"name":"Directional light"}},{"id":2,"mesh":{"dontCull":false,"resourcePath":"sponza/sponza.obj","visible":true},"name":{"name":"Sponza"},"rigidBody":{"bodyIndex":4,"layer":0},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":0.012193998321890831,"y":0.0,"z":0.0},"j1":{"w":0.0,"x":0.0,"y":0.012193998321890831,"z":0.0},"j2":{"w":0.0,"x":0.0,"y":0.0,"z":0.012193998321890831},"j3":{"w":1.0,"x":0.0,"y":0.0,"z":0.0}}}},{"id":3,"mesh":{"dontCull":false,"resourcePath":"chromesphere.gltf","visible":true},"name":{"name":"Sphere"},"rigidBody":{"bodyIndex":0,"layer":1},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":-0.05475284904241562,"y":-0.9576014280319214,"z":-0.2828459143638611},"j1":{"w":0.0,"x":-0.761136531829834,"y":0.22337371110916138,"z":-0.6089133620262146},"j2":{"w":0.0,"x":0.646276593208313,"y":0.1819445937871933,"z":-0.7410957217216492},"j3":{"w":1.0,"x":-12.68726634979248,"y":0.9694054126739502,"z":-1.4988267421722412}}}},{"id":4,"mesh":{"dontCull":false,"resourcePath":"metallicwall.gltf","visible":true},"name":{"name":"Wall"},"rigidBody":{"bodyIndex":1,"layer":1},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":0.11922791600227356,"y":7.185232107076445e-07,"z":0.08787291496992111},"j1":{"w":0.0,"x":-6.112605888120015e-07,"y":0.17914418876171112,"z":-6.354624701998546e-07},"j2":{"w":0.0,"x":-1.705381155014038,"y":2.3889349449746078e-06,"z":2.313899040222168},"j3":{"w":1.0,"x":7.41675329208374,"y":-0.04549086093902588,"z":-1.0144298076629639}}}},{"id":5,"mesh":{"dontCull":false,"resourcePath":"chromesphere.gltf","visible":true},"name":{"name":"Sphere"},"rigidBody":{"bodyIndex":2,"layer":1},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":0.7781524658203125,"y":0.19958826899528503,"z":-0.5955193638801575},"j1":{"w":0.0,"x":-0.30390915274620056,"y":-0.710123598575592,"z":-0.635109543800354},"j2":{"w":0.0,"x":-0.549652636051178,"y":0.6751958131790161,"z":-0.4919278025627136},"j3":{"w":1.0,"x":4.571228504180908,"y":2.559000015258789,"z":0.9528822898864746}}}},{"id":6,"mesh":{"dontCull":false,"resourcePath":"metallicwall.gltf","visible":true},"name":{"name":"Entity 7"},"rigidBody":{"bodyIndex":3,"layer":1},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":0.04754149541258812,"y":-1.7056215710908873e-06,"z":0.06713510304689407},"j1":{"w":0.0,"x":-2.278684860357316e-06,"y":-0.10399212688207626,"z":-1.028361111821141e-06},"j2":{"w":0.0,"x":0.816096305847168,"y":-1.21674593174248e-05,"z":-0.5779158473014832},"j3":{"w":1.0,"x":-11.392644882202148,"y":1.5304889678955078,"z":-0.4352414011955261}}}},{"camera":{"aspectRatio":2.0,"exposure":1.0,"farPlane":400.0,"fieldOfView":55.20000076293945,"isMain":true,"location":{"x":0.0,"y":0.0,"z":0.0},"nearPlane":1.0,"rotation":{"x":7.924738883972168,"y":-0.3975745141506195},"thirdPerson":true,"thirdPersonDistance":4.0,"useEntityRotation":true,"useEntityTranslation":true},"id":7,"mesh":{"dontCull":false,"resourcePath":"capsule.gltf","visible":true},"name":{"name":"Player"},"player":{"creationSettings":{"shape":{"capsuleShapeSettings":{"density":1.0,"height":1.2000000476837158,"radius":0.30000001192092896,"scale":{"x":1.0,"y":1.0,"z":1.0}}}},"fastVelocity":4.0,"jumpVelocity":4.0,"slowVelocity":1.600000023841858},"transform":{"isStatic":false,"matrix":{"j0":{"w":0.0,"x":1.0,"y":0.0,"z":0.0},"j1":{"w":0.0,"x":0.0,"y":1.0,"z":0.0},"j2":{"w":0.0,"x":0.0,"y":0.0,"z":1.0},"j3":{"w":1.0,"x":-4.039059162139893,"y":-0.030557187274098396,"z":-0.045003850013017654}}}}],"id":0,"name":{"name":"Root"},"root":false}],"fog":{"ambientFactor":0.009999999776482582,"density":0.00019999999494757503,"enable":true,"extinctionCoefficients":{"w":1.0,"x":0.9300000071525574,"y":0.9649999737739563,"z":1.0},"extinctionFactor":0.1599999964237213,"height":0.0,"heightFalloff":0.0284000001847744,"rayMarchStepCount":10,"rayMarching":true,"scatteringAnisotropy":-0.6000000238418579,"scatteringFactor":2.0,"volumetricIntensity":1.0},"irradianceVolume":{"aabb":{"max":{"x":23.738000869750977,"y":18.340999603271484,"z":17.85099983215332},"min":{"x":-38.63600158691406,"y":-9.817999839782715,"z":-21.163000106811523}},"bias":0.30000001192092896,"enable":true,"gamma":5.0,"hysteresis":0.9800000190734863,"lowerResMoments":true,"opacityCheck":false,"optimizeProbes":true,"probeCount":{"x":20,"y":20,"z":20},"rayCount":100,"rayCountInactive":32,"sampleEmissives":false,"sharpness":50.0,"strength":1.0,"useShadowMap":false},"name":"sponza","physicsWorld":{"bodies":[[4,{"angularDampening":0.0,"linearDampening":0.0,"shape":{"meshSettings":{"resourcePath":"sponza/sponza.obj","scale":{"x":0.012193998321890831,"y":0.012193998321890831,"z":0.012193998321890831}}}}],[3,{"motionQuality":1,"objectLayer":1,"shape":{"boundingBoxSettings":{"aabb":{"max":{"x":7.46401834487915,"y":15.011363983154297,"z":0.4019695222377777},"min":{"x":-7.46401834487915,"y":0.0833272933959961,"z":-0.4019695222377777}},"density":1.0,"scale":{"x":0.08226369321346283,"y":0.10399212688207626,"z":0.9999999403953552}}}}],[2,{"objectLayer":1,"restitution":0.8999999761581421,"shape":{"sphereSettings":{"density":1.0,"radius":1.0000001192092896,"scale":{"x":0.9999986886978149,"y":0.9999987483024597,"z":0.9999987483024597}}}}],[1,{"objectLayer":1,"shape":{"boundingBoxSettings":{"aabb":{"max":{"x":7.46401834487915,"y":15.011363983154297,"z":0.4019695222377777},"min":{"x":-7.46401834487915,"y":0.0833272933959961,"z":-0.4019695222377777}},"density":1.0,"scale":{"x":0.1481112539768219,"y":0.17914418876171112,"z":2.874448299407959}}}}],[0,{"objectLayer":1,"restitution":0.8999999761581421,"shape":{"sphereSettings":{"density":1.0,"radius":1.0000001192092896,"scale":{"x":1.0,"y":1.0,"z":1.0}}}}]]},"postProcessing":{"chromaticAberration":{"colorsReversed":false,"enable":false,"strength":1.0},"contrast":1.0,"filmGrain":{"enable":false,"strength":0.10000000149011612},"filmicTonemapping":false,"saturation":1.0,"sharpen":{"enable":true,"factor":0.15000000596046448},"taa":{"enable":true,"jitterRange":0.9900000095367432},"vignette":{"color":{"x":0.0,"y":0.0,"z":0.0},"enable":false,"offset":0.0,"power":0.0,"strength":0.0},"whitePoint":10.0},"reflection":{"bias":0.17299999296665192,"currentClipFactor":2.0,"enable":true,"gi":true,"historyClipMax":0.10000000149011612,"opacityCheck":false,"radianceLimit":10.0,"rt":true,"spatialFilterStrength":10.0,"temporalWeight":0.9520000219345093,"textureLevel":4,"useShadowMap":true},"sky":{"atmosphere":{"height":100000.0,"probeResolution":128},"clouds":{"castShadow":false,"coverageResolution":512,"coverageScale":0.25,"coverageSpeed":5.0,"darkEdgeAmbient":0.10000000149011612,"darkEdgeFocus":2.0,"densityMultiplier":0.800000011920929,"detailResolution":32,"detailScale":16.0,"detailSpeed":10.0,"detailStrength":0.15000000596046448,"distanceLimit":8000.0,"enable":true,"heightStretch":0.5,"maxHeight":1700.0,"minHeight":1400.0,"occlusionSampleCount":5,"sampleCount":64,"scattering":{"eccentricityFirstPhase":0.0,"eccentricitySecondPhase":-0.5,"extinctionCoefficients":{"w":1.0,"x":0.9300000071525574,"y":0.9649999737739563,"z":1.0},"extinctionFactor":0.1599999964237213,"phaseAlpha":0.5,"scatteringFactor":2.0},"shadowResolution":512,"shadowSampleFraction":4,"shapeResolution":128,"shapeScale":2.0,"shapeSpeed":5.0,"stochasticOcclusionSampling":true},"planetCenter":{"x":0.0,"y":-650000.0,"z":0.0},"planetRadius":649000.0},"ssgi":{"aoStrength":1.0,"enable":true,"enableAo":true,"irradianceLimit":10.0,"opacityCheck":false,"radius":1.0,"rayCount":2,"rt":false,"sampleCount":8},"sss":{"enable":true,"maxLength":0.5,"sampleCount":8,"thickness":0.30000001192092896}}
6 changes: 5 additions & 1 deletion data/shader/ao/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ ivec2 FindNearest3x3(ivec2 pixel) {
float depth = 1.0;

for (int i = 0; i < 9; i++) {
float currDepth = texelFetch(depthTexture, pixel + offsets[i], 0).r;
ivec2 offsetPixel = clamp(pixel + offsets[i], ivec2(0), ivec2(resolution) - ivec2(1));

float currDepth = texelFetch(depthTexture, offsetPixel, 0).r;
if (currDepth < depth) {
depth = currDepth;
offset = offsets[i];
Expand Down Expand Up @@ -177,6 +179,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out float history, out float
ivec2 offsetPixel = ivec2(historyPixel) + pixelOffsets[i];
float confidence = 1.0;

offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));

vec3 historyNormal = DecodeNormal(texelFetch(historyNormalTexture, offsetPixel, 0).rg);
confidence *= pow(abs(dot(historyNormal, normal)), 2.0);

Expand Down
4 changes: 3 additions & 1 deletion data/shader/common/material.hsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#extension GL_EXT_nonuniform_qualifier : require

#include <packing.hsh>

#define FEATURE_BASE_COLOR_MAP (1 << 1)
Expand Down Expand Up @@ -49,7 +51,7 @@ layout (std430, set = 1, binding = 14) buffer PackedMaterials {

Material UnpackMaterial(uint idx) {

PackedMaterial compressed = packedMaterials[idx];
PackedMaterial compressed = packedMaterials[nonuniformEXT(idx)];

Material material;

Expand Down
4 changes: 2 additions & 2 deletions data/shader/deferred/geometry.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Per vertex attributes
layout(location=0) in vec3 vPosition;
layout(location=1) in vec3 vNormal;
layout(location=1) in vec4 vNormal;
#ifdef TEX_COORDS
layout(location=2) in vec2 vTexCoord;
#endif
Expand Down Expand Up @@ -105,7 +105,7 @@ void main() {
// Only after ndc calculation apply the clip correction
gl_Position = gl_Position;

normalVS = mat3(mvMatrix) * vNormal;
normalVS = mat3(mvMatrix) * vNormal.xyz;

#if defined(NORMAL_MAP) || defined(HEIGHT_MAP)
vec3 normal = normalize(normalVS);
Expand Down
8 changes: 7 additions & 1 deletion data/shader/pathtracer/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ ivec2 FindNearest3x3(ivec2 pixel) {
float depth = 1.0;

for (int i = 0; i < 9; i++) {
float currDepth = texelFetch(depthTexture, pixel + offsets[i], 0).r;
ivec2 offsetPixel = clamp(pixel + offsets[i], ivec2(0), ivec2(resolution) - ivec2(1));

float currDepth = texelFetch(depthTexture, offsetPixel, 0).r;
if (currDepth < depth) {
depth = currDepth;
offset = offsets[i];
Expand Down Expand Up @@ -207,6 +209,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out vec4 hi
for (int i = 0; i < 4; i++) {
ivec2 offsetPixel = ivec2(historyPixel) + pixelOffsets[i];
offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));
if (IsHistoryPixelValid(offsetPixel, linearDepth, materialIdx, normal) > 0.0) {
totalWeight += weights[i];
history += texelFetch(inAccumImage, offsetPixel, 0) * weights[i];
Expand All @@ -223,6 +227,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out vec4 hi
for (int i = 0; i < 9; i++) {
ivec2 offsetPixel = ivec2(historyPixel) + offsets[i];
offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));
if (IsHistoryPixelValid(offsetPixel, linearDepth, materialIdx, normal) > 0.0) {
totalWeight += 1.0;
history += texelFetch(inAccumImage, offsetPixel, 0);
Expand Down
2 changes: 1 addition & 1 deletion data/shader/raytracer/common.hsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <../common/octahedron.hsh>

#define INF 1000000000000.0
#define EPSILON 0.01
#define EPSILON 0.1

#define DIRECTIONAL_LIGHT 0
#define TRIANGLE_LIGHT 1
Expand Down
2 changes: 1 addition & 1 deletion data/shader/reflection/rtreflection.csh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void main() {
float pdf = 1.0;
BRDFSample brdfSample;
if (material.roughness > 0.02) {
ImportanceSampleGGX(blueNoiseVec, N, V, alpha,
ImportanceSampleGGXVNDF(blueNoiseVec, N, V, alpha,
ray.direction, pdf);
}
else {
Expand Down
8 changes: 7 additions & 1 deletion data/shader/reflection/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ ivec2 FindNearest3x3(ivec2 pixel) {
float depth = 1.0;

for (int i = 0; i < 9; i++) {
float currDepth = texelFetch(depthTexture, pixel + offsets[i], 0).r;
ivec2 offsetPixel = clamp(pixel + offsets[i], ivec2(0), ivec2(resolution) - ivec2(1));

float currDepth = texelFetch(depthTexture, offsetPixel, 0).r;
if (currDepth < depth) {
depth = currDepth;
offset = offsets[i];
Expand Down Expand Up @@ -172,6 +174,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out vec4 hi
ivec2 offsetPixel = ivec2(historyPixel) + pixelOffsets[i];
float confidence = 1.0;
offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));
vec3 historyNormal = DecodeNormal(texelFetch(historyNormalTexture, offsetPixel, 0).rg);
confidence *= pow(abs(dot(historyNormal, normal)), 16.0);
Expand All @@ -196,6 +200,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out vec4 hi
ivec2 offsetPixel = ivec2(historyPixel) + offsets[i];
float confidence = 1.0;
offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));
vec3 historyNormal = DecodeNormal(texelFetch(historyNormalTexture, offsetPixel, 0).rg);
confidence *= pow(abs(dot(historyNormal, normal)), 16.0);
Expand Down
10 changes: 9 additions & 1 deletion data/shader/ssgi/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out float h
ivec2 offsetPixel = ivec2(historyPixel) + pixelOffsets[i];
float confidence = 1.0;

offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));

vec3 historyNormal = DecodeNormal(texelFetch(historyNormalTexture, offsetPixel, 0).rg);
confidence *= pow(abs(dot(historyNormal, normal)), 16.0);

Expand All @@ -212,6 +214,8 @@ bool SampleHistory(ivec2 pixel, vec2 historyPixel, out vec4 history, out float h
ivec2 offsetPixel = ivec2(historyPixel) + offsets[i];
float confidence = 1.0;

offsetPixel = clamp(offsetPixel, ivec2(0), ivec2(resolution) - ivec2(1));

vec3 historyNormal = DecodeNormal(texelFetch(historyNormalTexture, offsetPixel, 0).rg);
confidence *= pow(abs(dot(historyNormal, normal)), 16.0);

Expand Down Expand Up @@ -287,10 +291,14 @@ void main() {
historyLength = 0.0;
}

factor = min(factor, historyLength / (historyLength + 1.0));
factor = min(factor, historyLength / max(1.0, (historyLength + 1.0)));

vec4 resolve = mix(currentValue, historyValue, factor);

if (isnan(resolve.r) || isnan(resolve.b)) {
//resolve = vec4(1.0, 0.0, 0.0, 0.0);
}

imageStore(resolveImage, pixel, vec4(resolve));
imageStore(historyLengthImage, pixel, vec4(historyLength + 1.0, 0.0, 0.0, 0.0));

Expand Down
2 changes: 2 additions & 0 deletions libs/ImguiExtension/Panels.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#include "panels/ReflectionPanel.h"
#include "panels/VolumetricCloudsPanel.h"
#include "panels/IrradianceVolumePanel.h"
#include "panels/MaterialPanel.h"
#include "panels/GPUProfilerPanel.h"
2 changes: 1 addition & 1 deletion libs/ImguiExtension/panels/FogPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Atlas::ImguiExtension {

ImGui::Checkbox("Enable", &fog->enable);

ImGui::ColorPicker3("Extinction coefficients", &fog->extinctionCoefficients[0]);
ImGui::ColorEdit3("Extinction coefficients", &fog->extinctionCoefficients[0]);
ImGui::DragFloat("Extinction factor", &fog->extinctionFactor, 0.002f, 0.0001f, 4.0f);
ImGui::DragFloat("Scattering factor", &fog->scatteringFactor, 0.002f, 0.0001f, 4.0f);
ImGui::DragFloat("Ambient factor", &fog->ambientFactor, 0.001f, 0.0001f, 1.0f);
Expand Down
Loading

0 comments on commit 4beec4b

Please sign in to comment.