Skip to content

Commit

Permalink
Merge branch 'release/v0.8.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
bernstein committed Jun 12, 2014
2 parents c6eca4e + 9efd61f commit 4f3d235
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 87 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT(GUACAMOLE CXX)
# version number
set(GUACAMOLE_MAJOR 0)
set(GUACAMOLE_MINOR 8)
set(GUACAMOLE_PATCH 5)
set(GUACAMOLE_PATCH 6)
set(GUACAMOLE_VERSION ${GUACAMOLE_MAJOR}.${GUACAMOLE_MINOR}.${GUACAMOLE_PATCH})
set(GUACAMOLE_DESCRIPTION "GUACAMOLE - an astonishing virtual reality engine")
set(GUACAMOLE_HOMEPAGE "http://www.GUACAMOLE.org")
Expand Down
1 change: 1 addition & 0 deletions include/gua/renderer/Pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class GUA_DLL Pipeline {
void process(std::vector<std::unique_ptr<const SceneGraph>> const& scene_graphs,
float application_fps, float rendering_fps);

bool validate_resolution() const;
void set_context(RenderContext* ctx);
void create_passes();
void create_buffers();
Expand Down
9 changes: 9 additions & 0 deletions include/gua/renderer/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class GUA_DLL Window {
GUA_ADD_PROPERTY(math::vec2ui, right_resolution, math::vec2ui(800, 600));
GUA_ADD_PROPERTY(math::vec2ui, right_position, math::vec2ui(0, 0));
GUA_ADD_PROPERTY(bool, enable_vsync, true);
GUA_ADD_PROPERTY(bool, debug, false);
GUA_ADD_PROPERTY(std::string, warp_matrix_red_right, "");
GUA_ADD_PROPERTY(std::string, warp_matrix_green_right, "");
GUA_ADD_PROPERTY(std::string, warp_matrix_blue_right, "");
Expand Down Expand Up @@ -152,6 +153,14 @@ class GUA_DLL Window {
RenderContext* get_context();

protected:

struct DebugOutput : public scm::gl::render_context::debug_output {
/*virtual*/ void operator()(scm::gl::debug_source source,
scm::gl::debug_type type,
scm::gl::debug_severity severity,
const std::string& message) const;
};

ShaderProgram fullscreen_shader_;
scm::gl::quad_geometry_ptr fullscreen_quad_;

Expand Down
5 changes: 3 additions & 2 deletions include/gua/renderer/video3d_geometry/NetKinectArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gua/renderer/video3d_geometry/KinectCalibrationFile.hpp>

#include <atomic>

namespace boost{
class thread;
class mutex;
Expand Down Expand Up @@ -35,8 +37,7 @@ namespace video3d{
unsigned m_depthsize_byte;
unsigned char* m_buffer;
unsigned char* m_buffer_back;
bool m_need_swap;
bool m_need_swap2;
std::atomic<bool> m_need_swap;

};

Expand Down
2 changes: 0 additions & 2 deletions include/gua/scenegraph/Video3DNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class GUA_DLL Video3DNode : public GeometryNode {
std::string const& material = "gua_default_material",
math::mat4 const& transform = math::mat4::identity());

/*virtual*/ void update_bounding_box() const;

/*virtual*/ void ray_test_impl(RayNode const& ray,
PickResult::Options options,
Mask const& mask,
Expand Down
6 changes: 3 additions & 3 deletions resources/shaders/uber_shaders/gbuffer/video3d/warp_pass.frag
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
///////////////////////////////////////////////////////////////////////////////
uniform int layer;
uniform int bbxclip;
uniform vec3 bbx_min;// = vec3(-1.5,-0.1, -1.0);
uniform vec3 bbx_max;// = vec3( 1.5,2.2, 1.5);

///////////////////////////////////////////////////////////////////////////////
// input
Expand All @@ -32,8 +34,6 @@ layout (location=0) out vec4 out_color;
@include "shaders/common/pack_vec3.glsl"

// methods
vec3 bbx_min = vec3(-1.5,-0.1, -1.0);
vec3 bbx_max = vec3( 1.5,2.2, 1.5);

bool clip(vec3 p){
if(p.x < bbx_min.x ||
Expand Down Expand Up @@ -103,4 +103,4 @@ void main()
#else
out_color = vec4(texture_coord, packed_normal, quality);
#endif
}
}
11 changes: 8 additions & 3 deletions resources/shaders/uber_shaders/gbuffer/video3d/warp_pass.geom
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ layout (triangle_strip, max_vertices=3) out;
// video3d uniforms
///////////////////////////////////////////////////////////////////////////////
uniform int layer;
uniform float min_length; // 0.0125f * model_scale

///////////////////////////////////////////////////////////////////////////////
// input
Expand Down Expand Up @@ -50,7 +49,7 @@ bool validSurface(vec3 a, vec3 b, vec3 c,
{
float avg_depth = (depth_a + depth_b + depth_c)/3.0;
float baselength = 0.005;
float l = min_length * avg_depth + baselength;
float l = 0.0125 * avg_depth + baselength;

if((length(a) > l) || (length(b) > l) || (length(c) > l)){
return false;
Expand All @@ -65,6 +64,8 @@ bool validSurface(vec3 a, vec3 b, vec3 c,
}




///////////////////////////////////////////////////////////////////////////////
// main
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -83,7 +84,11 @@ void main()
float depth_b = VertexIn[1].depth;
float depth_c = VertexIn[2].depth;

bool valid = validSurface(a, b, c, depth_a, depth_b, depth_c);
vec3 a_ws = VertexIn[1].pos_ws - VertexIn[0].pos_ws;
vec3 b_ws = VertexIn[2].pos_ws - VertexIn[0].pos_ws;
vec3 c_ws = VertexIn[2].pos_ws - VertexIn[1].pos_ws;

bool valid = validSurface(a_ws, b_ws, c_ws, depth_a, depth_b, depth_c);

if (valid)
{
Expand Down
48 changes: 46 additions & 2 deletions src/gua/renderer/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ Pipeline::~Pipeline() {

////////////////////////////////////////////////////////////////////////////////

void Pipeline::print_shaders(std::string const& directory) const {

void Pipeline::print_shaders(std::string const& directory) const
{
std::unique_lock<std::mutex> lock(upload_mutex_);

for (auto pass : passes_) {
//pass->print_shaders();
}

}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -267,6 +272,11 @@ void Pipeline::process(std::vector<std::unique_ptr<const SceneGraph>> const& sce
create_buffers();
}

if (passes_need_reload_ || buffers_need_reload_) {
Logger::LOG_WARNING << "Pipeline::process() : Passes or buffers not created yet. Skipping frame." << std::endl;
return;
}

serialize(*current_graph, config.camera().eye_l, config.camera().screen_l,
current_scenes_[0]);
if (config.get_enable_stereo()) {
Expand Down Expand Up @@ -295,6 +305,31 @@ void Pipeline::process(std::vector<std::unique_ptr<const SceneGraph>> const& sce
}
}

////////////////////////////////////////////////////////////////////////////////

bool Pipeline::validate_resolution() const
{
// first, validate configuration
if (!config.get_enable_stereo()) // mono
{
if (!(config.get_left_resolution()[0] > 0 && config.get_left_resolution()[1] > 0))
{
gua::Logger::LOG_WARNING << "Pipeline::validate_resolution() : Invalid resolution for pipeline : " << config.get_left_resolution() << std::endl;
return false;
}
}
else { // stereo
if (!(config.get_left_resolution()[0] > 0 && config.get_left_resolution()[1] > 0 &&
config.get_right_resolution()[0] > 0 && config.get_right_resolution()[1] > 0))
{
gua::Logger::LOG_WARNING << "Pipeline::validate_resolution() : Invalid resolution for pipeline" << config.get_left_resolution() << " and " << config.get_right_resolution() << std::endl;
return false;
}
}
return true;
}


////////////////////////////////////////////////////////////////////////////////

void Pipeline::set_context(RenderContext* ctx) {
Expand All @@ -310,6 +345,11 @@ void Pipeline::set_context(RenderContext* ctx) {
void Pipeline::create_passes() {

if (passes_need_reload_) {

if (!validate_resolution()) {
return;
}

auto materials(MaterialDatabase::instance()->list_all());

auto pre_pass = new GBufferPass(this);
Expand Down Expand Up @@ -386,6 +426,10 @@ void Pipeline::create_buffers() {

if (buffers_need_reload_) {

if (passes_need_reload_ || !validate_resolution()) {
return;
}

std::vector<std::shared_ptr<StereoBuffer>> stereobuffers;

passes_[PipelineStage::geometry]->create(*context_, passes_[PipelineStage::geometry]->get_gbuffer_mapping()->get_layers());
Expand Down
106 changes: 60 additions & 46 deletions src/gua/renderer/Video3DRessource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ namespace gua {
////////////////////////////////////////////////////////////////////////////////
void Video3DRessource::init()
{

// approximately local space - can be overwritten from .ks file
bounding_box_ = math::BoundingBox<math::vec3>(math::vec3(-1.5,-0.1,-1.0),
math::vec3( 1.5, 2.2, 1.5));

std::fstream istr;
istr.open(ks_filename_.c_str(), std::ios::in);

Expand All @@ -129,7 +134,6 @@ void Video3DRessource::init()
if (istr.good())
{
std::string token;
std::vector<std::string> hostnames;

while (istr >> token)
{
Expand All @@ -148,55 +152,57 @@ void Video3DRessource::init()
//calib_file_ptr->printInfo();

calib_files_.push_back(calib_file_ptr);
} else if ( token == "hostname" )
{
istr >> token;
hostnames.push_back(token);
}
else if ( token == "bbx" ) {
float x_min,y_min,z_min,x_max,y_max,z_max;
istr >> x_min
>> y_min
>> z_min
>> x_max
>> y_max
>> z_max;
bounding_box_ = math::BoundingBox<math::vec3>(math::vec3(x_min,y_min,z_min),
math::vec3(x_max,y_max,z_max));
}

}


std::string hostname = boost::asio::ip::host_name();
boost::algorithm::to_lower(hostname);


if ( std::find(hostnames.begin(), hostnames.end(), hostname) != hostnames.end() )
{
for ( auto calib_file : calib_files_ )
{

for ( auto calib_file : calib_files_ ){
#if 0
sys::FileBuffer* tmp = new sys::FileBuffer(calib_file->get_stream_filename());
tmp->open();
tmp->setLooping(true);
file_buffers_.push_back(tmp);
sys::FileBuffer* tmp = new sys::FileBuffer(calib_file->get_stream_filename());
tmp->open();
tmp->setLooping(true);
file_buffers_.push_back(tmp);
#endif

const unsigned pixelcountc = calib_file->getWidthC() * calib_file->getHeightC();

depth_size_ = calib_file->getWidth() * calib_file->getHeight(); //== pixelcount
color_size_ = pixelcountc * 3 * sizeof(unsigned char);
depth_size_byte_ = depth_size_ * sizeof(float);

if(calib_file->isCompressedRGB()){
mvt::DXTCompressor dxt;
dxt.init(calib_file->getWidthC(), calib_file->getHeightC(), FORMAT_DXT1);
color_size_ = dxt.getStorageSize();
}

color_buffers_.push_back(new unsigned char[color_size_]);
depth_buffers_.push_back(new float[depth_size_]);
const unsigned pixelcountc = calib_file->getWidthC() * calib_file->getHeightC();

depth_size_ = calib_file->getWidth() * calib_file->getHeight(); //== pixelcount
color_size_ = pixelcountc * 3 * sizeof(unsigned char);
depth_size_byte_ = depth_size_ * sizeof(float);

if(calib_file->isCompressedRGB()){
mvt::DXTCompressor dxt;
dxt.init(calib_file->getWidthC(), calib_file->getHeightC(), FORMAT_DXT1);
color_size_ = dxt.getStorageSize();
}

assert (calib_files_.size() > 0);

width_depthimage_ = calib_files_[0]->getWidth();
height_depthimage_ = calib_files_[0]->getHeight();

width_colorimage_ = calib_files_[0]->getWidthC();
height_colorimage_ = calib_files_[0]->getHeightC();

} else { // host is not in hostname list
throw std::runtime_error("to implement: host is not in hostname list");

color_buffers_.push_back(new unsigned char[color_size_]);
depth_buffers_.push_back(new float[depth_size_]);
}


assert (calib_files_.size() > 0);

width_depthimage_ = calib_files_[0]->getWidth();
height_depthimage_ = calib_files_[0]->getHeight();

width_colorimage_ = calib_files_[0]->getWidthC();
height_colorimage_ = calib_files_[0]->getHeightC();

istr.close();
} else {
throw std::runtime_error("Couldn't open calib file");
Expand All @@ -215,8 +221,13 @@ void Video3DRessource::upload_to(RenderContext const& ctx) const
////////////////////////////////////////////////////////////////////////////////
void Video3DRessource::upload_proxy_mesh(RenderContext const& ctx) const
{
if (proxy_vertices_.size() > ctx.id ) {
return;
if (proxy_vertices_.size() > ctx.id) {
if (proxy_vertices_[ctx.id]) {
return;
}
else {
// continue instantiation below
}
} else {
proxy_vertices_.resize(ctx.id + 1);
proxy_indices_.resize(ctx.id + 1);
Expand Down Expand Up @@ -313,7 +324,11 @@ void Video3DRessource::upload_proxy_mesh(RenderContext const& ctx) const
void Video3DRessource::upload_video_textures(RenderContext const& ctx) const
{
if ( color_texArrays_.size() > ctx.id ) {
return;
if (color_texArrays_[ctx.id]) {
return;
} else {
// continue initialization
}
} else {
rstate_solid_.resize(ctx.id + 1);
color_texArrays_.resize(ctx.id + 1);
Expand Down Expand Up @@ -473,15 +488,14 @@ void Video3DRessource::update_buffers(RenderContext const& ctx) const
}
#endif


if(framecounter_per_context_[ctx.id] != ctx.framecount){
framecounter_per_context_[ctx.id] = ctx.framecount;
}
else{
return;
}
if(nka_per_context_[ctx.id]->update()){

unsigned char* buff = nka_per_context_[ctx.id]->getBuffer();
for(int i = 0; i < number_of_cameras(); ++i) {

Expand Down
Loading

0 comments on commit 4f3d235

Please sign in to comment.