Beispiel #1
0
 def __init__(self,
              color1=Color.fromHex("#FFFFFF"),
              color2=Color.fromHex("#000000"),
              ambient=0.05,
              diffuse=1.0,
              specular=1.0,
              reflection=0.5):
     self.color1 = color1
     self.color2 = color2
     self.ambient = ambient
     self.diffuse = diffuse
     self.specular = specular
     self.reflection = reflection
Beispiel #2
0
from light import Light
from material import Material
from time import time
import imageio
from pathlib import Path
from Test import RayTracingTesting
import os
from multiprocessing import cpu_count

if __name__ == "__main__":
    WIDTH = 400
    HEIGHT = 300
    camera = Vector(0, -0.35, -1)
    #0xFF is a hexadecimal constant which is 11111111 in binary.
    objects = [
        Sphere(Point(0.2, -0.1, 1), 0.7, Material(Color.fromHex("#0000FF"))),
        #Sphere(Point(0.1, -0.3, 0), 0.1, Material(Color.fromHex("#0000FF"))),
        Sphere(Point(-1, -0.2, 1), 0.2, Material(Color.fromHex("#00FF00"))),
        #Ground plane next
        Sphere(Point(0, 1000.5, 1), 1000.0,
               Material(Color.fromHex("#FFFFFF"), diffuse=6.0)),
    ]
    #objects = [Sphere(Point(0,0,0),0.5, Material(Color.fromHex("#FF0000")))]
    lights = [Light(Point(1.5, -0.5, -10.0), Color.fromHex("#FFFFFF"))]
    processCount = cpu_count()
    start = time()
    for i in range(0, 4):
        objects[1].center = Point(-1 + (i / 2), -0.2, -(0 + (i / 20)))
        scene = Scene(camera, objects, lights, WIDTH, HEIGHT)
        ppmFile = "sourceImages/test" + str(i) + ".ppm"
        with open(ppmFile, "w") as imgFile:
Beispiel #3
0
 def __init__(self, pos, color=Color.fromHex("#FFFFFF")):
     self.pos = pos
     self.color = color
from vector import Vector
from image import Image
from color import Color
from point import Point
from sphere import Sphere
from light import Light
from material import Material, CheckerMat

WIDTH = 3840
HEIGHT = 2160
CAMERA = Vector(0, -0.35, -1)

OBJECTS = [
    Sphere(Point(0, 10000.5, 1), 10000.0,
           CheckerMat(ambient=0.2, reflection=0.5)),
    Sphere(Point(0.75, -0.1, 1), 0.6, Material(Color.fromHex("#0000FF"))),
    Sphere(Point(-1, -0.1, 2.25), 0.6, Material(Color.fromHex("#ff6e6e")))
]

LIGHTS = [
    Light(Point(1.5, -0.5, -10), Color.fromHex("#FFFFFF")),
    Light(Point(-5, -10.5, 0), Color.fromHex("#E6E6E6"))
]
Beispiel #5
0
 def fromHex(cls, hexcode):
     return Section(Color.fromHex(hexcode))