Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3c93467
base test
Bigfoot71 Jul 1, 2025
10871fd
add assimp configuration
Bigfoot71 Jul 1, 2025
287b490
oops, fix previous commit
Bigfoot71 Jul 1, 2025
6d8eb65
fix disabled specular output
Bigfoot71 Jul 1, 2025
d8d2335
complete base model management impl + assimp submodule fix
Bigfoot71 Jul 2, 2025
1740e2d
review cmake configuration
Bigfoot71 Jul 2, 2025
1381614
use R3D_Mesh and R3D_Material
Bigfoot71 Jul 2, 2025
6f91af2
tweak default sprite material
Bigfoot71 Jul 2, 2025
3062ddd
update doc
Bigfoot71 Jul 2, 2025
3215acf
update examples
Bigfoot71 Jul 2, 2025
9a1751a
fix orm (shaders)
Bigfoot71 Jul 2, 2025
9ef3b72
fix model transform
Bigfoot71 Jul 2, 2025
73238e7
fix index format issue
Bigfoot71 Jul 2, 2025
9e3efa6
tweaks
Bigfoot71 Jul 2, 2025
45697fc
fix assimp scale issue
Bigfoot71 Jul 2, 2025
e78177b
adding configurable default texture filter
Bigfoot71 Jul 2, 2025
7879aec
review orm texture loading
Bigfoot71 Jul 2, 2025
f6d3d43
tweak material loading
Bigfoot71 Jul 2, 2025
4dca0e6
24 bit orm buffer
Bigfoot71 Jul 2, 2025
48956aa
review diffuse/specular contribution
Bigfoot71 Jul 2, 2025
ebf77b0
fix camera
Bigfoot71 Jul 2, 2025
697ad5e
fix sphere generation
Bigfoot71 Jul 2, 2025
871dd89
fix hemisphere generation
Bigfoot71 Jul 2, 2025
1ec7be4
fix cylinder generation
Bigfoot71 Jul 2, 2025
2085a9f
review cone generation
Bigfoot71 Jul 2, 2025
36002b2
fix torus generation
Bigfoot71 Jul 2, 2025
11ddb2d
review trefoil knot generation
Bigfoot71 Jul 2, 2025
ebc8ce0
fix vertex color...
Bigfoot71 Jul 2, 2025
d812440
tweak
Bigfoot71 Jul 2, 2025
982c337
fix depth clear issue with exclusive forward rendering
Bigfoot71 Jul 2, 2025
e9156ce
review blend and cull
Bigfoot71 Jul 2, 2025
ed27e83
update pbr example
Bigfoot71 Jul 2, 2025
2f1d8f6
set alpha blending by default for sprites
Bigfoot71 Jul 2, 2025
6c929a4
update primitives
Bigfoot71 Jul 2, 2025
e33c3c6
tweaks
Bigfoot71 Jul 2, 2025
05954a9
review drawcalls
Bigfoot71 Jul 2, 2025
7e477e3
review resource loading
Bigfoot71 Jul 2, 2025
233df8d
update todo
Bigfoot71 Jul 2, 2025
7d2c2b9
update todo
Bigfoot71 Jul 2, 2025
bc3570f
fix instanced shaders
Bigfoot71 Jul 3, 2025
ebae570
fix instanced geometry rendering
Bigfoot71 Jul 3, 2025
b5fb691
update todo
Bigfoot71 Jul 3, 2025
f0181d5
review primitives
Bigfoot71 Jul 3, 2025
1e18478
skybox fix
Bigfoot71 Jul 3, 2025
b80f91d
update primitive shortcut macros
Bigfoot71 Jul 3, 2025
fe0b7b5
fix instanced billboarding
Bigfoot71 Jul 3, 2025
ddbfde4
impl instanced sprite
Bigfoot71 Jul 3, 2025
3da8b8b
tweak sponza example
Bigfoot71 Jul 3, 2025
575ba33
tweak tonemap shader
Bigfoot71 Jul 3, 2025
736b2a3
improve aabb vs frustum
Bigfoot71 Jul 3, 2025
401316a
impl obb vs frustum
Bigfoot71 Jul 3, 2025
a46cfa3
review how material are handled
Bigfoot71 Jul 3, 2025
0198bd8
impl internal frustum culling
Bigfoot71 Jul 3, 2025
d26ce37
remove deferred upload parameter due to material upload issue...
Bigfoot71 Jul 3, 2025
6ccb5c8
fix instanced culling
Bigfoot71 Jul 3, 2025
6dcbf2a
Merge branch 'master' into model
Bigfoot71 Jul 3, 2025
119c002
re-add assimp submodule
Bigfoot71 Jul 3, 2025
63071d3
review default emission map
Bigfoot71 Jul 3, 2025
7abeb12
fix bloom example
Bigfoot71 Jul 3, 2025
dcdecb7
fix and improve object sorting
Bigfoot71 Jul 3, 2025
4737dfe
improves transparency management
Bigfoot71 Jul 4, 2025
373bda1
update todo
Bigfoot71 Jul 4, 2025
9279236
update header
Bigfoot71 Jul 4, 2025
ede2e43
adding new pbr car example
Bigfoot71 Jul 4, 2025
a1f6d22
update comment
Bigfoot71 Jul 4, 2025
71db5d3
update todo
Bigfoot71 Jul 4, 2025
fdbf2c6
fix particles example
Bigfoot71 Jul 4, 2025
efc0166
update todo
Bigfoot71 Jul 4, 2025
044bc2c
fix pbr example
Bigfoot71 Jul 4, 2025
470b6e5
tweak transparency example
Bigfoot71 Jul 4, 2025
de45ba4
update todo
Bigfoot71 Jul 4, 2025
1213430
optional sorting
Bigfoot71 Jul 4, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "external/raylib"]
path = external/raylib
url = https://github.com/raysan5/raylib.git
[submodule "external/assimp"]
path = external/assimp
url = https://github.com/assimp/assimp.git
110 changes: 109 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif()

option(R3D_BUILD_EXAMPLES "Build the examples" ${R3D_IS_MAIN})
option(R3D_RAYLIB_VENDORED "Use vendored raylib from submodule" OFF)
option(R3D_ASSIMP_VENDORED "Use vendored assimp from submodule" OFF)

# Set the cmake module path

Expand All @@ -33,6 +34,95 @@ include(CheckLibraryExists)
include(EmbedShaders)
include(EmbedAssets)

# Checks for assimp installation

if(R3D_ASSIMP_VENDORED)
set(R3D_ASSIMP_SUBMODULE_PATH "${R3D_ROOT_PATH}/external/assimp")
set(R3D_ASSIMP_CMAKELISTS "${R3D_ASSIMP_SUBMODULE_PATH}/CMakeLists.txt")

# Vendored assimp configuration here!
if(EXISTS "${R3D_ASSIMP_CMAKELISTS}")
message(STATUS "Using vendored assimp from: ${R3D_ASSIMP_SUBMODULE_PATH}")

set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "")
set(ASSIMP_WARNINGS_AS_ERRORS OFF CACHE BOOL "")
set(ASSIMP_IGNORE_GIT_HASH ON CACHE BOOL "")
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "")
set(ASSIMP_NO_EXPORT ON CACHE BOOL "")
set(ASSIMP_INSTALL OFF CACHE BOOL "")

set(ASSIMP_BUILD_COLLADA_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_GLTF_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_M3D_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_FBX_IMPORTER ON CACHE BOOL "")
set(ASSIMP_BUILD_IQM_IMPORTER ON CACHE BOOL "")

set(ASSIMP_BUILD_AMF_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_BVH_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_OFF_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_COB_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_STL_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_3DS_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_AC_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_ASE_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_ASSBIN_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_B3D_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_DXF_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_CSM_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_HMP_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_IRRMESH_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_IRR_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_LWO_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_LWS_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MD2_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MD3_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MD5_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MDC_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MDL_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_NFF_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_NDO_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_OGRE_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_OPENGEX_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_PLY_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MS3D_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_BLEND_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_IFC_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_XGL_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_Q3D_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_Q3BSP_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_RAW_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_SIB_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_SMD_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_TERRAGEN_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_3D_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_X_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_X3D_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_3MF_IMPORTER OFF CACHE BOOL "")
set(ASSIMP_BUILD_MMD_IMPORTER OFF CACHE BOOL "")

add_subdirectory("${R3D_ASSIMP_SUBMODULE_PATH}")

set(R3D_ASSIMP_INC_PATH "${R3D_ASSIMP_SUBMODULE_PATH}/src" CACHE STRING "Path to assimp includes" FORCE)
else()
message(FATAL_ERROR "Vendored assimp not found!
Missing: ${R3D_ASSIMP_CMAKELISTS}
Please initialize the submodule with:
git submodule update --init --recursive")
endif()
else()
find_package(assimp QUIET)

if(TARGET assimp)
message(STATUS "Using system-installed assimp")
get_target_property(RAYLIB_INCLUDE_DIR assimp INTERFACE_INCLUDE_DIRECTORIES)
set(R3D_ASSIMP_INC_PATH "${RAYLIB_INCLUDE_DIR}" CACHE STRING "Path to assimp includes" FORCE)
else()
message(FATAL_ERROR "System assimp not found.
Make sure assimp is installed and discoverable by CMake (e.g. via CMAKE_PREFIX_PATH or pkg-config).")
endif()
endif()

# Checks for raylib installation

# TODO: Add a version check for raylib, currently compatible with 5.6 dev
Expand All @@ -42,9 +132,25 @@ if(R3D_RAYLIB_VENDORED)
set(R3D_RAYLIB_SUBMODULE_PATH "${R3D_ROOT_PATH}/external/raylib")
set(R3D_RAYLIB_CMAKELISTS "${R3D_RAYLIB_SUBMODULE_PATH}/CMakeLists.txt")

# Vendored assimp configuration here!
if(EXISTS "${R3D_RAYLIB_CMAKELISTS}")
message(STATUS "Using vendored raylib from: ${R3D_RAYLIB_SUBMODULE_PATH}")

# Disable model loading and mesh generation support
# to avoid symbol redefinition errors with Assimp,
# and because it's not needed with r3d

set(CUSTOMIZE_BUILD ON CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_OBJ OFF CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_MTL OFF CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_IQM OFF CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_GLTF OFF CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_VOX OFF CACHE BOOL "" FORCE)
set(SUPPORT_FILEFORMAT_M3D OFF CACHE BOOL "" FORCE)
set(SUPPORT_MESH_GENERATION OFF CACHE BOOL "" FORCE)

add_subdirectory("${R3D_RAYLIB_SUBMODULE_PATH}")

set(R3D_RAYLIB_INC_PATH "${R3D_RAYLIB_SUBMODULE_PATH}/src" CACHE STRING "Path to raylib includes" FORCE)
else()
message(FATAL_ERROR "Vendored raylib not found!
Expand Down Expand Up @@ -87,6 +193,7 @@ add_library(${PROJECT_NAME}
"${R3D_ROOT_PATH}/src/r3d_skybox.c"
"${R3D_ROOT_PATH}/src/r3d_curves.c"
"${R3D_ROOT_PATH}/src/r3d_sprite.c"
"${R3D_ROOT_PATH}/src/r3d_model.c"
"${R3D_ROOT_PATH}/src/r3d_utils.c"
"${R3D_ROOT_PATH}/src/r3d_state.c"
"${R3D_ROOT_PATH}/src/r3d_core.c"
Expand Down Expand Up @@ -133,7 +240,7 @@ EmbedAssets(${PROJECT_NAME}

# Link project dependencies

target_link_libraries(${PROJECT_NAME} PUBLIC raylib)
target_link_libraries(${PROJECT_NAME} PUBLIC raylib assimp)

check_library_exists(m cos "" HAVE_LIB_M)

Expand All @@ -147,6 +254,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"${R3D_ROOT_PATH}/external/glad"
"${R3D_ROOT_PATH}/include"
"${R3D_RAYLIB_INC_PATH}"
"${R3D_ASSIMP_INC_PATH}"
)

# Ensure the C standard is set for MSVC if using CMake version greater than 3.12
Expand Down
10 changes: 8 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
- Fix issue with light culling and impl glScissor for deferred lighting
- PBR ambient lighting (without skybox)
- Adding intensity factor or something else for the skybox
- Adding texcoord scale/offset and normal scale to R3D_Material
- Adding an optionnal pass for debanding
- Use Sample2DArray for shadow maps

- Apply the alpha scissor test directly in the depth shaders (this will work for both forward rendering and shadow maps).
- Make SSAO work for forward rendering as well.
- Create an internal inclusion system for shaders to reduce GLSL code duplication.
- Provide an easy way to define the desired number of lights in the shader (forward) (preferably configurable at runtime).
- Implement a system to save loaded skyboxes along with their generated irradiance and prefiltered textures, allowing for later reloading.
- Implement CSM (Cascaded Shadow Maps) for directional shadows.
- Implement SSR (Screen Space Reflections) with an example.
- Implement support for shadow transparency interaction (colored shadows?)
- Implement better support for shadow and transparency interaction (colored shadows?)
4 changes: 3 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ endfunction()

add_example(r3d_basic "examples/basic.c")
add_example(r3d_lights "examples/lights.c")
add_example(r3d_pbr "examples/pbr.c")
add_example(r3d_pbr_musket "examples/pbr_musket.c")
add_example(r3d_pbr_car "examples/pbr_car.c")
add_example(r3d_transparency "examples/transparency.c")
add_example(r3d_skybox "examples/skybox.c")
add_example(r3d_sponza "examples/sponza.c")
Expand All @@ -20,4 +21,5 @@ add_example(r3d_bloom "examples/bloom.c")
add_example(r3d_resize "examples/resize.c")
add_example(r3d_particles "examples/particles.c")
add_example(r3d_instanced "examples/instanced.c")
add_example(r3d_sprite_instanced "examples/sprite_instanced.c")
add_example(r3d_directional "examples/directional.c")
31 changes: 13 additions & 18 deletions examples/basic.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
#include "./common.h"
#include "r3d.h"
#include "raymath.h"

/* === Resources === */

static Model plane = { 0 };
static Model sphere = { 0 };
static Camera3D camera = { 0 };
static R3D_Mesh plane = { 0 };
static R3D_Mesh sphere = { 0 };
static R3D_Material material = { 0 };
static Camera3D camera = { 0 };


/* === Examples === */
/* === Example === */

const char* Init(void)
{
R3D_Init(GetScreenWidth(), GetScreenHeight(), 0);
SetTargetFPS(60);

plane = LoadModelFromMesh(GenMeshPlane(1000, 1000, 1, 1));
plane.materials[0].maps[MATERIAL_MAP_OCCLUSION].value = 1;
plane.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value = 1;
plane.materials[0].maps[MATERIAL_MAP_METALNESS].value = 0;

sphere = LoadModelFromMesh(GenMeshSphere(0.5f, 64, 64));
sphere.materials[0].maps[MATERIAL_MAP_OCCLUSION].value = 1;
sphere.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value = 0.25;
sphere.materials[0].maps[MATERIAL_MAP_METALNESS].value = 0.75;
plane = R3D_GenMeshPlane(1000, 1000, 1, 1, true);
sphere = R3D_GenMeshSphere(0.5f, 64, 64, true);
material = R3D_GetDefaultMaterial();

camera = (Camera3D) {
.position = (Vector3) { 0, 2, 2 },
Expand All @@ -50,14 +45,14 @@ void Update(float delta)
void Draw(void)
{
R3D_Begin(camera);
R3D_DrawModel(plane, (Vector3) { 0, -0.5f, 0 }, 1.0f);
R3D_DrawModel(sphere, (Vector3) { 0 }, 1.0f);
R3D_DrawMesh(&plane, &material, MatrixTranslate(0, -0.5f, 0));
R3D_DrawMesh(&sphere, &material, MatrixIdentity());
R3D_End();
}

void Close(void)
{
UnloadModel(plane);
UnloadModel(sphere);
R3D_UnloadMesh(&plane);
R3D_UnloadMesh(&sphere);
R3D_Close();
}
33 changes: 16 additions & 17 deletions examples/bloom.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "./common.h"
#include "r3d.h"
#include "raymath.h"

/* === Resources === */

static Model cube = { 0 };
static Camera3D camera = { 0 };
static float hueCube = 0.0f;
static R3D_Mesh cube = { 0 };
static R3D_Material material = { 0 };
static Camera3D camera = { 0 };
static float hueCube = 0.0f;

/* === Local Functions === */

Expand All @@ -24,15 +27,7 @@ static const char* getBloomModeName(R3D_Bloom mode)
return "Unknown";
}

static void updateCubeColor(void)
{
Color color = ColorFromHSV(hueCube, 1.0f, 1.0f);
R3D_SetMaterialAlbedo(&cube.materials[0], NULL, color);
R3D_SetMaterialOcclusion(&cube.materials[0], NULL, 1.0f);
R3D_SetMaterialEmission(&cube.materials[0], NULL, color, 1.0f);
}

/* === Examples === */
/* === Example === */

const char* Init(void)
{
Expand All @@ -43,8 +38,12 @@ const char* Init(void)
R3D_SetBloomMode(R3D_BLOOM_MIX);
R3D_SetBackgroundColor(BLACK);

cube = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f));
updateCubeColor();
cube = R3D_GenMeshCube(1.0f, 1.0f, 1.0f, true);
material = R3D_GetDefaultMaterial();

material.emission.color = ColorFromHSV(hueCube, 1.0f, 1.0f);
material.emission.multiplier = 1.0f;
material.albedo.color = BLACK;

camera = (Camera3D){
.position = (Vector3) { 0, 3.5, 5 },
Expand All @@ -63,7 +62,7 @@ void Update(float delta)
int hueDir = IsMouseButtonDown(MOUSE_BUTTON_RIGHT) - IsMouseButtonDown(MOUSE_BUTTON_LEFT);
if (hueDir != 0) {
hueCube = Wrap(hueCube + hueDir * 90.0f * delta, 0, 360);
updateCubeColor();
material.emission.color = ColorFromHSV(hueCube, 1.0f, 1.0f);
}

int intensityDir = (IsKeyPressedRepeat(KEY_RIGHT) || IsKeyPressed(KEY_RIGHT)) -
Expand All @@ -88,7 +87,7 @@ void Update(float delta)
void Draw(void)
{
R3D_Begin(camera);
R3D_DrawModel(cube, (Vector3) { 0 }, 1.0f);
R3D_DrawMesh(&cube, &material, MatrixIdentity());
R3D_End();

R3D_DrawBufferEmission(10, 10, 100, 100);
Expand All @@ -112,6 +111,6 @@ void Draw(void)

void Close(void)
{
UnloadModel(cube);
R3D_UnloadMesh(&cube);
R3D_Close();
}
21 changes: 0 additions & 21 deletions examples/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,13 @@
# define RESOURCES_PATH "/"
#endif


/* === Helper functions === */

static inline Texture2D RES_LoadTexture(const char* fileName)
{
Texture2D texture = LoadTexture(TextFormat("%s%s", RESOURCES_PATH, fileName));

GenTextureMipmaps(&texture);
SetTextureFilter(texture, TEXTURE_FILTER_ANISOTROPIC_4X);

return texture;
}

static inline Model RES_LoadModel(const char* fileName)
{
return LoadModel(TextFormat("%s%s", RESOURCES_PATH, fileName));
}


/* === Example functions === */

const char* Init(void);
void Update(float delta);
void Draw(void);
void Close();


/* === Main program === */

int main(void)
Expand All @@ -61,5 +41,4 @@ int main(void)
return 0;
}


#endif // COMMON_H
Loading
Loading