Opened 7 years ago

Last modified 7 years ago

#16263 new enhancement

directional lighting in tachyon

Reported by: niles Owned by:
Priority: minor Milestone: sage-6.4
Component: graphics Keywords: tachyon
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: u/niles/16263/tachyon-lights (Commits, GitHub, GitLab) Commit: 84d0b894e5f34347220672f465a02350a641b890
Dependencies: Stopgaps:

Status badges

Description

Tachyon supports directional lighting with the syntax

DIRECTIONAL_LIGHT
    DIRECTION 0.0 -1.0 0.0
    COLOR 1.0 0.0 0.0

Implement this in sage.

Change History (3)

comment:1 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:2 Changed 7 years ago by niles

  • Branch set to u/niles/16263/tachyon-lights
  • Commit set to 84d0b894e5f34347220672f465a02350a641b890

I've done a little with this and then put it down; I'm attaching what I have so it doesn't get lost. The basic functionality is there, but needs to be documented.

At the moment, it's not clear that directional lights really produce something drastically better than the standard trick of just putting a light *really* far away. Here is some code I used for testing:

p = 3
q = 5
def K(s):
    """
    a (p,q) torus knot
    """
    var('t')
    r = cos(q*t + s) + 2
    x = fast_callable(r*cos(p*t + s),vars=[t])
    y = fast_callable(r*sin(p*t + s) ,vars=[t])
    z = fast_callable(-sin(q*t + s) ,vars=[t])
    def func(t):
        return (x(t),y(t),z(t))
    return func

X = Tachyon(camera_center=(4,4,10))
X.texture('t')
X.texture('mirror', ambient=0.05, diffuse=0.05, specular=.9, opacity=0.9, color=(.8,.8,.8))
X.texture('grey', color=(.8,.8,.8), texfunc=3)
X.parametric_plot(K(0),0,2*pi,'t',min_depth=6)
X.parametric_plot(K(pi/4),0,2*pi,'grey',min_depth=6)
X.parametric_plot(K(-pi/4),0,2*pi,'mirror',min_depth=6)
X.light((0,0,20),.5,(1,1,1))     # standard lights
X.light((-10,0,10),.5,(1,1,1))

Y = Tachyon(camera_center=(4,4,10))
Y.texture('t')
Y.texture('white',ambient=.8,diffuse=.8,specular=.1,color=(1,1,1))
Y.texture('mirror', ambient=0.05, diffuse=0.05, specular=.9, opacity=0.9, color=(.8,.8,.8))
Y.texture('grey', color=(.8,.8,.8), texfunc=3)
Y.parametric_plot(K(0),0,2*pi,'t',min_depth=6)
Y.parametric_plot(K(pi/4),0,2*pi,'grey',min_depth=6)
Y.parametric_plot(K(-pi/4),0,2*pi,'mirror',min_depth=6)
Y.plane((0,0,-20),(0,0,1),'white')
Y.light((0,0,1),.5,(1,1,1),'directional')    # directional lights
Y.light((-1,1,0),.5,(1,1,1),'directional')

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.