Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
c374893b34 | |||
5fb3b0c323 | |||
b905a949f2 | |||
d6242a7fad | |||
8d612ea31b | |||
23eff19d4c | |||
20c6413f44 | |||
ee7f06efa5 | |||
d361e171fd | |||
42226d3cde | |||
c8ec418c04 |
104
.gitea/workflows/BuildRelease.yaml
Normal file
@ -0,0 +1,104 @@
|
||||
name: Build & Release
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
Windows-AMD64-Build:
|
||||
runs-on: windows-x86_64
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Building/Compiling/Installing Project
|
||||
run: |
|
||||
cd ${{ gitea.workspace }}
|
||||
cmake -A x64 -DCMAKE_BUILD_TYPE=Release --preset=default .
|
||||
cd build
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Creating Appropriate Directories
|
||||
run: |
|
||||
cd ${{ gitea.workspace }}
|
||||
mv build/Release/Pong.exe .
|
||||
mv build/Release/zlib1.dll .
|
||||
|
||||
- name: Zipping Binaries
|
||||
run: |
|
||||
cd ${{ gitea.workspace }}
|
||||
tar -a -c -f pong-windows-amd64.zip Pong.exe zlib1.dll resources
|
||||
|
||||
- uses: https://github.com/actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.20.1'
|
||||
|
||||
- name: Use Go Action
|
||||
id: use-go-action
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
pong-windows-amd64.zip
|
||||
api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||
|
||||
Linux-AMD64-Build:
|
||||
runs-on: linux-x86_64
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installing Dependencies
|
||||
run: |
|
||||
sudo pacman -S --noconfirm zip alsa-lib libxcb xcb-util-cursor vulkan-headers mesa
|
||||
|
||||
- name: Building/Compiling/Installing Project
|
||||
run: |
|
||||
cd ${{ gitea.workspace }}
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Zipping Binaries
|
||||
run: zip -r pong-linux-amd64.zip Pong resources
|
||||
|
||||
- uses: https://github.com/actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.20.1'
|
||||
|
||||
- name: Use Go Action
|
||||
id: use-go-action
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
pong-linux-amd64.zip
|
||||
api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||
|
||||
Linux-AARCH64-Build:
|
||||
runs-on: linux-aarch64
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installing Dependencies
|
||||
run: sudo apt install -y zip libasound2-dev libxcb1-dev libxcb-xinput-dev libxcb-cursor-dev vulkan-headers
|
||||
|
||||
- name: Building/Compiling/Installing Project
|
||||
run: |
|
||||
cd ${{ gitea.workspace }}
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
cmake --build . --config Release
|
||||
|
||||
- name: Zipping Binaries
|
||||
run: zip -r pong-linux-aarch64.zip Pong resources
|
||||
|
||||
- uses: https://github.com/actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.20.1'
|
||||
|
||||
- name: Use Go Action
|
||||
id: use-go-action
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
pong-linux-aarch64.zip
|
||||
api_key: '${{secrets.RELEASE_TOKEN}}'
|
@ -2,7 +2,7 @@
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ClangTidy" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="clangTidyChecks" value="-*,bugprone-argument-comment,bugprone-assert-side-effect,bugprone-bad-signal-to-kill-thread,bugprone-branch-clone,bugprone-copy-constructor-init,bugprone-dangling-handle,bugprone-dynamic-static-initializers,bugprone-fold-init-type,bugprone-forward-declaration-namespace,bugprone-forwarding-reference-overload,bugprone-inaccurate-erase,bugprone-incorrect-roundings,bugprone-integer-division,bugprone-lambda-function-name,bugprone-macro-parentheses,bugprone-macro-repeated-side-effects,bugprone-misplaced-operator-in-strlen-in-alloc,bugprone-misplaced-pointer-arithmetic-in-alloc,bugprone-misplaced-widening-cast,bugprone-move-forwarding-reference,bugprone-multiple-statement-macro,bugprone-no-escape,bugprone-parent-virtual-call,bugprone-posix-return,bugprone-reserved-identifier,bugprone-sizeof-container,bugprone-sizeof-expression,bugprone-spuriously-wake-up-functions,bugprone-string-constructor,bugprone-string-integer-assignment,bugprone-string-literal-with-embedded-nul,bugprone-suspicious-enum-usage,bugprone-suspicious-include,bugprone-suspicious-memset-usage,bugprone-suspicious-missing-comma,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,bugprone-suspicious-memory-comparison,bugprone-suspicious-realloc-usage,bugprone-swapped-arguments,bugprone-terminating-continue,bugprone-throw-keyword-missing,bugprone-too-small-loop-variable,bugprone-undefined-memory-manipulation,bugprone-undelegated-constructor,bugprone-unhandled-self-assignment,bugprone-unused-raii,bugprone-unused-return-value,bugprone-use-after-move,bugprone-virtual-near-miss,cert-dcl21-cpp,cert-dcl58-cpp,cert-err34-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,cert-msc50-cpp,cert-msc51-cpp,cert-str34-c,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-narrowing-conversions,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-default-arguments,google-explicit-constructor,google-runtime-operator,hicpp-exception-baseclass,hicpp-multiway-paths-covered,misc-misplaced-const,misc-new-delete-overloads,misc-no-recursion,misc-non-copyable-objects,misc-throw-by-value-catch-by-reference,misc-unconventional-assign-operator,misc-uniqueptr-reset-release,mpi-buffer-deref,mpi-type-mismatch,openmp-use-default-none,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-algorithm,performance-inefficient-string-concatenation,performance-inefficient-vector-operation,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-noexcept-move-constructor,performance-trivially-destructible,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,portability-simd-intrinsics,readability-avoid-const-params-in-decls,readability-const-return-type,readability-container-size-empty,readability-convert-member-functions-to-static,readability-delete-null-pointer,readability-deleted-default,readability-inconsistent-declaration-parameter-name,readability-make-member-function-const,readability-misleading-indentation,readability-misplaced-array-index,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-use-anyofallof" />
|
||||
<option name="clangTidyChecks" value="-*,bugprone-argument-comment,bugprone-assert-side-effect,bugprone-bad-signal-to-kill-thread,bugprone-branch-clone,bugprone-copy-constructor-init,bugprone-dangling-handle,bugprone-dynamic-static-initializers,bugprone-fold-init-type,bugprone-forward-declaration-namespace,bugprone-forwarding-reference-overload,bugprone-inaccurate-erase,bugprone-incorrect-roundings,bugprone-integer-division,bugprone-lambda-function-name,bugprone-macro-parentheses,bugprone-macro-repeated-side-effects,bugprone-misplaced-operator-in-strlen-in-alloc,bugprone-misplaced-pointer-arithmetic-in-alloc,bugprone-misplaced-widening-cast,bugprone-move-forwarding-reference,bugprone-multiple-statement-macro,bugprone-no-escape,bugprone-parent-virtual-call,bugprone-posix-return,bugprone-reserved-identifier,bugprone-sizeof-container,bugprone-sizeof-expression,bugprone-spuriously-wake-up-functions,bugprone-string-constructor,bugprone-string-integer-assignment,bugprone-string-literal-with-embedded-nul,bugprone-suspicious-enum-usage,bugprone-suspicious-include,bugprone-suspicious-memset-usage,bugprone-suspicious-missing-comma,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,bugprone-suspicious-memory-comparison,bugprone-suspicious-realloc-usage,bugprone-swapped-arguments,bugprone-terminating-continue,bugprone-throw-keyword-missing,bugprone-too-small-loop-variable,bugprone-undefined-memory-manipulation,bugprone-undelegated-constructor,bugprone-unhandled-self-assignment,bugprone-unused-raii,bugprone-unused-return-value,bugprone-use-after-move,bugprone-virtual-near-miss,cert-dcl21-cpp,cert-dcl58-cpp,cert-err34-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,cert-msc50-cpp,cert-msc51-cpp,cert-str34-c,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-narrowing-conversions,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-default-arguments,google-explicit-constructor,google-runtime-operator,hicpp-exception-baseclass,hicpp-multiway-paths-covered,misc-misplaced-const,misc-new-delete-overloads,misc-no-recursion,misc-non-copyable-objects,misc-throw-by-value-catch-by-reference,misc-unconventional-assign-operator,misc-uniqueptr-reset-release,mpi-buffer-deref,mpi-type-mismatch,openmp-use-default-none,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-algorithm,performance-inefficient-string-concatenation,performance-inefficient-vector-operation,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-noexcept-move-constructor,performance-trivially-destructible,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,portability-simd-intrinsics,readability-const-return-type,readability-container-size-empty,readability-convert-member-functions-to-static,readability-delete-null-pointer,readability-deleted-default,readability-inconsistent-declaration-parameter-name,readability-make-member-function-const,readability-misleading-indentation,readability-misplaced-array-index,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-use-anyofallof" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakePythonSetting">
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
|
@ -33,15 +33,55 @@ add_executable(Pong
|
||||
Main.cpp
|
||||
)
|
||||
|
||||
if (IS_OS_WINDOWS)
|
||||
add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
|
||||
elseif (IS_OS_LINUX)
|
||||
add_compile_definitions(VK_USE_PLATFORM_XCB_KHR)
|
||||
find_package(ZLIB REQUIRED)
|
||||
if (ZLIB_FOUND)
|
||||
message(STATUS "ZLIB was found.")
|
||||
else ()
|
||||
message(STATUS "ZLIB was not found.")
|
||||
endif ()
|
||||
|
||||
target_link_directories(Pong PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/lib")
|
||||
target_include_directories(Pong PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/include")
|
||||
find_package(OpenSSL REQUIRED)
|
||||
if (OpenSSL_FOUND)
|
||||
message(STATUS "OpenSSL was found.")
|
||||
else ()
|
||||
message(STATUS "OpenSSL was not found.")
|
||||
endif ()
|
||||
|
||||
if (IS_OS_WINDOWS)
|
||||
add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
|
||||
|
||||
target_include_directories(Pong PUBLIC ${USER_HOME_DIRECTORY}/EHS/include)
|
||||
target_include_directories(Pong PUBLIC ${USER_HOME_DIRECTORY}/EHE/include)
|
||||
target_include_directories(Pong PUBLIC ${USER_HOME_DIRECTORY}/EHC/include)
|
||||
target_include_directories(Pong PUBLIC ${USER_HOME_DIRECTORY}/LWE/include)
|
||||
target_include_directories(Pong PUBLIC $ENV{VULKAN_SDK}/include)
|
||||
|
||||
message("VK Include Path: $ENV{VULKAN_SDK}/include")
|
||||
|
||||
target_link_directories(Pong PUBLIC "${USER_HOME_DIRECTORY}/EHS/lib")
|
||||
target_link_directories(Pong PUBLIC "${USER_HOME_DIRECTORY}/EHE/lib")
|
||||
target_link_directories(Pong PUBLIC "${USER_HOME_DIRECTORY}/EHC/lib")
|
||||
target_link_directories(Pong PUBLIC "${USER_HOME_DIRECTORY}/LWE/lib")
|
||||
target_link_directories(Pong PUBLIC $ENV{VULKAN_SDK}/lib)
|
||||
|
||||
target_link_libraries(Pong PUBLIC vulkan-1 ws2_32 avrt)
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/LWE")
|
||||
elseif (IS_OS_LINUX)
|
||||
add_compile_definitions(VK_USE_PLATFORM_XCB_KHR EHS_WS_XCB)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
if (Vulkan_FOUND)
|
||||
message(STATUS "Vulkan was found.")
|
||||
else ()
|
||||
message(STATUS "Vulkan was not found.")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Pong PRIVATE Vulkan::Headers Vulkan::Vulkan xcb xcb-xfixes xcb-xinput wooting_analog_wrapper LWE z asound)
|
||||
target_include_directories(Pong PRIVATE ${USER_HOME_DIRECTORY}/.local/include)
|
||||
|
||||
target_link_directories(Pong PRIVATE "${USER_HOME_DIRECTORY}/.local/lib")
|
||||
|
||||
target_link_libraries(Pong PRIVATE xcb xcb-cursor xcb-xfixes xcb-xinput asound Vulkan::Headers Vulkan::Vulkan)
|
||||
endif()
|
||||
|
||||
target_link_libraries(Pong PRIVATE LWE EHC EHE EHS OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
|
12
CMakePresets.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
196
Levels/Game.cpp
@ -1,40 +1,37 @@
|
||||
#include "Game.h"
|
||||
#include "LWE/IO/FontAtlas.h"
|
||||
|
||||
#include <LWE/GameLoop.h>
|
||||
#include <LWE/IO/RenderWindow.h>
|
||||
#include <LWE/Systems/AudioSystem.h>
|
||||
#include <LWE/Systems/RigidBodySystem.h>
|
||||
#include <LWE/Systems/Portrait2DSystem.h>
|
||||
#include <LWE/Systems/DynamicsSystem.h>
|
||||
#include <LWE/Systems/GuiSystem.h>
|
||||
#include <LWE/Components/AudioSource.h>
|
||||
#include <LWE/Components/AABB2D.h>
|
||||
#include <LWE/Components/Circle.h>
|
||||
#include <LWE/Components/Portrait2D.h>
|
||||
#include <LWE/Components/Dynamics.h>
|
||||
#include <LWE/Gui/LabelGui.h>
|
||||
#include <LWE/IO/Audio/Audio.h>
|
||||
#include <LWE/IO/HID/Input.h>
|
||||
#include <LWE/IO/HID/GenericInputHandler.h>
|
||||
#include <LWE/IO/HID/Keyboard.h>
|
||||
#include <LWE/HRNG.h>
|
||||
#include <LWE/System/CPU.h>
|
||||
#include <lwe/GameLoop.h>
|
||||
#include <lwe/RenderWindow.h>
|
||||
#include <lwe/systems/AudioSystem.h>
|
||||
#include <lwe/systems/RigidBodySystem.h>
|
||||
#include <lwe/systems/Portrait2DSystem.h>
|
||||
#include <lwe/systems/GuiSystem.h>
|
||||
#include <lwe/coms/AudioSource.h>
|
||||
#include <lwe/coms/AABB2D.h>
|
||||
#include <lwe/coms/Circle.h>
|
||||
#include <lwe/coms/Portrait2D.h>
|
||||
#include <lwe/gpu/GpuFontAtlas.h>
|
||||
#include <lwe/gui/LabelGui.h>
|
||||
#include <ehs/io/audio/Audio.h>
|
||||
#include <ehs/io/hid/Input.h>
|
||||
#include <ehs/io/hid/Keyboard.h>
|
||||
#include <ehs/HRNG.h>
|
||||
#include <ehs/system/CPU.h>
|
||||
|
||||
const float Game::paddleSpeed = 400.0f;
|
||||
const float Game::ballSpeed = 15000.0f;
|
||||
const float Game::ballSpeed = 5000.0f;
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
}
|
||||
|
||||
Game::Game()
|
||||
: Level("Game"), plyScore(0), aiScore(0)
|
||||
: Level("Game"), plyScore(0), aiScore(0), started(false)
|
||||
{
|
||||
}
|
||||
|
||||
Game::Game(const Game& lvl)
|
||||
: Level(lvl), plyScore(lvl.plyScore), aiScore(lvl.aiScore)
|
||||
: Level(lvl), plyScore(lvl.plyScore), aiScore(lvl.aiScore), started(lvl.started)
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,33 +44,34 @@ Game& Game::operator=(const Game& lvl)
|
||||
|
||||
plyScore = lvl.plyScore;
|
||||
aiScore = lvl.aiScore;
|
||||
started = lvl.started;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Game::SetupResources()
|
||||
void Game::SetupResources(lwe::GpuInterface *inf)
|
||||
{
|
||||
Level::SetupResources();
|
||||
Level::SetupResources(inf);
|
||||
|
||||
// Setup Resource Code Here
|
||||
AddResource(new lwe::Mesh("PortraitGui", lwe::portraitGuiVerts, lwe::portraitGuiIndices));
|
||||
AddResource(new lwe::GpuMesh(inf, ehs::portraitGui));
|
||||
|
||||
AddResource(lwe::Audio::FromFile_Heap("Resources/Audio/Wall.wav", lwe::DataType::FLOAT));
|
||||
AddResource(lwe::Audio::FromFile_Heap("Resources/Audio/Paddle.wav", lwe::DataType::FLOAT));
|
||||
AddResource(lwe::Audio::FromFile_Heap("Resources/Audio/Score.wav", lwe::DataType::FLOAT));
|
||||
AddResource(new ehs::Audio("resources/audio/Wall.wav", ehs::DataType::FLOAT));
|
||||
AddResource(new ehs::Audio("resources/audio/Paddle.wav", ehs::DataType::FLOAT));
|
||||
AddResource(new ehs::Audio("resources/audio/Score.wav", ehs::DataType::FLOAT));
|
||||
|
||||
constexpr lwe::UInt_8 circleData[] = {255, 255, 255, 255};
|
||||
lwe::Img* circle = new lwe::Img("Circle", 8, 4, 1, 1, (lwe::Byte*)circleData, lwe::ImgAspect::IMG_ASPECT_COLOR);
|
||||
constexpr ehs::UInt_8 circleData[] = {255, 255, 255, 255};
|
||||
lwe::GpuImg* circle = new lwe::GpuImg("Circle", inf, 1, 4, {1, 1}, (ehs::Byte*)circleData, lwe::GpuImgAspect::IMG_ASPECT_COLOR);
|
||||
AddResource(circle);
|
||||
}
|
||||
|
||||
void Game::Setup()
|
||||
void Game::Setup(lwe::GpuInterface *inf)
|
||||
{
|
||||
Level::Setup();
|
||||
Level::Setup(inf);
|
||||
|
||||
// Setup Code Here
|
||||
|
||||
lwe::GameLoop* gl = (lwe::GameLoop*)GetParent("GameLoop");
|
||||
lwe::GameLoop* gl = GetParent();
|
||||
|
||||
lwe::RenderWindow* win = gl->GetWindow();
|
||||
|
||||
@ -81,58 +79,57 @@ void Game::Setup()
|
||||
AddSystem(new lwe::AudioSystem());
|
||||
AddSystem(new lwe::Portrait2DSystem());
|
||||
AddSystem(new lwe::RigidBodySystem());
|
||||
AddSystem(new lwe::DynamicsSystem());
|
||||
|
||||
lwe::GuiSystem* gui = new lwe::GuiSystem();
|
||||
gui->AddResource(new lwe::FontAtlas("Resources/Fonts/Hack-Regular_48.ehf"));
|
||||
gui->AddResource(new lwe::GpuFontAtlas("resources/fonts/Arial_48.ehf", win->GetInterface()));
|
||||
AddSystem(gui);
|
||||
|
||||
lwe::Vec2_f scale = win->GetSwapChain()->GetScale();
|
||||
lwe::Vec2_f center = win->GetSwapChain()->GetScale() / 2;
|
||||
ehs::Vec2_f scale = win->GetSwapChain()->GetScale();
|
||||
ehs::Vec2_f center = win->GetSwapChain()->GetScale() / 2;
|
||||
|
||||
// Score Gui
|
||||
lwe::LabelGui* plyScore = new lwe::LabelGui("PlyScore", "Hack-Regular_48", "0");
|
||||
plyScore->SetPosition({20.0f, 20.0f});
|
||||
lwe::LabelGui* plyScore = new lwe::LabelGui("PlyScore", "Arial_48", "0");
|
||||
plyScore->SetPosition({20.0f, 20.0f, 0.0f});
|
||||
gui->AddGui(plyScore);
|
||||
|
||||
lwe::LabelGui* aiScore = new lwe::LabelGui("AiScore", "Hack-Regular_48", "0");
|
||||
aiScore->SetPosition({scale.x - 68.0f, 20.0f});
|
||||
lwe::LabelGui* aiScore = new lwe::LabelGui("AiScore", "Arial_48", "0");
|
||||
aiScore->SetPosition({scale.x - 68.0f, 20.0f, 0.0f});
|
||||
gui->AddGui(aiScore);
|
||||
|
||||
// Bounds Entity
|
||||
lwe::Entity* bounds = new lwe::Entity("Bounds");
|
||||
bounds->SetScale({win->GetSwapChain()->GetScale(), 1.0f});
|
||||
lwe::Entity bounds("Bounds");
|
||||
bounds.SetScale({win->GetSwapChain()->GetScale(), 1.0f});
|
||||
|
||||
lwe::AABB2D* collider = new lwe::AABB2D();
|
||||
lwe::AABB2D* collider = new lwe::AABB2D("BoundsCollider", 0.0f, 0.0f);
|
||||
collider->SetInverted(true);
|
||||
collider->EnableStatic(true);
|
||||
bounds->AddComponent(collider);
|
||||
collider->SetStatic(true);
|
||||
bounds.AddComponent(collider);
|
||||
|
||||
AddEntity(bounds);
|
||||
|
||||
// Field Separator Entity
|
||||
|
||||
lwe::Entity* fieldSep = new lwe::Entity("FieldSeparator");
|
||||
fieldSep->SetScale({10.0f, scale.y, 1.0f});
|
||||
fieldSep->SetPos({center.x - 5.0f, 0.0f, 0.0f});
|
||||
lwe::Entity fieldSep("FieldSeparator");
|
||||
fieldSep.SetScale({10.0f, scale.y, 1.0f});
|
||||
fieldSep.SetPos({center.x - 5.0f, 0.0f, 0.0f});
|
||||
|
||||
lwe::Portrait2D* fieldSepImg = new lwe::Portrait2D("PaddleImg", "Circle");
|
||||
fieldSepImg->SetColor({0.75f});
|
||||
fieldSep->AddComponent(fieldSepImg);
|
||||
fieldSep.AddComponent(fieldSepImg);
|
||||
|
||||
AddEntity(fieldSep);
|
||||
|
||||
// Paddle Entity Template
|
||||
lwe::Entity* paddle = new lwe::Entity("Paddle");
|
||||
paddle->SetScale({20.0f, 200.0f, 1.0f});
|
||||
lwe::Entity paddle("Paddle");
|
||||
paddle.SetScale({20.0f, 200.0f, 1.0f});
|
||||
|
||||
lwe::AABB2D* paddleCollider = new lwe::AABB2D("Collider");
|
||||
paddleCollider->EnableStatic(true);
|
||||
paddle->AddComponent(paddleCollider);
|
||||
lwe::AABB2D* paddleCollider = new lwe::AABB2D("PaddleCollider", 0.0f, 0.0f);
|
||||
paddleCollider->SetStatic(true);
|
||||
paddle.AddComponent(paddleCollider);
|
||||
|
||||
lwe::Portrait2D* paddleImg = new lwe::Portrait2D("PaddleImg", "Circle");
|
||||
paddleImg->SetColor({0.75f});
|
||||
paddle->AddComponent(paddleImg);
|
||||
paddle.AddComponent(paddleImg);
|
||||
|
||||
AddTemplate(paddle);
|
||||
|
||||
@ -145,21 +142,21 @@ void Game::Setup()
|
||||
aiPaddle->SetPos({scale.x - 50.0f, center.y - 100.0f, 0.0f});
|
||||
|
||||
// Ball Entity
|
||||
lwe::Entity* ball = new lwe::Entity("Ball");
|
||||
ball->SetScale({20.0f, 20.0f, 1.0f});
|
||||
ball->SetPos({center.x - 10.0f, center.y - 10.0f, 0.0f});
|
||||
lwe::Entity ball("Ball");
|
||||
ball.SetScale({20.0f, 20.0f, 1.0f});
|
||||
ball.SetPos({center.x - 10.0f, center.y - 10.0f, 0.0f});
|
||||
|
||||
lwe::AABB2D* ballCollider = new lwe::AABB2D("Collider");
|
||||
lwe::AABB2D* ballCollider = new lwe::AABB2D("BallCollider", 0.5f, 1.1f);
|
||||
ballCollider->SetCollidedCb([](lwe::RigidBody* a, lwe::RigidBody* b)
|
||||
{
|
||||
lwe::Entity* aOwner = (lwe::Entity*)a->GetParent();
|
||||
lwe::Entity* bOwner = (lwe::Entity*)b->GetParent();
|
||||
lwe::Entity* aOwner = (lwe::Entity*)a->GetEntity();
|
||||
lwe::Entity* bOwner = (lwe::Entity*)b->GetEntity();
|
||||
|
||||
static lwe::UInt_64 id = 0;
|
||||
static ehs::UInt_64 id = 0;
|
||||
|
||||
if (bOwner->GetId() == "Bounds")
|
||||
{
|
||||
lwe::AudioSource* audio = new lwe::AudioSource("Audio_" + lwe::Str_8::FromNum(id++),"Wall");
|
||||
lwe::AudioSource* audio = new lwe::AudioSource("Audio_" + ehs::Str_8::FromNum(id++),"Wall");
|
||||
audio->EnableAutoDelete(true);
|
||||
audio->EnableLoop(false);
|
||||
audio->Play();
|
||||
@ -167,21 +164,18 @@ void Game::Setup()
|
||||
}
|
||||
else
|
||||
{
|
||||
lwe::AudioSource* audio = new lwe::AudioSource("Audio_" + lwe::Str_8::FromNum(id++),"Paddle");
|
||||
lwe::AudioSource* audio = new lwe::AudioSource("Audio_" + ehs::Str_8::FromNum(id++),"Paddle");
|
||||
audio->EnableAutoDelete(true);
|
||||
audio->EnableLoop(false);
|
||||
audio->Play();
|
||||
aOwner->AddComponent(audio);
|
||||
}
|
||||
});
|
||||
ball->AddComponent(ballCollider);
|
||||
|
||||
lwe::Dynamics* ballDynamics = new lwe::Dynamics(1.0f, 1.01f);
|
||||
ball->AddComponent(ballDynamics);
|
||||
ball.AddComponent(ballCollider);
|
||||
|
||||
lwe::Portrait2D* ballImg = new lwe::Portrait2D("BallImg", "Circle");
|
||||
ballImg->SetColor({1.0f, 0.0f, 0.0f});
|
||||
ball->AddComponent(ballImg);
|
||||
ball.AddComponent(ballImg);
|
||||
|
||||
AddEntity(ball);
|
||||
}
|
||||
@ -193,78 +187,78 @@ void Game::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
|
||||
// Post Initialization Code Here
|
||||
}
|
||||
|
||||
void Game::OnUpdate(lwe::Input* input, const float delta)
|
||||
void Game::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float delta)
|
||||
{
|
||||
Level::OnUpdate(input, delta);
|
||||
Level::OnUpdate(win, input, delta);
|
||||
|
||||
// Update Code Here
|
||||
|
||||
const lwe::GenericInputHandler* handler = (lwe::GenericInputHandler*)input->GetHandler("GenericInputHandler");
|
||||
const ehs::InputHandler* ih = win->GetInputHandler();
|
||||
|
||||
const lwe::Keyboard* keyboard = handler->GetPrimaryKeyboard();
|
||||
const ehs::Keyboard* keyboard = (ehs::Keyboard*)ih->GetDeviceByType(EHS_HID_KEYBOARD);
|
||||
if (!keyboard)
|
||||
return;
|
||||
|
||||
lwe::Entity* bounds = GetEntity("Bounds");
|
||||
|
||||
lwe::Entity* ball = GetEntity("Ball");
|
||||
lwe::Vec3_f ballPos = ball->GetPos();
|
||||
lwe::Vec3_f ballScale = ball->GetScale();
|
||||
ehs::Vec3_f ballPos = ball->GetPos();
|
||||
ehs::Vec3_f ballScale = ball->GetScale();
|
||||
|
||||
if (ballPos.x <= bounds->GetPos().x)
|
||||
if (ballPos.x <= bounds->GetPos().x + 10.0f)
|
||||
{
|
||||
aiScore++;
|
||||
|
||||
lwe::GuiSystem* gui = (lwe::GuiSystem*)GetSystem("GuiSystem");
|
||||
lwe::LabelGui* aiScoreLabel = (lwe::LabelGui*)gui->GetGui("AiScore");
|
||||
aiScoreLabel->SetText(lwe::Str_8::FromNum(aiScore));
|
||||
aiScoreLabel->SetText(ehs::Str_8::FromNum(aiScore));
|
||||
|
||||
ResetGame(bounds, ball);
|
||||
}
|
||||
else if (ballPos.x + ballScale.x >= bounds->GetScale().x)
|
||||
else if (ballPos.x + ballScale.x >= bounds->GetScale().x - 10.0f)
|
||||
{
|
||||
plyScore++;
|
||||
|
||||
lwe::GuiSystem* gui = (lwe::GuiSystem*)GetSystem("GuiSystem");
|
||||
lwe::LabelGui* plyScoreLabel = (lwe::LabelGui*)gui->GetGui("PlyScore");
|
||||
plyScoreLabel->SetText(lwe::Str_8::FromNum(plyScore));
|
||||
plyScoreLabel->SetText(ehs::Str_8::FromNum(plyScore));
|
||||
|
||||
ResetGame(bounds, ball);
|
||||
}
|
||||
|
||||
lwe::Entity* plyPaddle = GetEntity("PlyPaddle");
|
||||
|
||||
if (!started && keyboard->IsTouched(lwe::Keyboard::Space))
|
||||
if (!started && keyboard->IsTouched(ehs::Keyboard::Space))
|
||||
{
|
||||
if (!lwe::CPU::HasRDRND())
|
||||
if (!ehs::CPU::HasRDRND())
|
||||
return;
|
||||
|
||||
lwe::Dynamics* ballDynamics = (lwe::Dynamics*)ball->GetComponent("Dynamics", "");
|
||||
//ballDynamics->ApplyForce({0.0f, ballSpeed, 0.0f});
|
||||
lwe::AABB2D* ballCollider = (lwe::AABB2D*)ball->GetComponent("AABB2D");
|
||||
|
||||
lwe::UInt_8 result = lwe::HRNG::Generate_s8(0, 4);
|
||||
if (result == 0)
|
||||
ballDynamics->ApplyForce({ballSpeed, ballSpeed, 0.0f});
|
||||
if (const ehs::UInt_8 result = ehs::HRNG::Generate_s8(0, 4); result == 0)
|
||||
ballCollider->ApplyForce({ballSpeed, ballSpeed, 0.0f});
|
||||
else if (result == 1)
|
||||
ballDynamics->ApplyForce({-ballSpeed, ballSpeed, 0.0f});
|
||||
ballCollider->ApplyForce({-ballSpeed, ballSpeed, 0.0f});
|
||||
else if (result == 2)
|
||||
ballDynamics->ApplyForce({ballSpeed, -ballSpeed, 0.0f});
|
||||
ballCollider->ApplyForce({ballSpeed, -ballSpeed, 0.0f});
|
||||
else if (result == 3)
|
||||
ballDynamics->ApplyForce({-ballSpeed, -ballSpeed, 0.0f});
|
||||
ballCollider->ApplyForce({-ballSpeed, -ballSpeed, 0.0f});
|
||||
|
||||
started = true;
|
||||
}
|
||||
|
||||
if (keyboard->IsDown(lwe::Keyboard::W))
|
||||
if (keyboard->IsDown(ehs::Keyboard::W))
|
||||
{
|
||||
lwe::Vec3_f newPos = plyPaddle->GetPos() - lwe::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
ehs::Vec3_f newPos = plyPaddle->GetPos() - ehs::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
if (newPos.y <= bounds->GetPos().y)
|
||||
newPos.y = bounds->GetPos().y;
|
||||
|
||||
plyPaddle->SetPos(newPos);
|
||||
}
|
||||
|
||||
if (keyboard->IsDown(lwe::Keyboard::S))
|
||||
if (keyboard->IsDown(ehs::Keyboard::S))
|
||||
{
|
||||
lwe::Vec3_f newPos = plyPaddle->GetPos() + lwe::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
ehs::Vec3_f newPos = plyPaddle->GetPos() + ehs::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
if (newPos.y + plyPaddle->GetScale().y >= bounds->GetScale().y)
|
||||
newPos.y = bounds->GetScale().y - plyPaddle->GetScale().y;
|
||||
|
||||
@ -272,12 +266,12 @@ void Game::OnUpdate(lwe::Input* input, const float delta)
|
||||
}
|
||||
|
||||
lwe::Entity* aiPaddle = GetEntity("AiPaddle");
|
||||
lwe::Vec3_f aiPaddlePos = aiPaddle->GetPos();
|
||||
lwe::Vec3_f aiPaddleScale = aiPaddle->GetScale();
|
||||
ehs::Vec3_f aiPaddlePos = aiPaddle->GetPos();
|
||||
ehs::Vec3_f aiPaddleScale = aiPaddle->GetScale();
|
||||
|
||||
if (aiPaddlePos.y + aiPaddleScale.y / 2.0f < ballPos.y + ballScale.y / 2.0f)
|
||||
{
|
||||
aiPaddlePos = aiPaddlePos + lwe::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
aiPaddlePos = aiPaddlePos + ehs::Vec3_f(0.0f, paddleSpeed * 2.0f, 0.0f) * delta;
|
||||
if (aiPaddlePos.y + aiPaddleScale.y / 2.0f > ballPos.y + ballScale.y / 2.0f)
|
||||
aiPaddlePos.y = ballPos.y + ballScale.y / 2.0f - aiPaddleScale.y / 2.0f;
|
||||
|
||||
@ -288,7 +282,7 @@ void Game::OnUpdate(lwe::Input* input, const float delta)
|
||||
}
|
||||
else
|
||||
{
|
||||
aiPaddlePos = aiPaddlePos - lwe::Vec3_f(0.0f, paddleSpeed, 0.0f) * delta;
|
||||
aiPaddlePos = aiPaddlePos - ehs::Vec3_f(0.0f, paddleSpeed * 2.0f, 0.0f) * delta;
|
||||
if (aiPaddlePos.y + aiPaddleScale.y / 2.0f < ballPos.y + ballScale.y / 2.0f)
|
||||
aiPaddlePos.y = ballPos.y + ballScale.y / 2.0f - aiPaddleScale.y / 2.0f;
|
||||
|
||||
@ -316,8 +310,8 @@ void Game::ResetGame(const lwe::Entity* bounds, lwe::Entity* ball)
|
||||
|
||||
ball->SetPos(bounds->GetScale() / 2.0f - ball->GetScale() / 2.0f);
|
||||
|
||||
lwe::Dynamics* ballDyn = (lwe::Dynamics*)ball->GetComponent("Dynamics");
|
||||
ballDyn->ResetVelocity();
|
||||
lwe::AABB2D* ballCollider = (lwe::AABB2D*)ball->GetComponent("AABB2D");
|
||||
ballCollider->ResetVelocity();
|
||||
|
||||
started = false;
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <LWE/LWE.h>
|
||||
#include <LWE/Level.h>
|
||||
#include <lwe/Level.h>
|
||||
#include <lwe/RenderWindow.h>
|
||||
|
||||
class Game : public lwe::Level
|
||||
{
|
||||
private:
|
||||
static const float paddleSpeed;
|
||||
static const float ballSpeed;
|
||||
lwe::UInt_64 plyScore;
|
||||
lwe::UInt_64 aiScore;
|
||||
ehs::UInt_64 plyScore;
|
||||
ehs::UInt_64 aiScore;
|
||||
bool started;
|
||||
|
||||
public:
|
||||
@ -21,13 +21,13 @@ public:
|
||||
|
||||
Game& operator=(const Game& lvl);
|
||||
|
||||
void SetupResources() override;
|
||||
void SetupResources(lwe::GpuInterface *inf) override;
|
||||
|
||||
void Setup() override;
|
||||
void Setup(lwe::GpuInterface *inf) override;
|
||||
|
||||
void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override;
|
||||
|
||||
void OnUpdate(lwe::Input* input, const float delta) override;
|
||||
void OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float delta) override;
|
||||
|
||||
void PreRender(lwe::GpuCmdBuffer* cmdBuffer) override;
|
||||
|
||||
|
39
Main.cpp
@ -1,37 +1,31 @@
|
||||
#include <LWE/LWE.h>
|
||||
#include <LWE/Log.h>
|
||||
#include <LWE/GarbageCollector.h>
|
||||
#include <LWE/GameLoop.h>
|
||||
#include <LWE/IO/RenderWindow.h>
|
||||
#include <LWE/IO/Console.h>
|
||||
#include <ehs/Log.h>
|
||||
#include <ehs/GC.h>
|
||||
#include <lwe/GameLoop.h>
|
||||
#include <lwe/RenderWindow.h>
|
||||
|
||||
#include <ehs/io/Console.h>
|
||||
|
||||
#include "Levels/Game.h"
|
||||
#include "LWE/IO/HID/GenericInputHandler.h"
|
||||
|
||||
void LogCallback(const lwe::Log& log)
|
||||
{
|
||||
lwe::Console::Write_8(log.ToStr());
|
||||
}
|
||||
|
||||
lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVer)
|
||||
ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer)
|
||||
{
|
||||
*appName = "Pong";
|
||||
*appVerId = "Release";
|
||||
*appVer = {1, 0, 0};
|
||||
|
||||
lwe::Console::Attach();
|
||||
ehs::Log::EnableImmediateMode(true);
|
||||
|
||||
lwe::Log::SetCallback(LogCallback);
|
||||
ehs::Console::Attach();
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
lwe::GpuInstance::AddExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
lwe::GpuInstance::AddExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
lwe::GpuInstance::AddExtension(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
|
||||
lwe::GpuInstance::Initialize(true);
|
||||
lwe::GpuInstance::Initialize(false);
|
||||
|
||||
lwe::GpuDevice primary = lwe::GpuDevice::GetBest();
|
||||
|
||||
@ -46,15 +40,10 @@ lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVe
|
||||
|
||||
lwe::RenderWindow win(&inf, &queue);
|
||||
win.Create_8(*appName, {0, 0}, {1024, 768});
|
||||
win.Show();
|
||||
|
||||
lwe::GameLoop gl(&win, 6, 0);
|
||||
gl.GetInput()->AddHandler(new lwe::GenericInputHandler());
|
||||
|
||||
lwe::Frame* mainFrame = new lwe::Frame("Main");
|
||||
|
||||
gl.AddFrame(mainFrame);
|
||||
|
||||
mainFrame->AddLevel(new Game());
|
||||
gl.AddLevel(new Game());
|
||||
|
||||
gl.Initialize();
|
||||
gl.Start();
|
||||
|
BIN
resources/audio/One True God - Careless (ft. Vania).wav
Normal file
BIN
resources/audio/Paddle.wav
Normal file
BIN
resources/audio/Score.wav
Normal file
BIN
resources/audio/Wall.wav
Normal file
BIN
resources/audio/sample.wav
Normal file
BIN
resources/fonts/Arial_24.ehf
Normal file
BIN
resources/fonts/Arial_48.ehf
Normal file
BIN
resources/fonts/Hack-Bold_12.ehf
Normal file
BIN
resources/fonts/Hack-Bold_48.ehf
Normal file
BIN
resources/fonts/Hack-Regular_24.ehf
Normal file
BIN
resources/fonts/Hack-Regular_48.ehf
Normal file
BIN
resources/models/Cube.ehm
Normal file
BIN
resources/models/Cube_P.ehm
Normal file
BIN
resources/models/PointLight.ehm
Normal file
BIN
resources/models/Rifle.ehm
Normal file
BIN
resources/models/Sphere.ehm
Normal file
BIN
resources/models/Test.ehm
Normal file
BIN
resources/models/Test2.ehm
Normal file
BIN
resources/models/Vampire.ehm
Normal file
BIN
resources/models/untitled.ehm
Normal file
31
resources/shaders/Billboard.frag
Normal file
@ -0,0 +1,31 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 fUv;
|
||||
layout(location = 1) in flat uint fChannels;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(binding = 1) uniform Opt
|
||||
{
|
||||
vec4 multiplier;
|
||||
bool preMultiply;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = opt.multiplier;
|
||||
if (fChannels == 1)
|
||||
result *= vec4(texture(render, fUv).rrr, 1.0f);
|
||||
else if (fChannels == 2)
|
||||
result *= vec4(texture(render, fUv).rrr, texture(render, fUv).g);
|
||||
else if (fChannels == 3)
|
||||
result *= vec4(texture(render, fUv).rgb, 1.0f);
|
||||
else if (fChannels == 4)
|
||||
result *= texture(render, fUv).rgba;
|
||||
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
53
resources/shaders/Billboard.vert
Normal file
@ -0,0 +1,53 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
layout(location = 1) out uint fChannels;
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
vec3 pos;
|
||||
uint channels;
|
||||
vec2 size;
|
||||
} trans;
|
||||
|
||||
mat4 RemoveRotation(mat4 inMat)
|
||||
{
|
||||
inMat[0][0] = 1.0;
|
||||
inMat[0][1] = 0.0;
|
||||
inMat[0][2] = 0.0;
|
||||
inMat[1][0] = 0.0;
|
||||
inMat[1][1] = 1.0;
|
||||
inMat[1][2] = 0.0;
|
||||
inMat[2][0] = 0.0;
|
||||
inMat[2][1] = 0.0;
|
||||
inMat[2][2] = 1.0;
|
||||
|
||||
return inMat;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// The vec4 we will use to set gl_Position
|
||||
vec4 pos = vec4(trans.pos, 1.0f);
|
||||
|
||||
// Adjust the position based on the camera view
|
||||
// Extract the right and up vectors from the view matrix
|
||||
vec3 right = vec3(trans.viewProj[0][0], trans.viewProj[1][0], trans.viewProj[2][0]);
|
||||
vec3 up = vec3(trans.viewProj[0][1], trans.viewProj[1][1], trans.viewProj[2][1]);
|
||||
|
||||
// Adjust the quad vertices to face the camera
|
||||
// The inPosition.xy should be in NDC space, from -1 to 1
|
||||
pos.xyz += (right * vPos.x * trans.size.x) + (up * vPos.y * trans.size.y);
|
||||
|
||||
// Output position
|
||||
gl_Position = trans.viewProj * pos;
|
||||
|
||||
// Pass through the texture coordinates
|
||||
fUv = vUv;
|
||||
fChannels = trans.channels;
|
||||
}
|
BIN
resources/shaders/Billboard_Frag.spv
Normal file
BIN
resources/shaders/Billboard_Vert.spv
Normal file
25
resources/shaders/Compile.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
for file in ./*.vert; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
|
||||
echo "Compiling vertex shader, ${filename}"
|
||||
|
||||
filename="${filename%.*}"
|
||||
|
||||
glslangValidator -V "${file}" -o "./${filename}_Vert.spv"
|
||||
fi
|
||||
done
|
||||
|
||||
for file in ./*.frag; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
|
||||
echo "Compiling vertex shader, ${filename}"
|
||||
|
||||
filename="${filename%.*}"
|
||||
|
||||
glslangValidator -V "${file}" -o "./${filename}_Frag.spv"
|
||||
fi
|
||||
done
|
22
resources/shaders/FA_Preview.frag
Normal file
@ -0,0 +1,22 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 fUv;
|
||||
layout(location = 1) in flat uint fChannels;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(binding = 1) uniform Opt
|
||||
{
|
||||
vec4 multiplier;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (fChannels != 1)
|
||||
return;
|
||||
|
||||
result = vec4(texture(render, fUv).rrrr) * opt.multiplier;
|
||||
}
|
24
resources/shaders/FA_Preview.vert
Normal file
@ -0,0 +1,24 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
layout(location = 1) out flat uint fChannels;
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
int channels;
|
||||
} trans;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0);
|
||||
|
||||
fUv = vUv;
|
||||
fChannels = trans.channels;
|
||||
}
|
BIN
resources/shaders/FA_Preview_Frag.spv
Normal file
BIN
resources/shaders/FA_Preview_Vert.spv
Normal file
12
resources/shaders/FBO.frag
Normal file
@ -0,0 +1,12 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(binding = 1) uniform sampler2D render;
|
||||
|
||||
void main() {
|
||||
outColor = texture(render, vUv);
|
||||
}
|
17
resources/shaders/FBO.vert
Normal file
@ -0,0 +1,17 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 mvp;
|
||||
} ubo;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.mvp * vec4(vPos, 1.0);
|
||||
|
||||
fUv = vUv;
|
||||
}
|
BIN
resources/shaders/FBO_Frag.spv
Normal file
BIN
resources/shaders/FBO_Vert.spv
Normal file
21
resources/shaders/Label.frag
Normal file
@ -0,0 +1,21 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 glyphUV;
|
||||
layout(location = 1) in vec4 glyphColor;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(std140, binding = 1) uniform Opt
|
||||
{
|
||||
bool preMultiply;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D atlas;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = vec4(glyphColor.r, glyphColor.g, glyphColor.b, glyphColor.a * texture(atlas, glyphUV).r);
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
23
resources/shaders/Label.vert
Normal file
@ -0,0 +1,23 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 glyphUV;
|
||||
layout(location = 1) out vec4 glyphColor;
|
||||
|
||||
layout(std140, binding = 0) uniform Data
|
||||
{
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
vec4 color;
|
||||
} data;
|
||||
|
||||
void main() {
|
||||
gl_Position = data.proj * data.view * data.model * vec4(vPos, 1.0);
|
||||
|
||||
glyphUV = vUv;
|
||||
glyphColor = data.color;
|
||||
}
|
BIN
resources/shaders/Label_Frag.spv
Normal file
BIN
resources/shaders/Label_Vert.spv
Normal file
21
resources/shaders/Light.frag
Normal file
@ -0,0 +1,21 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 fUv;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(binding = 1) uniform Material
|
||||
{
|
||||
vec3 lightColor;
|
||||
} material;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main() {
|
||||
vec4 result = texture(render, fUv);
|
||||
if (result.rgb == vec3(1.0f, 1.0f, 1.0f))
|
||||
result = vec4(material.lightColor, 1.0f);
|
||||
|
||||
outColor = vec4(result.rgb, 1.0f);
|
||||
}
|
17
resources/shaders/Light.vert
Normal file
@ -0,0 +1,17 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(binding = 0) uniform Transform {
|
||||
mat4 mvp;
|
||||
} transform;
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
|
||||
void main() {
|
||||
gl_Position = transform.mvp * vec4(vPos, 1.0);
|
||||
|
||||
fUv = vUv;
|
||||
}
|
26
resources/shaders/LightBillboard.frag
Normal file
@ -0,0 +1,26 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 fUv;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(binding = 1) uniform Opt
|
||||
{
|
||||
vec3 color;
|
||||
bool preMultiply;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = texture(render, fUv).rgba;
|
||||
|
||||
if (result.rgb == vec3(1.0f, 1.0f, 1.0f))
|
||||
result *= vec4(opt.color, 1.0f);
|
||||
|
||||
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
50
resources/shaders/LightBillboard.vert
Normal file
@ -0,0 +1,50 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
vec3 pos;
|
||||
vec2 size;
|
||||
} trans;
|
||||
|
||||
mat4 RemoveRotation(mat4 inMat)
|
||||
{
|
||||
inMat[0][0] = 1.0;
|
||||
inMat[0][1] = 0.0;
|
||||
inMat[0][2] = 0.0;
|
||||
inMat[1][0] = 0.0;
|
||||
inMat[1][1] = 1.0;
|
||||
inMat[1][2] = 0.0;
|
||||
inMat[2][0] = 0.0;
|
||||
inMat[2][1] = 0.0;
|
||||
inMat[2][2] = 1.0;
|
||||
|
||||
return inMat;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// The vec4 we will use to set gl_Position
|
||||
vec4 pos = vec4(trans.pos, 1.0f);
|
||||
|
||||
// Adjust the position based on the camera view
|
||||
// Extract the right and up vectors from the view matrix
|
||||
vec3 right = vec3(trans.viewProj[0][0], trans.viewProj[1][0], trans.viewProj[2][0]);
|
||||
vec3 up = vec3(trans.viewProj[0][1], trans.viewProj[1][1], trans.viewProj[2][1]);
|
||||
|
||||
// Adjust the quad vertices to face the camera
|
||||
// The inPosition.xy should be in NDC space, from -1 to 1
|
||||
pos.xyz += (right * vPos.x * trans.size.x) + (up * vPos.y * trans.size.y);
|
||||
|
||||
// Output position
|
||||
gl_Position = trans.viewProj * pos;
|
||||
|
||||
// Pass through the texture coordinates
|
||||
fUv = vUv;
|
||||
}
|
BIN
resources/shaders/LightBillboard_Frag.spv
Normal file
BIN
resources/shaders/LightBillboard_Vert.spv
Normal file
BIN
resources/shaders/Light_Frag.spv
Normal file
BIN
resources/shaders/Light_Vert.spv
Normal file
128
resources/shaders/Phong.frag
Normal file
@ -0,0 +1,128 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
|
||||
struct AmbientPointLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 pos;
|
||||
};
|
||||
|
||||
struct PointLight
|
||||
{
|
||||
vec3 color;
|
||||
float constant;
|
||||
vec3 pos;
|
||||
float linear;
|
||||
float quadratic;
|
||||
};
|
||||
|
||||
struct SpotLight
|
||||
{
|
||||
vec3 color;
|
||||
float innerCutOff;
|
||||
vec3 pos;
|
||||
float outerCutOff;
|
||||
vec3 dir;
|
||||
float constant;
|
||||
float linear;
|
||||
float quadratic;
|
||||
};
|
||||
|
||||
layout(std140, binding = 2) uniform Data
|
||||
{
|
||||
vec3 ambient;
|
||||
bool preMultiply;
|
||||
vec4 multiplier;
|
||||
uint ambientPointLightCount;
|
||||
uint pointLightCount;
|
||||
uint spotLightCount;
|
||||
AmbientPointLight ambientLights[MAX_LIGHTS];
|
||||
PointLight pointLights[MAX_LIGHTS];
|
||||
SpotLight spotLights[MAX_LIGHTS];
|
||||
} data;
|
||||
|
||||
layout(binding = 3) uniform sampler2D colorMap;
|
||||
layout(binding = 4) uniform sampler2D normalMap;
|
||||
layout(binding = 5) uniform sampler2D specularMap;
|
||||
|
||||
layout(location = 0) in vec4 fVertPos;
|
||||
layout(location = 1) in vec3 fTanPos;
|
||||
layout(location = 2) in vec2 fUV;
|
||||
layout(location = 3) in vec3 fViewPos;
|
||||
layout(location = 4) in mat3 fTBN;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
vec3 CalcAmbientPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, AmbientPointLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r);
|
||||
|
||||
return diffuse + specular;
|
||||
}
|
||||
|
||||
vec3 CalcPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, PointLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
float dist = length(light.pos - vertexPos);
|
||||
|
||||
float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist));
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r);
|
||||
|
||||
return (diffuse + specular) * attenuation;
|
||||
}
|
||||
|
||||
vec3 CalcSpotLight(vec3 normal, vec3 vertexPos, vec3 viewDir, SpotLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
float dist = length(light.pos - vertexPos);
|
||||
|
||||
float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist));
|
||||
|
||||
float theta = dot(lightDir, normalize(-light.dir));
|
||||
float epsilon = light.innerCutOff - light.outerCutOff;
|
||||
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0f, 1.0f);
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r);
|
||||
|
||||
return (diffuse + specular) * intensity * attenuation;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 viewDir = normalize(fViewPos - fTanPos);
|
||||
vec3 nNorm = normalize(texture(normalMap, fUV).rgb * 2.0f - 1.0f);
|
||||
|
||||
vec3 final = data.ambient;
|
||||
|
||||
//Ambient Point Lights
|
||||
for (uint i = 0; i < data.ambientPointLightCount; ++i)
|
||||
final += CalcAmbientPointLight(nNorm, fVertPos.xyz, viewDir, data.ambientLights[i]);
|
||||
|
||||
//Point Lights
|
||||
for (uint i = 0; i < data.pointLightCount; ++i)
|
||||
final += CalcPointLight(nNorm, fVertPos.xyz, viewDir, data.pointLights[i]);
|
||||
|
||||
//Spot Lights
|
||||
for (uint i = 0; i < data.spotLightCount; ++i)
|
||||
final += CalcSpotLight(nNorm, fVertPos.xyz, viewDir, data.spotLights[i]);
|
||||
|
||||
vec4 tColor = texture(colorMap, fUV);
|
||||
|
||||
result = vec4(tColor.rgb * final * data.multiplier.rgb, tColor.a * data.multiplier.a);
|
||||
|
||||
if (data.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
62
resources/shaders/Phong.vert
Normal file
@ -0,0 +1,62 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
struct Bone
|
||||
{
|
||||
mat4 trans;
|
||||
};
|
||||
|
||||
layout(std140, binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
mat4 model;
|
||||
vec3 viewPos;
|
||||
} transform;
|
||||
|
||||
layout(std140, binding = 1) uniform Skin
|
||||
{
|
||||
Bone skeleton[255];
|
||||
} skin;
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec3 vNorm;
|
||||
layout(location = 2) in vec2 vUV;
|
||||
layout(location = 3) in vec3 vTan;
|
||||
layout(location = 4) in vec3 vBiTan;
|
||||
layout(location = 5) in uvec4 bones;
|
||||
layout(location = 6) in vec4 weights;
|
||||
|
||||
layout(location = 0) out vec4 fVertPos;
|
||||
layout(location = 1) out vec3 fTanPos;
|
||||
layout(location = 2) out vec2 fUV;
|
||||
layout(location = 3) out vec3 fViewPos;
|
||||
layout(location = 4) out mat3 fTBN;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 totalPos = vec4(0.0f);
|
||||
|
||||
for (uint i = 0; i < 4; ++i)
|
||||
{
|
||||
if (weights[i] == 0.0f)
|
||||
continue;
|
||||
|
||||
totalPos += skin.skeleton[bones[i]].trans * vec4(vPos, 1.0f) * weights[i];
|
||||
}
|
||||
|
||||
fVertPos = transform.model * totalPos;
|
||||
fUV = vUV;
|
||||
|
||||
vec3 T = normalize(vec3(transform.model * vec4(vTan, 0.0f)));
|
||||
vec3 B = normalize(vec3(transform.model * vec4(vBiTan, 0.0f)));
|
||||
vec3 N = normalize(vec3(transform.model * vec4(vNorm, 0.0f)));
|
||||
|
||||
T = normalize(T - dot(T, N) * N);
|
||||
|
||||
fTBN = transpose(mat3(T, B, N));
|
||||
|
||||
fTanPos = fTBN * fVertPos.xyz;
|
||||
fViewPos = fTBN * transform.viewPos;
|
||||
|
||||
gl_Position = transform.viewProj * transform.model * totalPos;
|
||||
}
|
BIN
resources/shaders/Phong_Frag.spv
Normal file
BIN
resources/shaders/Phong_Vert.spv
Normal file
31
resources/shaders/Portrait.frag
Normal file
@ -0,0 +1,31 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 fUv;
|
||||
layout(location = 1) in flat uint fChannels;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(binding = 1) uniform Opt
|
||||
{
|
||||
bool preMultiply;
|
||||
vec4 multiplier;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = opt.multiplier;
|
||||
if (fChannels == 1)
|
||||
result *= vec4(texture(render, fUv).rrr, 1.0f);
|
||||
else if (fChannels == 2)
|
||||
result *= vec4(texture(render, fUv).rrr, texture(render, fUv).g);
|
||||
else if (fChannels == 3)
|
||||
result *= vec4(texture(render, fUv).rgb, 1.0f);
|
||||
else if (fChannels == 4)
|
||||
result *= texture(render, fUv).rgba;
|
||||
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
24
resources/shaders/Portrait.vert
Normal file
@ -0,0 +1,24 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
layout(location = 1) out flat uint fChannels;
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
int channels;
|
||||
} trans;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0);
|
||||
|
||||
fUv = vUv;
|
||||
fChannels = trans.channels;
|
||||
}
|
BIN
resources/shaders/Portrait_Frag.spv
Normal file
BIN
resources/shaders/Portrait_Vert.spv
Normal file
14
resources/shaders/RigidBodyDebug.frag
Normal file
@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(std140, binding = 1) uniform Data
|
||||
{
|
||||
vec4 color;
|
||||
} data;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = data.color;
|
||||
}
|
15
resources/shaders/RigidBodyDebug.vert
Normal file
@ -0,0 +1,15 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(std140, binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
mat4 model;
|
||||
} transform;
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = transform.viewProj * transform.model * vec4(vPos, 1.0f);
|
||||
}
|
BIN
resources/shaders/RigidBodyDebug_Frag.spv
Normal file
BIN
resources/shaders/RigidBodyDebug_Vert.spv
Normal file
20
resources/shaders/Skybox.frag
Normal file
@ -0,0 +1,20 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 skyboxUV;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(std140, binding = 1) uniform Opt
|
||||
{
|
||||
bool preMultiply;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform samplerCube skybox;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = texture(skybox, skyboxUV);
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
20
resources/shaders/Skybox.vert
Normal file
@ -0,0 +1,20 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
|
||||
layout(location = 0) out vec3 skyboxUV;
|
||||
|
||||
layout(std140, binding = 0) uniform Data
|
||||
{
|
||||
mat4 viewProj;
|
||||
} data;
|
||||
|
||||
void main()
|
||||
{
|
||||
skyboxUV = vPos;
|
||||
|
||||
vec4 pos = data.viewProj * vec4(vPos, 1.0);
|
||||
|
||||
gl_Position = pos.xyww;
|
||||
}
|
BIN
resources/shaders/Skybox_Frag.spv
Normal file
BIN
resources/shaders/Skybox_Vert.spv
Normal file
137
resources/shaders/SolidColor.frag
Normal file
@ -0,0 +1,137 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
|
||||
struct Material
|
||||
{
|
||||
vec4 color;
|
||||
bool diffused;
|
||||
float specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
struct AmbientPointLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 pos;
|
||||
};
|
||||
|
||||
struct PointLight
|
||||
{
|
||||
vec3 color;
|
||||
float constant;
|
||||
vec3 pos;
|
||||
float linear;
|
||||
float quadratic;
|
||||
};
|
||||
|
||||
struct SpotLight
|
||||
{
|
||||
vec3 color;
|
||||
float innerCutOff;
|
||||
vec3 pos;
|
||||
float outerCutOff;
|
||||
vec3 dir;
|
||||
float constant;
|
||||
float linear;
|
||||
float quadratic;
|
||||
};
|
||||
|
||||
layout(std140, binding = 1) uniform Data
|
||||
{
|
||||
vec3 ambient;
|
||||
bool preMultiply;
|
||||
vec3 camPos;
|
||||
Material material;
|
||||
uint ambientPointLightCount;
|
||||
uint pointLightCount;
|
||||
uint spotLightCount;
|
||||
AmbientPointLight ambientLights[MAX_LIGHTS];
|
||||
PointLight pointLights[MAX_LIGHTS];
|
||||
SpotLight spotLights[MAX_LIGHTS];
|
||||
} data;
|
||||
|
||||
layout(location = 1) in vec3 fNorm;
|
||||
layout(location = 0) in vec4 fWorldPos;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
vec3 CalcAmbientPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, AmbientPointLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess);
|
||||
|
||||
return diffuse + specular;
|
||||
}
|
||||
|
||||
vec3 CalcPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, PointLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
float dist = length(light.pos - vertexPos);
|
||||
|
||||
float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist));
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess);
|
||||
|
||||
return (diffuse + specular) * attenuation;
|
||||
}
|
||||
|
||||
vec3 CalcSpotLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, SpotLight light)
|
||||
{
|
||||
vec3 lightDir = normalize(light.pos - vertexPos);
|
||||
|
||||
float dist = length(light.pos - vertexPos);
|
||||
|
||||
float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist));
|
||||
|
||||
float theta = dot(lightDir, normalize(-light.dir));
|
||||
float epsilon = light.innerCutOff - light.outerCutOff;
|
||||
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0f, 1.0f);
|
||||
|
||||
vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess);
|
||||
|
||||
return (diffuse + specular) * intensity * attenuation;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
if (data.material.diffused == true)
|
||||
{
|
||||
vec3 viewDir = normalize(data.camPos - fWorldPos.xyz);
|
||||
vec3 nNorm = normalize(fNorm);
|
||||
|
||||
vec3 final = data.ambient;
|
||||
|
||||
//Ambient Point Lights
|
||||
for (uint i = 0; i < data.ambientPointLightCount; ++i)
|
||||
final += CalcAmbientPointLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.ambientLights[i]);
|
||||
|
||||
//Point Lights
|
||||
for (uint i = 0; i < data.pointLightCount; ++i)
|
||||
final += CalcPointLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.pointLights[i]);
|
||||
|
||||
//Spot Lights
|
||||
for (uint i = 0; i < data.spotLightCount; ++i)
|
||||
final += CalcSpotLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.spotLights[i]);
|
||||
|
||||
//outColor = vec4(data.spotLights[0].quadratic, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
result = vec4(data.material.color.rgb * final, data.material.color.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = data.material.color;
|
||||
}
|
||||
|
||||
if (data.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
22
resources/shaders/SolidColor.vert
Normal file
@ -0,0 +1,22 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(std140, binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
mat4 model;
|
||||
} transform;
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec3 vNorm;
|
||||
|
||||
layout(location = 1) out vec3 fNorm;
|
||||
layout(location = 0) out vec4 fWorldPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
fNorm = (transform.model * vec4(vNorm, 0.0f)).xyz;
|
||||
fWorldPos = transform.model * vec4(vPos, 1.0f);
|
||||
|
||||
gl_Position = transform.viewProj * fWorldPos;
|
||||
}
|
20
resources/shaders/SolidColor2D.frag
Normal file
@ -0,0 +1,20 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(binding = 1) uniform Shading
|
||||
{
|
||||
vec4 color;
|
||||
bool preMultiply;
|
||||
} shading;
|
||||
|
||||
layout(binding = 1) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
outColor = shading.color;
|
||||
|
||||
if (shading.preMultiply)
|
||||
outColor = vec4(outColor.rgb * outColor.a, outColor.a);
|
||||
}
|
15
resources/shaders/SolidColor2D.vert
Normal file
@ -0,0 +1,15 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject
|
||||
{
|
||||
mat4 viewProj;
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ubo.viewProj * ubo.model * vec4(vPos, 1.0);
|
||||
}
|
BIN
resources/shaders/SolidColor2D_Frag.spv
Normal file
BIN
resources/shaders/SolidColor2D_Vert.spv
Normal file
38
resources/shaders/SolidColorAnimated.vert
Normal file
@ -0,0 +1,38 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_scalar_block_layout : enable
|
||||
|
||||
#define MAX_WEIGHTS 3
|
||||
#define MAX_BONES 50
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 viewProj;
|
||||
mat4 model;
|
||||
mat4 bones[MAX_BONES];
|
||||
} transform;
|
||||
|
||||
layout(location = 0) in vec3 vNorm;
|
||||
layout(location = 1) in vec3 vPos;
|
||||
layout(location = 2) in uvec3 vBoneIndices;
|
||||
layout(location = 3) in vec3 vWeights;
|
||||
|
||||
layout(location = 0) out vec3 fNorm;
|
||||
layout(location = 1) out vec4 fWorldPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 totalLocalPos = vec4(0.0f);
|
||||
vec4 totalNormal = vec4(0.0f);
|
||||
|
||||
for (int i = 0; i < MAX_WEIGHTS; ++i)
|
||||
{
|
||||
totalLocalPos += transform.bones[vBoneIndices[i]] * vec4(vPos, 1.0f) * vWeights[i];
|
||||
totalNormal += transform.bones[vBoneIndices[i]] * vec4(vNorm, 0.0f) * vWeights[i];
|
||||
}
|
||||
|
||||
fNorm = (transform.model * totalNormal).xyz;
|
||||
fWorldPos = transform.model * totalLocalPos;
|
||||
|
||||
gl_Position = transform.viewProj * fWorldPos;
|
||||
}
|
BIN
resources/shaders/SolidColorAnimated_Vert.spv
Normal file
BIN
resources/shaders/SolidColor_Frag.spv
Normal file
BIN
resources/shaders/SolidColor_Vert.spv
Normal file
21
resources/shaders/Viewport.frag
Normal file
@ -0,0 +1,21 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec4 result;
|
||||
|
||||
layout(binding = 1) uniform Opt
|
||||
{
|
||||
bool preMultiply;
|
||||
vec4 multiplier;
|
||||
} opt;
|
||||
|
||||
layout(binding = 2) uniform sampler2D render;
|
||||
|
||||
void main()
|
||||
{
|
||||
result = opt.multiplier * texture(render, vUv);
|
||||
if (opt.preMultiply)
|
||||
result = vec4(result.rgb * result.a, result.a);
|
||||
}
|
21
resources/shaders/Viewport.vert
Normal file
@ -0,0 +1,21 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(location = 0) in vec3 vPos;
|
||||
layout(location = 1) in vec2 vUv;
|
||||
|
||||
layout(location = 0) out vec2 fUv;
|
||||
|
||||
layout(binding = 0) uniform Transform
|
||||
{
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
} trans;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0);
|
||||
|
||||
fUv = vUv;
|
||||
}
|
BIN
resources/shaders/Viewport_Frag.spv
Normal file
BIN
resources/shaders/Viewport_Vert.spv
Normal file
BIN
resources/textures/AmbientPointLight.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/textures/Character_Diffuse.png
Normal file
After Width: | Height: | Size: 481 KiB |
BIN
resources/textures/Character_Normal.png
Normal file
After Width: | Height: | Size: 558 KiB |
BIN
resources/textures/Character_Specular.png
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
resources/textures/Circle.qoi
Normal file
BIN
resources/textures/Cube_Diffuse.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
resources/textures/Cube_Normal.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
resources/textures/Cube_Specular.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
resources/textures/DownArrow.png
Normal file
After Width: | Height: | Size: 127 B |
BIN
resources/textures/LeftArrow.png
Normal file
After Width: | Height: | Size: 134 B |
BIN
resources/textures/LightBulb.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/textures/LightBulb_Lit.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
resources/textures/PointLight.png
Normal file
After Width: | Height: | Size: 186 KiB |
BIN
resources/textures/RightArrow.png
Normal file
After Width: | Height: | Size: 143 B |
BIN
resources/textures/SpotLight.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
resources/textures/Untitled.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
resources/textures/UpArrow.png
Normal file
After Width: | Height: | Size: 131 B |