Opened 12 years ago
Closed 7 years ago
#9855 closed defect (fixed)
fix support for projection options in Tachyon
Reported by:  mhampton  Owned by:  jason, was 

Priority:  minor  Milestone:  sage6.4 
Component:  graphics  Keywords:  tachyon, raytracing 
Cc:  vbraun  Merged in:  
Authors:  Marshall Hampton  Reviewers:  Volker Braun, David Joyner 
Report Upstream:  N/A  Work issues:  
Branch:  3c86139 (Commits, GitHub, GitLab)  Commit:  3c8613966ef181b8d6cbc6ed217806e1dc9a6a61 
Dependencies:  Stopgaps: 
Description
Currently the Tachyon object defined in plot3d/tachyon.py does not support projections other than the default.
Attachments (2)
Change History (22)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
 Status changed from new to needs_review
comment:3 Changed 12 years ago by
Here's a somewhat recursive example that shows the use of the fisheye projection and then uses that image as a plane tiling. This needs to be done in the notebook, or you need to change the DATA directory to something else.
T = Tachyon(xres = 800, yres = 600, camera_center = (2.0,.1,.3), projection='fisheye', frustum=(1.0, 1.0, 1.0, 1.0)) T.texture('t1',color=(0,0,1)) cedges = [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]] for ed in cedges: T.fcylinder(ed[0],ed[1],.05,'t1') T.light((4,4,4),.1,(1,1,1)) T.show()
T.save(DATA+'t1.png') r2 = os.system('convert '+DATA+'t1.png '+DATA+'t1.ppm') T = Tachyon(xres = 800, yres = 600, camera_center = (2.0,.1,.3), projection='fisheye', frustum=(1.0, 1.0, 1.0, 1.0)) T.texture('t1',color=(0,0,1)) T.texture('p1',color=(1,1,1),opacity = .1, imagefile=DATA+'t1.ppm', texfunc=9) cedges = [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]] T.plane((0,0,1),(0,0,1),'p1') for ed in cedges: T.fcylinder(ed[0],ed[1],.05,'t1') T.light((4,4,4),.1,(1,1,1)) T.show()
comment:4 Changed 12 years ago by
 Status changed from needs_review to needs_info
This applied fine to 4.5.a.a1 on a 32 bit 10.4 ubuntu machine, and passes sage testall.
It's a great patch (I've wondered how to implement it myself) but I worry that it will be too hard to use without further details in the documentation. Does that seem reasonable? If docstring tests are too complicated, maybe just a more complete docstring explanation?
comment:5 Changed 12 years ago by
 Cc vbraun added
The aperture
option does not work for me:
sage: T = Tachyon(xres = 800, yres = 600, camera_center = (1.5,1.5,.3), projection='fisheye', frustum=(1.0, 1.0, 1.0, 1.0), aperture = 1) sage: T.texture('t1',color=(0,0,1)) sage: cedges = [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]] sage: for ed in cedges: ....: T.fcylinder(ed[0],ed[1],.05,'t1') ....: sage: T.light((4,4,4),.1,(1,1,1)) sage: T.show()
and nothing appears. Works fine without the aperture option.
comment:6 Changed 12 years ago by
Thanks for taking a look.
Obviously I need to add quite a bit of examples and more documentation; unfortunately most of these options aren't well (or at all) documented upstream.
I think the aperture option only works with projection = 'perspective_dof', and then you also need the focallength parameter. These don't work quite as I would expect but my knowledge of optics is limited.
T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection = 'perspective_dof', focallength = '1.0', aperture = '.0025') T.light((0,5,7),1.0,(1,1,1)) T.texture('t1', opacity=1, specular = .3) T.texture('t2', opacity=1, specular = .3, color = (0,0,1)) T.texture('t3', opacity = 1, specular = 1, color = (1,.8,1), diffuse=0.2) T.plane((0,0,1),(0,0,1),'t3') ttlist = ['t1','t2'] tt = 't1' T.cylinder((0,0,.1),(1,1/3,0),.05,'t3') for q in srange(3,100,.15): if tt == 't1': tt = 't2' else: tt = 't1' T.sphere((q,q/3+.3*sin(3*q),.1+.3*cos(3*q)), .1, tt) T.show()
comment:7 Changed 12 years ago by
 Status changed from needs_info to needs_work
comment:8 Changed 11 years ago by
 Status changed from needs_work to needs_review
Added more examples and documentation, I think is ready for review again.
comment:9 Changed 11 years ago by
 Milestone set to sage4.6.2
 Reviewers set to Volker Braun, David Joyner
comment:10 Changed 11 years ago by
 Status changed from needs_review to needs_info
This installs on 4.6.1.rc1 and passes sage testall on an ubuntu linux machine with imagemagik loaded.
I am not seeing where it is documented that the # optional
lines require imagemagik (and linux?). Am I missing something? ALso, I could not het vbraun's example to work, even with projection = 'perspective_dof
. Am I doing something wrong?
comment:11 Changed 9 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:12 Changed 8 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:13 Changed 8 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:14 Changed 8 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:15 Changed 7 years ago by
 Branch set to u/chapoton/9855
 Commit set to 37c662f9be3318dc12846026a06e304ea35f93a6
comment:16 Changed 7 years ago by
comment:17 Changed 7 years ago by
 Commit changed from 37c662f9be3318dc12846026a06e304ea35f93a6 to 3c8613966ef181b8d6cbc6ed217806e1dc9a6a61
Branch pushed to git repo; I updated commit sha1. New commits:
3c86139  trac #9855 correct optional keyword

comment:18 Changed 7 years ago by
 Status changed from needs_info to needs_review
I have now added the correct optional tag. Back to Needs review !
comment:20 Changed 7 years ago by
 Branch changed from u/chapoton/9855 to 3c8613966ef181b8d6cbc6ed217806e1dc9a6a61
 Resolution set to fixed
 Status changed from positive_review to closed
In addition to supporting depthoffield projections and fisheye lens projections, textures can now use plane, cylinder, and spherewrapped bitmaps (ppm files).