Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
315 commits
Select commit Hold shift + click to select a range
3fb4358
Disabled distance correction because it messes with distance samples …
damacaa Oct 30, 2025
5b68ebf
If you want to interpolate data do it manually, texture save to disk …
damacaa Oct 30, 2025
c8f9db3
Cleaning up
damacaa Oct 31, 2025
03492d1
[WIP] Organizing files
damacaa Nov 4, 2025
ce9a347
[WIP] Trying a method to improve motion blur
damacaa Nov 6, 2025
4ea4ac4
Fixed camera motion compensation for motion blur
damacaa Nov 7, 2025
012a3b3
Update 2DSDFDistanceShader.frag
damacaa Nov 7, 2025
6c59d3c
Cleaning up sample scenes
damacaa Nov 7, 2025
fdcfe39
Delta time motion blur
damacaa Nov 7, 2025
ea28897
Fix vsync
damacaa Nov 7, 2025
0877eeb
Same material motion trail
damacaa Nov 7, 2025
2a0e43d
Fixed motion blur compensation with different aspect ratio
damacaa Nov 7, 2025
30d4e3b
Shader include system and default shapes moved to a new file
damacaa Nov 9, 2025
a7041f6
More info on collisions
damacaa Nov 9, 2025
d37393f
Update 2DSDFDistanceShader.frag
damacaa Nov 9, 2025
2ccbfbc
Split shape collision detection and resolution and call events properly
damacaa Nov 10, 2025
0566e60
Cleaning up physics
damacaa Nov 10, 2025
ac977ba
Actual tweaks
damacaa Nov 11, 2025
5ace841
Improving API and fixing samples
damacaa Nov 12, 2025
a0101cf
Motion blur consistent with different zoom levels
damacaa Nov 12, 2025
42dc51d
Removed and fixed some sample scenes
damacaa Nov 12, 2025
8b9333e
Distance upscaling
damacaa Nov 12, 2025
54af438
Wrong texture size
damacaa Nov 13, 2025
10de478
"Fixed race condition"
damacaa Nov 16, 2025
00a1a0a
Improving collisions
damacaa Nov 19, 2025
e10fda5
Merge branch 'feature/tuning-for-first-game' of https://github.com/da…
damacaa Nov 19, 2025
76bf4c8
Fixed sample scenes
damacaa Nov 20, 2025
6453581
Simple dynamic shader define system
damacaa Nov 20, 2025
93a1a89
Upscale now takes advantage of default texture filtering to save a fe…
damacaa Nov 20, 2025
7a9c17f
Antialiasing
damacaa Nov 20, 2025
62f41fb
Fixed collision bug
damacaa Nov 24, 2025
e84a19d
Improved ramp as an example
damacaa Nov 24, 2025
91d95bc
Enable/disable sdf fix
damacaa Nov 25, 2025
9869f86
Update 2DLightingShader.frag
damacaa Nov 25, 2025
68d1310
Toggle dithering
damacaa Nov 28, 2025
81ad2e9
Separate light and shadows
damacaa Nov 28, 2025
2ebdad1
Soft shadows!
damacaa Nov 28, 2025
c5d529d
Basic light
damacaa Nov 28, 2025
2d0a6b2
More controls
damacaa Nov 28, 2025
905fad1
Merge branch 'feature/tuning-for-first-game' into feature/2d-aa
damacaa Nov 28, 2025
0d9f692
Constant light edge size
damacaa Dec 1, 2025
cf878a9
Update 2DDistanceCorrection.frag
damacaa Dec 4, 2025
6cb307f
Limit shadow raymarch outside of frame
damacaa Dec 4, 2025
fe8bb97
Slightly reduced artifacts by improving blending between original and…
damacaa Dec 5, 2025
d7e17b3
Changed threshold
damacaa Dec 5, 2025
53a0b75
Use two distance textures for different purposes
damacaa Dec 6, 2025
4a93276
Fixed
damacaa Dec 6, 2025
9418af6
Simplified correction and increased steps to reduce artifacts
damacaa Dec 6, 2025
983ffcb
Automatic viewport adjustment
damacaa Dec 6, 2025
c4368da
Merge branch 'feature/tuning-for-first-game' into feature/2d-aa
damacaa Dec 6, 2025
ea0ba75
Fix old style uniforms
damacaa Dec 6, 2025
ae29cba
Merge branch 'feature/tuning-for-first-game' into feature/2d-aa
damacaa Dec 6, 2025
058b139
Merge branch 'feature/2d-aa' into feature/separate-shape-and-shadow-t…
damacaa Dec 6, 2025
d35f4f5
Tweaks to improve shadows at low resolution
damacaa Dec 6, 2025
4b43b05
Smooth lighting
damacaa Dec 6, 2025
0f60cc1
Dont check collisions when simulation is paused
damacaa Dec 6, 2025
e16b1cd
Update 2DLightingShader.frag
damacaa Dec 6, 2025
f9c32c4
Update Renderer.cpp
damacaa Dec 6, 2025
9eafab0
[WIP] Building UI using same distance shader
damacaa Dec 6, 2025
0fd1b7f
Screen coordinates
damacaa Dec 7, 2025
97fd022
Fix color texture contructor
damacaa Dec 7, 2025
44a305a
Fixed wrong type
damacaa Dec 10, 2025
bbf9949
UI Dot component and render system is now templated to allow normal a…
damacaa Dec 10, 2025
36391f3
fixed issues on windows
damacaa Dec 10, 2025
2fa0e9c
Added UI shapes
damacaa Dec 10, 2025
54e32bb
Update CMakeLists.txt
damacaa Dec 11, 2025
e1560bc
UI cleanup
damacaa Dec 11, 2025
7efecd4
Revert to old collision check
damacaa Dec 11, 2025
326b333
[WIP] Fixing shape groups
damacaa Dec 12, 2025
8578a4d
Liquid glass effect
damacaa Dec 19, 2025
a133b80
Various small changes and improvements
damacaa Dec 19, 2025
2fdba84
[WIP] UI materials
damacaa Dec 19, 2025
1a16b97
Removed some artifacts
damacaa Dec 19, 2025
7f68f15
Update 2DLightingShader.frag
damacaa Dec 21, 2025
537c858
Antialiasing refraction sample
damacaa Dec 22, 2025
90d13d5
[WIP] Text component
damacaa Dec 22, 2025
31b529b
[WIP] Text
damacaa Dec 23, 2025
3223852
Cooler text
damacaa Dec 23, 2025
797e00a
Fixed negative delta time in renderer
damacaa Dec 23, 2025
9eca879
Imprving text and fixed motion blur bug
damacaa Dec 24, 2025
cf886a7
Update ShapesCombinations.h
damacaa Dec 25, 2025
14f9f3a
Merge pull request #34 from damacaa/feature/ui
damacaa Dec 25, 2025
105079b
Fixed GLSL issue with amd drivers
damacaa Dec 26, 2025
2189abf
SDL3 changed to static link and build option
damacaa Dec 26, 2025
8878b18
Fonts path
damacaa Dec 27, 2025
153c5a9
Standalone build
damacaa Dec 27, 2025
15d5eb4
I don't need DLL's anymore (for now)
damacaa Dec 27, 2025
45f39ef
Much needed renderer refactor
damacaa Dec 27, 2025
615cf10
Improved material blending, some new artifacts have appeared and need…
damacaa Dec 28, 2025
bff2eff
Linear colorspace was causing NaN artifacts in blending shader
damacaa Dec 28, 2025
4934a34
Recovered correct color space
damacaa Dec 28, 2025
9e5eb0f
clamp values to avoid NaN
damacaa Dec 28, 2025
d44708b
Update 2DMaterialColorShader.frag
damacaa Dec 28, 2025
f70d01e
Motion blur double buffer
damacaa Dec 29, 2025
fe9d8e5
Renderer changes
damacaa Dec 29, 2025
6e74cb0
Audio refactor
damacaa Dec 29, 2025
2980fa2
[WIP] Multiple audio sources
damacaa Dec 29, 2025
721bf73
Nicer sounds
damacaa Dec 30, 2025
2004228
Color blend camera motion compensation
damacaa Dec 30, 2025
59c47fe
Update Scene.cpp
damacaa Dec 30, 2025
f2b30a1
Audio tweaks
damacaa Dec 30, 2025
bd80b64
Collision sound compression
damacaa Dec 30, 2025
0b89c3c
Update Scene.cpp
damacaa Dec 31, 2025
fcbc318
Update RopeScene.h
damacaa Dec 31, 2025
6e90dc6
Update AudioEngine.cpp
damacaa Dec 31, 2025
470c811
[WIP] Collision sound buffer
damacaa Dec 31, 2025
2e9b9e0
Last audio tweaks
damacaa Dec 31, 2025
b6c32ad
Fixed audio popping
damacaa Dec 31, 2025
566a9f6
Create .clang-format
damacaa Jan 4, 2026
93db706
Update 2DLightingShader.frag
damacaa Jan 4, 2026
5aeefe7
More audio tweaks
damacaa Jan 4, 2026
cf3d283
More consistent format
damacaa Jan 4, 2026
714af64
Update RopeScene.h
damacaa Jan 4, 2026
525cb9c
Update .clang-format
damacaa Jan 6, 2026
6a2a827
Resizable window
damacaa Jan 7, 2026
561289b
Improve UI distance motion
damacaa Jan 8, 2026
7a5996f
Fixed small issues
damacaa Jan 8, 2026
279dc64
Update CMakeLists.txt
damacaa Jan 8, 2026
d511a37
Making sure 3d isnt broken
damacaa Jan 9, 2026
0184f8e
Hopefully fixes submodules issues
damacaa Jan 9, 2026
4749d78
Tweaks
damacaa Jan 9, 2026
2b3a936
Update SDF2DRenderPipeline.cpp
damacaa Jan 20, 2026
d19016c
Small light rebound
damacaa Jan 29, 2026
d8416c3
Modern OpenGL error handling
damacaa Jan 29, 2026
52478ca
More efficient default shapes
damacaa Jan 29, 2026
dc34740
New scene change controlled from inside the scene
damacaa Jan 29, 2026
2b0cf37
Ignore non-significant OpenGL errors/warnings
damacaa Jan 29, 2026
2915650
Shader class caches uniform locations to improve performance
damacaa Jan 29, 2026
0d676a6
Renderer cleanup
damacaa Jan 29, 2026
7adf29f
Removed 0 radious artifact
damacaa Jan 29, 2026
928eb20
Fixed Linux compile
damacaa Jan 29, 2026
804209f
New penetration calculation
damacaa Jan 31, 2026
faf7c44
Improved shape framework
damacaa Jan 31, 2026
8b08f37
Added mutex to prevent crashes
damacaa Jan 31, 2026
edf1e5f
C++20 for better multithreading
damacaa Feb 1, 2026
23f9f21
Fixed render issues
damacaa Feb 7, 2026
4a262eb
Update Renderer.cpp
damacaa Feb 8, 2026
134a537
Better scene transition
damacaa Feb 8, 2026
42bbfbb
Added shape id to shape collision event
damacaa Feb 9, 2026
db66525
Update 2DBackground.frag
damacaa Feb 10, 2026
86af729
Fixed window scaling issues
damacaa Feb 12, 2026
00d7a09
Display settings
damacaa Feb 12, 2026
2d2cf5d
Window aspect ratio fix for refraction
damacaa Feb 13, 2026
4b01ef1
Cleanup
damacaa Feb 14, 2026
c902205
Procedural ambient audio
damacaa Feb 14, 2026
dc8d1cc
Friction tweak
damacaa Feb 20, 2026
5b0fc24
New blend method for ui and world
damacaa Feb 26, 2026
cbf95d5
Refresh rate
damacaa Feb 28, 2026
8ab9c0b
Text component alignment settings and bug fixes
damacaa Mar 7, 2026
61ba92f
Update .clang-format
damacaa Mar 7, 2026
83e9431
Fixed more text issues
damacaa Mar 8, 2026
f49e4ea
Update Fire.h
damacaa Mar 8, 2026
335d20c
Fast moving balls don't get smaller
damacaa Mar 8, 2026
9b7ebc7
Parameter to control ball rendering blending
damacaa Mar 8, 2026
11429c2
[WIP] UI buttons
damacaa Mar 9, 2026
7f1853b
[WIP] Toggles
damacaa Mar 9, 2026
4f99799
Update Default2DSDFs.h
damacaa Mar 9, 2026
f0a7f12
Error message
damacaa Mar 9, 2026
a07c028
Debugging tools
damacaa Mar 11, 2026
720eed0
Imporving shapes
damacaa Mar 11, 2026
22b2415
Component array optimization
damacaa Mar 13, 2026
826a457
[WIP] Improved springs
damacaa Mar 13, 2026
188c29b
Fixed critical memory bug
damacaa Mar 14, 2026
8ee822f
Improvements in sample scenes
damacaa Mar 15, 2026
96962c5
Split samples into two projects for 2d and 3d
damacaa Mar 17, 2026
94289af
Improvements in component array
damacaa Mar 18, 2026
a21508e
Visual improvements
damacaa Mar 18, 2026
47da587
Spatil hash grid to improve collision detection performance
damacaa Mar 18, 2026
95c8855
Refactor weird-renderer structure
damacaa Mar 18, 2026
d971250
Fixed crash
damacaa Mar 18, 2026
1c5aa10
More consistent naming
damacaa Mar 18, 2026
2cf974e
2D ao fix
damacaa Mar 18, 2026
7191952
Sample scenes
damacaa Mar 19, 2026
3a1fadc
AO improvements
damacaa Mar 19, 2026
9d99983
Added a simple profiler
damacaa Mar 19, 2026
766e774
Making the game look better
damacaa Mar 20, 2026
967ac6a
Physics and audio configs
damacaa Mar 20, 2026
b7398c6
Improved config and audioEngine is now a singleton
damacaa Mar 21, 2026
949de7a
Update main.cpp
damacaa Mar 21, 2026
58aafcc
Merge branch 'feature/expose-more-settings-to-user' into feature/tuni…
damacaa Mar 21, 2026
e682e7f
Fixed blurry surface on corrected distance field render
damacaa Mar 22, 2026
5abaef1
Better defaults
damacaa Mar 22, 2026
9871dec
Update main.cpp
damacaa Mar 23, 2026
d92608b
Add .weird scene file save/load system
Copilot Mar 24, 2026
05955c7
Fixed a couple of errors and added a new sample scene
damacaa Mar 24, 2026
2a08cb7
Extract SceneSerializer into its own file pair
Copilot Mar 24, 2026
5ad9a6e
Fixed compilation again since copilot keeps breaking it
damacaa Mar 24, 2026
b645299
Implement SceneLoadExample shape editor with spawn buttons and materi…
Copilot Mar 24, 2026
af7982c
Fixing example
damacaa Mar 24, 2026
749bba3
Building complex characters
damacaa Mar 25, 2026
174544b
Rendamed SDFRenderer component into Dot
damacaa Mar 25, 2026
054fa19
Initial plan
Copilot Mar 25, 2026
985c2b5
Add protected loadWeirdFile method to Scene class
Copilot Mar 25, 2026
564410a
Load example
damacaa Mar 26, 2026
0da38c0
Merge pull request #36 from damacaa/copilot/add-protected-method-load…
damacaa Mar 26, 2026
9f6a112
Reverted to old component array to fix multiple weird issues
damacaa Mar 26, 2026
784ed47
Update main.cpp
damacaa Mar 26, 2026
23246ac
Merge pull request #37 from damacaa/copilot/add-scene-file-saving-system
damacaa Mar 26, 2026
de4f7a8
Replace component manager map with a vector that uses compile time fi…
damacaa Mar 26, 2026
cf4b02c
Fixed had data bug
damacaa Mar 26, 2026
f3ce504
Update MoleculeEditor.h
damacaa Mar 26, 2026
fec2fb5
Living organisms
damacaa Mar 27, 2026
979681c
Button system
damacaa Mar 27, 2026
7d1d22d
Update MoleculeEditor.h
damacaa Mar 27, 2026
ee0ccfd
More life
damacaa Mar 27, 2026
e04e7ae
Initial plan
Copilot Mar 28, 2026
9491f53
Add --fullscreen/-f CLI argument to force full screen in sample scenes
Copilot Mar 28, 2026
6c57164
Merge pull request #38 from damacaa/copilot/add-fullscreen-argument-s…
damacaa Mar 28, 2026
e0a08a1
Fixed fullscreen
damacaa Mar 30, 2026
5bec2d8
Renderer refactor and renaming stuff
damacaa Mar 30, 2026
ddcd469
Motion blur and color blending zoom independent
damacaa Mar 30, 2026
fe5403f
Normals debug
damacaa Mar 30, 2026
d1d216e
Initial plan
Copilot Mar 31, 2026
78a98b7
Add entity tag system and tag editor to MoleculeEditor
Copilot Mar 31, 2026
bf93931
Add parameterless onStart() overload; revert derived scenes to no-par…
Copilot Mar 31, 2026
a55ead2
Dithering moved to post process shader
damacaa Mar 31, 2026
5d27139
Merge branch 'feature/tuning-for-first-game' into copilot/featuretuni…
damacaa Mar 31, 2026
7251e8a
Tag test
damacaa Mar 31, 2026
35c5c5b
loadWeirdFile returns separate tag map without polluting scene tags
Copilot Mar 31, 2026
3b004ec
Complete molecule editor
damacaa Mar 31, 2026
e41d6bb
Merge pull request #40 from damacaa/copilot/featuretuning-for-first-a…
damacaa Mar 31, 2026
bcca5cb
Material editor
damacaa Mar 31, 2026
e7b5218
Render the scene with some overscan to have objects outside of the vi…
damacaa Apr 1, 2026
d246fe0
Fixed critical bug with custom component managers
damacaa Apr 1, 2026
d82ca3c
Fixed bug shapes not deleting from physics simulation
damacaa Apr 1, 2026
528e9e1
Update DestroyScene.h
damacaa Apr 2, 2026
02beecf
Free camera 2D removed floor limit
damacaa Apr 1, 2026
c08d43c
Made shadows short, long shadows can be enabled back with a define
damacaa Apr 1, 2026
2845d96
Tinted shadows look better
damacaa Apr 2, 2026
4390732
Configurable shadow tint and shadows
damacaa Apr 2, 2026
f81cfed
Removed virtual method from component to reduce the size of component…
damacaa Apr 2, 2026
06bb6e5
Huge ECS system refactor, remove system classes
damacaa Apr 2, 2026
54e03d9
clang format
damacaa Apr 3, 2026
e266f54
Updated JSON library to fix compilation issues with Clang
damacaa Apr 3, 2026
a1be898
Shapes default parameters
damacaa Apr 3, 2026
469c80a
Missing include
damacaa Apr 3, 2026
7b78dab
Fixing warnings
damacaa Apr 3, 2026
9baeda9
New shape lighting
damacaa Apr 3, 2026
6b21681
Update lighting.frag
damacaa Apr 4, 2026
c359e8c
Shader cleanup and removed self shadow because it looked ugly
damacaa Apr 4, 2026
79389df
Renderer settings
damacaa Apr 4, 2026
7655d71
Shape refactor
damacaa Apr 4, 2026
9ee45c6
New math
damacaa Apr 4, 2026
223e4fe
SDF math improvements
damacaa Apr 5, 2026
31cb9d6
[WIP] Destroying entities but causes issues
damacaa Apr 5, 2026
38ebc84
Fixed m_size calculation that created issues when removing objects fr…
damacaa Apr 5, 2026
d600591
Reuse deleted entities
damacaa Apr 5, 2026
049d3ff
Update RigidBodyManager.h
damacaa Apr 5, 2026
38079ae
Update SceneLoadExample.h
damacaa Apr 5, 2026
6613ff7
Deterministic serialization
damacaa Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Language: Cpp
# Start with the Microsoft base style
BasedOnStyle: Microsoft

# Visual Studio Standard: Allman style (curly braces on new lines)
BreakBeforeBraces: Allman

# USE TABS INSTEAD OF SPACES
# UseTab: Always tells clang-format to use tab characters (\t)
# IndentWidth and TabWidth ensure the tabs appear as 4 columns wide
UseTab: Always
IndentWidth: 4
TabWidth: 4

# Align pointers to the type (int* p)
PointerAlignment: Left

# Access Modifiers (public/private)
# We pull modifiers back by 1 tab (4 columns) to align with the class definition
AccessModifierOffset: -4

# Indentation logic
IndentCaseLabels: true
IndentRequires: true
NamespaceIndentation: All

# Line breaking and Column limits
# Set to 0 to disable line wrapping, or keep 120 as a guideline
ColumnLimit: 120

# C++ Version
Standard: Latest

# Sort includes (mimics VS "Organize Imports" behavior)
SortIncludes: CaseInsensitive

# Specific Visual Studio nuances
AllowShortFunctionsOnASingleLine: Empty
BreakAfterAttributes: Always
BreakBeforeBinaryOperators: None
BreakConstructorInitializers: BeforeComma
FixNamespaceComments: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInParentheses: false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ bld/
.vscode/
[Bb]uild/

# Ignore CLion build/temporary directories
cmake-build*/

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down
38 changes: 31 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ cmake_minimum_required(VERSION 3.10)

project(WeirdEngine)

set(CMAKE_CXX_STANDARD 17)
execute_process(COMMAND git submodule update --init --recursive)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Ensure strictly standard C++

message(STATUS "WeirdEngine path: ${CMAKE_CURRENT_SOURCE_DIR}")

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.vert" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.frag")
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.vert" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.frag" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.glsl")
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")

add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
Expand All @@ -31,6 +34,11 @@ target_include_directories(glad


# SDL3 setup
# FORCE SDL3 to build as a STATIC library.
# This prevents the creation of libSDL3.so and embeds the code
# directly into your engine/game.
set(SDL_SHARED OFF CACHE BOOL "Build SDL shared library" FORCE)
set(SDL_STATIC ON CACHE BOOL "Build SDL static library" FORCE)
# Add dependencies
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third-party/SDL)
# add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third-party/SDL_image)
Expand Down Expand Up @@ -68,18 +76,34 @@ target_link_libraries(${PROJECT_NAME} PUBLIC SDL3::SDL3)


# Shaders
option(WEIRD_ENGINE_USE_RUNTIME_ASSETS
"Load shaders/assets from runtime folder instead of source tree"
OFF
)

if (WEIRD_ENGINE_USE_RUNTIME_ASSETS)
set(WEIRD_ENGINE_FONTS_PATH "./fonts/")
set(WEIRD_ENGINE_SHADERS_PATH "./shaders/")
else()
set(WEIRD_ENGINE_FONTS_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/src/weird-renderer/fonts/"
)
set(WEIRD_ENGINE_SHADERS_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/src/weird-renderer/shaders/"
)
endif()

target_compile_definitions(${PROJECT_NAME} PUBLIC
ENGINE_PATH="${CMAKE_CURRENT_SOURCE_DIR}"
SHADERS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/weird-renderer/shaders/"
FONTS_PATH="${WEIRD_ENGINE_FONTS_PATH}"
SHADERS_PATH="${WEIRD_ENGINE_SHADERS_PATH}"
)

#
# target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX)

set_target_properties(${PROJECT_NAME} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib
)



function(assign_source_groups TARGET)
foreach(source_file IN LISTS ARGN)
get_filename_component(FILE_PATH "${source_file}" PATH)
Expand Down
94 changes: 94 additions & 0 deletions examples/3d-experiments/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
cmake_minimum_required(VERSION 3.10)
project(Weird3D)

# Create folders if they don't exist
file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/assets")
file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/include")
file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/src")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Option to switch between local and online version of WeirdEngine
option(USE_LOCAL_WEIRD_ENGINE "Use local version of WeirdEngine" ON)

# Set paths for the local WeirdEngine
set(WEIRD_ENGINE_LOCAL_PATH "../../")

if(USE_LOCAL_WEIRD_ENGINE)
# Use the local version of WeirdEngine
message(STATUS "Using local version of WeirdEngine")
add_subdirectory(${WEIRD_ENGINE_LOCAL_PATH} ${CMAKE_BINARY_DIR}/weird-engine)
else()
# Fetch WeirdEngine from GitHub
message(STATUS "Using online version of WeirdEngine")
include(FetchContent)
FetchContent_Declare(
WeirdEngine
GIT_REPOSITORY https://github.com/damacaa/weird-engine
GIT_TAG main
)
FetchContent_MakeAvailable(WeirdEngine)
endif()

# Glob source files and header files from the proper directories.
file(GLOB_RECURSE WEIRDGAME_SOURCES "${CMAKE_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE WEIRDGAME_HEADERS
"${CMAKE_SOURCE_DIR}/include/*.h"
"${CMAKE_SOURCE_DIR}/include/*.hpp"
)
file(GLOB_RECURSE WEIRDGAME_ASSETS
"${CMAKE_SOURCE_DIR}/assets/*.*"
)

# Mark headers as header-only so that Visual Studio treats them appropriately.
set_source_files_properties(${WEIRDGAME_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)

# Add executable including both sources and headers.
add_executable(${PROJECT_NAME} ${WEIRDGAME_SOURCES} ${WEIRDGAME_HEADERS} ${WEIRDGAME_ASSETS})

# Set include directories.
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_BINARY_DIR}/weird-engine/include
${CMAKE_BINARY_DIR}/weird-engine/third-party/include
)

# Link to WeirdEngine.
target_link_libraries(${PROJECT_NAME} PRIVATE WeirdEngine)

# Set Asset Path Macro
# Define the assets path variable
set(ASSETS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets/")
# set(ASSETS_PATH "./assets") # Set the asset path macro in release mode to a relative path that assumes the assets folder is in the same directory as the game executable

# Print the assets path for debugging or confirmation
message(STATUS "Assets path: ${ASSETS_PATH}")

# Use the variable in target_compile_definitions
target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="${ASSETS_PATH}")

if (MINGW)
target_link_options(${PROJECT_NAME} PRIVATE -static -static-libgcc -static-libstdc++)
endif()

# ----------------------------------------------------------
# Helper function to assign source groups based on folder structure.
function(assign_source_groups TARGET)
foreach(source_file IN LISTS ARGN)
# Get the full path to the file's directory.
get_filename_component(FILE_PATH "${source_file}" PATH)
# Compute the path relative to the project's root.
file(RELATIVE_PATH REL_PATH "${CMAKE_SOURCE_DIR}" "${FILE_PATH}")
# Replace forward slashes with backslashes for Visual Studio filter naming.
string(REPLACE "/" "\\" FILTER_PATH "${REL_PATH}")
if(FILTER_PATH STREQUAL "")
set(FILTER_PATH "Root")
endif()
# Assign the file to the computed filter.
source_group("${FILTER_PATH}" FILES "${source_file}")
endforeach()
endfunction()

# Assign source groups for all your files.
assign_source_groups(${PROJECT_NAME} ${WEIRDGAME_SOURCES} ${WEIRDGAME_HEADERS} ${WEIRDGAME_ASSETS})
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#version 330 core

// Vertex attributes
layout (location = 0) in vec3 in_position;
layout (location = 1) in vec3 in_normal;
layout (location = 2) in vec3 in_color;
layout (location = 3) in vec2 in_texCoord;
layout(location = 0) in vec3 in_position;
layout(location = 1) in vec3 in_normal;
layout(location = 2) in vec3 in_color;
layout(location = 3) in vec2 in_texCoord;

// Outputs to fragment shader
out vec3 v_worldPos;
Expand All @@ -20,9 +20,9 @@ uniform mat3 u_normalMatrix;
uniform float u_time;

// ChatGPT: I want a function that, for a given x, gros linearly but then plateaus
float plateauFunction(float x, float maxValue, float growthRate)
float plateauFunction(float x, float maxValue, float growthRate)
{
return maxValue * (1.0 - exp(-growthRate * x));
return maxValue * (1.0 - exp(-growthRate * x));
}

void main()
Expand All @@ -32,19 +32,16 @@ void main()

float maxHeight = 1.5 + (fract(gl_InstanceID * 123.45678) - 0.5); // Constant + random offset
float y = plateauFunction(2.0 * delta, maxHeight, 0.8);

float distanceToCenterXZ = 0.1 + (0.3 * smoothstep(0, 1, sqrt(1.5 * delta))); // TODO: find an alternative to sqrt

vec3 offset = vec3(
distanceToCenterXZ * sin(u_time + gl_InstanceID),
y,
distanceToCenterXZ * cos(u_time + gl_InstanceID)
);
vec3 offset =
vec3(distanceToCenterXZ * sin(u_time + gl_InstanceID), y, distanceToCenterXZ * cos(u_time + gl_InstanceID));

v_worldPos = vec3(u_model * vec4(2.0 * (1.0 - delta * delta) * in_position, 1.0)) + offset;
v_normal = u_normalMatrix * in_normal;
v_color = in_color;
v_texCoord = in_texCoord;
v_worldPos = vec3(u_model * vec4(2.0 * (1.0 - delta * delta) * in_position, 1.0)) + offset;
v_normal = u_normalMatrix * in_normal;
v_color = in_color;
v_texCoord = in_texCoord;

gl_Position = u_camMatrix * vec4(v_worldPos, 1.0);
gl_Position = u_camMatrix * vec4(v_worldPos, 1.0);
}
71 changes: 71 additions & 0 deletions examples/3d-experiments/assets/fire/shaders/flame.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#version 330 core

out vec4 FragColor;

// Inputs from vertex shader
in vec3 v_worldPos;
in vec3 v_normal;
in vec3 v_color;
in vec2 v_texCoord;

uniform float u_time;

uniform sampler2D t_noise;
uniform sampler2D t_flameShape;

const int NUM_STOPS = 4;
uniform vec3 colors[NUM_STOPS] = vec3[](vec3(0.1, 0.1, 0.1), // Grey
vec3(0.8, 0.3, 0.2), // Red
vec3(1.1, 0.7, 0.2), // Orange
vec3(1.2, 1.2, 1.2) // White
);

uniform float stops[NUM_STOPS] = float[](0.0, 0.7, 0.9, 1.0);

vec3 getGradientColor(float t)
{
// This could be replace with a texture, but this approach makes it easier to iterate and choose colors
for (int i = 0; i < NUM_STOPS - 1; ++i)
{
if (t >= stops[i] && t <= stops[i + 1])
{
float localT = (t - stops[i]) / (stops[i + 1] - stops[i]);
return mix(colors[i], colors[i + 1], localT);
}
}

return colors[NUM_STOPS - 1]; // fallback
}

void main()
{
vec2 uv = v_texCoord;

// Noise0
float noise0 = texture(t_noise, fract((3.0f * uv) - vec2(0.0f, u_time))).x - 0.5f;

// Noise1
float noise1 = texture(t_noise, fract((2.0 * uv) - vec2(0.0f, 1.2f * u_time))).x - 0.5f;

// Combine all noise
float sumNoise = noise0 + noise1;

// Reduce noise at the bottom of the flame
float noiseMask = clamp(3.0f * (v_texCoord.y - 0.35f), 0, 1);
sumNoise *= noiseMask;

// Reduce overall noise strength
float noiseIntensity = 0.1f;
sumNoise *= noiseIntensity;

// Sample texture with noise applied to uv coordinates
float alpha = texture(t_flameShape, clamp(uv + sumNoise, 0, 1)).x;

alpha = smoothstep(.3, 1.0, alpha);
alpha = alpha * (alpha + 0.01f);
alpha = clamp(alpha, 0.0, 1.0);

FragColor = vec4(getGradientColor(alpha), alpha);
// FragColor = vec4(vec3(sumNoise / noiseIntensity), 1.0f); // Debug noise
// FragColor = vec4(vec3(alpha), 1.0f); // Debug alpha
}
Loading
Loading