48 if ((1 == i) || (size - 2 == i)) {
49 v->attribute().setThickness(_thickness / 4.0, _thickness / 4.0);
51 if ((0 == i) || (size - 1 == i)) {
52 v->attribute().setThickness(0, 0);
55 v->attribute().setThickness(_thickness / 2.0, _thickness / 2.0);
68 if ((1 == i) || (size - 2 == i)) {
69 v->attribute().setThickness(_thickness / 2.0, 0);
71 if ((0 == i) || (size - 1 == i)) {
72 v->attribute().setThickness(0, 0);
75 v->attribute().setThickness(_thickness, 0);
88 if (i <
float(n) / 2.0f) {
89 t = (1.0 -
float(i) /
float(n)) * _ThicknessMin +
float(i) /
float(n) * _ThicknessMax;
92 t = (1.0 -
float(i) /
float(n)) * _ThicknessMax +
float(i) /
float(n) * _ThicknessMin;
94 v->attribute().setThickness(t / 2.0, t / 2.0);
102 float maxT =
min(_ratio * slength, _ThicknessMax);
111 if (i <
float(n) / 2.0f) {
112 t = (1.0 -
float(i) /
float(n)) * _ThicknessMin +
float(i) /
float(n) * maxT;
115 t = (1.0 -
float(i) /
float(n)) * maxT +
float(i) /
float(n) * _ThicknessMin;
117 v->attribute().setThickness(t / 2.0, t / 2.0);
119 v->attribute().setThickness(_ThicknessMin / 2.0, _ThicknessMin / 2.0);
127 float step = (_maxThickness - _minThickness) / 3.0f;
129 float thickness = 0.0f;
131 thickness = _minThickness + 3.0f * step;
133 else if ((
l < 300.0f) && (
l > 100.0f)) {
134 thickness = _minThickness + 2.0f * step;
136 else if ((
l < 100.0f) && (
l > 50.0f)) {
137 thickness = _minThickness + 1.0f * step;
140 thickness = _minThickness;
149 if ((1 == i) || (size - 2 == i)) {
150 v->attribute().setThickness(thickness / 4.0, thickness / 4.0);
152 if ((0 == i) || (size - 1 == i)) {
153 v->attribute().setThickness(0, 0);
156 v->attribute().setThickness(thickness / 2.0, thickness / 2.0);
171 _amplitude = iAmplitude;
190 const float *originalThickness =
v->attribute().getThickness();
191 float r = bruit * _amplitude + originalThickness[0];
192 float l = bruit2 * _amplitude + originalThickness[1];
193 v->attribute().setThickness(r,
l);
208 v->attribute().setColor(_color[0], _color[1], _color[2]);
209 v->attribute().setAlpha(_color[3]);
222 for (
int i = 0; i < 4; ++i) {
223 newcolor[i] = (1.0 -
float(yo) /
float(n)) * _colorMin[i] +
224 float(yo) /
float(n) * _colorMax[i];
226 v->attribute().setColor(newcolor[0], newcolor[1], newcolor[2]);
227 v->attribute().setAlpha(newcolor[3]);
244 diffuse[0] * _coefficient, diffuse[1] * _coefficient, diffuse[2] * _coefficient);
258 _amplitude = iAmplitude;
273 const float *originalColor =
v->attribute().getColor();
274 float r = bruit * _amplitude + originalColor[0];
275 float g = bruit * _amplitude + originalColor[1];
276 float b = bruit * _amplitude + originalColor[2];
277 v->attribute().setColor(r, g,
b);
325 Vec2d first((v0)->
x(), (v0)->
y());
326 Vec2d last((vn)->
x(), (vn)->
y());
333 Vec2d newFirst(first + _amount * d1);
334 (v0)->setPoint(newFirst[0], newFirst[1]);
335 Vec2d newLast(last + _amount * dn);
336 (vn)->setPoint(newLast[0], newLast[1]);
361 Vec2d newPoint(sv->
x() + _amount * n.
x(), sv->
y() + _amount * n.
y());
362 sv->
setPoint(newPoint[0], newPoint[1]);
378 data.emplace_back(
v->x(),
v->y());
385 data.emplace_back(
v->x(),
v->y());
394 vector<Vec2d> CurveVertices;
395 vector<BezierCurveSegment *> &bsegments = bcurve.
segments();
396 vector<BezierCurveSegment *>::iterator s = bsegments.begin(), send;
397 vector<Vec2d> &segmentsVertices = (*s)->vertices();
398 vector<Vec2d>::iterator p, pend;
400 CurveVertices.push_back(segmentsVertices[0]);
401 for (send = bsegments.end(); s != send; ++s) {
402 segmentsVertices = (*s)->vertices();
403 p = segmentsVertices.begin();
405 for (pend = segmentsVertices.end(); p != pend; ++p) {
406 CurveVertices.push_back(*p);
411 int originalSize = CurveVertices.size();
418 int nExtraVertex = 0;
419 if (newsize < originalSize) {
420 cerr <<
"Warning: insufficient resampling" << endl;
423 nExtraVertex = newsize - originalSize;
424 if (nExtraVertex != 0) {
426 cout <<
"Bezier Shader : Stroke " << stroke.
getId() <<
" have not been resampled" << endl;
432 p = CurveVertices.begin();
433 vector<Vec2d>::iterator last = p;
439 pend = CurveVertices.end();
440 (it != itend) && (p != pend);
450 if (nExtraVertex == 0) {
455 vector<StrokeAttribute> attributes;
456 vector<StrokeVertex *> verticesToRemove;
457 for (
int i = 0; i < nExtraVertex; ++i, ++it, ++n) {
458 verticesToRemove.push_back(&(*it));
462 cout <<
"messed up!" << endl;
467 attributes.push_back(it->attribute());
470 for (vector<StrokeVertex *>::iterator vr = verticesToRemove.begin(),
471 vrend = verticesToRemove.end();
478 vector<StrokeAttribute>::iterator a = attributes.begin(), aend = attributes.end();
480 int index1 =
int(
floor(
float(originalSize) / 2.0));
481 int index2 = index1 + nExtraVertex;
483 (it != itend) && (a != aend);
486 (it)->setAttribute(*a);
487 if ((index <= index1) || (index > index2)) {
520 Vec2d P(it->x(), it->y());
539 for (
int i = 0; i < ns1; ++it, ++i) {
553 vector<CurvePiece *> _pieces;
554 vector<CurvePiece *> _results;
555 vector<CurvePiece *>::iterator cp, cpend;
564 _pieces.push_back(piece);
566 while (!_pieces.empty()) {
567 piece = _pieces.back();
569 if (piece->
size > 2 && piece->
error() > _error) {
571 _pieces.push_back(second);
572 _pieces.push_back(piece);
575 _results.push_back(piece);
580 for (cp = _results.begin(), cpend = _results.end(); cp != cpend; ++cp) {
583 Vec2d u = (*cp)->B - (*cp)->A;
584 Vec2d n(u[1], -u[0]);
587 float offset = ((*cp)->_error);
589 for (
v = a;
v !=
b; ++
v) {
590 v->setPoint((*cp)->A.x() +
v->u() * u.
x() + n.
x() * offset,
591 (*cp)->A.y() +
v->u() * u.
y() + n.
y() * offset);
595 (*a)->setPoint((*a)->x() - u.
x() * 10, (*a)->y() - u.
y() * 10);
601 for (cp = _results.begin(), cpend = _results.end(); cp != cpend; ++cp) {
618 Vec2f n(u[1], -u[0]);
620 if (norm_fun(stroke) < 0) {
624 if (n * strokeN < 0) {
628 float offset = piece.
error() / 2.0f * _offset;
631 v->setPoint(piece.
A.
x() +
v->u() * u.
x() + n.
x() * offset,
632 piece.
A.
y() +
v->u() * u.
y() + n.
y() * offset);
653 if (originalSize < 4) {
658 vector<StrokeVertex *> verticesToRemove;
659 vector<StrokeAttribute> oldAttributes;
662 (
v->strokeLength() -
v->curvilinearAbscissa() <
_tipLength))
664 verticesToRemove.push_back(&(*
v));
666 oldAttributes.push_back(
v->attribute());
669 if (originalSize - verticesToRemove.size() < 2) {
673 vector<StrokeVertex *>::iterator sv, svend;
674 for (sv = verticesToRemove.begin(), svend = verticesToRemove.end(); sv != svend; ++sv) {
682 cerr <<
"Warning: resampling problem" << endl;
686 vector<StrokeAttribute>::iterator a = oldAttributes.begin(), aend = oldAttributes.end();
688 (
v != vend) && (a != aend);
Functions taking 0D input.
Functions taking 1D input.
Class gathering basic stroke shaders.
Functions taking 0D input.
Functions taking 1D input.
Contains defines and structs used throughout the imbuf module.
Class to define a pseudo Perlin noise.
Pseudo-random number generator.
Functions to manage I/O for the stroke.
Iterators used to iterate over the elements of the Stroke.
Classes to render a stroke with OpenGL.
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
std::vector< BezierCurveSegment * > & segments()
const float * diffuse() const
real turbulenceSmooth(real x, uint nbOctave=8)
void setColor(float r, float g, float b)
void setAlpha(float alpha)
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
! Bezier curve stroke shader
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
StrokeInternal::StrokeVertexIterator _begin
CurvePiece * subdivide()
Subdivides the curve into two pieces.
StrokeInternal::StrokeVertexIterator _last
CurvePiece(StrokeInternal::StrokeVertexIterator b, StrokeInternal::StrokeVertexIterator l, int iSize)
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
virtual int shade(Stroke &stroke) const
TipRemoverShader(real tipLength)
void setPoint(real x, real y)
const StrokeAttribute & attribute() const
void setTextureStep(float step)
virtual Interface0DIterator verticesBegin()
void RemoveVertex(StrokeVertex *iVertex)
virtual Interface0DIterator verticesEnd()
uint strokeVerticesSize() const
float ComputeSampling(int iNVertices)
StrokeInternal::StrokeVertexIterator strokeVerticesEnd()
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t=0.0f)
void setNodeTree(bNodeTree *iNodeTree)
int Resample(int iNPoints)
Vec< T, N > & normalize()
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float2 fabs(const float2 a)
real distPointSegment(const T &P, const T &A, const T &B)
VecMat::Vec2< double > Vec2d
static const uint NB_VALUE_NOISE
static const real M_EPSILON