openFrameworks addon to easily test, learn, and use the new PBR features from the new OF 0.12+ releases.
(You should use the GitHub master branch!)
All this code is copied from and hardly based on this OF forum topic.
Original authors: @NickHardeman and @paolo-scoppola.
output.mp4
SCREENSHOTS
-
Main class
ofxSurfingPBR.h
is a Scene Manager with default common elements:- Two ready-to-use editable parametric materials:
- Material A. For the Plane (floor).
- Material B. For the other Objects.
- Default Lights combo:
- Flexible Point, Directional and Spot.
- Cubemaps (HDR) files loader.
- Background color and Sphere/Box container with material.
- Two ready-to-use editable parametric materials:
-
Class
SurfingMaterial.h
: Standalone Materials can be used independently of the main class. -
Class
SurfingLights.h
: Four bundled lights:Point
,Direct
,Spot
andArea
with shadows. -
Class
SurfingSceneManager.h
: Bundles the lights fromSurfingLights.h
and allows queuing materials dynamically. Standalone and not loaded by default onofxSurfingPBR
. -
Persistent settings:
- Optimized auto save on any change.
- Plane simple material, colors, transforms, snapshots, etc...
- All materials with full PBR specs.
- Internal
camera
.
-
Material Randomizers.
- History browsing workflow.
- Presets/Snapshots (Store/Recall) explorer system.
- History browsing workflow.
-
Included 3D models browser/loader class.
-
Added Shader for testing/code.
- Displacement applied to the plane and his material/mesh.
- Add more Shaders related stuff. / HELP IS WELCOME!
- Mesh/vertex displacements (not just heightmaps). / TODO
- Shader Debugger. / TODO
USAGE
#include "ofApp.h"
#include "ofMain.h"
int main() {
ofGLWindowSettings settings;
settings.setGLVersion(3, 2);
auto window = ofCreateWindow(settings);
ofRunApp(window, make_shared<ofApp>());
ofRunMainLoop();
}
#pragma once
#include "ofMain.h"
#include "ofxSurfingPBR.h"
class ofApp : public ofBaseApp {
public:
void setup();
void draw();
ofxSurfingPBR pbr;
void renderScene();
};
void ofApp::setup() {
pbr.setup();
// Pass the render scene function
callback_t f = std::bind(&ofApp::renderScene, this);
pbr.setFunctionRenderScene(f);
}
void ofApp::draw() {
pbr.draw();
pbr.drawGui();
}
void ofApp::renderScene()
{
// Plane floor
pbr.drawPlane();
// Other objects
pbr.beginMaterial();
{
/* DRAW HERE! */
}
pbr.endMaterial();
}
- OF 0.12+.
- ofxSurfingHelpersLite.
- Helper classes for settings serializers, auto saver,
ofxGui
customizer, layout helpers,ofDrawBitmapStringBox
...etc.
- Helper classes for settings serializers, auto saver,
- ofxSurfingCameraSimple.
- An internal improved
ofEasyCam
is bundled.
- An internal improved
- ofxAssimpModelLoader / OF core
- Only for the example
2_Example_Models
.
- Only for the example
- Download and copy the content of
data.zip
to the examples or to your projects into/bin/data
:- Data for any or new projects: bin/data.zip
- Data for
2_Example_Models
: bin/data.zip - Data for
6_Example_3D_Parts
: bin/data.zip - Only shaders: bin/dataShaders.zip
- Folder with all the files: @ MEGA.
- Notice that all the examples should work without the data files too.
/bin/
-- /data/
---- /assets/fonts/ - ttf,otf | for ofxGui customize
---- /cubemaps/ - exr,hdr,jpg | for CubeMaps
---- /models/ - obj,ply,fbx | for 3d objects
---- /images/ - jpg,png | for Bg sphere texture
---- /shadersGL2/ - frag,vert | used when enabled
---- /shadersGL3/ - frag,vert | used when enabled
- Windows 11 / VS 2022 / OF 0.12+ @ GitHub master branch
MIT License