40bool SphericalGrid::Cell::compareOccludersByShallowestPoint(
const SphericalGrid::OccluderData *
a,
41 const SphericalGrid::OccluderData *
b)
43 return a->shallowest <
b->shallowest;
46void SphericalGrid::Cell::indexPolygons()
49 sort(
faces.begin(),
faces.end(), compareOccludersByShallowestPoint);
56 : _target(SphericalGrid::
Transform::sphericalProjection(center)), _foundOccludee(
false)
60#if SPHERICAL_GRID_LOGGING
62 cout <<
"Searching for occluders of edge centered at " << _target <<
" in cell ["
63 << _cell->boundary[0] <<
", " << _cell->boundary[1] <<
", " << _cell->boundary[2] <<
", "
64 << _cell->boundary[3] <<
"] (" << _cell->faces.size() <<
" occluders)" << endl;
69 _current = _cell->faces.begin();
83 cout <<
"Generate Cell structure" << endl;
88 cout <<
"Distribute occluders" << endl;
93 cout <<
"Reorganize cells" << endl;
98 cout <<
"Ready to use SphericalGrid" << endl;
109 _cellsX = density.
cellsX();
110 _cellsY = density.
cellsY();
114 cout <<
"Using " << _cellsX <<
"x" << _cellsY <<
" cells of size " << _cellSize <<
" square."
116 cout <<
"Cell origin: " << _cellOrigin[0] <<
", " << _cellOrigin[1] << endl;
120 _cells.resize(_cellsX * _cellsY);
121 for (cellContainer::iterator i = _cells.begin(), end = _cells.end(); i != end; ++i) {
127 for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; ++f)
129 if ((*f)->isInImage()) {
130 Vec3r point = SphericalGrid::Transform::sphericalProjection((*f)->center3d());
132 getCellCoordinates(
point, i, j);
133 if (_cells[i * _cellsY + j] ==
nullptr) {
137 x = _cellOrigin[0] + _cellSize * i;
140 y = _cellOrigin[1] + _cellSize * j;
144 Cell *
b = _cells[i * _cellsY + j] =
new Cell();
145 b->setDimensions(
x,
y, width, height);
154 ulong nKeptFaces = 0;
161 _faces.push_back(occluder);
175 cout <<
"Distributed " << nFaces <<
" occluders. Retained " << nKeptFaces <<
"." << endl;
182 for (vector<Cell *>::iterator i = _cells.begin(), end = _cells.end(); i != end; ++i) {
184 (*i)->indexPolygons();
198 getCellCoordinates(
point,
x,
y);
199 return _cells[
x * _cellsY +
y];
222Vec3r SphericalGrid::Transform::sphericalProjection(
const Vec3r &
M)
226 newPoint[0] = ::atan(
M[0] /
M[2]);
227 newPoint[1] = ::atan(
M[1] /
M[2]);
228 newPoint[2] =
::sqrt(
M[0] *
M[0] +
M[1] *
M[1] +
M[2] *
M[2]);
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
Class to define a cell grid surrounding the projected image of a scene.
static DBVT_INLINE btDbvtNode * sort(btDbvtNode *n, btDbvtNode *&r)
float cellOrigin(int index)
Iterator(SphericalGrid &grid, Vec3r ¢er, real epsilon=1.0e-06)
void assignCells(OccluderSource &source, GridDensityProvider &density, ViewMap *viewMap)
const Vec3r & viewpoint() const
bool orthographicProjection() const
Cell * findCell(const Vec3r &point)
void distributePolygons(OccluderSource &source)
bool insertOccluder(OccluderSource &source, OccluderData *&occluder)
vector< FEdge * > fedges_container
fedges_container & FEdges()
local_group_size(16, 16) .push_constant(Type b
ccl_device_inline float2 floor(const float2 a)
VecMat::Vec3< real > Vec3r
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.