Skip to content

Conversation

@Bigfoot71
Copy link
Owner

This major update introduces a complete overhaul of the 3D model and material system, with significant improvements to performance, compatibility, and ease of use.

🎯 Major Changes (Most Important)

1. New Core Types Architecture

Introduces four fundamental new types that form the backbone of the rendering system:

  • R3D_Vertex - Unified vertex structure
  • R3D_Mesh - Optimized mesh container
  • R3D_Material - Complete material system
  • R3D_Model - Enhanced model representation

2. Assimp Integration for Model Loading

  • Replaced raylib's model loading with Assimp for vastly improved compatibility
  • Supports all raylib-compatible formats by default (configurable via CMakeLists)
  • Automatic tangent and normal generation for models that lack them
  • Eliminates the manual tangent generation requirement that was needed with raylib

3. Unified Vertex Buffer System

The new R3D_Mesh uses a single vertex buffer containing all attributes in order:

  • position
  • texcoord
  • normal
  • color
  • tangent

This design ensures all attributes are always present, eliminating the need for multiple buffers and fallback handling.

🚀 Performance & Rendering Improvements

4. Automatic Frustum Culling

  • Enabled by default (but can be disabled with R3D_FLAG_NO_FRUSTUM_CULLING)
  • Both R3D_Mesh and R3D_Model now include BoundingBox aabb member
  • Supports OBB (Oriented Bounding Box) for precise culling using local-space AABB and transformation matrices
  • Automatic AABB generation during model loading and mesh generation

5. Enhanced Instanced Rendering

  • Added support for global AABB in instanced rendering
  • Primarily motivated by particle system frustum culling
  • R3D_ParticleSystem now includes BoundingBox aabb member
  • Manual AABB calculation via R3D_CalculateParticleSystemBoundingBox() or custom dimensions

🔧 API Improvements

6. Reimplemented Mesh Generation Functions

  • All raylib mesh generation functions have been reimplemented to work with new structs
  • Generate all vertex attributes automatically
  • Added bool upload parameter for deferred manual upload via R3D_UploadMesh()

7. New Memory-Based Model Loading

  • R3D_LoadModelFromMemory() function added (thanks to Assimp)
  • Works with models that have all resources embedded
  • Limitation: Won't work with models containing external resources due to relative path issues
  • Future consideration: basePath parameter if needed

8. Simplified Material System

  • Eliminates R3D_ApplyXXX() functions for blend mode, face culling, etc.
  • Everything is now handled through the R3D_Material system
  • Cleaner, more organized material management

🎨 Rendering System Updates

9. Manual Transparency Sorting

  • Transparent object sorting now requires manual activation when needed
  • Provides better control over rendering performance

10. Forward Rendering Flag

  • Forcing forward rendering is now handled via R3D_FLAG_FORCE_FORWARD flag
  • Replaces the previous R3D_ApplyRenderMode() function approach

🐛 Bug Fixes & Adjustments

11. Numerous Bug Fixes

  • Extensive bug fixes and adjustments throughout the codebase
  • Too many to enumerate individually, but collectively improve stability and performance

Summary

This update represents a major step forward in the library's architecture, and I'm excited about where the library is heading! The switch to Assimp alone makes model loading so much more reliable, and the automatic frustum culling should give everyone some nice performance gains out of the box. The new unified approach makes everything feel more cohesive while still keeping things straightforward to use.

Note: Some features like deferred model upload weren't implemented due to texture upload complexities, but can be reconsidered if needed.


And here, a new example was added to celebrate this and to showcase something that would have been difficult before in terms of loading and managing materials!

output.mp4

@Bigfoot71 Bigfoot71 merged commit 50cc7de into master Jul 4, 2025
0 of 3 checks passed
@Bigfoot71 Bigfoot71 deleted the model branch September 6, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants