Skip to content

Simple helper with examples for easily testing the new PBR features from OF 0.12+.

Notifications You must be signed in to change notification settings

moebiussurfing/ofxSurfingPBR

Repository files navigation

WIP

OVERVIEW

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.

VIDEO

output.mp4
SCREENSHOTS

1_Example_Basic

2_Example_Models

3_Example_Lights

4_Example_Materials

5_Example_Shadows

6_Example-3D_Parts

FEATURES

  • 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.
  • Class SurfingMaterial.h: Standalone Materials can be used independently of the main class.

  • Class SurfingLights.h: Four bundled lights: Point, Direct, Spot and Area with shadows.

  • Class SurfingSceneManager.h: Bundles the lights from SurfingLights.h and allows queuing materials dynamically. Standalone and not loaded by default on ofxSurfingPBR.

  • 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.
  • Included 3D models browser/loader class.

  • Added Shader for testing/code.

    • Displacement applied to the plane and his material/mesh.

TODO

  • Add more Shaders related stuff. / HELP IS WELCOME!
    • Mesh/vertex displacements (not just heightmaps). / TODO
    • Shader Debugger. / TODO
USAGE

EXAMPLE

main.cpp

#include "ofApp.h"
#include "ofMain.h"

int main() {
    ofGLWindowSettings settings;
    settings.setGLVersion(3, 2);

    auto window = ofCreateWindow(settings);

    ofRunApp(window, make_shared<ofApp>());
    ofRunMainLoop();
}

ofApp.h

#pragma once
#include "ofMain.h"

#include "ofxSurfingPBR.h"

class ofApp : public ofBaseApp {
public:
    void setup();
    void draw();

    ofxSurfingPBR pbr;
    void renderScene();
};

ofApp.cpp

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();
}

DEPENDENCIES

  • OF 0.12+.
  • ofxSurfingHelpersLite.
    • Helper classes for settings serializers, auto saver, ofxGui customizer, layout helpers, ofDrawBitmapStringBox...etc.
  • ofxSurfingCameraSimple.
    • An internal improved ofEasyCam is bundled.
  • ofxAssimpModelLoader / OF core
    • Only for the example 2_Example_Models.

REQUERIMENTS

  • Download and copy the content of data.zip to the examples or to your projects into /bin/data:
  • 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

TESTED SYSTEMS

LICENSE

MIT License

About

Simple helper with examples for easily testing the new PBR features from OF 0.12+.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published