Skip to content
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

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

tribal-tec
Copy link
Contributor

  • use OSPRay volume and transfer function to support volume rendering
  • add VolumeLoader for *.raw and *.mhd volumes

@tribal-tec tribal-tec requested review from favreau and rdumusc July 2, 2018 13:13
@@ -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
Copy link

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)

}

virtual void setBrick(void* data, const Vector3ui& position,
const Vector3ui& size) = 0;
Copy link

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?

Copy link
Contributor Author

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

Copy link

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.

Copy link
Contributor Author

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.

Copy link

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?

Copy link
Contributor Author

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);
Copy link

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)

@@ -50,32 +50,33 @@ class OSPRayScene : public Scene
bool commitLights() final;

void commitSimulationData();
void commitVolumeData();
bool commitVolumeData();
Copy link

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

Copy link
Contributor Author

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;
// }
Copy link

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?

Copy link
Contributor Author

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.

dataRange = {std::numeric_limits<int32_t>::min() / 100,
std::numeric_limits<int32_t>::max() / 100};
break;
}
Copy link

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

@tribal-tec tribal-tec force-pushed the volume_final branch 2 times, most recently from c912666 to 8aa2a29 Compare July 3, 2018 08:35
@tribal-tec
Copy link
Contributor Author

The default camera position has changed somehow, that's why the tests fail. Will look into that.

@tribal-tec tribal-tec force-pushed the volume_final branch 2 times, most recently from bd65bf7 to a512d10 Compare July 4, 2018 09:26
@favreau
Copy link
Member

favreau commented Jul 4, 2018

VolumeHandler h and cpp can be removed, right?

@tribal-tec
Copy link
Contributor Author

Yes, I forgot the header file somehow. Thx for the hint!

Copy link

@rdumusc rdumusc left a 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.

const Volumes& getVolumes() const { return _volumes; }
bool isVolumesDirty() const { return _volumesDirty; }
void resetVolumesDirty() { _volumesDirty = false; }
void updateSizeInBytes();
Copy link

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};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not false?

Copy link
Contributor Author

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.

Copy link

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

{"element-spacing", std::to_string(spacing.x()) + " " +
std::to_string(spacing.y()) +
" " +
std::to_string(spacing.z())}});
Copy link

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();
Copy link

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...

Copy link
Contributor Author

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();
Copy link

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

Copy link
Contributor Author

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
@tribal-tec tribal-tec merged commit 93a9ea3 into BlueBrain:master Jul 10, 2018
@tribal-tec tribal-tec deleted the volume_final branch July 10, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants