Skip to content

Commit

Permalink
Various small fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
favreau committed Apr 4, 2017
1 parent 08d475c commit 77506a0
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 9 deletions.
47 changes: 47 additions & 0 deletions apps/BraynsViewer/BraynsViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "BraynsViewer.h"

#include <brayns/Brayns.h>
#include <brayns/common/camera/Camera.h>
#include <brayns/common/engine/Engine.h>
#include <brayns/common/input/KeyboardHandler.h>
#include <brayns/common/log.h>
Expand All @@ -37,6 +38,8 @@ namespace brayns
{
BraynsViewer::BraynsViewer(Brayns& brayns)
: BaseWindow(brayns)
, _fieldOfView(45.f)
, _eyeSeparation(0.0635f)
{
_registerKeyboardShortcuts();
}
Expand All @@ -63,6 +66,50 @@ void BraynsViewer::_registerKeyboardShortcuts()
keyHandler.registerKeyboardShortcut(
'|', "Create cache file ",
std::bind(&BraynsViewer::_saveSceneToCacheFile, this));
keyHandler.registerKeyboardShortcut(
'{', "Decrease eye separation",
std::bind(&BraynsViewer::_decreaseEyeSeparation, this));
keyHandler.registerKeyboardShortcut(
'}', "Increase eye separation",
std::bind(&BraynsViewer::_increaseEyeSeparation, this));
keyHandler.registerKeyboardShortcut(
'<', "Decrease field of view",
std::bind(&BraynsViewer::_decreaseFieldOfView, this));
keyHandler.registerKeyboardShortcut(
'>', "Increase field of view",
std::bind(&BraynsViewer::_increaseFieldOfView, this));
}

void BraynsViewer::_decreaseFieldOfView()
{
_fieldOfView -= 1.f;
//_fieldOfView = std::max(1.f, _fieldOfView);
_brayns.getEngine().getCamera().setFieldOfView(_fieldOfView);
BRAYNS_INFO << "Field of view: " << _fieldOfView << std::endl;
}

void BraynsViewer::_increaseFieldOfView()
{
_fieldOfView += 1.f;
// _fieldOfView = std::min(179.f, _fieldOfView);
_brayns.getEngine().getCamera().setFieldOfView(_fieldOfView);
BRAYNS_INFO << "Field of view: " << _fieldOfView << std::endl;
}

void BraynsViewer::_decreaseEyeSeparation()
{
_eyeSeparation -= 0.01f;
//_eyeSeparation = std::max(0.1f, _eyeSeparation);
_brayns.getEngine().getCamera().setEyeSeparation(_eyeSeparation);
BRAYNS_INFO << "Eye separation: " << _eyeSeparation << std::endl;
}

void BraynsViewer::_increaseEyeSeparation()
{
_eyeSeparation += 0.01f;
//_eyeSeparation = std::min(1.0f, _eyeSeparation);
_brayns.getEngine().getCamera().setEyeSeparation(_eyeSeparation);
BRAYNS_INFO << "Eye separation: " << _eyeSeparation << std::endl;
}

void BraynsViewer::_gradientMaterials()
Expand Down
7 changes: 7 additions & 0 deletions apps/BraynsViewer/BraynsViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class BraynsViewer : public BaseWindow
void _toggleIncrementalTimestamp();
void _defaultTimestamp();
void _saveSceneToCacheFile();
void _decreaseFieldOfView();
void _increaseFieldOfView();
void _decreaseEyeSeparation();
void _increaseEyeSeparation();

float _fieldOfView;
float _eyeSeparation;
};
}
#endif // BRAYNSVIEWER_H
6 changes: 4 additions & 2 deletions brayns/common/volume/VolumeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ float VolumeHandler::getEpsilon(const Vector3f& elementSpacing,
if (_volumeDescriptors.find(_timestamp) == _volumeDescriptors.end())
return 0.f;
const Vector3f diag =
_volumeDescriptors.at(_timestamp)->getDimensions() * elementSpacing;
return diag.find_max() / float(samplesPerRay);
elementSpacing * _volumeDescriptors.at(_timestamp)->getDimensions();
const float diagMax = diag.find_max();
const float epsilon = diagMax / float(samplesPerRay);
return epsilon;
}

Vector3ui VolumeHandler::getDimensions() const
Expand Down
4 changes: 2 additions & 2 deletions brayns/io/MorphologyLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ bool MorphologyLoader::_importMorphology(
if (layout.nbColumns != 0)
{
Boxf morphologyAABB;
const brain::Vector4fs& points = morphology.getPoints();
for (Vector4f point : points)
const auto& points = morphology.getPoints();
for (const auto& point : points)
morphologyAABB.merge({point.x(), point.y(), point.z()});

const Vector3f positionInGrid = {
Expand Down
2 changes: 1 addition & 1 deletion plugins/engines/optix/cuda/renderer/Phong.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static __device__ float4 getVolumeContribution(optix::Ray volumeRay,
optix::size_t2 screen = output_buffer.size();
unsigned int seed =
tea<16>(screen.x * launch_index.y + launch_index.x, frame);
const float delta = (float)(seed % (int)volumeEpsilon);
const float delta = (float)(seed % (int)(volumeEpsilon + 1));

float t = volumeEpsilon - delta;
const float tMax = t_hit - volumeEpsilon + volumeDiag;
Expand Down
2 changes: 2 additions & 0 deletions plugins/engines/ospray/OSPRayCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void OSPRayCamera::commit()
ospSet1f(_camera, "focusDistance", getFocalLength());
ospSet1i(_camera, "stereoMode", static_cast<uint>(getStereoMode()));
ospSet1f(_camera, "interpupillaryDistance", getEyeSeparation());
ospSet1f(_camera, "fovy", getFieldOfView());
ospSet1f(_camera, "architectural", true);

// Clip planes
const auto& clipPlanes = getClipPlanes();
Expand Down
5 changes: 3 additions & 2 deletions plugins/engines/ospray/ispc/render/SimulationRenderer.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ inline vec3f SimulationRenderer_shadeRay(

// Diffuse color
const varying vec3f localUnshadedColor =
localOpacity * cosNL * localLightIntensity *
cosNL * localLightIntensity *
(
// Affect shading with color determined
// by
Expand All @@ -361,7 +361,8 @@ inline vec3f SimulationRenderer_shadeRay(

// Add contribution of current light
localShadedColor =
localShadedColor + localUnshadedColor;
localShadedColor * (1.f - localOpacity) +
localUnshadedColor * localOpacity;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline bool launchRandomRay(
randomDirection = getRandomVector(sample, normal, self->randomNumber);
backgroundColor = self->bgColor;

if (dot(randomDirection, normal) < 0.f)
if (dot(randomDirection, normal) > 0.f)
// Invert direction of random ray direction is opposite to surface
// normal
randomDirection = neg(randomDirection);
Expand Down Expand Up @@ -284,7 +284,7 @@ inline varying vec4f getVolumeContribution(
const vec3i dimensions = self->volumeDimensions;

const float delta =
(float)((self->randomNumber) % (int)self->volumeEpsilon);
(float)((self->randomNumber) % (int)(self->volumeEpsilon + 1));
float t = ray.t0 + self->volumeEpsilon - delta;
const float tMax = ray.t - self->volumeEpsilon;

Expand Down
Binary file modified tests/testdataLayer1.bin
Binary file not shown.
Binary file modified tests/testdataProtein.bin
Binary file not shown.
Binary file modified tests/testdataProteinStereo.bin
Binary file not shown.

0 comments on commit 77506a0

Please sign in to comment.