Example #1
0
def create_shape_sphere(paramset: ParamSet, object2world: Transform, world2object: Transform) -> Sphere:
    radius = paramset.find_float("radius", 1.0)
    zmin = paramset.find_float("zmin", -radius)
    zmax = paramset.find_float("zmax", radius)
    phimax = paramset.find_float("phimax", 360.0)
    shape = Sphere(object2world, world2object, radius, zmin, zmax, phimax)
    return shape
Example #2
0
def create_perspective_camera(paramset: ParamSet, cam2world: Transform, film: Film) -> PerspectiveCamera:
    shutteropen = paramset.find_float("shutteropen", 0.0)
    shutterclose = paramset.find_float("shutterclose", 1.0)
    if shutterclose < shutteropen:
        shutterclose, shutteropen = shutteropen, shutterclose
    lensradius = paramset.find_float("lensradius", 0.0)
    focaldistance = paramset.find_float("focaldistance", 1e30)
    frame = paramset.find_float("frameaspectratio", float(film.width) / float(film.height))
    fov = paramset.find_float("fov", 90.0)
    halffov = paramset.find_float("halffov", -1.0)
    if halffov > 0.0:
        # hack for structure synth, which exports half of the full fov
        fov = 2.0 * halffov

    screen_window = [float] * 4
    if frame > 1.0:
        screen_window[0] = -frame
        screen_window[1] = frame
        screen_window[2] = -1.0
        screen_window[3] = 1.0
    else:
        screen_window[0] = -1.0
        screen_window[1] = 1.0
        screen_window[2] = -1.0 / frame
        screen_window[3] = 1.0 / frame

    camera = PerspectiveCamera(cam2world, screen_window, shutteropen, shutterclose, lensradius, focaldistance, fov,
                               film)
    return camera
Example #3
0
def create_spotLight(paramSet: ParamSet, light2world: Transform) -> PointLight:
    from maths.matrix44 import Matrix44
    from maths.vector4d import Vector4d

    I = paramSet.find_spectrum("I", Spectrum(1.0))
    sc = paramSet.find_spectrum("scale", Spectrum(1.0))
    coneangle = paramSet.find_float("coneangle", 30.0)
    conedelta = paramSet.find_float("conedeltaangle", 5.0)

    # Compute spotlight world to light transformation
    frome = paramSet.find_point("from", Point3d(0.0, 0.0, 0.0))
    to = paramSet.find_point("to", Point3d(0.0, 0.0, 1.0))
    direction = (to - frome).get_normalized()
    du, dv = Transform.create_coordinateSystem(dir)
    m = Matrix44.create_from_vector4d(
        Vector4d(du.x, du.y, du.z, 0.0),
        Vector4d(dv.x, dv.y, dv.z, 0.0),
        Vector4d(direction.x, direction.y, direction.z, 0.0),
        Vector4d(0.0, 0.0, 0.0, 1.0))
    dirToZ = Transform(m)
    light2world = light2world * Transform.create_translate(frome.ex, frome.ey, frome.ez) * dirToZ.get_invert()
    return SpotLight(light2world, I * sc, coneangle, coneangle - conedelta)
Example #4
0
def create_surface_integrator_direct_lighting(paramset: ParamSet) -> DirectLightingIntegrator:
    samples_count = paramset.find_int("nsamples", 2048)
    max_distance = paramset.find_float("maxdist", infinity_max_f)
    #todo depth etc
    integrator = DirectLightingIntegrator(samples_count, max_distance)
    return integrator
Example #5
0
def create_surface_integrator_ambient_occlusion(paramset: ParamSet) -> AmbientOcclusionIntegrator:
    samples_count = paramset.find_int("nsamples", 2048)
    max_distance = paramset.find_float("maxdist", infinity_max_f)
    integrator = AmbientOcclusionIntegrator(samples_count, max_distance)
    return integrator
Example #6
0
def create_projection_light(paramSet: ParamSet, light2world: Transform) -> PointLight:
    I = paramSet.find_spectrum("I", Spectrum(1.0))
    sc = paramSet.find_spectrum("scale", Spectrum(1.0))
    fov = paramSet.find_float("fov", 45.)
    texname = paramSet.find_filename("mapname", "")
    return ProjectionLight(light2world, I * sc, texname, fov)