Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Mon May 30 00:07:10 2022
- """
- import numpy as np
- from numpy import cos
- from numpy import sin
- from numpy import sqrt
- # docs, examples: https://plotoptix.rnd.team
- from plotoptix import TkOptiX
- from plotoptix.utils import make_color
- from plotoptix.materials import m_plastic
- def trefoil(u, v, r):
- q = 8.0 * cos(3*u) + 17.0
- p = 6.0 * cos(3*u)
- qq = q**2
- pp = p**2
- dc = r * cos(v)
- ds = r * sin(v)
- L = sqrt(q*pp+qq)
- Xuv = sin(u) + 2.0*sin(2*u) - ( (4.0*sin(2*u)-sin(u))/sqrt(q) ) * dc +\
- ( (p * (4.0*cos(2*u) + cos(u)) ) / L ) * ds
- Yuv = cos(u) - 2.0*cos(2*u) + ( (cos(u)+4.0*cos(2*u))/sqrt(q) ) * dc -\
- ( (p * (sin(u) - 4.0*sin(2*u)) ) / L ) * ds
- Zuv = (q/L) * ds - 2.0*sin(3*u)
- return np.array([Xuv, Yuv, Zuv], dtype=np.float32)
- r = (0.0, 2.0*np.pi)
- n = 500
- i = np.linspace(r[0], r[1], n)
- U, V = np.meshgrid(i, i)
- S = np.swapaxes(trefoil(U, V, 3.0/4.0), 0, 2)
- rt = TkOptiX(width=800, height=600)
- rt.set_param(min_accumulation_step=2,
- max_accumulation_frames=2000,
- light_shading="Hard")
- rt.set_uint("path_seg_range", 6, 15)
- rt.setup_material("plastic", m_plastic)
- exposure = 0.8; gamma = 2.2
- rt.set_float("tonemap_exposure", exposure)
- rt.set_float("tonemap_gamma", gamma)
- rt.add_postproc("Gamma")
- rt.set_background(0)
- rt.set_ambient(0.15)
- rt.set_surface("surface", S, c=0.94, make_normals=True, mat="plastic")
- rt.set_data("plane", geom="Parallelograms",
- pos=[[-10, -5, -16]], u=[200, 0, 0], v=[0, 0, 200],
- c=make_color([0.1, 0.2, 0.3], exposure=exposure, gamma=gamma))
- rt.setup_camera("cam1", cam_type="DoF",
- eye=[0, 10, 10], target=[0, 0, 0], up=[0, 1, 0],
- aperture_radius=0.3, aperture_fract=0.2,
- focal_scale=0.99, fov=35)
- rt.setup_light("light1", pos=[-15, 20, 15], color=8, radius=6)
- rt.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement