-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SharedData- and BrickedVolume support #448
Conversation
tribal-tec
commented
Jul 2, 2018
- use OSPRay volume and transfer function to support volume rendering
- add VolumeLoader for *.raw and *.mhd volumes
brayns/common/scene/Scene.h
Outdated
@@ -109,6 +109,22 @@ class Scene : public BaseObject | |||
|
|||
BRAYNS_API virtual ModelPtr createModel() const = 0; | |||
|
|||
/** | |||
* Create a volume with the given dimension, voxel spacing and data type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's volume dimensions (in plural form)
brayns/common/volume/BrickedVolume.h
Outdated
} | ||
|
||
virtual void setBrick(void* data, const Vector3ui& position, | ||
const Vector3ui& size) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the size of the bricks does not have to be fixed in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, can be different for each brick if desired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's interesting, I'd like to learn how Ospray handles that. I wonder what happens in case of overlapping bricks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no overlap, it just overrides potential existing voxels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see that the class documentation says the bricks are copied. Last thing, shouldn't the data* be const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to const_cast it then to pass it to ospray... Though they use const data internally behind the API...
* Convenience function to use voxels from given file and pass them to | ||
* setVoxels(). | ||
*/ | ||
void setData(const std::string& filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest mapData(filename)
plugins/engines/ospray/OSPRayScene.h
Outdated
@@ -50,32 +50,33 @@ class OSPRayScene : public Scene | |||
bool commitLights() final; | |||
|
|||
void commitSimulationData(); | |||
void commitVolumeData(); | |||
bool commitVolumeData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this return value is a bit obscure; I would imagine that it indicates a possible failure, but after checking the code that's not the case... I think a separate getter for rebuildScene is preferable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't make it better imo. That functions is private anyways, I'll do that first and we can discuss if you like.
// voxelColor.x = voxelColor.x * giAttenuation; | ||
// voxelColor.y = voxelColor.y * giAttenuation; | ||
// voxelColor.z = voxelColor.z * giAttenuation; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of commented code here, is there a good reason not to delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@favreau has to adapt the shaders to use the ospray volumes.
brayns/io/VolumeLoader.cpp
Outdated
dataRange = {std::numeric_limits<int32_t>::min() / 100, | ||
std::numeric_limits<int32_t>::max() / 100}; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can easily be a helper function
c912666
to
8aa2a29
Compare
The default camera position has changed somehow, that's why the tests fail. Will look into that. |
bd65bf7
to
a512d10
Compare
VolumeHandler h and cpp can be removed, right? |
Yes, I forgot the header file somehow. Thx for the hint! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, looks good enough already, although a few things are still not very clear to me.
brayns/common/scene/Model.h
Outdated
const Volumes& getVolumes() const { return _volumes; } | ||
bool isVolumesDirty() const { return _volumesDirty; } | ||
void resetVolumesDirty() { _volumesDirty = false; } | ||
void updateSizeInBytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public?
@@ -324,6 +335,9 @@ class Model | |||
bool _sdfGeometriesDirty{false}; | |||
bool _instancesDirty{true}; | |||
|
|||
Volumes _volumes; | |||
bool _volumesDirty{true}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all other entities are dirty by default as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that things are dirty by default but OK. Just FYI there is also bool _sdfGeometriesDirty{false};
brayns/io/VolumeLoader.cpp
Outdated
{"element-spacing", std::to_string(spacing.x()) + " " + | ||
std::to_string(spacing.y()) + | ||
" " + | ||
std::to_string(spacing.z())}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providing a std::to_string(vector) would make this a lot cleaner
else | ||
{ | ||
dimensions = _volumeParameters.getDimensions(); | ||
spacing = _volumeParameters.getElementSpacing(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here only these 2 properties from VolumeParameters are used (which are the same as passed to the Volume constructor(s)). But I'm not sure they should be in the VolumeParameters class, because if you load an mhd then the dimensions of the Volume won't match with the VolumeParameters anymore (so they only act as default values, but that's kind of confusing).
I have the impression that {dimensions+spacing+type} could go into a separate class/struct (named VolumeParameters) that can be used here (stored as _defaultVolumeParameters) and maybe also used in Volume(s), while the rest of the class VolumeParameters is renamed to VolumeRenderingParameters.
Otherwise, if we want to keep the VolumeParameters (including dimensions) as a whole, then it should be updated from here to keep matching the size of what was loaded...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parameters are the fallback if you don't have an mhd. They should be updated at best today if an mhd was provided.
@@ -78,12 +78,12 @@ OSPRayScene::~OSPRayScene() | |||
void OSPRayScene::commit() | |||
{ | |||
const bool rebuildScene = isModified(); | |||
const bool addRemoveVolumes = _commitVolumeData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without knowing too much, I still find the logic here convoluted. I don't know why the isModified() is checked before _commitSimulationData and commitTransferFunctionData and what's so different with _commitVolumeData... Couldn't they just set the isModified() flag as needed, and then we would "ideally" have a commit() function that looks like this:
void OSPRayScene::commit()
{
_commitVolumeData();
_commitSimulationData();
_commitTransferFunctionData();
if (isModified())
_rebuildScene();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the modified state is also evaluated outside after this function to clear the framebuffer for instance. This happens if for instance the transfer function has changed, hence _commitTransferFunctionData() updates the modified state in the scene. But it does not require a rebuild of the scene, so the state is stored explicitly before.
- use OSPRay volume and transfer function to support volume rendering - add VolumeLoader for *.raw and *.mhd volumes