Tachyon (current)  Current Main Branch
tachyon.h
Go to the documentation of this file.
1 /*
2  * tachyon.h - Tachyon public APIs used to drive the ray tracing engine.
3  *
4  * (C) Copyright 1994-2022 John E. Stone
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * $Id: tachyon.h,v 1.146 2022/04/23 15:23:51 johns Exp $
8  *
9  */
10 
17 #if !defined(TACHYON_H)
18 #define TACHYON_H 1
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include "util.h" /* rt_timer_xxx() and rt_rand() */
25 #include "hash.h" /* rt_hash_xxx() */
26 
27 /******************************************************************/
28 /* Constants and types defined for use with the Tachyon API calls */
29 /******************************************************************/
30 
31 /*
32  * Tachyon version strings for feature detection and compatibility testing.
33  */
34 #define TACHYON_VERSION_STRING "0.99.5"
35 #define TACHYON_MAJOR_VERSION 0
36 #define TACHYON_MINOR_VERSION 99
37 #define TACHYON_PATCH_VERSION 5
39 /*
40  * Build Tachyon and its interfaces using either double- or single-precision
41  * floating point types, based on compile-time defition of the
42  * USESINGLEFLT macro.
43  */
44 #ifdef USESINGLEFLT
45 typedef float flt;
46 #else
47 typedef double flt;
48 #endif
49 typedef flt apiflt;
51 typedef void * SceneHandle;
52 
53 typedef struct {
54  flt x;
55  flt y;
56  flt z;
57 } apivector;
58 
59 typedef struct {
60  float r;
61  float g;
62  float b;
63 } apicolor;
64 
65 typedef struct {
68  int shadowcast;
79  char imap[96];
80 } apitexture;
81 
82 /********************************************/
83 /* Functions implemented to provide the API */
84 /********************************************/
85 
87 apivector rt_vector(flt x, flt y, flt z);
88 
90 apicolor rt_color(flt r, flt g, flt b);
93 void rt_set_ui_message(void (* func) (int, char *));
94 
96 void rt_set_ui_progress(void (* func) (int));
97 
98 /* Backwards compatibility with older revs of Tachyon that provided
99  * convenience wrappers for parallel runs on the Intel iPSC/860 NX OS.
100  */
101 int rt_mynode(void);
102 int rt_numnodes(void);
109 int rt_initialize_nompi();
110 
120 int rt_initialize(int *, char ***);
121 
122 
134 
145 int rt_initialize_mpi_comm(void *mpicomm);
146 
159 int rt_initialize_mpi_comm_split(void *mpicomm, int color, int key);
160 
169 int rt_set_mpi_comm(void *mpicomm);
170 
181 int rt_set_mpi_comm_split(void *mpicomm, int color, int key);
182 
191 int rt_set_mpi_comm_world(void);
192 
203 int rt_set_mpi_comm_world_split(int color, int key);
204 
216 
217 
223 void rt_finalize(void);
224 
226 SceneHandle rt_newscene(void);
227 
230 
233 
235 void rt_outputfile(SceneHandle, const char * outname);
236 
237 /*
238  * 24-bit color image formats
239  */
240 #define RT_FORMAT_TARGA 0
241 #define RT_FORMAT_PPM 1
242 #define RT_FORMAT_SGIRGB 2
243 #define RT_FORMAT_JPEG 3
244 #define RT_FORMAT_WINBMP 4
245 #define RT_FORMAT_PNG 5
247 /*
248  * 48-bit deep-color image formats
249  */
250 #define RT_FORMAT_PPM48 6
251 #define RT_FORMAT_PSD48 7
254 void rt_outputformat(SceneHandle, int format);
255 
260 void rt_resolution(SceneHandle, int hres, int vres);
261 
266 void rt_get_resolution(SceneHandle, int *hres, int *vres);
267 
269 void rt_aspectratio(SceneHandle voidscene, float aspectratio);
270 
272 void rt_get_aspectratio(SceneHandle voidscene, float *aspectratio);
273 
274 /*
275  * Image cropping modes
276  */
277 #define RT_CROP_DISABLED 0
278 #define RT_CROP_ENABLED 1
284 void rt_crop_output(SceneHandle, int hres, int vres, int lx, int ly);
285 
288 
290 void rt_aa_maxsamples(SceneHandle, int maxsamples);
291 
296 void rt_verbose(SceneHandle, int v);
297 
298 /*
299  * Surface normal and winding order fixup mode constants used
300  * to optionally auto-correct triangles with interpolate normals
301  */
302 #define RT_NORMAL_FIXUP_OFF 0
303 #define RT_NORMAL_FIXUP_FLIP 1
304 #define RT_NORMAL_FIXUP_GUESS 2
310 void rt_normal_fixup_mode(SceneHandle, int mode);
311 
317 void rt_image_clamp(SceneHandle voidscene);
318 
323 void rt_image_normalize(SceneHandle voidscene);
324 
326 void rt_image_gamma(SceneHandle voidscene, float gamma);
327 
334 void rt_rawimage_rgb24(SceneHandle, unsigned char *rawimage);
335 
342 void rt_rawimage_rgb96f(SceneHandle, float *rawimage);
343 
344 #if 1
345 /*
346  * Accumulation buffer mode constants
347  */
348 #define RT_ACCUMULATE_OFF 0
349 #define RT_ACCUMULATE_ON 1
350 #define RT_ACCUMULATE_CLEAR 2
359 void rt_accumulation_mode(SceneHandle, int mode);
360 #endif
361 
363 void rt_set_numthreads(SceneHandle, int);
364 
367 
379  flt topval, flt botval,
380  apicolor topcolor, apicolor botcolor);
381 
382 /*
383  * Background texture modes for rt_background_mode,
384  * determines behavior to use when rays don't hit any objects.
385  */
386 #define RT_BACKGROUND_TEXTURE_SOLID 0
387 #define RT_BACKGROUND_TEXTURE_SKY_SPHERE 1
388 #define RT_BACKGROUND_TEXTURE_SKY_ORTHO_PLANE 2
413 void rt_background_mode(SceneHandle, int mode);
414 
415 /*
416  * Fog modes for rt_fog_rendering_mode()
417  */
418 #define RT_FOG_NORMAL 0
419 #define RT_FOG_OPENGL 1
420 #define RT_FOG_VMD 1
435 void rt_fog_rendering_mode(SceneHandle, int);
436 
437 /*
438  * Fog type parameters.
439  */
440 #define RT_FOG_NONE 0
441 #define RT_FOG_LINEAR 1
442 #define RT_FOG_EXP 2
443 #define RT_FOG_EXP2 3
446 void rt_fog_mode(SceneHandle, int);
447 
450  flt start, flt end, flt density);
451 
453 void rt_trans_max_surfaces(SceneHandle, int maxsurfaces);
454 
455 /*
456  * Transparency mode flags for rt_trans_mode()
457  */
458 #define RT_TRANS_ORIG 0
459 #define RT_TRANS_VMD 1
460 #define RT_TRANS_RASTER3D 2
463 void rt_trans_mode(SceneHandle, int mode);
464 
468 void rt_shadow_filtering(SceneHandle, int mode);
469 
470 
471 /*
472  * Parameter values for rt_boundmode()
473  */
474 #define RT_BOUNDING_DISABLED 0
475 #define RT_BOUNDING_ENABLED 1
481 void rt_boundmode(SceneHandle, int mode);
482 
490 void rt_boundthresh(SceneHandle, int threshold);
491 
492 
493 /**************************/
494 /* Camera definition APIs */
495 /**************************/
496 
497 /*
498  * Parameter values for rt_camera_projection()
499  */
500 #define RT_PROJECTION_PERSPECTIVE 0
501 #define RT_PROJECTION_ORTHOGRAPHIC 1
502 #define RT_PROJECTION_PERSPECTIVE_DOF 2
503 #define RT_PROJECTION_ORTHOGRAPHIC_DOF 3
504 #define RT_PROJECTION_EQUIRECTANGULAR 4
505 #define RT_PROJECTION_FISHEYE 5
506 #define RT_PROJECTION_STEREO_EQUIRECTANGULAR 6
509 void rt_camera_projection(SceneHandle, int mode);
510 
512 void rt_camera_position(SceneHandle, apivector center, apivector viewdir,
513  apivector updir);
514 
516 void rt_camera_position3fv(SceneHandle, const float *center,
517  const float *viewdir, const float *updir);
518 
520 void rt_get_camera_position(SceneHandle, apivector *center, apivector *viewdir,
521  apivector *updir, apivector *rightdir);
522 
524 void rt_get_camera_position3fv(SceneHandle, float *center, float *viewdir,
525  float *updir, float *rightdir);
526 
531 void rt_camera_raydepth(SceneHandle, int maxdepth);
532 
545 void rt_camera_zoom(SceneHandle, flt zoom);
546 
549 
554 
557 
562 
565 
570 void rt_camera_vfov(SceneHandle, flt vfov);
571 
577 
578 
589 void rt_camera_frustum(SceneHandle, flt left, flt right, flt bottom, flt top);
590 
592 void rt_camera_dof(SceneHandle voidscene, flt focaldist, flt aperture);
593 
594 
595 /***********************/
596 /*Texture mapping APIs */
597 /***********************/
598 
599 /*
600  * Object texture mapping functions.
601  */
602 #define RT_TEXTURE_CONSTANT 0
603 #define RT_TEXTURE_3D_CHECKER 1
604 #define RT_TEXTURE_GRIT 2
605 #define RT_TEXTURE_MARBLE 3
606 #define RT_TEXTURE_WOOD 4
607 #define RT_TEXTURE_GRADIENT 5
608 #define RT_TEXTURE_CYLINDRICAL_CHECKER 6
609 #define RT_TEXTURE_CYLINDRICAL_IMAGE 7
610 #define RT_TEXTURE_SPHERICAL_IMAGE 8
611 #define RT_TEXTURE_PLANAR_IMAGE 9
612 #define RT_TEXTURE_VOLUME_IMAGE 10
622 void * rt_texture(SceneHandle, apitexture *);
623 
630 void rt_define_teximage_rgb24(const char *name, int xsize, int ysize, int zsize,
631  unsigned char *rgb24data);
632 
637 void * rt_texture_copy_standard(SceneHandle, void *oldtex);
638 
643 void * rt_texture_copy_vcstri(SceneHandle, void *oldtex);
644 
645 
646 /*****************************/
647 /* Shading and lighting APIs */
648 /*****************************/
649 
650 /*
651  * Shader mode settings for rt_shadermode()
652  * These are sorted from lowest quality (and fastest execution)
653  * to highest quality (and slowest execution)
654  */
655 #define RT_SHADER_AUTO 0
656 #define RT_SHADER_LOWEST 1
657 #define RT_SHADER_LOW 2
658 #define RT_SHADER_MEDIUM 3
659 #define RT_SHADER_HIGH 4
660 #define RT_SHADER_FULL 5
667 void rt_shadermode(SceneHandle voidscene, int mode);
668 
669 
670 /*
671  * Shader modes for rt_phong_shader()
672  */
673 #define RT_SHADER_NULL_PHONG 0
674 #define RT_SHADER_BLINN_FAST 1
675 #define RT_SHADER_BLINN 2
676 #define RT_SHADER_PHONG 3
679 void rt_phong_shader(SceneHandle voidscene, int mode);
680 
681 /*
682  * Phong types
683  */
684 #define RT_PHONG_PLASTIC 0
685 #define RT_PHONG_METAL 1
688 void rt_tex_phong(void * voidtex, flt phong, flt phongexp, int type);
689 
694 void rt_tex_transmode(void * voidtex, int transmode);
695 
697 void rt_tex_outline(void * voidtex, flt outline, flt outlinewidth);
698 
699 
701 void rt_rescale_lights(SceneHandle, flt lightscale);
702 
703 
705 void * rt_light(SceneHandle, void *tex, apivector center, flt radius);
706 
708 void * rt_light3fv(SceneHandle, void *tex, const float *center, float radius);
709 
710 
712 void * rt_directional_light(SceneHandle, void *tex, apivector direction);
713 
715 void * rt_directional_light3fv(SceneHandle, void *tex, const float *direction);
716 
717 
722 void * rt_spotlight(SceneHandle, void *tex, apivector center, flt radius,
723  apivector direction, flt fallstart, flt fallend);
728 void * rt_spotlight3fv(SceneHandle, void *tex, const float *center,
729  float radius, const float *direction,
730  float fallstart, float fallend);
731 
732 
734 void rt_light_attenuation(void *light, flt constfactor,
735  flt linearfactor, flt quadfactor);
736 
737 #define RT_AO_MAXDIST_UNLIMITED 3.402823e+38
743 void rt_ambient_occlusion(void *scene, int numsamples,
744  flt maxdist, apicolor col);
745 
746 /************************/
747 /* Object Creation APIs */
748 /************************/
750 void rt_clip_fv(SceneHandle, int numplanes, const float * planes);
751 
753 void rt_clip_dv(SceneHandle, int numplanes, const double * planes);
754 
757 
758 
760 void rt_cylinder(SceneHandle, void *tex, apivector center,
761  apivector axis, flt radius);
763 void rt_cylinder3fv(SceneHandle, void *tex, const float *center,
764  const float *axis, float radius);
765 
766 
768 void rt_fcylinder(SceneHandle, void *tex, apivector center,
769  apivector axis, flt radius);
771 void rt_fcylinder3fv(SceneHandle, void *tex, const float *center,
772  const float *axis, float radius);
773 
774 
776 void rt_polycylinder(SceneHandle, void *tex, apivector *points,
777  int numpoints, flt radius);
779 void rt_polycylinder3fv(SceneHandle, void *tex, const float *points,
780  int numpoints, float radius);
781 
782 
784 void rt_sphere(SceneHandle, void *tex, apivector center, flt radius);
786 void rt_sphere3fv(SceneHandle, void *tex, const float *center, float radius);
787 
788 
790 void rt_plane(SceneHandle, void *tex, apivector center, apivector normal);
792 void rt_plane3fv(SceneHandle, void *tex, const float *center,
793  const float *normal);
794 
795 
797 void rt_ring(SceneHandle, void *tex, apivector center, apivector mormal,
798  flt innerrad, flt outerrad);
800 void rt_ring3fv(SceneHandle, void *tex, const float *center,
801  const float *normal, float innerrad, float outerrad);
802 
803 
805 void rt_tri(SceneHandle, void *tex, apivector v0, apivector v1, apivector v2);
807 void rt_tri3fv(SceneHandle, void *tex,
808  const float *v0, const float *v1, const float *v2);
809 
810 
812 void rt_stri(SceneHandle, void *, apivector v0, apivector v1, apivector v2,
813  apivector n0, apivector n1, apivector n2);
815 void rt_stri3fv(SceneHandle, void *,
816  const float *v0, const float *v1, const float *v2,
817  const float *n0, const float *n1, const float *n2);
818 
819 
824 void rt_vcstri(SceneHandle, void *tex, apivector v0, apivector v1, apivector v2,
825  apivector n0, apivector n1, apivector n2,
826  apicolor c0, apicolor c1, apicolor c2);
831 void rt_vcstri3fv(SceneHandle, void *tex,
832  const float *v0, const float *v1, const float *v2,
833  const float *n0, const float *n1, const float *n2,
834  const float *c0, const float *c1, const float *c2);
835 
836 
845 void rt_tristripscnv3fv(SceneHandle scene, void * tex,
846  int numverts, const float * cnv,
847  int numstrips, const int *vertsperstrip,
848  const int *facets);
849 
850 
855 void rt_extvol(SceneHandle, void *tex,
856  apivector mincoord, apivector maxcoord,
857  int samples, flt (* evaluator)(flt, flt, flt));
858 
862 void rt_scalarvol(SceneHandle, void *tex,
863  apivector mincoord, apivector maxcoord,
864  int xsize, int ysize, int zsize,
865  const char *filename, void *invol);
866 
867 
869 void rt_heightfield(SceneHandle, void *tex, apivector center,
870  int m, int n, flt *field, flt wx, flt wy);
871 
873 void rt_landscape(SceneHandle, void *tex, int m, int n,
874  apivector center, flt wx, flt wy);
875 
876 
878 void rt_box(SceneHandle, void *tex, apivector mincoord, apivector maxcoord);
879 
880 
884 void rt_quadsphere(SceneHandle, void *tex, apivector center, flt rad);
885 
886 
887 /*
888  * Include now-deprecated Tachyon APIs, unless the user has told us not to
889  */
890 #if !defined(TACHYON_NO_DEPRECATED)
891 #include "tachyon_dep.h"
892 #endif
893 
894 
895 /*
896  * Internal Tachyon APIs and data structures.
897  * Application developers should not be using anything below this point
898  * in the header file.
899  */
900 #if defined(TACHYON_INTERNAL)
901 
902 #ifdef USESINGLEFLT
903 /* All floating point types will be based on "float" */
904 #define SPEPSILON 0.0004f
905 #define EPSILON 0.0004f
906 #define FHUGE 1e18f
907 #define TWOPI 6.28318531f
908 #define MINCONTRIB 0.001959f
911 #else
912 /* All floating point types will be based on "double" */
913 #define SPEPSILON 0.000000001
914 #define EPSILON 0.000000001
915 #define FHUGE 1e18
916 #define TWOPI 6.28318531
917 #define MINCONTRIB 0.001959
920 #endif
921 
922 #define BOUNDTHRESH 16
925 /*
926  * Maximum internal table sizes
927  * Use prime numbers for best memory system performance
928  * (helps avoid cache aliasing..)
929  */
930 #define MAXIMGS 39
933 /*
934  * Ray flags
935  *
936  * These are used in order to skip calculations which are only
937  * needed some of the time. For example, when shooting shadow
938  * rays, we only have to find *one* intersection that's valid,
939  * if we find even one, we can quit early, thus saving lots of work.
940  */
941 #define RT_RAY_PRIMARY 1
942 #define RT_RAY_REGULAR 2
943 #define RT_RAY_SHADOW 4
944 #define RT_RAY_FINISHED 8
957 #define RT_SHADE_NOFLAGS 0
958 #define RT_SHADE_LIGHTING 1
959 #define RT_SHADE_PHONG 2
960 #define RT_SHADE_TEXTURE_MAPS 4
961 #define RT_SHADE_MIPMAP 8
962 #define RT_SHADE_REFLECTION 16
963 #define RT_SHADE_REFRACTION 32
964 #define RT_SHADE_SHADOWS 64
965 #define RT_SHADE_VOLUMETRIC 128
966 #define RT_SHADE_ANTIALIASING 256
967 #define RT_SHADE_DEPTH_OF_FIELD 512
968 #define RT_SHADE_SOFT_SHADOW 1024
969 #define RT_SHADE_VOLUMETRIC_SHADOW 2048
970 #define RT_SHADE_CLIPPING 4096
971 #define RT_SHADE_AMBIENTOCCLUSION 8192
974 /*
975  * Texture flags
976  *
977  * These are used in order to skip calculations that are only needed
978  * some of the time.
979  */
980 #define RT_TEXTURE_NOFLAGS 0
981 #define RT_TEXTURE_SHADOWCAST 1
982 #define RT_TEXTURE_ISLIGHT 2
985 /*
986  * Image buffer format flags
987  */
988 #define RT_IMAGE_BUFFER_RGB24 0
989 #define RT_IMAGE_BUFFER_RGB96F 1
992 /*
993  * Image post-processing flags
994  */
995 #define RT_IMAGE_CLAMP 0
996 #define RT_IMAGE_NORMALIZE 1
997 #define RT_IMAGE_GAMMA 2
1000 struct ray_t;
1001 typedef unsigned char byte; /* 1 byte */
1002 typedef apivector vector;
1003 typedef apicolor color;
1004 
1005 
1006 typedef struct {
1007  int loaded;
1008  int xres;
1009  int yres;
1010  int zres;
1011  int bpp;
1012  char name[96];
1013  unsigned char * data;
1014 } rawimage;
1015 
1016 
1017 typedef struct {
1018  int levels;
1019  rawimage ** images;
1020 } mipmap;
1021 
1022 
1023 typedef struct {
1024  int loaded;
1025  int xres;
1026  int yres;
1027  int zres;
1028  flt opacity;
1029  char name[96];
1030  unsigned char * data;
1031 } scalarvol;
1032 
1033 
1034 /*
1035  * Background texture data structure
1036  */
1037 typedef struct {
1038  color bg_color;
1039  color bg_grad_top;
1040  color bg_grad_bot;
1041  vector bg_grad_updir;
1042  flt bg_grad_topval;
1043  flt bg_grad_botval;
1044  flt bg_grad_invrange;
1045  flt bg_grad_noisemag;
1046 } background_texture;
1047 
1048 /*
1049  * Object texture data structures
1050  */
1051 typedef struct {
1052  void (* freetex)(void *);
1053 } texture_methods;
1054 
1055 #define RT_TEXTURE_HEAD \
1056  color (* texfunc)(const void *, const void *, void *); \
1057  texture_methods * methods; \
1058  unsigned int flags; \
1059  float ambient; \
1060  float diffuse; \
1061  float phong; \
1062  float phongexp; \
1063  int phongtype; \
1064  float specular; \
1065  float opacity; \
1066  int transmode; \
1067  float outline; \
1068  float outlinewidth;
1070 typedef struct {
1071  RT_TEXTURE_HEAD
1072 } texture;
1073 
1074 typedef struct {
1075  RT_TEXTURE_HEAD
1076  color col;
1077  vector ctr;
1078  vector rot;
1079  vector scale;
1080  vector uaxs;
1081  vector vaxs;
1082  vector waxs;
1083  void * img;
1084  void * obj;
1085 } standard_texture;
1086 
1087 typedef struct {
1088  RT_TEXTURE_HEAD
1089  void * obj;
1090  color c0;
1091  color c1;
1092  color c2;
1093 } vcstri_texture;
1094 
1095 
1096 /*
1097  * Object data structures
1098  */
1099 typedef struct {
1100  void (* intersect)(const void *, void *);
1101  void (* normal)(const void *, const void *, const void *, void *);
1102  int (* bbox)(void *, vector *, vector *);
1103  void (* freeobj)(void *);
1104 } object_methods;
1105 
1106 
1107 /*
1108  * Clipping plane data structure
1109  */
1110 typedef struct {
1111  int numplanes;
1112  flt * planes;
1113 } clip_group;
1114 
1115 
1116 #define RT_OBJECT_HEAD \
1117  unsigned int id; \
1118  void * nextobj; \
1119  object_methods * methods; \
1120  clip_group * clip; \
1121  texture * tex;
1124 typedef struct {
1125  RT_OBJECT_HEAD
1126 } object;
1127 
1128 
1129 typedef struct {
1130  const object * obj;
1131  flt t;
1132 } intersection;
1133 
1134 
1135 typedef struct {
1136  int num;
1137  intersection closest;
1138  flt shadowfilter;
1139 } intersectstruct;
1140 
1141 
1142 /* camera related defines etc */
1143 #define RT_CAMERA_FRUSTUM_AUTO 0
1144 #define RT_CAMERA_FRUSTUM_USER 1
1146 typedef struct {
1147  int frustumcalc;
1148  int projection;
1149  vector center;
1150  vector viewvec;
1151  vector rightvec;
1152  vector upvec;
1153  flt camzoom;
1154  flt px;
1155  flt py;
1156  flt psx;
1157  flt psy;
1158  flt dof_focaldist;
1159  flt left;
1160  flt right;
1161  flt top;
1162  flt bottom;
1163  flt dof_aperture_rad;
1164  vector projcent;
1165  flt eyeshift;
1166  int modulate_eyeshift;
1167  flt modulate_eyeshift_pow;
1168  color (* cam_ray)(void *, flt, flt);
1169  vector lowleft;
1170  vector iplaneright;
1171  vector iplaneup;
1172 } camdef;
1173 
1174 typedef struct fogdata_t {
1175  color (* fog_fctn)(struct fogdata_t *, color, flt);
1176  int type;
1177  color col;
1178  flt start;
1179  flt end;
1180  flt density;
1181 } fogdata;
1182 
1183 typedef struct amboccdata_t {
1184  int numsamples;
1185  flt ao_maxdist;
1186  color col;
1187 } amboccludedata;
1188 
1189 typedef struct {
1190  int numcpus;
1191  flt cpuspeed;
1192  flt nodespeed;
1193  char machname[512];
1194  void *cpucaps;
1195 } nodeinfo;
1196 
1197 typedef struct list {
1198  void * item;
1199  struct list * next;
1200 } list;
1201 
1202 typedef struct {
1203  vector hit;
1204  vector N;
1205  vector L;
1206  flt Llen;
1207 } shadedata;
1208 
1209 typedef struct {
1210  int cropmode;
1211  int xres;
1212  int yres;
1213  int xstart;
1214  int ystart;
1215 } cropinfo;
1216 
1217 typedef struct {
1218  object * boundedobj;
1219  object * unboundedobj;
1220  int numobjects;
1221 } displist;
1222 
1223 typedef void * rt_parhandle;
1224 typedef void * rt_parbuf;
1225 
1226 typedef struct {
1227  char outfilename[256];
1228  int writeimagefile;
1229  void * img;
1230  int imginternal;
1231  int imgprocess;
1232  float imggamma;
1233  int imgbufformat;
1234  int imgfileformat;
1235  cropinfo imgcrop;
1236 #if defined(RT_ACCUMULATE_ON)
1237  float *accum_buf;
1238  unsigned int accum_count;
1239  int accum_mode;
1240 #endif
1241  int numthreads;
1242  int nodes;
1243  int mynode;
1244  nodeinfo * cpuinfo;
1245  int hres;
1246  int vres;
1247  flt aspectratio;
1248  int raydepth;
1249  int transcount;
1250  int shadowfilter;
1251  int antialiasing;
1252  int verbosemode;
1253  int boundmode;
1254  int boundthresh;
1255  list * texlist;
1256  list * cliplist;
1257  unsigned int flags;
1258  camdef camera;
1259  color (* shader)(void *);
1260  flt (* phongfunc)(const struct ray_t * incident, const shadedata * shadevars, flt specpower);
1261  int transmode;
1262  background_texture bgtex;
1263  color (* bgtexfunc)(struct ray_t * incident);
1264  fogdata fog;
1265  displist objgroup;
1266  list * lightlist;
1267  flt light_scale;
1268  int numlights;
1269  amboccludedata ambocc;
1270  int scenecheck;
1271  rt_parhandle parhnd;
1272  rt_parbuf parbuf;
1273  void * threads;
1274  void * threadparms;
1275  clip_group * curclipgroup;
1276  int normalfixupmode;
1277 } scenedef;
1278 
1279 
1280 typedef struct ray_t {
1281  vector o;
1282  vector d;
1283  flt maxdist;
1284  flt opticdist;
1285  void (* add_intersection)(flt, const object *, struct ray_t *);
1286  intersectstruct intstruct;
1287  unsigned int depth;
1288  int transcnt;
1289  unsigned int flags;
1290  unsigned long serial;
1291  unsigned long * mbox;
1292  scenedef * scene;
1293  unsigned int idx;
1294  unsigned int randval;
1295  rng_frand_handle frng;
1296 } ray;
1297 
1298 
1299 #endif
1300 
1301 #ifdef __cplusplus
1302 }
1303 #endif
1304 #endif
void rt_scalarvol(SceneHandle, void *tex, apivector mincoord, apivector maxcoord, int xsize, int ysize, int zsize, const char *filename, void *invol)
Define an axis-aligned scalar volumetric data set, loaded from a file.
Definition: api.c:1146
void rt_ring(SceneHandle, void *tex, apivector center, apivector mormal, flt innerrad, flt outerrad)
Define an annular ring.
Definition: api.c:1199
float g
Green color component.
Definition: tachyon.h:61
void rt_trans_max_surfaces(SceneHandle, int maxsurfaces)
Set the maximum number of transparent surfaces that will be rendered.
Definition: api.c:224
float r
Red color component.
Definition: tachyon.h:60
void rt_clip_fv(SceneHandle, int numplanes, const float *planes)
Enable or update a clipping plane group.
Definition: api.c:1433
int rt_set_mpi_comm_world_split(int color, int key)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:139
void rt_light_attenuation(void *light, flt constfactor, flt linearfactor, flt quadfactor)
Set light attenuation parameters for an existing light.
Definition: api.c:1142
apicolor col
base object color
Definition: tachyon.h:67
Definition: light.h:13
apivector rot
rotation of texture around origin
Definition: tachyon.h:74
void rt_fog_parms(SceneHandle, apicolor col, flt start, flt end, flt density)
Set fog rendering parameters.
Definition: api.c:573
void * rt_spotlight(SceneHandle, void *tex, apivector center, flt radius, apivector direction, flt fallstart, flt fallend)
Define a spotlight with associated texture, position, radius, direction, falloff start, and falloff end parameters.
Definition: api.c:1107
void rt_camera_vfov(SceneHandle, flt vfov)
Set vertical field of view (in degrees) for a perspective camera.
Definition: api.c:333
void rt_stri(SceneHandle, void *, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2)
Define a smooth-shaded triangle using interpolated vertex normals.
Definition: api.c:1252
flt diffuse
diffuse reflection
Definition: tachyon.h:70
flt opacity
how opaque the object is
Definition: tachyon.h:72
void rt_get_aspectratio(SceneHandle voidscene, float *aspectratio)
Get the view frustum aspect ratio (width/height)
Definition: api.c:391
void rt_boundthresh(SceneHandle, int threshold)
Set the threshold to be used when automatic generation of ray tracing acceleration structures is to b...
Definition: api.c:630
void rt_polycylinder3fv(SceneHandle, void *tex, const float *points, int numpoints, float radius)
Define a sequence of connected cylinders.
Definition: apigeom.c:44
void rt_extvol(SceneHandle, void *tex, apivector mincoord, apivector maxcoord, int samples, flt(*evaluator)(flt, flt, flt))
Define an axis-aligned volumetric data set, with a user-defined sample evaluation callback function...
Definition: api.c:1152
int shadowcast
does the object cast a shadow
Definition: tachyon.h:68
void rt_landscape(SceneHandle, void *tex, int m, int n, apivector center, flt wx, flt wy)
Define an auto-generated height field.
Definition: apigeom.c:225
void rt_polycylinder(SceneHandle, void *tex, apivector *points, int numpoints, flt radius)
Define a sequence of connected cylinders.
Definition: apigeom.c:20
flt specular
specular reflection
Definition: tachyon.h:71
void rt_cylinder3fv(SceneHandle, void *tex, const float *center, const float *axis, float radius)
Define an infinite cylinder.
Definition: api.c:1164
void rt_background_gradient(SceneHandle, apivector up, flt topval, flt botval, apicolor topcolor, apicolor botcolor)
Set parameters for gradient (sky plane or sphere) background texturing.
Definition: api.c:497
void rt_clip_off(SceneHandle)
Disable active clipping plane group.
Definition: api.c:1483
void rt_rawimage_rgb96f(SceneHandle, float *rawimage)
Request Tachyon to save the output image in the specified memory area, in raw 96-bit, packed, pixel interleaved, 32-bit float RGB bytes.
Definition: api.c:428
int rt_set_mpi_comm_world(void)
Override the previously set MPI communicator with MPI_COMM_WORLD.
Definition: api.c:118
void rt_define_teximage_rgb24(const char *name, int xsize, int ysize, int zsize, unsigned char *rgb24data)
Define a named 1-D, 2-D, or 3-D texture image with a 24-bit RGB image buffer, without any file refere...
Definition: api.c:951
flt rt_get_camera_vfov(SceneHandle)
Return vertical field of view (in degrees) for a perspective camera.
Definition: api.c:338
void rt_crop_disable(SceneHandle)
Disable output image cropping.
Definition: api.c:396
apivector ctr
origin of texture
Definition: tachyon.h:73
void rt_resolution(SceneHandle, int hres, int vres)
Set the horizontal and vertical resolution (in pixels) for the specified scene.
Definition: api.c:372
void rt_box(SceneHandle, void *tex, apivector mincoord, apivector maxcoord)
Define an axis-aligned box.
Definition: api.c:1156
void rt_plane(SceneHandle, void *tex, apivector center, apivector normal)
Define a plane.
Definition: api.c:1186
int rt_set_mpi_comm(void *mpicomm)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:125
int rt_initialize_mpi_comm_world()
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:94
int rt_mynode(void)
distributed memory parallel node rank
Definition: api.c:49
void rt_outputfile(SceneHandle, const char *outname)
Set the filename for the output image for the specified scene.
Definition: api.c:350
void rt_tristripscnv3fv(SceneHandle scene, void *tex, int numverts, const float *cnv, int numstrips, const int *vertsperstrip, const int *facets)
Define smooth-shaded triangle strips using interpolated vertex normals, and per-vertex colors...
Definition: api.c:1332
void rt_background(SceneHandle, apicolor)
Set the background color of the specified scene.
Definition: api.c:490
void rt_fcylinder3fv(SceneHandle, void *tex, const float *center, const float *axis, float radius)
Define a finite-length cylinder.
Definition: api.c:1177
void rt_quadsphere(SceneHandle, void *tex, apivector center, flt rad)
Define a quadric sphere, normally used only for testing and benchmarking.
Definition: api.c:1410
double flt
generic floating point number, using double
Definition: tachyon.h:47
void rt_tex_outline(void *voidtex, flt outline, flt outlinewidth)
Set edge cueing outline shading parameters for an existing texture.
Definition: api.c:1008
void rt_fcylinder(SceneHandle, void *tex, apivector center, apivector axis, flt radius)
Define a finite-length cylinder.
Definition: api.c:1173
flt x
X coordinate or direction component.
Definition: tachyon.h:54
void rt_verbose(SceneHandle, int v)
Enables or Disables verbose messages from the Tachyon library during rendering.
Definition: api.c:414
void rt_tri3fv(SceneHandle, void *tex, const float *v0, const float *v1, const float *v2)
Define a flat-shaded triangle.
Definition: api.c:1234
void rt_camera_modulate_eye_separation(SceneHandle, flt cospow)
Set camera stereoscopic eye separation modulation and cosine power.
Definition: api.c:317
flt apiflt
for backward compatibility
Definition: tachyon.h:49
void rt_camera_position3fv(SceneHandle, const float *center, const float *viewdir, const float *updir)
Set camera position and orientation.
Definition: api.c:262
void rt_cylinder(SceneHandle, void *tex, apivector center, apivector axis, flt radius)
Define an infinite cylinder.
Definition: api.c:1160
flt y
Y coordinate or direction component.
Definition: tachyon.h:55
apivector scale
scale of texture in x,y,z
Definition: tachyon.h:75
void rt_camera_frustum(SceneHandle, flt left, flt right, flt bottom, flt top)
Set view frustum for active camera.
Definition: api.c:345
void * rt_light(SceneHandle, void *tex, apivector center, flt radius)
Define a point light with associated texture, position, and radius.
Definition: api.c:1049
void rt_set_ui_message(void(*func)(int, char *))
Set function pointer for user interface output callbacks.
Definition: ui.c:23
apivector uaxs
planar map u axis
Definition: tachyon.h:76
void rt_renderscene(SceneHandle)
Render the current scene.
Definition: api.c:180
void rt_set_ui_progress(void(*func)(int))
Set function pointer for user interface progress callbacks.
Definition: ui.c:27
flt rt_get_camera_zoom(SceneHandle)
Return current camera "zoom" factor.
Definition: api.c:302
void rt_get_resolution(SceneHandle, int *hres, int *vres)
Get the horizontal and vertical resolution (in pixels) for the specified scene.
Definition: api.c:379
Tachyon cross-platform timers, special math function wrappers, and RNGs.
void rt_vcstri3fv(SceneHandle, void *tex, const float *v0, const float *v1, const float *v2, const float *n0, const float *n1, const float *n2, const float *c0, const float *c1, const float *c2)
Define a smooth-shaded triangle using interpolated vertex normals and per-vertex colors.
Definition: api.c:1303
flt rt_get_camera_modulate_eye_separation(SceneHandle)
Return current camera eye separation.
void rt_stri3fv(SceneHandle, void *, const float *v0, const float *v1, const float *v2, const float *n0, const float *n1, const float *n2)
Define a smooth-shaded triangle using interpolated vertex normals.
Definition: api.c:1264
void rt_image_gamma(SceneHandle voidscene, float gamma)
Apply gamma correction to the pixel values after normalization.
Definition: api.c:449
int rt_initialize_nompi()
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:58
void * rt_directional_light(SceneHandle, void *tex, apivector direction)
Define a directional light with associated texture and direction.
Definition: api.c:1077
int rt_set_mpi_comm_split(void *mpicomm, int color, int key)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:132
void * rt_directional_light3fv(SceneHandle, void *tex, const float *direction)
Define a directional light with associated texture and direction.
Definition: api.c:1099
void * SceneHandle
Definition: tachyon.h:51
SceneHandle rt_newscene(void)
Allocate, initialize, and return a handle for a new scene.
Definition: api.c:698
void rt_camera_dof(SceneHandle voidscene, flt focaldist, flt aperture)
Set depth-of-field rendering options.
Definition: api.c:361
void rt_get_camera_position(SceneHandle, apivector *center, apivector *viewdir, apivector *updir, apivector *rightdir)
Get camera position and orientation.
Definition: api.c:273
int texturefunc
which texture function to use
Definition: tachyon.h:66
flt ambient
ambient lighting
Definition: tachyon.h:69
apivector vaxs
planar map v axis
Definition: tachyon.h:77
void rt_vcstri(SceneHandle, void *tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2, apicolor c0, apicolor c1, apicolor c2)
Define a smooth-shaded triangle using interpolated vertex normals and per-vertex colors.
Definition: api.c:1288
void rt_tex_transmode(void *voidtex, int transmode)
Set transparent surface shading parameters for an existing texture, enabling or disabling angle-modul...
Definition: api.c:1002
Old now-deprecated Tachyon APIs that have been replaced by newer APIs and/or improved functionality...
apivector rt_vector(flt x, flt y, flt z)
Helper function to make vectors.
Definition: api.c:159
void rt_shadow_filtering(SceneHandle, int mode)
Control whether or not transparent surfaces modulate incident light or not.
Definition: api.c:219
int rt_numnodes(void)
distributed memory parallel node count
Definition: api.c:53
void rt_finalize(void)
Shut down Tachyon library for good, at final use before program termination.
Definition: api.c:153
void rt_ring3fv(SceneHandle, void *tex, const float *center, const float *normal, float innerrad, float outerrad)
Define an annular ring.
Definition: api.c:1203
void rt_plane3fv(SceneHandle, void *tex, const float *center, const float *normal)
Define a plane.
Definition: api.c:1190
void rt_image_normalize(SceneHandle voidscene)
Enable renormalization of pixel values to the range [0 1) (rather than clamping) prior to output...
Definition: api.c:443
void rt_camera_eye_separation(SceneHandle, flt eyesep)
Set camera stereoscopic eye separation.
Definition: api.c:307
void rt_aa_maxsamples(SceneHandle, int maxsamples)
Sets the maximum number of supersamples to take for any pixel.
Definition: api.c:210
float b
Blue color component.
Definition: tachyon.h:62
void rt_heightfield(SceneHandle, void *tex, apivector center, int m, int n, flt *field, flt wx, flt wy)
Define an axis-aligned height field.
Definition: apigeom.c:70
void rt_sphere3fv(SceneHandle, void *tex, const float *center, float radius)
Define a sphere with associated texture, center, and radius.
Definition: api.c:1216
apicolor rt_color(flt r, flt g, flt b)
Helper function to make colors.
Definition: api.c:169
void rt_aspectratio(SceneHandle voidscene, float aspectratio)
Set the view frustum aspect ratio (width/height)
Definition: api.c:385
void * rt_texture_copy_standard(SceneHandle, void *oldtex)
Do not use this unless you know what you're doing, this is a short-term workaround until new object t...
Definition: api.c:967
void rt_sphere(SceneHandle, void *tex, apivector center, flt radius)
Define a sphere with associated texture, center, and radius.
Definition: api.c:1212
void rt_clip_dv(SceneHandle, int numplanes, const double *planes)
Enable or update a clipping plane group.
Definition: api.c:1458
void rt_set_numthreads(SceneHandle, int)
Explicitly set the number of worker threads Tachyon will use.
Definition: api.c:471
void * rt_spotlight3fv(SceneHandle, void *tex, const float *center, float radius, const float *direction, float fallstart, float fallend)
Define a spotlight with associated texture, position, radius, direction, falloff start, and falloff end parameters.
Definition: api.c:1132
void * rt_texture_copy_vcstri(SceneHandle, void *oldtex)
Do not use this unless you know what you're doing, this is a short-term workaround until new object t...
Definition: api.c:973
void rt_camera_raydepth(SceneHandle, int maxdepth)
Camera maximum ray recursion depth (i.e.
Definition: api.c:292
apivector waxs
volume map W axis
Definition: tachyon.h:78
void rt_rawimage_rgb24(SceneHandle, unsigned char *rawimage)
Have Tachyon save the output image in the specified memory area, in raw 24-bit, packed, pixel interleaved, unsigned RGB bytes.
Definition: api.c:419
int rt_initialize_mpi_comm_split(void *mpicomm, int color, int key)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:106
int rt_initialize_mpi_comm(void *mpicomm)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:82
flt rt_get_camera_eye_separation(SceneHandle)
Return current camera eye separation.
void rt_camera_position(SceneHandle, apivector center, apivector viewdir, apivector updir)
Set camera position and orientation.
Definition: api.c:256
void rt_tri(SceneHandle, void *tex, apivector v0, apivector v1, apivector v2)
Define a flat-shaded triangle.
Definition: api.c:1224
void rt_get_camera_position3fv(SceneHandle, float *center, float *viewdir, float *updir, float *rightdir)
Get camera position and orientation.
Definition: api.c:280
int rt_initialize(int *, char ***)
Initialize Tachyon library, must be first Tachyon API called.
Definition: api.c:70
void rt_camera_zoom(SceneHandle, flt zoom)
Set camera "zoom" factor.
Definition: api.c:297
int rt_set_mpi_comm_world_split_all(void)
Override the previously set MPI communicator for Tachyon to use.
Definition: api.c:146
void rt_image_clamp(SceneHandle voidscene)
Enable clamping of pixel values to the range [0 1) (rather than renormalizing) prior to output...
Definition: api.c:437
flt z
Z coordinate or direction component.
Definition: tachyon.h:56
void rt_deletescene(SceneHandle)
Destroy and deallocate the specified scene.
Definition: api.c:784
void * rt_light3fv(SceneHandle, void *tex, const float *center, float radius)
Define a point light with associated texture, position, and radius.
Definition: api.c:1069
void rt_rescale_lights(SceneHandle, flt lightscale)
Rescale all light sources in the scene by factor lightscale.
Definition: api.c:673