Vulkanizing
Star Wars: Jedi Knight
"Porting from OpenGL to Vulkan, Enabling modern features and boosting frame rates."
"Porting from OpenGL to Vulkan, Enabling modern features and boosting frame rates."
Having already celebrated its 20th anniversary, this game series clearly has something special going on.
The dedicated community continues to bring DLC's, ranging from maps, models, skins to new game-modes and even total conversions.
Since the public release of the code-base, In addition to new content, there are also Community mods that improve stability, enhance graphics, and boost FPS.
All of this is done while maintaining the core gameplay experience that we love.
Optimizing the renderer backend is nothing new.
OpenJK introduced Rend2 years ago, improving performance and graphics by bumping OpenGL from vanilla version 1.1 to 4.3
Another key aspect is the introduction of Modularized renderer binaries. Allowing the player to switch renderers using the 'cl_renderer' setting.
Introduced by Khronos Group in 2016, it provides a instruction set helping developers to interface an application with the GPU. Game engines use it to transform vertices and textures to a 3D environment.
Game engines are slowly migrating from OpenGL to Vulkan due to its high-efficiency, low-overhead GPU access, allowing for better performance and enabling latest technologies, for example Ray Tracing.
Quake III and more games powered by "id Tech 3 engine" decided to make their code-base public, bringing various Community coders together.
Shoutout to developers from
Quake-III-Arena-Kenny-Edition and Quake3e who brought Vulkan to Quake III, Along with helpfull Community Feedback is of invaluable source for this project.
Even though RavenSoft's engine modifications made it challenging at times.
Showcasing the power of collaboration within the open-source community.
Core development primarily happens on a fork of EternalJK which in turn is a fork of OpenJK, providing a solid and stable base. The initial focus was a merge upstream.
That shifted when to my surprise mods started to package Vulkan with their releases.
Therefore, only mindful changes outside of the renderer module are made to keep the update process simpler.
Ensuring compatibility with existing and future mods, external libaries like SDL2, imagelibs and zlib will be maintained.
Q: How to enable the Vulkan renderer?
A: Certain mods allow you to do this in the game menu.
This is a convenient way to toggle the "cl_renderer" cvar.
To do this manually, or on a mod that has no built-in option in the menu; \
Q: How to check if the game is running on Vulkan?
A: In the console, type either vkinfo
or gfxinfo
and hit enter.
If vkinfo
prints out GPU usage information instead of Unknown command vkinfo
, the renderer is properly initialized.
Driver and API versions and available extensions can be printed using gfxinfo
. This is also the case for the Vanilla renderer
Q: Is Single Player supported?
A: No.
INFO: Physically Based Rendering (PBR) is a rendering technique that aims to simulate the interaction between light and materials more accurately, resulting in more realistic visuals.
- Traditional rendering methods often relied on baked specular highlights, where the shine of surfaces was pre-computed and stored in the texture maps, leading to less realistic and static effects.
- PBR however, uses separate texture maps for different material properties; albedo/diffuse (base color), metallic, roughness, and normal maps. This separation allows for more precise control over how materials react to lighting conditions in real time.
Implementation of PBR material system is based on Rend2 renderer from OpenJK
Adding the ability to apply normal, roughness, metallic or specular texture maps by introducing the .mtr file extension, which is an override for .shader
INFO: IBL cubemaps use a six-sided texture to capture the surrounding environment of a point in world space. Basicly a 360° photo.
Cubemaps are generated during map-loading and are later used to reproject on 3D surfaces in real-time, allowing for more realistic specular reflections, diffuse and ambient light sampling.
Being pre-computed during map-loading makes cubemaps static, but efficient. In combination with PBR, cubemaps provide a fast way to light scenes by sampling reprojected pre-computed (static) environmental textures.
Implementation of IBL is based the on Rend2 renderer from OpenJK.
256x256 pixel dimensions are used.
Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline-enabled application. It is fast, portable, renderer agnostic, and self-contained (no external dependencies).
Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal and lacks certain features commonly found in more high-level libraries. Among other things, full internationalization (right-to-left text, bidirectional text, text shaping etc.) and accessibility features are not supported.
Dear ImGui is particularly suited to integration in game engines (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on console platforms where operating system features are non-standard.
Legit profiler: ImGui helper class for simple profiler histogram
Repository -
License
ImGuiColorTextEdit: Syntax highlighting text editor for ImGui
Repository -
License
ImNodeFlow: Node-based editor/blueprints for ImGui
Repository -
License
NetRadiant-custom: The open-source, cross-platform level editor for id Tech based games.
- As Inspiration for auto-complete -
Commit -
Repository -
License
NOTE This is Work-in-progress, and is unstable.
E.g. switching map requires a full restart because buffer clearing is not implemented yet.
I wanted to learn more on the topic of RayTracing.
The current implementation is not yet complete, but the essential functionality should be there.
It needs more TLC, due to time constraints I have decided to put this project on hold.
I believe its a waste to let this codebase collect dust, and decided to share it.
Because the Jedi Knight community remains highly active, with further development, this project could become stable and playable, either through my efforts or with your involvement.
I used Quake-III-Arena-R as a starting point, however transitioned to Q2RTX relativly quickly.
Q2RTX is active and receives frequent updates.
Also the code base is very clear plus I like the RayTraced result!
I can highly recommend you to give their great effort a try if you have not done so already.
Main differences in this codebase:
Q2RTX implemented their own material system.
However I wanted to use the native .shader and support the .mtr material system from Rend2
I did a quick mockup of that, I have not added multistage support yet.
Ghoul2 support is added (No MD3 yet), and uses the same IBO's and VBO's used for Beta and PBR branch with minor tweaks.
Q2RTX uses a single buffer for the IBO and VBO and does not have Ghoul2 support.
I did port this method, but it is define guarded and can safely be removed.
BSP level loading and buffers differ.
This should however be looked at and transitioned to Q2RTX method of tlas and blas creation (top/bottom level accel structure)
GETTING STARTED
Set cvar r_normalMapping 1, r_specularMapping 1, r_cubeMapping 0, r_hdr 0, r_fullscreen 1 and r_vertexLight 2 Everything is define guarded using USE_RTX in the codebase
IMPORTANT Requires assets from Q2RTX on Steam
Download and locate the install folder and open baseq2 folder
Locate and open blue_noise.pkz and copy the folder "blue_noise" to the base folder of your Jedi Academy install folder.
Do the same for the folder "env" in q2rtx_media.pkz.
You should now have the following file structure: GameData/base/blue_noise and GameData/base/env
~ Give Q2RTX a try as well
Sources:
Quake-III-Arena-R
Q2RTX - License
References:
Vulkan Specification
SaschaWillems - Vulkan
r_DynamicGlow
r_DynamicGlowAllStages - Vanilla renderer skips certain collapsed glow stages. Render these anyway (3e62987)
r_DynamicGlowPasses unused
r_DynamicGlowDelta unused
r_DynamicGlowIntensity unused
r_DynamicGlowSoft unused
r_DynamicGlowWidth unused
r_DynamicGlowHeight unused
r_DynamicGlowScale unused
screenMap
texture rendering - to create realistic environment reflectionsSource: Quake3e
Refraction method ported from Rend2
INFO: An offscreen FBO (Frame Buffer Object) is used to render to a separate image or texture that is not directly displayed on the screen. This allows for techniques like post-processing effects or rendering to textures for later use. On the other hand, a non-FBO approach involves rendering directly to the swapchain (screen), which is suitable for simple rendering scenarios without the need for offscreen rendering or additional processing.
Enable for:
- PBR branches have this enabled hard-coded
r_fbo
INFO: VBO (Vertex Buffer Object) caching is a technique used to optimize rendering performance for static surfaces. By storing vertex data in a VBO on the GPU, it can be efficiently reused across multiple draw calls, reducing the overhead of transferring data to the GPU. This is particularly beneficial for surfaces that do not change frequently, as it minimizes the CPU to GPU communication and improves overall rendering efficiency.
PBR branches have this enabled hard-coded
PBR branches have this enabled hard-coded
Beta branch adds support for Ghoul2 and MD3 models.
r_vbo - Cache static surfaces:
0 : off
1 : world
INFO: Lightmaps are baked textures used to simulate lighting in 3D environments. They store information about how light interacts with surfaces, such as shadows and color variations. By applying these lightmaps to static world surfaces, it can achieve a more visually appealing environment.
Vulkan renderer merges multiple lightmaps into texture atlases, increasing mergeability of surfaces thus reducing GPU drawcalls
In addition to static world surfaces support for Ghoul2 (player) and MD3 models is added.
Enabled hard-coded on PBR branches
r_vbo - Cache static surfaces:
0 : off
1 : world
2 : world + models
r_bloom
r_bloom_threshold - Color level to extract to bloom texture, default is 0.05
r_bloom_intensity - Final bloom blend factor, default is 0.15
r_bloom_threshold_mode - Color extraction mode:
0 : ( r | g | b ) >= threshold
1 : ( r + g + b ) / 3 >= threshold
2 : luma( r, g, b ) >= threshold
r_bloom_modulate - Modulate extracted color:
0 : off (color = color, i.e. no changes)
1 : by itself (color = color * color)
2 : by intensity (color = color * luma(color))
Native implemention of the Vulkan renderer module.
NOTE: upstream repository EternalJK is discontinued and is replaced with TaystJK - includes Vulkan
Implementation of PBR (Physical Based Rendering) material system based on Rend2 renderer from OpenJK
This adds the ability to apply normal, roughness, metallic or specular mapping.
by introducing the .mtr file extension which is an override for .shader
NOTE Incompatible with master or beta branch! cvar r_fbo and r_vbo are enabled hard-coded.
NOTE Release unavailable! build binaries yourself from source
Combines PBR and ImGui branch.
Began as a local codebase to inspect/debug the PBR material system implementation.
A basic GUI is added, renders the game in a viewport and allows displaying various PBR layers
Other features: View collapsed shader, text/node based shader editor, profiler and a few more bits an bobs.
Started entity inspector, but this has been commented out.
NOTE Release unavailable! build binaries yourself from source - Initially for personal use only, but here we are
Based on PBR Inspector branch.
NOTE This is Work-in-progress, and is unstable.
E.g. switching map requires a full restart because buffer clearing is not implemented yet.
This is an effort to port RayTracing from Q2RTX by NVIDIA, which builds upon Q2VKPT.
NOTE Release unavailable! build binaries yourself from source