Opened 11 years ago

Closed 6 years ago

#9855 closed defect (fixed)

fix support for projection options in Tachyon

Reported by: mhampton Owned by: jason, was
Priority: minor Milestone: sage-6.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:

Status badges

Description

Currently the Tachyon object defined in plot3d/tachyon.py does not support projections other than the default.

Attachments (2)

trac_9855_tachyon.patch (17.5 KB) - added by mhampton 10 years ago.
Improves tachyon support
texture_mapping.png (88.0 KB) - added by chapoton 6 years ago.
result of texture mapping

Download all attachments as: .zip

Change History (22)

comment:1 Changed 11 years ago by mhampton

In addition to supporting depth-of-field projections and fisheye lens projections, textures can now use plane-, cylinder-, and sphere-wrapped bitmaps (ppm files).

comment:2 Changed 11 years ago by mhampton

  • Status changed from new to needs_review

comment:3 Changed 11 years ago by mhampton

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 11 years ago by wdj

  • 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 11 years ago by vbraun

  • 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 11 years ago by mhampton

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 11 years ago by mhampton

  • Status changed from needs_info to needs_work

Changed 10 years ago by mhampton

Improves tachyon support

comment:8 Changed 10 years ago by mhampton

  • Status changed from needs_work to needs_review

Added more examples and documentation, I think is ready for review again.

comment:9 Changed 10 years ago by mhampton

  • Authors set to Marshall Hampton
  • Milestone set to sage-4.6.2
  • Reviewers set to Volker Braun, David Joyner

comment:10 Changed 10 years ago by wdj

  • 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 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:12 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:13 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:14 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:15 Changed 6 years ago by chapoton

  • Branch set to u/chapoton/9855
  • Commit set to 37c662f9be3318dc12846026a06e304ea35f93a6

Here is a git branch, still working after so many years ! I just made a quick refreshing.

There remains to make the #optional more precise. Can one use #optional - convert ?


New commits:

eda445ftrac_9855: fix support for project options in tachyon
37c662ftrac #9855 little polishing of doc

Changed 6 years ago by chapoton

result of texture mapping

comment:16 Changed 6 years ago by chapoton

Here is one example image

result of texture mapping

comment:17 Changed 6 years ago by git

  • Commit changed from 37c662f9be3318dc12846026a06e304ea35f93a6 to 3c8613966ef181b8d6cbc6ed217806e1dc9a6a61

Branch pushed to git repo; I updated commit sha1. New commits:

3c86139trac #9855 correct optional keyword

comment:18 Changed 6 years ago by chapoton

  • Status changed from needs_info to needs_review

I have now added the correct optional tag. Back to Needs review !

comment:19 Changed 6 years ago by vbraun

  • Status changed from needs_review to positive_review

lgtm

comment:20 Changed 6 years ago by vbraun

  • Branch changed from u/chapoton/9855 to 3c8613966ef181b8d6cbc6ed217806e1dc9a6a61
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.