![]() |
| GPU based Ray Marcher for Production Volume Renderer |
I had to put the video on vimeo as youtube is occassionally blocked in my country. The PVR code to model this volume is follows. This is based of the example python code from Chapter 1.
#include < pvr/Modeler.h >
#include < pvr/Primitives/Rasterization/PyroclasticPoint.h >
#include < pvr/Renderer.h >
#include < pvr/RaymarchSamplers/PhysicalSampler.h >
#include < pvr/Raymarchers/UniformRaymarcher.h >
#include < pvr/Camera.h >
#include < pvr/Occluders/OtfTransmittanceMapOccluder.h >
#include < pvr/Lights/PointLight.h >
#include < pvr/Volumes/VoxelVolume.h >
#include < Imath/ImathVec.h >
#include < pvr/VoxelBuffer.h >
void GenerateVolumeData(std::vector < GLubyte > & buffer, int& xdim, int& ydim, int& zdim) {
pvr::Model::Modeler::Ptr modeler = pvr::Model::Modeler::create();
pvr::Model::ModelerInput::Ptr input = pvr::Model::ModelerInput::create();
pvr::Geo::Particles::Ptr parts = pvr::Geo::Particles::create();
pvr::Geo::Geometry::Ptr geo = pvr::Geo::Geometry::create();
pvr::Model::Prim::Rast::PyroclasticPoint::Ptr prim = pvr::Model::Prim::Rast::PyroclasticPoint::create();
parts - > add(1);
geo - > setParticles(parts);
pvr::Util::ParamMap map;
map.floatMap["amplitude"] = 0.5f;
prim - > setParams(map);
input - > setGeometry(geo);
input - > setVolumePrimitive(prim);
modeler - > addInput(input);
modeler - > updateBounds();
modeler - > setResolution(200);
modeler - > execute();
pvr::VoxelBuffer::Ptr buf = modeler - > buffer();
Imath::V3i res = buf - > dataResolution();
xdim = res.x;
ydim = res.y;
zdim = res.z;
int index = 0;
for(pvr::VoxelBuffer::iterator i = buf - > begin(); i!= buf - > end(); ++i)
{
Imath::V3f value = *i;
buffer.push_back((GLubyte)(value.x*255));
buffer.push_back((GLubyte)(value.y*255));
buffer.push_back((GLubyte)(value.z*255));
}
}


