28 #define STB_IMAGE_WRITE_IMPLEMENTATION 33 #if defined(TACHYON_USEPINNEDMEMORY) 34 #include <cuda_runtime.h> 38 void HSItoRGB(
float h,
float s,
float i,
float &r,
float &g,
float &b) {
39 float t=2.0f *
M_PI * h;
40 float scale = i / 2.0f;
41 r=(1.0f + s*sin(t - 2.0f*
M_PI/3.0f)) * scale;
42 g=(1.0f + s*sin(t)) * scale;
43 b=(1.0f + s*sin(t + 2.0f*
M_PI/3.0f)) * scale;
49 int vdiv,
float vmin,
float vmax,
51 int numpts = udiv * vdiv;
52 #if defined(TACHYON_USEPINNEDMEMORY) 54 cudaMallocHost(&coords, numpts *
sizeof(
float) * 3);
56 float *coords =
new float[numpts * 3];
58 float uinc = (umax-umin) / udiv;
59 float vinc = (vmax-vmin) / vdiv;
63 for (iu=0; iu<udiv; iu++,u+=uinc) {
66 for (iv=0; iv<vdiv; iv++,v+=vinc,ind+=3) {
67 function(coords+ind, u, v);
76 const float twopi = 2.0f *
M_PI;
84 if (!strcmp(surftype,
"bour")) {
88 [=](
float *coords,
float u,
float v) {
92 sincosf(v, &sinv, &cosv);
94 coords[0] = r * ( u * cosv - 0.5f * (u*u)*cosf(2.0f * v));
95 coords[1] = r * (-u * sinv * (u * cosv + 1.0f));
96 coords[2] = r * (4.0f/3.0f * powf(u, 1.5f) * cosf(3.0f * v * 0.5f));
104 if (!strcmp(surftype,
"bowtie")) {
107 [=](
float *coords,
float u,
float v) {
108 const float r = 1.0f;
110 float sinu, cosu, sinv, cosv;
111 sincosf(u, &sinu, &cosu);
112 sincosf(v, &sinv, &cosv);
114 const float sqrt2 = 1.41421356237309504880f;
115 coords[0] = r * sinu / (sqrt2 + sinv);
116 coords[1] = r * sinu / (sqrt2 + cosv);
117 coords[2] = r * cosu / (1.0f + sqrt2);
125 if (!strcmp(surftype,
"chiclet")) {
128 [=](
float *coords,
float u,
float v) {
129 const float r = 1.5f;
131 float sinu, cosu, sinv, cosv;
132 sincosf(u, &sinu, &cosu);
133 sincosf(v, &sinv, &cosv);
135 coords[0] = 0.5f * r * (sinu + cosv);
136 coords[1] = r * cosu;
137 coords[2] = r * sinv;
144 if (!strcmp(surftype,
"cone")) {
147 [=](
float *coords,
float u,
float v) {
148 const float r = 2.0f;
151 sincosf(u, &sinu, &cosu);
153 coords[0] = r * sinu * sinf(v);
154 coords[1] = r * sinf(v);
155 coords[2] = r * cosu * sinf(v);
163 if (!strcmp(surftype,
"klein")) {
165 float unowrapscale = udiv/float(udiv-1);
166 float vnowrapscale = vdiv/float(vdiv-1);
170 [=](
float *coords,
float u,
float v) {
171 float u2 = u * unowrapscale;
172 float v2 = v * vnowrapscale;
174 float sinu, cosu, sinv, cosv;
175 sincosf(u2, &sinu, &cosu);
176 sincosf(v2, &sinv, &cosv);
178 const float r = 2.0f - cosu;
179 coords[0] = 0.4f * (2.0f * (1.0f - sinu) * cosu +
180 r * cosv * (2.0f * expf(-powf(u2/2.0f -
M_PI, 2.0f)) - 1.0f));
181 coords[1] = 0.4f * (-(6.0f * sinu +
182 0.5f * r * sinu * cosv * expf(-powf(u2 - 3.0f *
M_PI * 0.5f, 2.0f))));
183 coords[2] = 0.4f * (r * sinv);
190 if (!strcmp(surftype,
"plane")) {
195 [=](
float *coords,
float u,
float v) {
196 const float r = 1.0f;
207 if (!strcmp(surftype,
"shell")) {
209 float unowrapscale = udiv/float(udiv-1);
210 float vnowrapscale = vdiv/float(vdiv-1);
214 [=](
float *coords,
float u,
float v) {
215 float u3 = u * unowrapscale * 3.0f;
216 float v2 = v * vnowrapscale;
217 float coshalfvsqr = cosf(v2 * 0.5f);
218 coshalfvsqr *= coshalfvsqr;
219 float expu_6f = expf(u3/(6.0f *
M_PI));
220 coords[0] = 2.0f * ( 1.0f - expu_6f) * cosf(u3) * coshalfvsqr;
221 coords[1] = -5.5f -(-expf(u3/(3.0f *
M_PI)) - sinf(v2) + expf(u3/(6.0f *
M_PI)) * sinf(v2));
222 coords[2] = 2.0f * (-1.0f + expu_6f) * sinf(u3) * coshalfvsqr;
229 if (!strcmp(surftype,
"sphere")) {
230 float vnowrapscale = vdiv/float(vdiv-1);
234 [=](
float *coords,
float u,
float v) {
235 const float r = 2.0f;
236 float v2 = v * vnowrapscale;
237 coords[0] = r * sinf(u) * cosf(v2);
238 coords[1] = r * sinf(v2);
239 coords[2] = r * cosf(u) * cosf(v2);
247 if (!strcmp(surftype,
"spiral")) {
252 [=](
float *coords,
float u,
float v) {
253 const float r = 2.0f;
257 float sinu, cosu, sinv, cosv;
258 sincosf(u2, &sinu, &cosu);
259 sincosf(v2, &sinv, &cosv);
261 coords[0] = r * cosu * sinv;
262 coords[1] = 1.0 + -r * ((cosv + logf(tanf(v2 * 0.5f))) + 0.2f*u2);
263 coords[2] = r * sinu * sinv;
269 if (!strcmp(surftype,
"spiral2")) {
271 float unowrapscale = udiv/float(udiv-1);
272 float vnowrapscale = vdiv/float(vdiv-1);
276 [=](
float *coords,
float u,
float v) {
277 const float r = 0.5f;
278 float u2 = u * unowrapscale * 1.4f;
279 float v2 = v * vnowrapscale * 0.4f;
281 float sinu, cosu, sinv, cosv;
282 sincosf(u2, &sinu, &cosu);
283 sincosf(v2, &sinv, &cosv);
285 coords[0] = -1.0f + r * u2 * sinu * cosv;
286 coords[1] = -3.0f + r * u2 * sinv;
287 coords[2] = r * u2 * cosu * cosv;
293 if (!strcmp(surftype,
"torus")) {
296 [=](
float *coords,
float u,
float v) {
297 float sinu, cosu, sinv, cosv;
298 sincosf(u, &sinu, &cosu);
299 sincosf(v, &sinv, &cosv);
301 coords[0] = 2.0f * cosu * (1.0f - cosv * 0.5f);
302 coords[1] = 2.0f * sinv * 0.5f;
303 coords[2] = 2.0f * sinu * (1.0f - cosv * 0.5f);
311 if (!strcmp(surftype,
"trefoil")) {
314 [=](
float *coords,
float u,
float v) {
315 const float r = 0.7f;
318 coords[0] = r * ((4.0f * (1.0f + 0.25f*sinf(v3)) + cosf(u))*cosf(v2));
319 coords[1] = r * ((4.0f * (1.0f + 0.25f*sinf(v3)) + cosf(u))*sinf(v2));
320 coords[2] = r * (sinf(u) + 2.0f*cosf(v3));
326 if (!strcmp(surftype,
"trefoil2")) {
329 [=](
float *coords,
float u,
float v) {
330 const float r = 2.0f;
333 const float twothirdspi =
M_PI * 2.0f / 3.0f;
334 coords[0] = r * sinf(u3) / (2.0f + cosf(v));
335 coords[1] = r / 2.0f * (cosf(u) - 2.0f * cosf(u2)) * (2.0f + cosf(v)) * (2.0f + cosf(v + twothirdspi)) / 4.0f;
336 coords[2] = r * (sinf(u) + 2.0f * sinf(u2)) / (2.0f + cosf(v + twothirdspi)) / 4.0f;
344 if (!strcmp(surftype,
"twisty")) {
347 [=](
float *coords,
float u,
float v) {
348 const float r = 0.5f;
351 coords[0] = r * cosf(v) * (6.0f - (1.25f + sinf(u3)) * sinf(u - v3));
352 coords[2] = r * (6.0f - (1.25f + sinf(u3)) * sinf(u - v3)) * sinf(v);
353 coords[1] = r * -cosf(u - v3) * (1.25f + sinf(u3));
360 if (!strcmp(surftype,
"vase")) {
363 [=](
float *coords,
float u,
float v) {
365 sincosf(u, &sinu, &cosu);
379 int numpts = udiv * vdiv;
380 #if defined(TACHYON_USEPINNEDMEMORY) 382 cudaMallocHost(&colors, numpts *
sizeof(
float) * 3);
384 float *colors =
new float[numpts * 3];
387 for (
int iu=0; iu<udiv; iu++) {
388 for (
int iv=0; iv<vdiv; iv++) {
389 int i = iu*vdiv + iv;
392 float h = float(i) / float(numpts);
398 HSItoRGB(h, s, l, colors[ind], colors[ind + 1], colors[ind + 2]);
407 int numpts = udiv * vdiv;
408 #if defined(TACHYON_USEPINNEDMEMORY) 410 cudaMallocHost(&colors, numpts *
sizeof(
float) * 4);
412 float *colors =
new float[numpts * 4];
415 for (
int iu=0; iu<udiv; iu++) {
416 for (
int iv=0; iv<vdiv; iv++) {
417 int i = iu*vdiv + iv;
420 float h = float(i) / float(numpts);
426 HSItoRGB(h, s, l, colors[ind], colors[ind + 1], colors[ind + 2]);
427 colors[ind + 3] = 1.0f;
437 int umax = (wrapmesh) ? udiv : (udiv-1);
438 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
440 int numedges = umax * vmax;
441 #if defined(TACHYON_USEPINNEDMEMORY) 442 int * quadmesh_indices;
443 cudaMallocHost(&quadmesh_indices, numedges *
sizeof(
int) * 4);
445 int * quadmesh_indices =
new int[numedges * 4];
448 for (
int iu=0; iu<umax; iu++) {
449 for (
int iv=0; iv<vmax; iv++) {
450 int vertind = iu * vdiv + iv;
451 int quadind = 4 * (iu * vmax + iv);
452 int iunext = (iu+1) % udiv;
453 int ivnext = (iv+1) % vdiv;
456 quadmesh_indices[quadind ] = vertind;
457 quadmesh_indices[quadind + 1] = iu * vdiv + ivnext;
458 quadmesh_indices[quadind + 2] = iunext * vdiv + ivnext;
459 quadmesh_indices[quadind + 3] = iunext * vdiv + iv;
463 return quadmesh_indices;
469 int umax = (wrapmesh) ? udiv : (udiv-1);
470 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
472 int numedges = umax * vmax;
473 #if defined(TACHYON_USEPINNEDMEMORY) 474 int * trimesh_indices;
475 cudaMallocHost(&trimesh_indices, numedges *
sizeof(
int) * 2 * 3);
477 int * trimesh_indices =
new int[numedges * 2 * 3];
480 for (
int iu=0; iu<umax; iu++) {
481 for (
int iv=0; iv<vmax; iv++) {
482 int vertind = iu * vdiv + iv;
483 int quadind = 6 * (iu * vmax + iv);
484 int iunext = (iu+1) % udiv;
485 int ivnext = (iv+1) % vdiv;
488 trimesh_indices[quadind ] = vertind;
489 trimesh_indices[quadind + 1] = iu * vdiv + ivnext;
490 trimesh_indices[quadind + 2] = iunext * vdiv + iv;
492 trimesh_indices[quadind + 3] = iu * vdiv + ivnext;
493 trimesh_indices[quadind + 4] = iunext * vdiv + iv;
494 trimesh_indices[quadind + 5] = iunext * vdiv + ivnext;
498 return trimesh_indices;
504 int umax = (wrapmesh) ? udiv : (udiv-1);
505 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
507 int numedges = umax * vmax;
508 #if defined(TACHYON_USEPINNEDMEMORY) 509 int * wiremesh_indices;
510 cudaMallocHost(&wiremesh_indices, numedges *
sizeof(
int) * 2 * 3);
512 int * wiremesh_indices =
new int[numedges * 2 * 2];
515 for (
int iu=0; iu<umax; iu++) {
516 for (
int iv=0; iv<vmax; iv++) {
517 int vertind = iu * vdiv + iv;
518 int cylind = 4 * (iu * vmax + iv);
519 int iunext = (iu+1) % udiv;
520 int ivnext = (iv+1) % vdiv;
523 wiremesh_indices[cylind ] = vertind;
524 wiremesh_indices[cylind + 1] = iu * vdiv + ivnext;
526 wiremesh_indices[cylind + 2] = vertind;
527 wiremesh_indices[cylind + 3] = iunext * vdiv + iv;
531 return wiremesh_indices;
539 float *coords,
float *colors,
int *trimesh_indices,
int mat) {
540 int numpts = udiv * vdiv;
543 int umax = (wrapmesh) ? udiv : (udiv-1);
544 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
545 int numedges = umax * vmax;
550 mesh.
indices.resize(numedges*2);
552 float3 *verts = mesh.
vertices.data();
554 int3 *indices = mesh.
indices.data();
556 memcpy(verts, coords, numpts * 3 *
sizeof(
float));
557 memcpy(cols, colors, numpts * 3 *
sizeof(
float));
558 memcpy(indices, trimesh_indices, numedges * 2 * 3 *
sizeof(
int));
568 float *coords,
float *colors,
int *quadmesh_indices,
int mat) {
569 int numpts = udiv * vdiv;
572 int umax = (wrapmesh) ? udiv : (udiv-1);
573 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
574 int numedges = umax * vmax;
581 float3 *verts = mesh.
vertices.data();
583 int4 *indices = mesh.
indices.data();
585 memcpy(verts, coords, numpts * 3 *
sizeof(
float));
586 memcpy(cols, colors, numpts * 3 *
sizeof(
float));
587 memcpy(indices, quadmesh_indices, numedges * 4 *
sizeof(
int));
597 float *coords,
float radius,
float *colors,
int mat) {
598 int numpts = udiv * vdiv;
601 spheres.
center.resize(numpts);
602 spheres.
radius.resize(numpts);
605 float3 *verts = spheres.
center.data();
606 float *radii = spheres.
radius.data();
609 memcpy(verts, coords, numpts * 3 *
sizeof(
float));
611 if (colors != NULL) {
612 memcpy(cols, colors, numpts * 3 *
sizeof(
float));
614 for (
int i=0; i<numpts; i++) {
618 for (
int i=0; i<numpts; i++)
630 float *coords,
float radius,
float *colors,
631 int *wiremesh_indices,
int mat) {
635 int umax = (wrapmesh) ? udiv : (udiv-1);
636 int vmax = (wrapmesh) ? vdiv : (vdiv-1);
637 int numedges = umax * vmax;
640 cyls.
start.resize(numedges*2);
641 cyls.
end.resize(numedges*2);
642 cyls.
radius.resize(numedges*2);
645 float3 *vstart = cyls.
start.data();
646 float3 *vend = cyls.
end.data();
647 float *vrad = cyls.
radius.data();
650 for (
int i=0; i<numedges*2; i++) {
651 int idx1 = 3 * wiremesh_indices[i*2 ];
652 int idx2 = 3 * wiremesh_indices[i*2+1];
653 vstart[i] =
make_float3(coords[idx1], coords[idx1+1], coords[idx1+2]);
654 vend[i] =
make_float3(coords[idx2], coords[idx2+1], coords[idx2+2]);
657 cols[i] =
make_float3(colors[idx1], colors[idx1+1], colors[idx1+2]);
672 -100.0f, 4.0f, -100.0f,
673 -100.0f, 4.0f, 100.0f,
674 100.0f, 4.0f, -100.0f,
678 1.0f, 1.0f, 1.0f, 1.0f,
679 1.0f, 1.0f, 1.0f, 1.0f,
680 1.0f, 1.0f, 1.0f, 1.0f,
681 1.0f, 1.0f, 1.0f, 1.0f
688 vertex[ 0] = -width / 2.0f;
689 vertex[ 3] = -width / 2.0f;
690 vertex[ 6] = width / 2.0f;
691 vertex[ 9] = width / 2.0f;
698 vertex[ 2] = -
length / 2.0f;
699 vertex[ 5] =
length / 2.0f;
700 vertex[ 8] = -
length / 2.0f;
701 vertex[11] =
length / 2.0f;
708 float3 *verts = mesh.
vertices.data();
710 int3 *indices = mesh.
indices.data();
712 memcpy(verts, vertex, 4 * 3 *
sizeof(
float));
713 memcpy(cols, color, 4 * 3 *
sizeof(
float));
714 memcpy(indices, index, 2 * 3 *
sizeof(
int));
722 printf(
"Coordinate dump:\n");
727 for (i=0; i<count; i++) {
729 printf(
"[%d]: %.3f %.3f %.3f\n",
730 i, coords[ind], coords[ind+1], coords[ind+2]);
734 for (i=numpts-count; i<numpts; i++) {
736 printf(
"[%d]: %.3f %.3f %.3f\n",
737 i, coords[ind], coords[ind+1], coords[ind+2]);
742 int main(
int argc,
const char **argv) {
746 int imgSize[2] = {4096, 4096 };
747 const char *surftype =
"twisty";
754 float radius = 0.025f;
755 int ambientocclusion = 1;
764 float cam_pos[] = {0.0f, -6.0f, -8.0f};
765 float cam_up[] = {0.0f, 1.0f, 0.0f};
769 float invlen = 1.0f / sqrtf(cam_pos[0]*cam_pos[0] +
770 cam_pos[1]*cam_pos[1] +
771 cam_pos[2]*cam_pos[2]);
772 cam_view[0] = -cam_pos[0] * invlen;
773 cam_view[1] = -cam_pos[1] * invlen;
774 cam_view[2] = -cam_pos[2] * invlen;
781 printf(
"Usage: %s surftype udivs vdivs [optional flags]\n", argv[0]);
782 printf(
" optional flags: -nofloor: don't draw floor\n");
783 printf(
" -nospheres: don't draw spheres\n");
784 printf(
" -quads: draw surfaces using quads\n");
785 printf(
" -wireframe: draw wireframe over surfaces\n");
786 printf(
" -ao: add renderer-specific AO lighting\n");
787 printf(
" -res XXXX YYYY: override default image res\n");
798 udiv = atoi(argv[2]);
799 vdiv = atoi(argv[3]);
804 for (
int i=4; i<argc; i++) {
805 if (!strcmp(
"-wireframe", argv[i])) {
808 printf(
"Drawing wireframe mesh over surface...\n");
812 if (!strcmp(
"-quads", argv[i])) {
814 printf(
"Drawing surface using quads.\n");
818 if (!strcmp(
"-nofloor", argv[i])) {
820 printf(
"Drawing surface without floor.\n");
824 if (!strcmp(
"-nosurf", argv[i])) {
826 printf(
"Don't draw surface.\n");
830 if (!strcmp(
"-nospheres", argv[i])) {
832 printf(
"Drawing surface without sphere points.\n");
836 if (!strcmp(
"-ao", argv[i])) {
837 ambientocclusion = 1;
838 printf(
"Enabling renderer-specific AO lighting.\n");
842 if (!strcmp(
"-noao", argv[i])) {
843 ambientocclusion = 0;
844 printf(
"Disabling renderer-specific AO lighting.\n");
848 if (!strcmp(
"-res", argv[i])) {
849 if ((argc - i) >= 2) {
850 imgSize[0] = atoi(argv[++i]);
851 imgSize[1] = atoi(argv[++i]);
852 printf(
"Image resolution set to: %d x %d\n", imgSize[0], imgSize[1]);
858 if (!strcmp(
"-pause", argv[i])) {
863 if (!strcmp(
"-dumpcoords", argv[i])) {
865 if ((argc - i) >= 2) {
866 dumpcoords = atoi(argv[++i]);
870 if (!strcmp(
"-warmup", argv[i])) {
872 printf(
"Enabling profiling warm-up pass and timing.\n");
876 printf(
"Unrecognized flag: '%s'.\n", argv[i]);
881 #if defined(TACHYON_USEPINNEDMEMORY) 882 printf(
"USING PINNED HOST MEMORY ALLOCATIONS\n");
889 int numpts = udiv * vdiv;
890 printf(
"Calculating parametric grid type: %s, udiv: %d, vdiv: %d, points: %d\n", surftype, udiv, vdiv, numpts);
895 printf(
"Surface type '%s' unrecognized, exiting.\n", surftype);
912 printf(
"Surface mesh contains %d quads, or %d triangles\n",
913 udiv*vdiv, udiv*vdiv*2);
916 printf(
"Surface scene contains %d spheres\n", numpts);
921 printf(
"Initializing TachyonOptiX...");
928 printf(
"Found %u OptiX devices\n", devcount);
929 printf(
"OptiX version used for build: %d.%d.%d (%u)\n",
931 (optixversion%10000)/100,
948 float rtbgcolor[] = { 1.0, 1.0, 1.0 };
949 float rtbggradtopcolor[] = { 0.6, 0.0, 0.0 };
950 float rtbggradbotcolor[] = { 0.0, 0.0, 0.6 };
956 float bggradient[] = { 0.0f, 1.0f, 0.0f };
968 if (ambientocclusion) {
978 float lightdir0[] = { -0.5f, 0.5f, -1.0f };
979 float lightcolor0[] = { 1.0f, 1.0f, 1.0f };
986 float campos[3] = {0.0f, 10.0f, 12.f};
988 float camV[3] = {0.0f, 1.0f, 0.0f};
990 float camat[3] = {0.0f, 0.0f, 0.0f};
1006 float density = 0.33f;
1013 float ambient = 0.0f;
1014 float diffuse = 0.7f;
1015 float specular = 0.0f;
1016 float shininess = 0.0f;
1017 float reflectivity = 0.0f;
1018 float opacity = 1.0f;
1019 float outline = 0.0f;
1020 float outlinewidth = 0.0f;
1023 rt->
add_material(ambient, diffuse, specular, shininess, reflectivity,
1024 opacity, outline, outlinewidth, transmode, mat);
1033 for (
int w=0; w<100; w++) {
1049 (wireframe) ? NULL : colors, mat);
1055 gen_wiremesh(rt, udiv, vdiv, wrapmesh, coords, radius, (wireframe) ? NULL : colors, wiremesh_indices, mat);
1060 gen_quadmesh(rt, udiv, vdiv, wrapmesh, coords, colors, quadmesh_indices, mat);
1063 gen_trimesh(rt, udiv, vdiv, wrapmesh, coords, colors, trimesh_indices, mat);
1069 gen_floor(rt, 200.0f, -4.0f, 200.0f, mat);
1074 printf(
"Rendering frames w/ accumulation buffer...\n");
1085 char filename[1024];
1086 sprintf(filename,
"parametric-%s-%d-%d.png", surftype, udiv, vdiv);
1087 printf(
"Writing accumulated frames to '%s'...\n", filename);
1088 if (filename != NULL) {
1090 size_t bufsz = imgSize[0] * imgSize[1] *
sizeof(int);
1091 unsigned char *rgb4u = (
unsigned char *) calloc(1, bufsz);
1096 printf(
"Writing rgba4u alpha channel output image 2\n");
1097 if (write_image_file_rgba4u(filename, rgb4u, imgSize[0], imgSize[1]))
1098 printf(
"Failed to write image '%s'!!\n", filename);
1100 if (write_image_file_rgb4u(filename, rgb4u, imgSize[0], imgSize[1]))
1101 printf(
"Failed to write image '%s'!!\n", filename);
1106 stbi_write_png(filename, imgSize[0], imgSize[1], 4, rgb4u, imgSize[0] *
sizeof(
int));
1113 #if defined(TACHYON_USEPINNEDMEMORY) 1114 cudaFreeHost(coords);
1115 cudaFreeHost(colors);
1116 cudaFreeHost(quadmesh_indices);
1117 cudaFreeHost(trimesh_indices);
1118 cudaFreeHost(wiremesh_indices);
1122 delete [] quadmesh_indices;
1123 delete [] trimesh_indices;
1124 delete [] wiremesh_indices;
STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean)
void gen_spheresurf(TachyonOptiX *rt, int udiv, int vdiv, float *coords, float radius, float *colors, int mat)
void set_ao_maxdist(float dist)
set AO maximum occlusion distance
std::vector< float3 PINALLOCS(float3)> center
void set_bg_gradient_topval(float v)
set background gradient "top" value (view direction dot product)
float * parametric_grid_verts(const char *surftype, int udiv, int vdiv, int &wrapmesh)
void gen_quadmesh(TachyonOptiX *rt, int udiv, int vdiv, int wrapmesh, float *coords, float *colors, int *quadmesh_indices, int mat)
std::vector< float3 PINALLOCS(float3)> vertcolors3f
void HSItoRGB(float h, float s, float i, float &r, float &g, float &b)
std::vector< float PINALLOCS(float)> radius
void gen_trimesh(TachyonOptiX *rt, int udiv, int vdiv, int wrapmesh, float *coords, float *colors, int *trimesh_indices, int mat)
void set_ao_samples(int cnt)
ambient occlusion (samples > 1 == on)
float * parametric_grid_colors3f(int udiv, int vdiv)
void gen_wiremesh(TachyonOptiX *rt, int udiv, int vdiv, int wrapmesh, float *coords, float radius, float *colors, int *wiremesh_indices, int mat)
int * parametric_wiremesh_indices(int udiv, int vdiv, int wrapmesh)
__host__ __device__ float3 make_float3(const float s)
void framebuffer_get_size(int &fbwidth, int &fbheight)
void add_directional_light(const float *dir, const float *color)
std::vector< float3 PINALLOCS(float3)> primcolors3f
int main(int argc, const char **argv)
int add_material(float ambient, float diffuse, float specular, float shininess, float reflectivity, float opacity, float outline, float outlinewidth, int transmode, int userindex)
add a material with an associated user-provided index
CPU and GPU profiling utility macros/routines.
#define PROFILE_PUSH_RANGE(name, cid)
Pushes a time range annotation onto the profiler's trace stack, beginning at the time of submission...
std::vector< float PINALLOCS(float)> radius
void framebuffer_resize(int fbwidth, int fbheight)
void camera_dof_enable(int onoff)
depth of field on/off
static int device_count(void)
static GPU device query
void set_camera_lookat(const float *at, const float *V)
set camera orientation to look "at" a point in space, with a given "up" direction (camera ONB "V" vec...
void print_raystats_info(void)
report performance statistics
std::vector< float3 PINALLOCS(float3) > vertices
std::vector< float3 PINALLOCS(float3)> start
Output timing/perf data only.
int * parametric_trimesh_indices(int udiv, int vdiv, int wrapmesh)
void set_ao_direct(float aod)
set AO direct lighting rescale factor
void framebuffer_clear(void)
void set_bg_gradient(float *vec)
set world "up" direction for background gradient
void add_spherearray(SphereArray &model, int matidx)
std::vector< float3 PINALLOCS(float3) > vertcolors3f
float * parametric_grid_colors4f(int udiv, int vdiv)
#define PROFILE_POP_RANGE()
Pops the innermost time range off of the profiler's trace stack, at the time of execution.
void set_camera_zoom(float zoomfactor)
set camera zoom factor
void set_camera_dof_fnumber(float n)
set depth of field f/stop number
std::vector< float3 PINALLOCS(float3)> vertices
std::vector< int4 PINALLOCS(int4)> indices
void set_bg_color_grad_bot(float *rgb)
set color for "bottom" of background gradient
void set_camera_type(CameraType m)
set the camera projection mode
void framebuffer_download_rgb4u(unsigned char *imgrgb4u)
void print_coords(float *coords, int numpts, int count)
void set_camera_stereo_convergence_dist(float dist)
set stereo convergence distance
void shadows_enable(int onoff)
enable/disable shadows
void set_bg_color(float *rgb)
set solid background color
void set_ao_ambient(float aoa)
set AO ambient lighting factor
int * parametric_quadmesh_indices(int udiv, int vdiv, int wrapmesh)
void set_aa_samples(int cnt)
antialiasing (samples > 1 == on)
#define PROFILE_START()
Trigger the beginning of profiler trace capture, for those that support it.
void set_cue_mode(FogMode mode, float start, float end, float density)
set depth cueing mode and parameters
void set_bg_gradient_botval(float v)
set background gradient "bottom" value (view direction dot product)
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
void set_verbose_mode(TachyonOptiX::Verbosity mode)
programmatically set verbosity
void set_bg_color_grad_top(float *rgb)
set color for "top" of background gradient
__host__ __device__ float length(const float3 &v)
void set_camera_pos(const float *pos)
set the camera position
static unsigned int optix_version(void)
static OptiX version query
std::vector< int3 PINALLOCS(int3) > indices
void set_camera_stereo_eyesep(float eyesep)
set stereo eye separation
void gen_floor(TachyonOptiX *rt, float width, float height, float length, int mat)
void framebuffer_colorspace(int colspace)
Tachyon ray tracing host side routines and internal APIs that provide the core ray OptiX-based RTX-ac...
void add_cylarray(CylinderArray &model, int matidx)
float * parametric_lambda(int udiv, float umin, float umax, int vdiv, float vmin, float vmax, F function)
void set_bg_mode(BGMode m)
set background rendering mode
void set_camera_dof_focal_dist(float d)
set depth of field focal plane distance
std::vector< float3 PINALLOCS(float3)> primcolors3f
void add_trimesh(TriangleMesh &model, int matidx)
std::vector< float3 PINALLOCS(float3)> end
void add_quadmesh(QuadMesh &model, int matidx)
#define PROFILE_INITIALIZE()
Initialize the profiling system.