-
Notifications
You must be signed in to change notification settings - Fork 37
Examples
The images found in https://ktstephano.github.io/rendering/stratusgfx/feature_reel and the video demo found at https://www.youtube.com/watch?v=s5aIsgzwNPE were both created using the example code found under the Examples/ folder.
Each example is effectively its own project which implements the Application interface, defines the application entry point, and links against libStratusEngine. Here is the simplest possible example application:
#include "StratusEngine.h"
#include "StratusLog.h"
// Create ExampleApp which implements the Application interface
class ExampleApp : public stratus::Application {
public:
virtual ~ExampleApp() = default;
const char * GetAppName() const override {
// ExampleApp00 will show up as the name of the window
return "ExampleApp00";
}
// Core engine design: by the time this function is called,
// the application can safely use anything within the engine
// without wondering if it has been initialized or not
virtual bool Initialize() override {
return true; // success
}
virtual stratus::SystemStatus Update(const double deltaSeconds) override {
STRATUS_LOG
<< "Successfully entered ExampleApp::Update! Delta seconds = "
<< deltaSeconds
<< std::endl;
// Tells the engine to end after this frame
return stratus::SystemStatus::SYSTEM_SHUTDOWN;
}
// Core engine design: this needs to be called first during shutdown
// so that any engine code the application calls won't crash
virtual void Shutdown() override {
STRATUS_LOG << "Successfully entered ExampleApp::ShutDown()"
<< std::endl;
}
};
// Sets up the main loop and starts the engine
// with a focus on ExampleApp class
STRATUS_ENTRY_POINT(ExampleApp)
STRATUS_ENTRY_POINT defines the ExampleApp class as the main application and creates the main function which has a call to start the engine.
The source for the above example can be found under Examples/ExampleEnv00/ExampleApp.cpp.
By default the source code does not include the data for the demo scenes. The examples should all still run without crashing, but you will either see a blank screen or a screen with very basic shapes and colors (no textures).
The demo data is packaged separately and can be found here: https://drive.google.com/file/d/1zuxILmOs9fX-w37EB65yOtOZA8em6nnP/view?usp=sharing
Here are the credits for each scene since I did not create the 3D assets myself:
Sponza: https://www.intel.com/content/www/us/en/developer/topic-technology/graphics-research/samples.html
Bistro: https://developer.nvidia.com/orca/amazon-lumberyard-bistro
San Miguel: https://casual-effects.com/data/
Bathroom: https://sketchfab.com/3d-models/the-bathroom-free-d5e5035dda434b8d9beaa7271f1c85fc (for the version in this bundle I made a few changes to the model that were not present in the original)
Interrogation Room: https://sketchfab.com/3d-models/interogation-room-6e9151ec29494469a74081ddc054d569
If you downloaded from the above Google Drive link you will have a Resources.zip folder. Copy this folder and place it at the top level of your clone of StratusGFX, at the same level as Bin/, Examples/, Source/, Tests/.
Extract this folder here. If using a GUI, make sure to remove the trailing "Resources" it may add. Here is an example:
The trailing "Resources" is highlighted in yellow. Erase it so that it looks like this and then you are safe to extract the contents to the StratusGFX folder:
Now that you have the demo scene data, you can go into the Bin/ directory and run any of the examples. ExampleEnv01 will still be a forest of cubes. ExampleEnv07 is not included with the data at this time since my copy of it was corrupted. I will redownload it and package it later.
Here is an example of running the Bistro example from inside the Bin/ directory:
Each scene can take a little bit to load since it has to read the OBj, FBX or GLTF file and do some preprocessing on it. Usually the first thing to come up is the skybox and the rest of the scene after.
Note: in the above image, the console gives you information such as which files it is trying to load and the current frame rate.
When running the examples, the controls are as follows:
-> Mouse move to look around
-> WASD to move forward, left, right, back
-> Left mouse to fly up, right mouse to fly down
-> Space + WASD or Space + mouse click will cause you to move faster
-> F toggles camera light
-> E toggles main environment light
-> G toggles global illumination
-> R recompiles all shaders