Blender  V3.3
BlenderStrokeRenderer.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 
9 #include "../application/AppConfig.h"
10 #include "../stroke/Canvas.h"
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "RNA_access.h"
15 #include "RNA_prototypes.h"
16 #include "RNA_types.h"
17 
18 #include "DNA_camera_types.h"
19 #include "DNA_collection_types.h"
20 #include "DNA_linestyle_types.h"
21 #include "DNA_listBase.h"
22 #include "DNA_material_types.h"
23 #include "DNA_mesh_types.h"
24 #include "DNA_meshdata_types.h"
25 #include "DNA_object_types.h"
26 #include "DNA_scene_types.h"
27 #include "DNA_screen_types.h"
28 
29 #include "BKE_collection.h"
30 #include "BKE_customdata.h"
31 #include "BKE_global.h"
32 #include "BKE_idprop.h"
33 #include "BKE_layer.h"
34 #include "BKE_lib_id.h" /* free_libblock */
35 #include "BKE_material.h"
36 #include "BKE_mesh.h"
37 #include "BKE_node.h"
38 #include "BKE_node_tree_update.h"
39 #include "BKE_object.h"
40 #include "BKE_scene.h"
41 
42 #include "BLI_ghash.h"
43 #include "BLI_listbase.h"
44 #include "BLI_math_color.h"
45 #include "BLI_math_vector.h"
46 #include "BLI_utildefines.h"
47 
48 #include "DEG_depsgraph.h"
49 #include "DEG_depsgraph_build.h"
50 
51 #include "RE_pipeline.h"
52 
53 #include "render_types.h"
54 
55 #include <climits>
56 
57 namespace Freestyle {
58 
59 const char *BlenderStrokeRenderer::uvNames[] = {"along_stroke", "along_stroke_tips"};
60 
62 {
64 
65  /* We use the same window manager for freestyle bmain as
66  * real bmain uses. This is needed because freestyle's
67  * bmain could be used to tag scenes for update, which
68  * implies call of ED_render_scene_update in some cases
69  * and that function requires proper window manager
70  * to present (sergey)
71  */
72  freestyle_bmain->wm = re->main->wm;
73 
74  // for stroke mesh generation
75  _width = re->winx;
76  _height = re->winy;
77 
78  old_scene = re->scene;
79 
80  char name[MAX_ID_NAME - 2];
81  BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2);
85  freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch
86  freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch
87  freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp;
88  freestyle_scene->r.yasp = 1.0f; // old_scene->r.yasp;
89  freestyle_scene->r.size = 100; // old_scene->r.size
90  freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag;
93  (re->r.scemode);
100  strcpy(freestyle_scene->r.pic, old_scene->r.pic);
103  if (G.debug & G_DEBUG_FREESTYLE) {
104  cout << "Stroke rendering engine : " << freestyle_scene->r.engine << endl;
105  }
108 
109  // Copy ID properties, including Cycles render properties
110  if (old_scene->id.properties) {
112  }
113  // Copy eevee render settings.
115 
116  /* Render with transparent background. */
118 
119  if (G.debug & G_DEBUG_FREESTYLE) {
120  printf("%s: %d thread(s)\n", __func__, BKE_render_num_threads(&freestyle_scene->r));
121  }
122 
124 
125  // Scene layer.
127  view_layer->layflag = SCE_LAY_SOLID;
128 
129  // Camera
130  Object *object_camera = BKE_object_add(freestyle_bmain, view_layer, OB_CAMERA, nullptr);
131 
132  Camera *camera = (Camera *)object_camera->data;
133  camera->type = CAM_ORTHO;
134  camera->ortho_scale = max(re->rectx, re->recty);
135  camera->clip_start = 0.1f;
136  camera->clip_end = 100.0f;
137 
138  _z_delta = 0.00001f;
139  _z = camera->clip_start + _z_delta;
140 
141  object_camera->loc[0] = re->disprect.xmin + 0.5f * re->rectx;
142  object_camera->loc[1] = re->disprect.ymin + 0.5f * re->recty;
143  object_camera->loc[2] = 1.0f;
144 
145  freestyle_scene->camera = object_camera;
146 
147  // Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh())
148  _mesh_id = 0xffffffff;
149 
150  // Create a bNodeTree-to-Material hash table
151  _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash");
152 
153  // Depsgraph
159 }
160 
162 {
163  BLI_ghash_free(_nodetree_hash, nullptr, nullptr);
164 
166 
168 
169  /* detach the window manager from freestyle bmain (see comments
170  * in add_freestyle() for more detail)
171  */
173 
175 }
176 
178 {
179  float z = _z;
180  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
181  if (!(_z < _z_delta * 100000.0f)) {
182  self->_z_delta *= 10.0f;
183  }
184  self->_z += _z_delta;
185  return -z;
186 }
187 
189 {
190  unsigned mesh_id = _mesh_id;
191  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
192  self->_mesh_id--;
193  return mesh_id;
194 }
195 
197  bNodeTree *iNodeTree,
198  bool do_id_user)
199 {
200  Material *ma = BKE_material_add(bmain, "stroke_shader");
201  bNodeTree *ntree;
202  bNode *output_linestyle = nullptr;
203  bNodeSocket *fromsock, *tosock;
204  PointerRNA fromptr, toptr;
205  NodeShaderAttribute *storage;
206 
207  id_us_min(&ma->id);
208 
209  if (iNodeTree) {
210  // make a copy of linestyle->nodetree
211  ntree = ntreeCopyTree_ex(iNodeTree, bmain, do_id_user);
212 
213  // find the active Output Line Style node
214  for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
215  if (node->type == SH_NODE_OUTPUT_LINESTYLE && (node->flag & NODE_DO_OUTPUT)) {
216  output_linestyle = node;
217  break;
218  }
219  }
220  }
221  else {
222  ntree = ntreeAddTree(nullptr, "stroke_shader", "ShaderNodeTree");
223  }
224  ma->nodetree = ntree;
225  ma->use_nodes = 1;
227 
228  bNode *input_attr_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
229  input_attr_color->locx = 0.0f;
230  input_attr_color->locy = -200.0f;
231  storage = (NodeShaderAttribute *)input_attr_color->storage;
232  BLI_strncpy(storage->name, "Color", sizeof(storage->name));
233 
234  bNode *mix_rgb_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
235  mix_rgb_color->custom1 = MA_RAMP_BLEND; // Mix
236  mix_rgb_color->locx = 200.0f;
237  mix_rgb_color->locy = -200.0f;
238  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 0); // Fac
239  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
240  RNA_float_set(&toptr, "default_value", 0.0f);
241 
242  bNode *input_attr_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
243  input_attr_alpha->locx = 400.0f;
244  input_attr_alpha->locy = 300.0f;
245  storage = (NodeShaderAttribute *)input_attr_alpha->storage;
246  BLI_strncpy(storage->name, "Alpha", sizeof(storage->name));
247 
248  bNode *mix_rgb_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
249  mix_rgb_alpha->custom1 = MA_RAMP_BLEND; // Mix
250  mix_rgb_alpha->locx = 600.0f;
251  mix_rgb_alpha->locy = 300.0f;
252  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 0); // Fac
253  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
254  RNA_float_set(&toptr, "default_value", 0.0f);
255 
256  bNode *shader_emission = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION);
257  shader_emission->locx = 400.0f;
258  shader_emission->locy = -200.0f;
259 
260  bNode *input_light_path = nodeAddStaticNode(nullptr, ntree, SH_NODE_LIGHT_PATH);
261  input_light_path->locx = 400.0f;
262  input_light_path->locy = 100.0f;
263 
264  bNode *mix_shader_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
265  mix_shader_color->locx = 600.0f;
266  mix_shader_color->locy = -100.0f;
267 
268  bNode *shader_transparent = nodeAddStaticNode(nullptr, ntree, SH_NODE_BSDF_TRANSPARENT);
269  shader_transparent->locx = 600.0f;
270  shader_transparent->locy = 100.0f;
271 
272  bNode *mix_shader_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
273  mix_shader_alpha->locx = 800.0f;
274  mix_shader_alpha->locy = 100.0f;
275 
276  bNode *output_material = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_MATERIAL);
277  output_material->locx = 1000.0f;
278  output_material->locy = 100.0f;
279 
280  fromsock = (bNodeSocket *)BLI_findlink(&input_attr_color->outputs, 0); // Color
281  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 1); // Color1
282  nodeAddLink(ntree, input_attr_color, fromsock, mix_rgb_color, tosock);
283 
284  fromsock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->outputs, 0); // Color
285  tosock = (bNodeSocket *)BLI_findlink(&shader_emission->inputs, 0); // Color
286  nodeAddLink(ntree, mix_rgb_color, fromsock, shader_emission, tosock);
287 
288  fromsock = (bNodeSocket *)BLI_findlink(&shader_emission->outputs, 0); // Emission
289  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_color->inputs, 2); // Shader (second)
290  nodeAddLink(ntree, shader_emission, fromsock, mix_shader_color, tosock);
291 
292  fromsock = (bNodeSocket *)BLI_findlink(&input_light_path->outputs, 0); // In Camera Ray
293  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_color->inputs, 0); // Fac
294  nodeAddLink(ntree, input_light_path, fromsock, mix_shader_color, tosock);
295 
296  fromsock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->outputs, 0); // Color
297  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 0); // Fac
298  nodeAddLink(ntree, mix_rgb_alpha, fromsock, mix_shader_alpha, tosock);
299 
300  fromsock = (bNodeSocket *)BLI_findlink(&input_attr_alpha->outputs, 0); // Color
301  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 1); // Color1
302  nodeAddLink(ntree, input_attr_alpha, fromsock, mix_rgb_alpha, tosock);
303 
304  fromsock = (bNodeSocket *)BLI_findlink(&shader_transparent->outputs, 0); // BSDF
305  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 1); // Shader (first)
306  nodeAddLink(ntree, shader_transparent, fromsock, mix_shader_alpha, tosock);
307 
308  fromsock = (bNodeSocket *)BLI_findlink(&mix_shader_color->outputs, 0); // Shader
309  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 2); // Shader (second)
310  nodeAddLink(ntree, mix_shader_color, fromsock, mix_shader_alpha, tosock);
311 
312  fromsock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->outputs, 0); // Shader
313  tosock = (bNodeSocket *)BLI_findlink(&output_material->inputs, 0); // Surface
314  nodeAddLink(ntree, mix_shader_alpha, fromsock, output_material, tosock);
315 
316  if (output_linestyle) {
317  bNodeSocket *outsock;
318  bNodeLink *link;
319 
320  mix_rgb_color->custom1 = output_linestyle->custom1; // blend_type
321  mix_rgb_color->custom2 = output_linestyle->custom2; // use_clamp
322 
323  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 0); // Color
324  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 2); // Color2
325  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
326  if (link) {
327  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_color, tosock);
328  }
329  else {
330  float color[4];
331  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
332  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
333  RNA_float_get_array(&fromptr, "default_value", color);
334  RNA_float_set_array(&toptr, "default_value", color);
335  }
336 
337  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 1); // Color Fac
338  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 0); // Fac
339  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
340  if (link) {
341  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_color, tosock);
342  }
343  else {
344  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
345  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
346  RNA_float_set(&toptr, "default_value", RNA_float_get(&fromptr, "default_value"));
347  }
348 
349  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 2); // Alpha
350  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 2); // Color2
351  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
352  if (link) {
353  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_alpha, tosock);
354  }
355  else {
356  float color[4];
357  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
358  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
359  color[0] = color[1] = color[2] = RNA_float_get(&fromptr, "default_value");
360  color[3] = 1.0f;
361  RNA_float_set_array(&toptr, "default_value", color);
362  }
363 
364  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 3); // Alpha Fac
365  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 0); // Fac
366  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
367  if (link) {
368  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_alpha, tosock);
369  }
370  else {
371  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
372  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
373  RNA_float_set(&toptr, "default_value", RNA_float_get(&fromptr, "default_value"));
374  }
375 
376  for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
377  if (node->type == SH_NODE_UVALONGSTROKE) {
378  // UV output of the UV Along Stroke node
379  bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->outputs, 0);
380 
381  // add new UV Map node
382  bNode *input_uvmap = nodeAddStaticNode(nullptr, ntree, SH_NODE_UVMAP);
383  input_uvmap->locx = node->locx - 200.0f;
384  input_uvmap->locy = node->locy;
385  NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage;
386  if (node->custom1 & 1) { // use_tips
387  BLI_strncpy(storage->uv_map, uvNames[1], sizeof(storage->uv_map));
388  }
389  else {
390  BLI_strncpy(storage->uv_map, uvNames[0], sizeof(storage->uv_map));
391  }
392  fromsock = (bNodeSocket *)BLI_findlink(&input_uvmap->outputs, 0); // UV
393 
394  // replace links from the UV Along Stroke node by links from the UV Map node
395  for (bNodeLink *link = (bNodeLink *)ntree->links.first; link; link = link->next) {
396  if (link->fromnode == node && link->fromsock == sock) {
397  nodeAddLink(ntree, input_uvmap, fromsock, link->tonode, link->tosock);
398  }
399  }
400  nodeRemSocketLinks(ntree, sock);
401  }
402  }
403  }
404 
405  nodeSetActive(ntree, output_material);
406  BKE_ntree_update_main_tree(bmain, ntree, nullptr);
407 
408  return ma;
409 }
410 
412 {
413  RenderStrokeRepBasic(iStrokeRep);
414 }
415 
417 {
418  bNodeTree *nt = iStrokeRep->getNodeTree();
420  if (!ma) {
423  }
424  iStrokeRep->setMaterial(ma);
425 
426  const vector<Strip *> &strips = iStrokeRep->getStrips();
427  const bool hasTex = iStrokeRep->hasTex();
428  int totvert = 0, totedge = 0, totpoly = 0, totloop = 0;
429  int visible_faces, visible_segments;
430  for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
431  Strip::vertex_container &strip_vertices = (*s)->vertices();
432 
433  // count visible faces and strip segments
434  test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
435  if (visible_faces == 0) {
436  continue;
437  }
438 
439  totvert += visible_faces + visible_segments * 2;
440  totedge += visible_faces * 2 + visible_segments;
441  totpoly += visible_faces;
442  totloop += visible_faces * 3;
443  }
444 
445  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this); // FIXME
446  vector<StrokeGroup *> *groups = hasTex ? &self->texturedStrokeGroups : &self->strokeGroups;
447  StrokeGroup *group;
448  if (groups->empty() || !(groups->back()->totvert + totvert < MESH_MAX_VERTS &&
449  groups->back()->materials.size() + 1 < MAXMAT)) {
450  group = new StrokeGroup;
451  groups->push_back(group);
452  }
453  else {
454  group = groups->back();
455  }
456  group->strokes.push_back(iStrokeRep);
457  group->totvert += totvert;
458  group->totedge += totedge;
459  group->totpoly += totpoly;
460  group->totloop += totloop;
461 
462  if (!group->materials.contains(ma)) {
463  group->materials.add_new(ma, group->materials.size());
464  }
465 }
466 
467 // Check if the triangle is visible (i.e., within the render image boundary)
469 {
470  int xl, xu, yl, yu;
471  Vec2r p;
472 
473  xl = xu = yl = yu = 0;
474  for (int i = 0; i < 3; i++) {
475  p = svRep[i]->point2d();
476  if (p[0] < 0.0) {
477  xl++;
478  }
479  else if (p[0] > _width) {
480  xu++;
481  }
482  if (p[1] < 0.0) {
483  yl++;
484  }
485  else if (p[1] > _height) {
486  yu++;
487  }
488  }
489  return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
490 }
491 
492 // Check the visibility of faces and strip segments.
494  int *visible_faces,
495  int *visible_segments) const
496 {
497  const int strip_vertex_count = strip_vertices.size();
498  Strip::vertex_container::iterator v[3];
499  StrokeVertexRep *svRep[3];
500  bool visible;
501 
502  /* Iterate over all vertices and count visible faces and strip segments
503  * (NOTE: a strip segment is a series of visible faces, while two strip
504  * segments are separated by one or more invisible faces). */
505  v[0] = strip_vertices.begin();
506  v[1] = v[0] + 1;
507  v[2] = v[0] + 2;
508  *visible_faces = *visible_segments = 0;
509  visible = false;
510  for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
511  svRep[0] = *(v[0]);
512  svRep[1] = *(v[1]);
513  svRep[2] = *(v[2]);
514  if (test_triangle_visibility(svRep)) {
515  (*visible_faces)++;
516  if (!visible) {
517  (*visible_segments)++;
518  }
519  visible = true;
520  }
521  else {
522  visible = false;
523  }
524  }
525 }
526 
527 // Release allocated memory for stroke groups
529 {
530  vector<StrokeGroup *>::const_iterator it, itend;
531 
532  for (it = strokeGroups.begin(), itend = strokeGroups.end(); it != itend; ++it) {
533  delete (*it);
534  }
535  for (it = texturedStrokeGroups.begin(), itend = texturedStrokeGroups.end(); it != itend; ++it) {
536  delete (*it);
537  }
538 }
539 
540 // Build a scene populated by mesh objects representing stylized strokes
542 {
543  vector<StrokeGroup *>::const_iterator it, itend;
544 
545  for (it = strokeGroups.begin(), itend = strokeGroups.end(); it != itend; ++it) {
546  GenerateStrokeMesh(*it, false);
547  }
548  for (it = texturedStrokeGroups.begin(), itend = texturedStrokeGroups.end(); it != itend; ++it) {
549  GenerateStrokeMesh(*it, true);
550  }
551  return get_stroke_count();
552 }
553 
554 // Return the number of strokes
556 {
557  return strokeGroups.size() + texturedStrokeGroups.size();
558 }
559 
560 // Build a mesh object representing a group of stylized strokes
562 {
563 #if 0
564  Object *object_mesh = BKE_object_add(
567 #else
568  Object *object_mesh = NewMesh();
569 #endif
570  Mesh *mesh = (Mesh *)object_mesh->data;
571 
572  mesh->totvert = group->totvert;
573  mesh->totedge = group->totedge;
574  mesh->totpoly = group->totpoly;
575  mesh->totloop = group->totloop;
576  mesh->totcol = group->materials.size();
577 
579  &mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
581  &mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
583  &mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
585  &mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
586 
587  MVert *vertices = mesh->mvert;
588  MEdge *edges = mesh->medge;
589  MPoly *polys = mesh->mpoly;
590  MLoop *loops = mesh->mloop;
591  MLoopUV *loopsuv[2] = {nullptr};
592 
593  if (hasTex) {
594  // First UV layer
596  &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[0]);
599  loopsuv[0] = mesh->mloopuv;
600 
601  // Second UV layer
603  &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[1]);
606  loopsuv[1] = mesh->mloopuv;
607  }
608 
609  // colors and transparency (the latter represented by grayscale colors)
611  &mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Color");
613  &mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
614  mesh->mloopcol = colors;
615 
616  mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
617  for (const auto item : group->materials.items()) {
618  Material *material = item.key;
619  const int matnr = item.value;
620  mesh->mat[matnr] = material;
621  if (material) {
623  }
624  }
625 
627  // Data copy
629 
630  int vertex_index = 0, edge_index = 0, loop_index = 0;
631  int visible_faces, visible_segments;
632  bool visible;
633  Strip::vertex_container::iterator v[3];
634  StrokeVertexRep *svRep[3];
635  Vec2r p;
636 
637  for (vector<StrokeRep *>::const_iterator it = group->strokes.begin(),
638  itend = group->strokes.end();
639  it != itend;
640  ++it) {
641  const int matnr = group->materials.lookup_default((*it)->getMaterial(), 0);
642 
643  vector<Strip *> &strips = (*it)->getStrips();
644  for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
645  Strip::vertex_container &strip_vertices = (*s)->vertices();
646  int strip_vertex_count = strip_vertices.size();
647 
648  // count visible faces and strip segments
649  test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
650  if (visible_faces == 0) {
651  continue;
652  }
653 
654  v[0] = strip_vertices.begin();
655  v[1] = v[0] + 1;
656  v[2] = v[0] + 2;
657 
658  visible = false;
659 
660  // NOTE: Mesh generation in the following loop assumes stroke strips
661  // to be triangle strips.
662  for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
663  svRep[0] = *(v[0]);
664  svRep[1] = *(v[1]);
665  svRep[2] = *(v[2]);
666  if (!test_triangle_visibility(svRep)) {
667  visible = false;
668  }
669  else {
670  if (!visible) {
671  // first vertex
672  vertices->co[0] = svRep[0]->point2d()[0];
673  vertices->co[1] = svRep[0]->point2d()[1];
674  vertices->co[2] = get_stroke_vertex_z();
675 
676  ++vertices;
677  ++vertex_index;
678 
679  // second vertex
680  vertices->co[0] = svRep[1]->point2d()[0];
681  vertices->co[1] = svRep[1]->point2d()[1];
682  vertices->co[2] = get_stroke_vertex_z();
683 
684  ++vertices;
685  ++vertex_index;
686 
687  // first edge
688  edges->v1 = vertex_index - 2;
689  edges->v2 = vertex_index - 1;
690  ++edges;
691  ++edge_index;
692  }
693  visible = true;
694 
695  // vertex
696  vertices->co[0] = svRep[2]->point2d()[0];
697  vertices->co[1] = svRep[2]->point2d()[1];
698  vertices->co[2] = get_stroke_vertex_z();
699  ++vertices;
700  ++vertex_index;
701 
702  // edges
703  edges->v1 = vertex_index - 1;
704  edges->v2 = vertex_index - 3;
705  ++edges;
706  ++edge_index;
707 
708  edges->v1 = vertex_index - 1;
709  edges->v2 = vertex_index - 2;
710  ++edges;
711  ++edge_index;
712 
713  // poly
714  polys->loopstart = loop_index;
715  polys->totloop = 3;
716  polys->mat_nr = matnr;
717  ++polys;
718 
719  // Even and odd loops connect triangles vertices differently
720  bool is_odd = n % 2;
721  // loops
722  if (is_odd) {
723  loops[0].v = vertex_index - 1;
724  loops[0].e = edge_index - 2;
725 
726  loops[1].v = vertex_index - 3;
727  loops[1].e = edge_index - 3;
728 
729  loops[2].v = vertex_index - 2;
730  loops[2].e = edge_index - 1;
731  }
732  else {
733  loops[0].v = vertex_index - 1;
734  loops[0].e = edge_index - 1;
735 
736  loops[1].v = vertex_index - 2;
737  loops[1].e = edge_index - 3;
738 
739  loops[2].v = vertex_index - 3;
740  loops[2].e = edge_index - 2;
741  }
742  loops += 3;
743  loop_index += 3;
744 
745  // UV
746  if (hasTex) {
747  // First UV layer (loopsuv[0]) has no tips (texCoord(0)).
748  // Second UV layer (loopsuv[1]) has tips: (texCoord(1)).
749  for (int L = 0; L < 2; L++) {
750  if (is_odd) {
751  loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
752  loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
753 
754  loopsuv[L][1].uv[0] = svRep[0]->texCoord(L).x();
755  loopsuv[L][1].uv[1] = svRep[0]->texCoord(L).y();
756 
757  loopsuv[L][2].uv[0] = svRep[1]->texCoord(L).x();
758  loopsuv[L][2].uv[1] = svRep[1]->texCoord(L).y();
759  }
760  else {
761  loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
762  loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
763 
764  loopsuv[L][1].uv[0] = svRep[1]->texCoord(L).x();
765  loopsuv[L][1].uv[1] = svRep[1]->texCoord(L).y();
766 
767  loopsuv[L][2].uv[0] = svRep[0]->texCoord(L).x();
768  loopsuv[L][2].uv[1] = svRep[0]->texCoord(L).y();
769  }
770  loopsuv[L] += 3;
771  }
772  }
773 
774  // colors and alpha transparency. vertex colors are in sRGB
775  // space by convention, so convert from linear
776  float rgba[3][4];
777 
778  for (int i = 0; i < 3; i++) {
779  copy_v3fl_v3db(rgba[i], &svRep[i]->color()[0]);
780  rgba[i][3] = svRep[i]->alpha();
781  }
782 
783  if (is_odd) {
784  linearrgb_to_srgb_uchar4(&colors[0].r, rgba[2]);
785  linearrgb_to_srgb_uchar4(&colors[1].r, rgba[0]);
786  linearrgb_to_srgb_uchar4(&colors[2].r, rgba[1]);
787  }
788  else {
789  linearrgb_to_srgb_uchar4(&colors[0].r, rgba[2]);
790  linearrgb_to_srgb_uchar4(&colors[1].r, rgba[1]);
791  linearrgb_to_srgb_uchar4(&colors[2].r, rgba[0]);
792  }
793  transp[0].r = transp[0].g = transp[0].b = colors[0].a;
794  transp[1].r = transp[1].g = transp[1].b = colors[1].a;
795  transp[2].r = transp[2].g = transp[2].b = colors[2].a;
796  colors += 3;
797  transp += 3;
798  }
799  } // loop over strip vertices
800  } // loop over strips
801  } // loop over strokes
802 
805 
806 #if 0 // XXX
807  BLI_assert(mesh->totvert == vertex_index);
808  BLI_assert(mesh->totedge == edge_index);
809  BLI_assert(mesh->totloop == loop_index);
810  BKE_mesh_validate(mesh, true, true);
811 #endif
812 }
813 
814 // A replacement of BKE_object_add() for better performance.
816 {
817  Object *ob;
818  char name[MAX_ID_NAME];
819  unsigned int mesh_id = get_stroke_mesh_id();
820 
821  BLI_snprintf(name, MAX_ID_NAME, "0%08xOB", mesh_id);
823  BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id);
824  ob->data = BKE_mesh_add(freestyle_bmain, name);
825 
826  Collection *collection_master = freestyle_scene->master_collection;
827  BKE_collection_object_add(freestyle_bmain, collection_master, ob);
829 
832  &ob->id,
834 
835  return ob;
836 }
837 
839 {
841  if (camera->clip_end < _z) {
842  camera->clip_end = _z + _z_delta * 100.0f;
843  }
844 #if 0
845  if (G.debug & G_DEBUG_FREESTYLE) {
846  cout << "clip_start " << camera->clip_start << ", clip_end " << camera->clip_end << endl;
847  }
848 #endif
849 
850  Render *freestyle_render = RE_NewSceneRender(freestyle_scene);
852 
853  RE_RenderFreestyleStrokes(
854  freestyle_render, freestyle_bmain, freestyle_scene, render && get_stroke_count() > 0);
855 
856  return freestyle_render;
857 }
858 
859 } /* namespace Freestyle */
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
Definition: collection.c:1125
CustomData interface, see also DNA_customdata_types.h.
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
Definition: customdata.cc:2542
@ CD_CALLOC
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
Definition: customdata.cc:2792
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.cc:2776
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:181
struct IDProperty * IDP_CopyProperty_ex(const struct IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
struct Main * BKE_main_new(void)
Definition: main.c:32
void BKE_main_free(struct Main *mainvar)
Definition: main.c:40
General operations, lookup, etc. for materials.
void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id)
Definition: material.c:864
struct Material * BKE_material_add(struct Main *bmain, const char *name)
Definition: material.c:289
struct Mesh * BKE_mesh_add(struct Main *bmain, const char *name)
Definition: mesh.cc:963
bool BKE_mesh_validate(struct Mesh *me, bool do_verbose, bool cddata_check_mask)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, bool do_ensure_tess_cd)
Definition: mesh.cc:874
void BKE_mesh_normals_tag_dirty(struct Mesh *mesh)
Definition: mesh_normals.cc:95
#define SH_NODE_MIX_SHADER
Definition: BKE_node.h:1105
#define SH_NODE_UVMAP
Definition: BKE_node.h:1158
void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock)
Definition: node.cc:2455
#define SH_NODE_EMISSION
Definition: BKE_node.h:1115
#define SH_NODE_UVALONGSTROKE
Definition: BKE_node.h:1162
struct bNodeTree * ntreeCopyTree_ex(const struct bNodeTree *ntree, struct Main *bmain, bool do_id_user)
#define SH_NODE_BSDF_TRANSPARENT
Definition: BKE_node.h:1113
#define SH_NODE_OUTPUT_MATERIAL
Definition: BKE_node.h:1101
struct bNodeLink * nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock)
Definition: node.cc:2296
struct bNodeTree * ntreeAddTree(struct Main *bmain, const char *name, const char *idname)
Definition: node.cc:2674
struct bNode * nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type)
Definition: node.cc:2151
void nodeSetActive(struct bNodeTree *ntree, struct bNode *node)
Definition: node.cc:3644
#define SH_NODE_OUTPUT_LINESTYLE
Definition: BKE_node.h:1161
#define SH_NODE_ATTRIBUTE
Definition: BKE_node.h:1106
#define SH_NODE_LIGHT_PATH
Definition: BKE_node.h:1117
void BKE_ntree_update_main_tree(struct Main *bmain, struct bNodeTree *ntree, struct NodeTreeUpdateExtraParams *params)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_add(struct Main *bmain, struct ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
struct Object * BKE_object_add_only_object(struct Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
Definition: object.cc:2241
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce)
Definition: scene.cc:2075
int BKE_render_num_threads(const struct RenderData *r)
struct Scene * BKE_scene_add(struct Main *bmain, const char *name)
Definition: scene.cc:2044
void BKE_scene_copy_data_eevee(struct Scene *sce_dst, const struct Scene *sce_src)
#define BLI_assert(a)
Definition: BLI_assert.h:46
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void copy_v3fl_v3db(float r[3], const double a[3])
#define STRNCPY(dst, src)
Definition: BLI_string.h:483
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:267
void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, int flag)
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:46
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:295
void DEG_graph_tag_relations_update(struct Depsgraph *graph)
void DEG_relations_tag_update(struct Main *bmain)
void DEG_graph_relations_update(struct Depsgraph *graph)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:794
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
#define MAX_ID_NAME
Definition: DNA_ID.h:337
@ CAM_ORTHO
Object groups, one object can be in many groups at once.
@ CD_PROP_BYTE_COLOR
@ CD_MEDGE
@ CD_MVERT
@ CD_MLOOPUV
These structs are the foundation for all linked lists in the library system.
#define MAXMAT
@ MA_BM_HASHED
#define MA_RAMP_BLEND
#define MESH_MAX_VERTS
#define NODE_DO_OUTPUT
Object is a sort of wrapper for general info.
@ OB_CAMERA
@ OB_MESH
#define R_SINGLE_LAYER
#define R_BORDER
#define R_MULTIVIEW
#define R_IMF_IMTYPE_PNG
@ R_ALPHAPREMUL
#define SCE_LAY_SOLID
#define R_IMF_PLANES_RGBA
#define R_EDGE_FRS
#define R_NO_FRAME_UPDATE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker SH_NODE_MIX_RGB
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 Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise 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 or normal between camera
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const
vector< StrokeGroup * > texturedStrokeGroups
vector< StrokeGroup * > strokeGroups
Render * RenderScene(Render *re, bool render)
void test_strip_visibility(Strip::vertex_container &strip_vertices, int *visible_faces, int *visible_segments) const
void GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
static Material * GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
BlenderStrokeRenderer(Render *re, int render_count)
unsigned int get_stroke_mesh_id(void) const
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
std::vector< StrokeVertexRep * > vertex_container
Definition: StrokeRep.h:125
bNodeTree * getNodeTree() const
Definition: StrokeRep.h:213
bool hasTex() const
Definition: StrokeRep.h:218
void setMaterial(Material *mat)
Definition: StrokeRep.h:249
vector< Strip * > & getStrips()
Definition: StrokeRep.h:223
Vec2r & texCoord(bool tips=false)
Definition: StrokeRep.h:66
value_type x() const
Definition: VecMat.h:305
value_type y() const
Definition: VecMat.h:315
Value lookup_default(const Key &key, const Value &default_value) const
Definition: BLI_map.hh:510
void add_new(const Key &key, const Value &value)
Definition: BLI_map.hh:220
int64_t size() const
Definition: BLI_map.hh:901
ItemIterator items() const
Definition: BLI_map.hh:859
bool contains(const Key &key) const
Definition: BLI_map.hh:308
OperationNode * node
Material material
bNodeTree * ntree
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
#define L
#define G(x, y, z)
inherits from class Rep
Definition: AppCanvas.cpp:18
static const pxr::TfToken rgba("rgba", pxr::TfToken::Immortal)
Render * RE_NewSceneRender(const Scene *scene)
Definition: pipeline.c:558
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:4968
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:4992
Definition: DNA_ID.h:368
IDProperty * properties
Definition: DNA_ID.h:409
char name[66]
Definition: DNA_ID.h:378
void * first
Definition: DNA_listBase.h:31
unsigned int v1
unsigned int v2
unsigned char a
unsigned char b
unsigned char r
unsigned char g
unsigned int e
unsigned int v
short mat_nr
float co[3]
Definition: BKE_main.h:121
ListBase wm
Definition: BKE_main.h:197
struct bNodeTree * nodetree
struct MEdge * medge
CustomData vdata
struct MVert * mvert
struct MLoopCol * mloopcol
struct Material ** mat
int totedge
struct MLoopUV * mloopuv
int totvert
struct MLoop * mloop
CustomData pdata
int totpoly
short totcol
CustomData edata
int totloop
struct MPoly * mpoly
CustomData ldata
void * data
char engine[32]
struct ImageFormatData im_format
char pic[1024]
float dither_intensity
int recty
Definition: render_types.h:70
RenderData r
Definition: render_types.h:82
int winy
Definition: render_types.h:65
struct Main * main
Definition: render_types.h:80
Scene * scene
Definition: render_types.h:81
int rectx
Definition: render_types.h:70
int winx
Definition: render_types.h:65
rcti disprect
Definition: render_types.h:66
struct Collection * master_collection
struct RenderData r
ListBase view_layers
struct Object * camera
ListBase nodes
ListBase links
short custom1
float locy
ListBase inputs
float locx
void * storage
short custom2
ListBase outputs
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
int ymin
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
float max