Skip to content

Commit

Permalink
updates: init, vulkan, editor, readme, documentation (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij authored May 1, 2023
1 parent e02ca53 commit 3369ede
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 94 deletions.
22 changes: 17 additions & 5 deletions Content/Documentation/WickedEngine-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ This is a reference for the C++ features of Wicked Engine
15. [RayTracingAccelerationStructure](#raytracingaccelerationstructure)
16. [RayTracingPipelineState](#raytracingpipelinestate)
17. [Variable Rate Shading](#variable-rate-shading)
2. [GraphicsDevice_DX11](#wigraphicsdevice_dx11)
3. [GraphicsDevice_DX12](#wigraphicsdevice_dx12)
4. [GraphicsDevice_Vulkan](#wigraphicsdevice_vulkan)
17. [Video decoding](#video-decoding)
2. [GraphicsDevice_DX11](#graphicsdevice_dx11)
3. [GraphicsDevice_DX12](#graphicsdevice_dx12)
4. [GraphicsDevice_Vulkan](#graphicsdevice_vulkan)
2. [Renderer](#renderer)
1. [DrawScene](#drawscene)
2. [DrawScene_Transparent](#drawscene_transparent)
Expand Down Expand Up @@ -693,6 +694,17 @@ The final shading rate will be determined from the above methods using the maxim
To read more about variable rate shading, refer to the [DirectX specifications.](https://microsoft.github.io/DirectX-Specs/d3d/VariableRateShading)
##### Video Decoding
Video decoding can be used to decode compressed video bitstream in real time on the GPU. Currently only the H264 format is supported. To decode a video, the following steps need to be taken:
- Provide H264 slice data in a `GPUBuffer`. The slice data offset needs to be aligned within the buffer with `GraphcisDevice::GetVideoDecodeBitstreamAlignment()`. The bitstream buffer needs to be an `UPLOAD` buffer currently.
- Create `VideoDecoder` object, while providing appropriate paraemters parsed from H264 such as resolution, picture parameters, sequence parameters. The decode format must be `Format::NV12` which is a multi planar YUV420 format.
- Create a "Decode Picture Buffer" (DPB), which is a texture array storing reference and decoded images in the native video format (currently only `Format::NV12` is supported). Indicate in the `misc_flags` that it will be used as `ResourceMiscFlags::VIDEO_DECODE`.
- Run the `GraphicsDevice::VideoDecode` operation providing correct arguments to decode a single video frame. You are responsible to provide correct H264 arguments and DPB picture indices.
- You will need to manually read from the DPB texture (eg. in a shader) and resolve the YUV format to RGB if you want.
All this is demonstrated in the [wi::video](../../WickedEngine/wiVideo.cpp) implementation.
#### GraphicsDevice_DX11
The DirectX11 interface has been removed after version 0.56
Expand Down Expand Up @@ -752,14 +764,14 @@ Hardware accelerated ray tracing API is now available, so a variety of renderer
After the acceleration structures are updated, ray tracing shaders can use it after binding to a shader resource slot.
#### Ray tracing (legacy)
Ray tracing can be used in multiple ways to render the scene. The `RayTraceScene()` function will render the scene with the rays that are provided as the `RayBuffers` type argument. For example, to render the scene from the camera perspective, first create rays that originate from the camera and shoot towards the caera far plane for every pixel. The `GenerateScreenRayBuffers()` helper function implements this functionality, by expecting a [CameraComponent](#cameracomponent) argument and returns a `RayBuffers` structure. The result will be written to a texture that is provided as parameter. The texture must have been created with `UNORDERED_ACCESS` bind flags, because it will be written in compute shaders. The scene BVH structure must have been already built to use this, it can be accomplished by calling [wi::renderer::BuildSceneBVH()](#build-scene-bvh). The [RenderPath3D_Pathracing](#renderpath3d_pathtracing) uses this ray tracing functionality to render a path traced scene.
Ray tracing can be used in multiple ways to render the scene. The `RayTraceScene()` function will render the scene with path tracing. The result will be written to a texture that is provided as parameter. The texture must have been created with `UNORDERED_ACCESS` bind flags, because it will be written in compute shaders. The scene BVH structure must have been already built to use this, it can be accomplished by calling `wi::renderer::UpdateRaytracingAccelerationStructures()`. The [RenderPath3D_Pathracing](#renderpath3d_pathtracing) uses this ray tracing functionality to render a path traced scene.
Other than path tracing, the scene BVH can be rendered by using the `RayTraceSceneBVH` function. This will render the bounding box hierarchy to the screen as a heatmap. Blue colors mean that few boxes were hit per pixel, and with more bounding box hits the colors go to green, yellow, red, and finaly white. This is useful to determine how expensive a the scene is with regards to ray tracing performance.
The lightmap baking is also using ray tracing on the GPU to precompute static lighting for objects in the scene. [Objects](#objectcomponent) that contain lightmap atlas texture coordinate set can start lightmap rendering by setting `ObjectComponent::SetLightmapRenderRequest(true)`. Every object that have this flag set will have their lightmaps updated by performing ray traced rendering by the [wi::renderer](#wi::renderer) internally. Lightmap texture coordinates can be generated by a separate tool, such as the Wicked Engine Editor application. Lightmaps will be rendered to a global lightmap atlas that can be used by all shaders to read static lighting data. The global lightmap atlas texture contains lightmaps from all objects inside the scene in a compact format for performance. Apart from that, each object contains its own lightmap in a full precision texture format that can be post-processed and saved to disc for later use. To denoise lightmaps, follow the same steps as the path tracer denoiser setup described in the [Denoiser](#denoiser) section.
#### Scene BVH
The scene BVH can be rebuilt from scratch using the `wi::renderer::BuildSceneBVH()` function. This will use the global scene to build the BVH hierarchy and global material atlases. The [ray tracing](#ray-tracing) features require the scene BVH to be built before using them. This is using the [wiGPUBVH](#wigpubvh) facility to build the BVH using compute shaders running on the GPU.
The scene BVH can be rebuilt from scratch using the `wi::renderer::UpdateRaytracingAccelerationStructures()` function. The [ray tracing](#ray-tracing) features require the scene BVH to be built before using them. This is using the [wiGPUBVH](#wigpubvh) facility to build the BVH using compute shaders running on the GPU when hardware ray tracing is not available. Otherwise it uses ray tracing acceleration structure API objects.
#### Decals
The [DecalComponents](#decalcomponent) in the scene can be rendered differently based on the rendering technique that is being used. The two main rendering techinques are forward and deferred rendering.
Expand Down
4 changes: 2 additions & 2 deletions Editor/VideoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void VideoWindow::Create(EditorComponent* _editor)
{
editor = _editor;
wi::gui::Window::Create(ICON_VIDEO " Video", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE);
SetSize(XMFLOAT2(440, 600));
SetSize(XMFLOAT2(440, 840));

closeButton.SetTooltip("Delete VideoComponent");
OnClose([=](wi::gui::EventArgs args) {
Expand Down Expand Up @@ -163,7 +163,7 @@ void VideoWindow::Create(EditorComponent* _editor)
AddWidget(&preview);

infoLabel.Create("");
infoLabel.SetSize(XMFLOAT2(800, 600));
infoLabel.SetSize(XMFLOAT2(800, 500));
AddWidget(&infoLabel);


Expand Down
99 changes: 20 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


<br/>
<img align="right" src="https://turanszkij.files.wordpress.com/2019/02/emitterskinned2.gif" width="256px"/>
<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/npc.gif" width="320px"/>
Wicked Engine is an open-source C++ engine focusing on modern rendering techniques and performance. Use this as a framework for your graphics projects, or learning. Some programming skills are required for the best experience, but some simple tools like an Editor are also included. It is free to be used for anything good.<br/>
This project is hosted on <a href="https://github.com/turanszkij/WickedEngine/">GitHub</a>.

Expand All @@ -25,8 +25,7 @@ You can download the source code by using Git and cloning the repository, or dow
Tip: try loading models or scripts from the Content folder using the Editor app to see how everything works.
<br/>


<img align="right" src="https://turanszkij.files.wordpress.com/2018/11/physics.gif" width="256px"/>
<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/swimming.gif" width="320px"/>

### Platforms:
- Windows 10 or newer
Expand All @@ -38,11 +37,13 @@ Tip: try loading models or scripts from the Content folder using the Editor app
#### Windows
To build Wicked Engine for Windows 10, use Visual Studio and the provided `WickedEngine.sln` solution file. There are a couple of projects that you can run up front: Editor, Tests and Template. You just have to set either as startup project and press F5 in Visual Studio to build and run. For optimal performance, choose `Release` mode, for the best debugging experience, choose `Debug` mode.

<img align="right" src="https://turanszkij.files.wordpress.com/2020/08/fighting_game_small-1.gif" width="256px"/>
<img align="right" src="https://turanszkij.files.wordpress.com/2023/05/fighting_game.gif" width="320px"/>

If you want to develop an application that uses Wicked Engine, you can build the WickedEngine static library project for the appropriate platform, such as `WickedEngine_Windows` and link against it. Including the `"WickedEngine.h"` header will attempt to link the binaries for the appropriate platform, but search directories should be set up beforehand. For example, you can set additional library directories to `$(SolutionDir)BUILD\$(Platform)\$(Configuration)` by default. For examples, see the `Template`, `Tests`, and `Editor` projects.

You can also download prebuilt and packaged versions of the Editor and Tests here: [![Github Build Status](https://github.com/turanszkij/WickedEngine/workflows/Build/badge.svg)](https://github.com/turanszkij/WickedEngine/actions)
You can also download prebuilt and packaged versions of the Editor and Tests here (requires Github sign in): [![Github Build Status](https://github.com/turanszkij/WickedEngine/workflows/Build/badge.svg)](https://github.com/turanszkij/WickedEngine/actions)

<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/inverse_kinematics.gif" width="320px"/>

If you have questions or stuck, please use the `windows` communication channel on Discord: [![Discord chat](https://img.shields.io/discord/602811659224088577?logo=discord)](https://discord.gg/CFjRYmE)

Expand All @@ -52,6 +53,9 @@ Cmake: It is possible to build the windows version with Cmake, but the recommend

#### Linux
To build the engine for Linux, use Cmake. You can find a sample build script for Ubuntu 20.04 [here](.github/workflows/build.yml) (in the linux section). You might need to install some dependencies, such as Cmake (3.7 or newer), g++ compiler (C++ 17 compliant version) and SDL2. For Ubuntu 20.04, you can use the following commands to install dependencies:

<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/grass.gif" width="320px"/>

```bash
sudo apt update
sudo apt install libsdl2-dev
Expand All @@ -67,7 +71,7 @@ make

If you want to develop an application that uses Wicked Engine, you will have to link to libWickedEngine.a and `#include "WickedEngine.h"` into the source code. For examples, look at the Cmake files, or the Tests and the Editor applications.

You can also download prebuilt and packaged versions of the Editor and Tests here: [![Github Build Status](https://github.com/turanszkij/WickedEngine/workflows/Build/badge.svg)](https://github.com/turanszkij/WickedEngine/actions)
You can also download prebuilt and packaged versions of the Editor and Tests here (requires Github sign in): [![Github Build Status](https://github.com/turanszkij/WickedEngine/workflows/Build/badge.svg)](https://github.com/turanszkij/WickedEngine/actions)

If you have questions or stuck, please use the `linux` communication channel on Discord: [![Discord chat](https://img.shields.io/discord/602811659224088577?logo=discord)](https://discord.gg/CFjRYmE)

Expand All @@ -76,7 +80,7 @@ If you have questions or stuck, please use the `linux` communication channel on

#### Initialization (C++):

<img align="right" src="https://turanszkij.files.wordpress.com/2018/05/sphinit.gif" width="256px"/>
<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/character_lookat.gif" width="320px"/>

```cpp
// Include engine headers:
Expand All @@ -96,6 +100,8 @@ while(true) {

#### Basics (C++):
```cpp
wi::initializer::InitializeComponentsImmediate(); // (Optional) allows to initialize all components immediately and block the application until finished. Otherwise the initialization will take place at the first application.Run() asynchronously. This is useful if you want to start using other parts of the engine before application.Run() is called.

wi::RenderPath3D myGame; // Declare a game screen component, aka "RenderPath" (you could also override its Update(), Render() etc. functions).
application.ActivatePath(&myGame); // Register your game to the application. It will call Start(), Update(), Render(), etc. from now on...

Expand Down Expand Up @@ -174,7 +180,7 @@ For more code samples and advanced use cases, please see the example projects, l

### Scripting API:

<img align="right" src="https://turanszkij.files.wordpress.com/2018/11/hairparticle2.gif" width="256px"/>
<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/clouds.gif" width="320px"/>

You can use a great number of engine features through the Lua scripting api, which can even be used real time while the program is running. The included applications, like the Editor,
contain a scripting input method toggled by the "Home" key. A blue screen will be presented where the user can type in LUA commands. It is very minimal in regards to input methods.
Expand All @@ -191,6 +197,8 @@ In addition, the Editor supports the importing of some common model formats (the

The preferred workflow is to import models into the Editor, and save them as <b>WISCENE</b>, then any Wicked Engine application can open them.<br/>

<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/snowstorm.gif" width="320px"/>

### Graphics API:
The default renderer is `DirectX 12` on Windows and `Vulkan` on Linux. The `DirectX 11` renderer is no longer available starting from version 0.57.0, but it can be found on the <a href="https://github.com/turanszkij/WickedEngine/tree/dx11-backup">dx11-backup branch</a>.
You can specify command line arguments (without any prefix) to switch between render devices or other settings. Currently the list of options:
Expand Down Expand Up @@ -229,8 +237,8 @@ You can specify command line arguments (without any prefix) to switch between re
</tr>
</table>

<img align="right" src="https://turanszkij.files.wordpress.com/2018/11/soft.gif" width="256px"/>

<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/talking.gif" width="320px"/>
<br/>

### Other software using Wicked Engine
Expand All @@ -245,78 +253,11 @@ If you are having trouble getting the applications to run, make sure that you sa
- If you built the application with Visual Studio, run it from the Visual Studio environment, where the executable working directory is set up to be the Project directory (not the build directory where the exe will be found)
- If you want to run an application without Visual Studio, either copy the executable from the BUILD directory to the correct project directory, or set the working directory appropriately. You can also check the Working directory setting in Visual Studio to find out the right working directory of every project.
- If you want to build UWP application, then you will first need to build the shaders into a shader dump. For that, build and run the `offlineshadercompiler` project with the `hlsl6 shaderdump` command line arguments. If the `wiShaderDump.h` file is successfully generated, rebuilding the engine will embed all the shader files so they are not loaded separately. But embedded shaders also cannot be recompiled during runtime.

<img align="right" src="https://github.com/turanszkij/wickedengine-gifs/raw/main/weather.gif" width="320px"/>

- If you experience crashes, follow these steps to find out the problem:
- make sure your environment is up to date, with latest graphics drivers and operating system updates.
- see if there is a wiBackLog.txt in your user temp folder (for example: C:\Users\username\AppData\Local\Temp), and request help on Discord or Github issue
- build the engine in Debug mode and try to run it, see where it crashes, provide call stack on Discord or Github issue
- run the engine with the `debugdevice` command argument and post the text from your console output window when the crash happens

<br/>

### Screenshots:

Procedural terrain generator:
![ProceduralTerrain](https://turanszkij.files.wordpress.com/2022/04/procedural_terrain.png)

Path tracing:
![PathTracing](https://turanszkij.files.wordpress.com/2022/04/sanmiguel.png)

Dynamic Diffuse Global Illumination (DDGI):
![DDGI](https://turanszkij.files.wordpress.com/2022/04/ddgi.png)

Snow storm with particle systems:
![SnowStorm](https://turanszkij.files.wordpress.com/2022/04/snowstorm.png)

Sponza scene with voxel GI enabled:
![Sponza](https://turanszkij.files.wordpress.com/2020/08/vxgi_sponza_small.png)

Damaged Helmet sample model imported from GLTF:
![Sponza](https://turanszkij.files.wordpress.com/2019/03/damagedhelmet.png)

Bokeh Depth of Field (Lain model by <a href="https://sketchfab.com/3d-models/lain-20-bf255be16da34df08d48abb5443a6706">woopoodle at Sketchfab</a>):
![DepthOfField](https://turanszkij.files.wordpress.com/2020/08/dof_bokeh_small.png)

Motion blur (fighting game sample):
![MotionBlur](https://turanszkij.files.wordpress.com/2019/12/motionblur.png)

Stochastic Screen Space Reflections:
![ScreenSpaceReflections](https://turanszkij.files.wordpress.com/2020/08/ssr.png)

Real time ray traced shadows and ambient occlusion (DXR, VK_KHR_raytracing):
![RaytracedShadows](https://turanszkij.files.wordpress.com/2020/08/dxr_rtao_rtshadow_small.png)

Bloom:
![Bloom](https://turanszkij.files.wordpress.com/2020/08/bloom_new.png)

Path tracing in the living room (model from <a href="http://casual-effects.com/data/index.html">Morgan McGuire's graphics archive</a>):
![LivingRoom](https://turanszkij.files.wordpress.com/2019/09/livingroom.jpg)

City scene with a light map (model by <a href="https://www.cgtrader.com/michaelmilesgallie">Michael Gallie at CgTrader</a>):
![City](https://turanszkij.files.wordpress.com/2019/01/city1.png)

Path tracing in the city:
![Balcony](https://turanszkij.files.wordpress.com/2019/01/city2.png)

Path traced caustics:
![Caustics](https://turanszkij.files.wordpress.com/2019/01/trace.png)

Vegetation particle system and depth of field:
![Vegetation](https://turanszkij.files.wordpress.com/2020/08/grass.png)

Bistro scene from Amazon Lumberyard (model from <a href="http://casual-effects.com/data/index.html">Morgan McGuire's graphics archive</a>):
![Bistro_out](https://turanszkij.files.wordpress.com/2019/01/bistro_out_0.png)

Bistro scene from the inside:
![Bistro_in](https://turanszkij.files.wordpress.com/2019/01/bistro_in_2.png)

Parallax occlusion mapping:
![ParallxOcclusionMapping](https://turanszkij.files.wordpress.com/2019/01/pom.png)

Large scale particle simulation on the GPU:
![ParticleSimulation](https://turanszkij.files.wordpress.com/2020/08/particles_2.png)

Tiled light culling in the Bistro:
![TiledLightCulling](https://turanszkij.files.wordpress.com/2019/02/bistro_heatmap-1.png)

GPU-based BVH builder:
![GPU_BVH](https://turanszkij.files.wordpress.com/2019/07/bvh_livingroom.png)
2 changes: 1 addition & 1 deletion WickedEngine/wiGraphicsDevice_DX12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2978,7 +2978,7 @@ using namespace dx12_internal;
wi::helper::messageBox(ss.str(), "Warning!");
}

wi::backlog::post("Created GraphicsDevice_DX12 (" + std::to_string((int)std::round(timer.elapsed())) + " ms)");
wi::backlog::post("Created GraphicsDevice_DX12 (" + std::to_string((int)std::round(timer.elapsed())) + " ms)\Adapter: " + adapterName);
}
GraphicsDevice_DX12::~GraphicsDevice_DX12()
{
Expand Down
Loading

0 comments on commit 3369ede

Please sign in to comment.