Skip to content

Commit 0d69865

Browse files
authored
Merge pull request #50 from Williscool13/gameplay-expansion
Gameplay Expansion
2 parents 24ecd51 + 9d8eaa6 commit 0d69865

173 files changed

Lines changed: 2303 additions & 1303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 182 additions & 170 deletions
Large diffs are not rendered by default.

assets/maps/sampleScene.willmap

Lines changed: 336 additions & 31 deletions
Large diffs are not rendered by default.

assets/settings.willengine

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
},
1010
"cameraSettings": {
1111
"position": [
12-
-7.438582420349121,
13-
34.399600982666016,
14-
47.61833953857422
12+
2.7129502296447754,
13+
69.97366333007813,
14+
7.650825500488281
1515
],
1616
"rotation": [
17-
0.025229064747691154,
18-
-0.12272556871175766,
19-
0.0031201005913317204,
20-
0.9921150803565979
17+
-0.015324143692851067,
18+
0.3289414346218109,
19+
0.005338272545486689,
20+
0.944210946559906
2121
],
2222
"fov": 1.3089969158172607,
2323
"aspectRatio": 1.7777777910232544,
@@ -27,9 +27,9 @@
2727
"lightSettings": {
2828
"mainLight": {
2929
"direction": [
30-
-0.6859943270683289,
31-
-0.5144957900047302,
32-
-0.5144957900047302
30+
-0.17871452867984772,
31+
-0.8167253732681274,
32+
-0.5486536026000977
3333
],
3434
"color": [
3535
1.0,

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define STB_IMAGE_WRITE_IMPLEMENTATION
1010
#include <stb/stb_image_write.h>
1111

12-
#include "src/core/engine.h"
12+
#include "engine/core/engine.h"
1313

1414
int main(int argc, char* argv[])
1515
{

shaders/ambient_occlusion/ground_truth/gtao_depth_prefilter.comp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ void main() {
7070

7171
vec2 uv = (vec2(screenPos) + 0.5) * sceneData.texelSize;
7272

73-
// todo: optimize with textureGather?
7473
vec4 depths = textureGatherOffset(depthImage, vec2(screenPos) * sceneData.texelSize, ivec2(1,1), 0);
7574
float rDepth0 = depths.w;
7675
float rDepth1 = depths.z;

src/core/input.h

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,23 @@ void will_engine::Camera::setCameraTransform(const glm::vec3 position, const glm
7373
transform.setRotation(rotation);
7474
updateViewMatrix();
7575
}
76+
77+
glm::vec3 will_engine::Camera::screenToWorldDirection(const glm::vec2& screenPos) const
78+
{
79+
const glm::vec4 ndcPos(
80+
screenPos.x * 2.0f - 1.0f,
81+
(1.0f - screenPos.y) * 2.0f - 1.0f,
82+
-1.0f,
83+
1.0f
84+
);
85+
86+
glm::mat4 invProj = glm::inverse(cachedProjMatrix);
87+
glm::vec4 viewPos = invProj * ndcPos;
88+
89+
viewPos.w = 0.0f;
90+
91+
const glm::mat4 invView = glm::inverse(cachedViewMatrix);
92+
const glm::vec4 worldDir = invView * viewPos;
93+
94+
return glm::normalize(glm::vec3(worldDir));
95+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#define CAMERA_H
66

77
#include "camera_types.h"
8-
#include "src/core/transform.h"
9-
#include "src/renderer/renderer_constants.h"
8+
#include "engine/core/transform.h"
9+
#include "engine/renderer/renderer_constants.h"
1010

1111
namespace will_engine
1212
{
@@ -65,6 +65,8 @@ class Camera
6565

6666
void setCameraTransform(glm::vec3 position, glm::quat rotation);
6767

68+
glm::vec3 screenToWorldDirection(const glm::vec2& screenPos) const;
69+
6870
protected:
6971
/**
7072
* Updates the projection matrix. FOV is in degrees and converted to radians in this function
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@
44

55
#include "free_camera.h"
66

7-
#include "src/core/input.h"
8-
#include "src/core/time.h"
7+
#include "engine/core/input.h"
8+
#include "engine/core/time.h"
99

1010
will_engine::FreeCamera::FreeCamera(const float fov, const float aspect, const float nearPlane, const float farPlane) : Camera(fov, aspect, nearPlane, farPlane)
1111
{}
1212

1313
void will_engine::FreeCamera::update(const float deltaTime)
1414
{
15-
const Input& input = Input::Get();
15+
const input::Input& input = input::Input::get();
1616
if (!input.isInFocus()) {
1717
return;
1818
}
1919

2020
glm::vec3 velocity{0.f};
2121
float verticalVelocity{0.f};
2222

23-
if (input.isKeyDown(SDLK_D)) {
23+
if (input.isKeyDown(input::Key::D)) {
2424
velocity.x += 1.0f;
2525
}
26-
if (input.isKeyDown(SDLK_A)) {
26+
if (input.isKeyDown(input::Key::A)) {
2727
velocity.x -= 1.0f;
2828
}
29-
if (input.isKeyDown(SDLK_LCTRL)) {
29+
if (input.isKeyDown(input::Key::LCTRL)) {
3030
verticalVelocity -= 1.0f;
3131
}
32-
if (input.isKeyDown(SDLK_SPACE)) {
32+
if (input.isKeyDown(input::Key::SPACE)) {
3333
verticalVelocity += 1.0f;
3434
}
3535
// I guess vulkan is negative Z forward?!
36-
if (input.isKeyDown(SDLK_W)) {
36+
if (input.isKeyDown(input::Key::W)) {
3737
velocity.z -= 1.0f;
3838
}
39-
if (input.isKeyDown(SDLK_S)) {
39+
if (input.isKeyDown(input::Key::S)) {
4040
velocity.z += 1.0f;
4141
}
4242

43-
if (input.isKeyPressed(SDLK_PERIOD)) {
43+
if (input.isKeyPressed(input::Key::PERIOD)) {
4444
speed += 1;
4545
}
46-
if (input.isKeyPressed(SDLK_COMMA)) {
46+
if (input.isKeyPressed(input::Key::COMMA)) {
4747
speed -= 1;
4848
}
4949
speed = glm::clamp(speed, -2.0f, 3.0f);

0 commit comments

Comments
 (0)