Created
March 25, 2020 18:26
-
-
Save arpit15/aa326fe42519aee54cb276ee1e5dc206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPointEmitter(Emitter): | |
"""docstring for MyPointEmitter""" | |
def __init__(self, props): | |
# super(MyPointEmitter, props).__init__(props) | |
Emitter.__init__(self, props) | |
print(self.m_world_transform) | |
self.m_intensity = props['intensity'] # assumption that a texture is returned | |
print(self.m_intensity.class_().name()) | |
self.m_needs_sample_3 = False | |
self.m_flags = +EmitterFlags.DeltaPosition | |
def sample_ray(self, time, | |
sample1, # wavelength | |
sample2, # pos | |
sample3, # dir | |
active): | |
wavelengths, spec_weight = self.m_intensity.sample(SurfaceInteraction3f(), np.arange(sample1), active) | |
trafo = self.m_world_transform.eval(ref.time) | |
ray = Ray3f(trafo*Point3f(0), warp.square_to_uniform_sphere(sample3), | |
time, wavelengths) | |
print(spec_weight.class_().name()) | |
return (ray, spec_weight*4.0*Pi) | |
def sample_direction(self, ref, sample, active): | |
trafo = self.m_world_transform.eval(ref.time, active) | |
ds = DirectionSample3f() | |
ds.p = trafo.translation() | |
ds.n = 0 | |
ds.uv = 0 | |
ds.time = ref.time | |
ds.pdf = 1 | |
ds.delta = True | |
ds.d = ds.p - ref.p | |
ds.dist = ek.norm(ds.d) | |
inv_dist = ek.rcp(ds.dist) | |
ds.d *= inv_dist | |
si = SurfaceInteraction3f() | |
si.wavelengths = ref.wavelengths | |
spec = self.m_intensity.eval(si, active)*(inv_dist*inv_dist) | |
print(spec.class_().name()) | |
return (ds, spec) | |
def pdf_direction(self, ref, ds, active): | |
return 0 | |
def eval(self, si, active): | |
return 0 | |
def bbox(self): | |
return self.m_world_transform.translation_bounds() | |
def to_string(self): | |
mystr = "MyPointLight\n" | |
mystr.append(" world_transform" + self.m_world_transform.to_string()) | |
mystr.append(" intensity" + self.m_intensity + "\n") | |
return mystr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment