Blender  V3.3
cycles_xml.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #include <stdio.h>
5 
6 #include <algorithm>
7 #include <iterator>
8 #include <sstream>
9 
10 #include "graph/node_xml.h"
11 
12 #include "scene/alembic.h"
13 #include "scene/background.h"
14 #include "scene/camera.h"
15 #include "scene/film.h"
16 #include "scene/integrator.h"
17 #include "scene/light.h"
18 #include "scene/mesh.h"
19 #include "scene/object.h"
20 #include "scene/osl.h"
21 #include "scene/scene.h"
22 #include "scene/shader.h"
23 #include "scene/shader_graph.h"
24 #include "scene/shader_nodes.h"
25 
26 #include "subd/patch.h"
27 #include "subd/split.h"
28 
29 #include "util/foreach.h"
30 #include "util/path.h"
31 #include "util/projection.h"
32 #include "util/transform.h"
33 #include "util/xml.h"
34 
35 #include "app/cycles_xml.h"
36 
38 
39 /* XML reading state */
40 
41 struct XMLReadState : public XMLReader {
42  Scene *scene; /* Scene pointer. */
43  Transform tfm; /* Current transform state. */
44  bool smooth; /* Smooth normal state. */
45  Shader *shader; /* Current shader. */
46  string base; /* Base path to current file. */
47  float dicing_rate; /* Current dicing rate. */
48 
50  {
52  }
53 };
54 
55 /* Attribute Reading */
56 
57 static bool xml_read_int(int *value, xml_node node, const char *name)
58 {
59  xml_attribute attr = node.attribute(name);
60 
61  if (attr) {
62  *value = atoi(attr.value());
63  return true;
64  }
65 
66  return false;
67 }
68 
69 static bool xml_read_int_array(vector<int> &value, xml_node node, const char *name)
70 {
71  xml_attribute attr = node.attribute(name);
72 
73  if (attr) {
74  vector<string> tokens;
75  string_split(tokens, attr.value());
76 
77  foreach (const string &token, tokens)
78  value.push_back(atoi(token.c_str()));
79 
80  return true;
81  }
82 
83  return false;
84 }
85 
86 static bool xml_read_float(float *value, xml_node node, const char *name)
87 {
88  xml_attribute attr = node.attribute(name);
89 
90  if (attr) {
91  *value = (float)atof(attr.value());
92  return true;
93  }
94 
95  return false;
96 }
97 
98 static bool xml_read_float_array(vector<float> &value, xml_node node, const char *name)
99 {
100  xml_attribute attr = node.attribute(name);
101 
102  if (attr) {
103  vector<string> tokens;
104  string_split(tokens, attr.value());
105 
106  foreach (const string &token, tokens)
107  value.push_back((float)atof(token.c_str()));
108 
109  return true;
110  }
111 
112  return false;
113 }
114 
115 static bool xml_read_float3(float3 *value, xml_node node, const char *name)
116 {
118 
119  if (xml_read_float_array(array, node, name) && array.size() == 3) {
120  *value = make_float3(array[0], array[1], array[2]);
121  return true;
122  }
123 
124  return false;
125 }
126 
127 static bool xml_read_float3_array(vector<float3> &value, xml_node node, const char *name)
128 {
130 
131  if (xml_read_float_array(array, node, name)) {
132  for (size_t i = 0; i < array.size(); i += 3)
133  value.push_back(make_float3(array[i + 0], array[i + 1], array[i + 2]));
134 
135  return true;
136  }
137 
138  return false;
139 }
140 
141 static bool xml_read_float4(float4 *value, xml_node node, const char *name)
142 {
144 
145  if (xml_read_float_array(array, node, name) && array.size() == 4) {
146  *value = make_float4(array[0], array[1], array[2], array[3]);
147  return true;
148  }
149 
150  return false;
151 }
152 
153 static bool xml_read_string(string *str, xml_node node, const char *name)
154 {
155  xml_attribute attr = node.attribute(name);
156 
157  if (attr) {
158  *str = attr.value();
159  return true;
160  }
161 
162  return false;
163 }
164 
165 static bool xml_equal_string(xml_node node, const char *name, const char *value)
166 {
167  xml_attribute attr = node.attribute(name);
168 
169  if (attr)
170  return string_iequals(attr.value(), value);
171 
172  return false;
173 }
174 
175 /* Camera */
176 
177 static void xml_read_camera(XMLReadState &state, xml_node node)
178 {
179  Camera *cam = state.scene->camera;
180 
181  int width = -1, height = -1;
182  xml_read_int(&width, node, "width");
183  xml_read_int(&height, node, "height");
184 
185  cam->set_full_width(width);
186  cam->set_full_height(height);
187 
188  xml_read_node(state, cam, node);
189 
190  cam->set_matrix(state.tfm);
191 
192  cam->need_flags_update = true;
193  cam->update(state.scene);
194 }
195 
196 /* Alembic */
197 
198 #ifdef WITH_ALEMBIC
199 static void xml_read_alembic(XMLReadState &state, xml_node graph_node)
200 {
201  AlembicProcedural *proc = state.scene->create_node<AlembicProcedural>();
202  xml_read_node(state, proc, graph_node);
203 
204  for (xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
205  if (string_iequals(node.name(), "object")) {
206  string path;
207  if (xml_read_string(&path, node, "path")) {
208  ustring object_path(path, 0);
209  AlembicObject *object = static_cast<AlembicObject *>(
210  proc->get_or_create_object(object_path));
211 
212  array<Node *> used_shaders = object->get_used_shaders();
213  used_shaders.push_back_slow(state.shader);
214  object->set_used_shaders(used_shaders);
215  }
216  }
217  }
218 }
219 #endif
220 
221 /* Shader */
222 
223 static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
224 {
225  xml_read_node(state, shader, graph_node);
226 
227  ShaderGraph *graph = new ShaderGraph();
228 
229  /* local state, shader nodes can't link to nodes outside the shader graph */
230  XMLReader graph_reader;
231  graph_reader.node_map[ustring("output")] = graph->output();
232 
233  for (xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
234  ustring node_name(node.name());
235 
236  if (node_name == "connect") {
237  /* connect nodes */
238  vector<string> from_tokens, to_tokens;
239 
240  string_split(from_tokens, node.attribute("from").value());
241  string_split(to_tokens, node.attribute("to").value());
242 
243  if (from_tokens.size() == 2 && to_tokens.size() == 2) {
244  ustring from_node_name(from_tokens[0]);
245  ustring from_socket_name(from_tokens[1]);
246  ustring to_node_name(to_tokens[0]);
247  ustring to_socket_name(to_tokens[1]);
248 
249  /* find nodes and sockets */
252 
253  if (graph_reader.node_map.find(from_node_name) != graph_reader.node_map.end()) {
254  ShaderNode *fromnode = (ShaderNode *)graph_reader.node_map[from_node_name];
255 
256  foreach (ShaderOutput *out, fromnode->outputs)
257  if (string_iequals(out->socket_type.name.string(), from_socket_name.string()))
258  output = out;
259 
260  if (!output)
261  fprintf(stderr,
262  "Unknown output socket name \"%s\" on \"%s\".\n",
263  from_node_name.c_str(),
264  from_socket_name.c_str());
265  }
266  else
267  fprintf(stderr, "Unknown shader node name \"%s\".\n", from_node_name.c_str());
268 
269  if (graph_reader.node_map.find(to_node_name) != graph_reader.node_map.end()) {
270  ShaderNode *tonode = (ShaderNode *)graph_reader.node_map[to_node_name];
271 
272  foreach (ShaderInput *in, tonode->inputs)
273  if (string_iequals(in->socket_type.name.string(), to_socket_name.string()))
274  input = in;
275 
276  if (!input)
277  fprintf(stderr,
278  "Unknown input socket name \"%s\" on \"%s\".\n",
279  to_socket_name.c_str(),
280  to_node_name.c_str());
281  }
282  else
283  fprintf(stderr, "Unknown shader node name \"%s\".\n", to_node_name.c_str());
284 
285  /* connect */
286  if (output && input)
287  graph->connect(output, input);
288  }
289  else
290  fprintf(stderr, "Invalid from or to value for connect node.\n");
291 
292  continue;
293  }
294 
295  ShaderNode *snode = NULL;
296 
297 #ifdef WITH_OSL
298  if (node_name == "osl_shader") {
299  ShaderManager *manager = state.scene->shader_manager;
300 
301  if (manager->use_osl()) {
302  std::string filepath;
303 
304  if (xml_read_string(&filepath, node, "src")) {
305  if (path_is_relative(filepath)) {
306  filepath = path_join(state.base, filepath);
307  }
308 
309  snode = OSLShaderManager::osl_node(graph, manager, filepath, "");
310 
311  if (!snode) {
312  fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());
313  continue;
314  }
315  }
316  else {
317  fprintf(stderr, "OSL node missing \"src\" attribute.\n");
318  continue;
319  }
320  }
321  else {
322  fprintf(stderr, "OSL node without using --shadingsys osl.\n");
323  continue;
324  }
325  }
326  else
327 #endif
328  {
329  /* exception for name collision */
330  if (node_name == "background")
331  node_name = "background_shader";
332 
333  const NodeType *node_type = NodeType::find(node_name);
334 
335  if (!node_type) {
336  fprintf(stderr, "Unknown shader node \"%s\".\n", node.name());
337  continue;
338  }
339  else if (node_type->type != NodeType::SHADER) {
340  fprintf(stderr, "Node type \"%s\" is not a shader node.\n", node_type->name.c_str());
341  continue;
342  }
343  else if (node_type->create == NULL) {
344  fprintf(stderr, "Can't create abstract node type \"%s\".\n", node_type->name.c_str());
345  continue;
346  }
347 
348  snode = (ShaderNode *)node_type->create(node_type);
349  snode->set_owner(graph);
350  }
351 
352  xml_read_node(graph_reader, snode, node);
353 
354  if (node_name == "image_texture") {
355  ImageTextureNode *img = (ImageTextureNode *)snode;
356  ustring filename(path_join(state.base, img->get_filename().string()));
357  img->set_filename(filename);
358  }
359  else if (node_name == "environment_texture") {
361  ustring filename(path_join(state.base, env->get_filename().string()));
362  env->set_filename(filename);
363  }
364 
365  if (snode) {
366  /* add to graph */
367  graph->add(snode);
368  }
369  }
370 
371  shader->set_graph(graph);
372  shader->tag_update(state.scene);
373 }
374 
375 static void xml_read_shader(XMLReadState &state, xml_node node)
376 {
377  Shader *shader = new Shader();
378  xml_read_shader_graph(state, shader, node);
379  state.scene->shaders.push_back(shader);
380 }
381 
382 /* Background */
383 
385 {
386  /* Background Settings */
387  xml_read_node(state, state.scene->background, node);
388 
389  /* Background Shader */
390  Shader *shader = state.scene->default_background;
391  xml_read_shader_graph(state, shader, node);
392 }
393 
394 /* Mesh */
395 
396 static Mesh *xml_add_mesh(Scene *scene, const Transform &tfm)
397 {
398  /* create mesh */
399  Mesh *mesh = new Mesh();
400  scene->geometry.push_back(mesh);
401 
402  /* Create object. */
403  Object *object = new Object();
404  object->set_geometry(mesh);
405  object->set_tfm(tfm);
406  scene->objects.push_back(object);
407 
408  return mesh;
409 }
410 
411 static void xml_read_mesh(const XMLReadState &state, xml_node node)
412 {
413  /* add mesh */
414  Mesh *mesh = xml_add_mesh(state.scene, state.tfm);
415  array<Node *> used_shaders = mesh->get_used_shaders();
416  used_shaders.push_back_slow(state.shader);
417  mesh->set_used_shaders(used_shaders);
418 
419  /* read state */
420  int shader = 0;
421  bool smooth = state.smooth;
422 
423  /* read vertices and polygons */
425  vector<float> UV;
426  vector<int> verts, nverts;
427 
429  xml_read_int_array(verts, node, "verts");
430  xml_read_int_array(nverts, node, "nverts");
431 
432  if (xml_equal_string(node, "subdivision", "catmull-clark")) {
433  mesh->set_subdivision_type(Mesh::SUBDIVISION_CATMULL_CLARK);
434  }
435  else if (xml_equal_string(node, "subdivision", "linear")) {
436  mesh->set_subdivision_type(Mesh::SUBDIVISION_LINEAR);
437  }
438 
439  array<float3> P_array;
440  P_array = P;
441 
442  if (mesh->get_subdivision_type() == Mesh::SUBDIVISION_NONE) {
443  /* create vertices */
444 
445  mesh->set_verts(P_array);
446 
447  size_t num_triangles = 0;
448  for (size_t i = 0; i < nverts.size(); i++)
449  num_triangles += nverts[i] - 2;
450  mesh->reserve_mesh(mesh->get_verts().size(), num_triangles);
451 
452  /* create triangles */
453  int index_offset = 0;
454 
455  for (size_t i = 0; i < nverts.size(); i++) {
456  for (int j = 0; j < nverts[i] - 2; j++) {
457  int v0 = verts[index_offset];
458  int v1 = verts[index_offset + j + 1];
459  int v2 = verts[index_offset + j + 2];
460 
461  assert(v0 < (int)P.size());
462  assert(v1 < (int)P.size());
463  assert(v2 < (int)P.size());
464 
465  mesh->add_triangle(v0, v1, v2, shader, smooth);
466  }
467 
468  index_offset += nverts[i];
469  }
470 
471  if (xml_read_float_array(UV, node, "UV")) {
472  ustring name = ustring("UVMap");
473  Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
474  float2 *fdata = attr->data_float2();
475 
476  /* loop over the triangles */
477  index_offset = 0;
478  for (size_t i = 0; i < nverts.size(); i++) {
479  for (int j = 0; j < nverts[i] - 2; j++) {
480  int v0 = index_offset;
481  int v1 = index_offset + j + 1;
482  int v2 = index_offset + j + 2;
483 
484  assert(v0 * 2 + 1 < (int)UV.size());
485  assert(v1 * 2 + 1 < (int)UV.size());
486  assert(v2 * 2 + 1 < (int)UV.size());
487 
488  fdata[0] = make_float2(UV[v0 * 2], UV[v0 * 2 + 1]);
489  fdata[1] = make_float2(UV[v1 * 2], UV[v1 * 2 + 1]);
490  fdata[2] = make_float2(UV[v2 * 2], UV[v2 * 2 + 1]);
491  fdata += 3;
492  }
493 
494  index_offset += nverts[i];
495  }
496  }
497  }
498  else {
499  /* create vertices */
500  mesh->set_verts(P_array);
501 
502  size_t num_ngons = 0;
503  size_t num_corners = 0;
504  for (size_t i = 0; i < nverts.size(); i++) {
505  num_ngons += (nverts[i] == 4) ? 0 : 1;
506  num_corners += nverts[i];
507  }
508  mesh->reserve_subd_faces(nverts.size(), num_ngons, num_corners);
509 
510  /* create subd_faces */
511  int index_offset = 0;
512 
513  for (size_t i = 0; i < nverts.size(); i++) {
514  mesh->add_subd_face(&verts[index_offset], nverts[i], shader, smooth);
515  index_offset += nverts[i];
516  }
517 
518  /* uv map */
519  if (xml_read_float_array(UV, node, "UV")) {
520  ustring name = ustring("UVMap");
521  Attribute *attr = mesh->subd_attributes.add(ATTR_STD_UV, name);
522  float3 *fdata = attr->data_float3();
523 
524 #if 0
525  if (subdivide_uvs) {
526  attr->flags |= ATTR_SUBDIVIDED;
527  }
528 #endif
529 
530  index_offset = 0;
531  for (size_t i = 0; i < nverts.size(); i++) {
532  for (int j = 0; j < nverts[i]; j++) {
533  *(fdata++) = make_float3(UV[index_offset++]);
534  }
535  }
536  }
537 
538  /* setup subd params */
539  float dicing_rate = state.dicing_rate;
540  xml_read_float(&dicing_rate, node, "dicing_rate");
541  dicing_rate = std::max(0.1f, dicing_rate);
542 
543  mesh->set_subd_dicing_rate(dicing_rate);
544  mesh->set_subd_objecttoworld(state.tfm);
545  }
546 
547  /* we don't yet support arbitrary attributes, for now add vertex
548  * coordinates as generated coordinates if requested */
551  memcpy(
552  attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * mesh->get_verts().size());
553  }
554 }
555 
556 /* Light */
557 
558 static void xml_read_light(XMLReadState &state, xml_node node)
559 {
560  Light *light = new Light();
561 
562  light->set_shader(state.shader);
563  xml_read_node(state, light, node);
564 
565  state.scene->lights.push_back(light);
566 }
567 
568 /* Transform */
569 
570 static void xml_read_transform(xml_node node, Transform &tfm)
571 {
572  if (node.attribute("matrix")) {
573  vector<float> matrix;
574  if (xml_read_float_array(matrix, node, "matrix") && matrix.size() == 16) {
575  ProjectionTransform projection = *(ProjectionTransform *)&matrix[0];
576  tfm = tfm * projection_to_transform(projection_transpose(projection));
577  }
578  }
579 
580  if (node.attribute("translate")) {
581  float3 translate = zero_float3();
582  xml_read_float3(&translate, node, "translate");
583  tfm = tfm * transform_translate(translate);
584  }
585 
586  if (node.attribute("rotate")) {
588  xml_read_float4(&rotate, node, "rotate");
589  tfm = tfm * transform_rotate(DEG2RADF(rotate.x), make_float3(rotate.y, rotate.z, rotate.w));
590  }
591 
592  if (node.attribute("scale")) {
593  float3 scale = zero_float3();
594  xml_read_float3(&scale, node, "scale");
595  tfm = tfm * transform_scale(scale);
596  }
597 }
598 
599 /* State */
600 
601 static void xml_read_state(XMLReadState &state, xml_node node)
602 {
603  /* read shader */
604  string shadername;
605 
606  if (xml_read_string(&shadername, node, "shader")) {
607  bool found = false;
608 
609  foreach (Shader *shader, state.scene->shaders) {
610  if (shader->name == shadername) {
611  state.shader = shader;
612  found = true;
613  break;
614  }
615  }
616 
617  if (!found)
618  fprintf(stderr, "Unknown shader \"%s\".\n", shadername.c_str());
619  }
620 
621  xml_read_float(&state.dicing_rate, node, "dicing_rate");
622 
623  /* read smooth/flat */
624  if (xml_equal_string(node, "interpolation", "smooth"))
625  state.smooth = true;
626  else if (xml_equal_string(node, "interpolation", "flat"))
627  state.smooth = false;
628 }
629 
630 /* Scene */
631 
632 static void xml_read_include(XMLReadState &state, const string &src);
633 
634 static void xml_read_scene(XMLReadState &state, xml_node scene_node)
635 {
636  for (xml_node node = scene_node.first_child(); node; node = node.next_sibling()) {
637  if (string_iequals(node.name(), "film")) {
638  xml_read_node(state, state.scene->film, node);
639  }
640  else if (string_iequals(node.name(), "integrator")) {
641  xml_read_node(state, state.scene->integrator, node);
642  }
643  else if (string_iequals(node.name(), "camera")) {
645  }
646  else if (string_iequals(node.name(), "shader")) {
648  }
649  else if (string_iequals(node.name(), "background")) {
651  }
652  else if (string_iequals(node.name(), "mesh")) {
654  }
655  else if (string_iequals(node.name(), "light")) {
657  }
658  else if (string_iequals(node.name(), "transform")) {
659  XMLReadState substate = state;
660 
661  xml_read_transform(node, substate.tfm);
662  xml_read_scene(substate, node);
663  }
664  else if (string_iequals(node.name(), "state")) {
665  XMLReadState substate = state;
666 
667  xml_read_state(substate, node);
668  xml_read_scene(substate, node);
669  }
670  else if (string_iequals(node.name(), "include")) {
671  string src;
672 
673  if (xml_read_string(&src, node, "src"))
675  }
676 #ifdef WITH_ALEMBIC
677  else if (string_iequals(node.name(), "alembic")) {
678  xml_read_alembic(state, node);
679  }
680 #endif
681  else
682  fprintf(stderr, "Unknown node \"%s\".\n", node.name());
683  }
684 }
685 
686 /* Include */
687 
688 static void xml_read_include(XMLReadState &state, const string &src)
689 {
690  /* open XML document */
691  xml_document doc;
692  xml_parse_result parse_result;
693 
694  string path = path_join(state.base, src);
695  parse_result = doc.load_file(path.c_str());
696 
697  if (parse_result) {
698  XMLReadState substate = state;
699  substate.base = path_dirname(path);
700 
701  xml_node cycles = doc.child("cycles");
702  xml_read_scene(substate, cycles);
703  }
704  else {
705  fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description());
706  exit(EXIT_FAILURE);
707  }
708 }
709 
710 /* File */
711 
712 void xml_read_file(Scene *scene, const char *filepath)
713 {
715 
716  state.scene = scene;
717  state.tfm = transform_identity();
718  state.shader = scene->default_surface;
719  state.smooth = false;
720  state.dicing_rate = 1.0f;
721  state.base = path_dirname(filepath);
722 
724 
726 }
727 
typedef float(TangentPoint)[2]
#define DEG2RADF(_deg)
struct Light Light
struct Mesh Mesh
struct Object Object
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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 width
_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 v1
float float4[4]
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE btVector3 rotate(const btVector3 &wAxis, const btScalar angle) const
Return a rotated version of this vector.
Attribute * add(ustring name, TypeDesc type, AttributeElement element)
float3 * data_float3()
float2 * data_float2()
bool need_attribute(Scene *scene, AttributeStandard std)
AttributeSet attributes
BVHType bvh_type
Definition: scene.h:148
const SocketType & socket_type
Definition: shader_graph.h:101
virtual bool use_osl()
Definition: scene/shader.h:178
vector< ShaderOutput * > outputs
Definition: shader_graph.h:215
vector< ShaderInput * > inputs
Definition: shader_graph.h:214
void set_graph(ShaderGraph *graph)
void tag_update(Scene *scene)
size_t size() const
void push_back_slow(const T &t)
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_device_inline Transform projection_to_transform(const ProjectionTransform &a)
ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform &a)
static bool xml_read_float4(float4 *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:141
static bool xml_read_float3(float3 *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:115
static void xml_read_include(XMLReadState &state, const string &src)
Definition: cycles_xml.cpp:688
static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node)
Definition: cycles_xml.cpp:223
static bool xml_read_int_array(vector< int > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:69
static bool xml_read_int(int *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:57
static bool xml_read_float_array(vector< float > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:98
void xml_read_file(Scene *scene, const char *filepath)
Definition: cycles_xml.cpp:712
static bool xml_read_string(string *str, xml_node node, const char *name)
Definition: cycles_xml.cpp:153
static void xml_read_mesh(const XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:411
static Mesh * xml_add_mesh(Scene *scene, const Transform &tfm)
Definition: cycles_xml.cpp:396
static bool xml_equal_string(xml_node node, const char *name, const char *value)
Definition: cycles_xml.cpp:165
static bool xml_read_float3_array(vector< float3 > &value, xml_node node, const char *name)
Definition: cycles_xml.cpp:127
static void xml_read_light(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:558
static void xml_read_state(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:601
static void xml_read_camera(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:177
static void xml_read_transform(xml_node node, Transform &tfm)
Definition: cycles_xml.cpp:570
static bool xml_read_float(float *value, xml_node node, const char *name)
Definition: cycles_xml.cpp:86
static void xml_read_scene(XMLReadState &state, xml_node scene_node)
Definition: cycles_xml.cpp:634
static void xml_read_shader(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:375
static void xml_read_background(XMLReadState &state, xml_node node)
Definition: cycles_xml.cpp:384
OperationNode * node
Depsgraph * graph
Scene scene
SyclQueue void void * src
#define str(s)
#define foreach(x, y)
Definition: foreach.h:9
static float verts[][3]
ccl_device_inline Transform transform_identity()
ccl_device_inline Transform transform_rotate(float angle, float3 axis)
ccl_device_inline Transform transform_translate(float3 t)
ccl_device_inline Transform transform_scale(float3 s)
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
const int state
@ ATTR_STD_UV
Definition: kernel/types.h:616
@ ATTR_STD_GENERATED
Definition: kernel/types.h:620
@ ATTR_SUBDIVIDED
Definition: kernel/types.h:652
ccl_device_inline float3 zero_float3()
Definition: math_float3.h:80
ccl_device_inline float4 zero_float4()
Definition: math_float4.h:92
static float P(float k)
Definition: math_interp.c:25
#define make_float2(x, y)
Definition: metal/compat.h:203
#define make_float4(x, y, z, w)
Definition: metal/compat.h:205
#define make_float3(x, y, z)
Definition: metal/compat.h:204
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken Shader("Shader", pxr::TfToken::Immortal)
void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node)
Definition: node_xml.cpp:41
smooth(Type::FLOAT, "mask_weight")
@ BVH_TYPE_STATIC
Definition: params.h:37
string path_dirname(const string &path)
Definition: path.cpp:399
bool path_is_relative(const string &path)
Definition: path.cpp:442
string path_join(const string &dir, const string &file)
Definition: path.cpp:413
string path_filename(const string &path)
Definition: path.cpp:376
bool string_iequals(const string &a, const string &b)
Definition: string.cpp:54
void string_split(vector< string > &tokens, const string &str, const string &separators, bool skip_empty_tokens)
Definition: string.cpp:67
bool need_flags_update
Definition: scene/camera.h:173
void update(Scene *scene)
void reserve_subd_faces(int numfaces, int num_ngons, int numcorners)
Definition: scene/mesh.cpp:250
float size[3]
void reserve_mesh(int numverts, int numfaces)
Definition: scene/mesh.cpp:220
@ SUBDIVISION_NONE
Definition: scene/mesh.h:120
@ SUBDIVISION_LINEAR
Definition: scene/mesh.h:121
@ SUBDIVISION_CATMULL_CLARK
Definition: scene/mesh.h:122
void add_triangle(int v0, int v1, int v2, int shader, bool smooth)
Definition: scene/mesh.cpp:342
void add_subd_face(const int *corners, int num_corners, int shader_, bool smooth_)
Definition: scene/mesh.cpp:360
Type type
Definition: node_type.h:116
@ SHADER
Definition: node_type.h:94
CreateFunc create
Definition: node_type.h:120
ustring name
Definition: node_type.h:115
static const NodeType * find(ustring name)
ustring name
Definition: graph/node.h:174
void set_owner(const NodeOwner *owner_)
Definition: graph/node.cpp:773
vector< Geometry * > geometry
Definition: scene.h:214
SceneParams params
Definition: scene.h:243
Shader * default_surface
Definition: scene.h:232
vector< Object * > objects
Definition: scene.h:213
ustring name
Definition: node_type.h:72
Scene * scene
Definition: cycles_xml.cpp:42
Transform tfm
Definition: cycles_xml.cpp:43
Shader * shader
Definition: cycles_xml.cpp:45
float dicing_rate
Definition: cycles_xml.cpp:47
map< ustring, Node * > node_map
Definition: node_xml.h:15
float max