Skip to content

Commit

Permalink
Added light loading from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Khokhlov committed Sep 18, 2018
1 parent 9d18d31 commit ba1656f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 47 deletions.
2 changes: 2 additions & 0 deletions BaikalStandalone/Application/app_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ namespace Baikal

s.image_file_format = m_cmd_parser.GetOption("-iff", s.image_file_format);

s.light_file = m_cmd_parser.GetOption("-lights", s.light_file);

if (m_cmd_parser.OptionExists("-ct"))
{
auto camera_type = m_cmd_parser.GetOption("-ct");
Expand Down
3 changes: 3 additions & 0 deletions BaikalStandalone/Application/app_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ namespace Baikal
std::string base_image_file_name;
std::string image_file_format;

//light file
std::string light_file;

//unused
int num_shadow_rays;
int samplecount;
Expand Down
50 changes: 5 additions & 45 deletions BaikalStandalone/Application/cl_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ THE SOFTWARE.
#include <thread>
#include <chrono>

#include "Application/scene_load_utils.h"

#ifdef ENABLE_DENOISER
#include "PostEffects/wavelet_denoiser.h"
#endif
Expand All @@ -50,7 +52,7 @@ namespace Baikal
AppClRender::AppClRender(AppSettings& settings, GLuint tex) : m_tex(tex), m_output_type(Renderer::OutputType::kColor)
{
InitCl(settings, m_tex);
LoadScene(settings);
InitScene(settings);
}

void AppClRender::InitCl(AppSettings& settings, GLuint tex)
Expand Down Expand Up @@ -139,53 +141,11 @@ namespace Baikal
}


void AppClRender::LoadScene(AppSettings& settings)
void AppClRender::InitScene(AppSettings& settings)
{
rand_init();

// Load obj file
std::string basepath = settings.path;
basepath += "/";
std::string filename = basepath + settings.modelname;

{
m_scene = Baikal::SceneIo::LoadScene(filename, basepath);

{
#ifdef WIN32
#undef LoadImage
#endif
auto image_io(ImageIo::CreateImageIo());
auto ibl_texture = image_io->LoadImage(settings.envmapname);

auto ibl = ImageBasedLight::Create();
ibl->SetTexture(ibl_texture);
m_scene->AttachLight(ibl);
}

// Enable this to generate new materal mapping for a model
#if 0
auto material_io{Baikal::MaterialIo::CreateMaterialIoXML()};
material_io->SaveMaterialsFromScene(basepath + "materials.xml", *m_scene);
material_io->SaveIdentityMapping(basepath + "mapping.xml", *m_scene);
#endif

// Check it we have material remapping
std::ifstream in_materials(basepath + "materials.xml");
std::ifstream in_mapping(basepath + "mapping.xml");

if (in_materials && in_mapping)
{
in_materials.close();
in_mapping.close();

auto material_io = Baikal::MaterialIo::CreateMaterialIoXML();
auto mats = material_io->LoadMaterials(basepath + "materials.xml");
auto mapping = material_io->LoadMaterialMapping(basepath + "mapping.xml");

material_io->ReplaceSceneMaterials(*m_scene, *mats, mapping);
}
}
m_scene = LoadScene(settings);

switch (settings.camera_type)
{
Expand Down
2 changes: 1 addition & 1 deletion BaikalStandalone/Application/cl_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace Baikal
#endif
private:
void InitCl(AppSettings& settings, GLuint tex);
void LoadScene(AppSettings& settings);
void InitScene(AppSettings& settings);
void RenderThread(ControlData& cd);

Baikal::Scene1::Ptr m_scene;
Expand Down
4 changes: 3 additions & 1 deletion BaikalStandalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ set(APPLICATION_SOURCES
Application/graph_scheme.h
Application/graph_scheme.cpp
Application/material_explorer.h
Application/material_explorer.cpp)
Application/material_explorer.cpp
Application/scene_load_utils.h
Application/scene_load_utils.cpp)

set(IMGUI_SORUCES
ImGUI/imconfig.h
Expand Down

0 comments on commit ba1656f

Please sign in to comment.