Esempio n. 1
0
    def createContext(self):
        print "\there 0.0"
        context = optix.contextCreate()
        print "\t\there 0.0.0"
        context.setRayTypeCount(1)
        print "\t\there 0.0.1"
        context.setEntryPointCount(1)

        print "\there 0.1"
        # should be context["radiance_ray_type"].set( 0 )
        variable = context.declareVariable("radiance_ray_type")
        variable.set1ui(0)
        variable = context.declareVariable("scene_epsilon")
        variable.set1f(0.0001)

        print "\there 0.2"
        output_buffer = context.declareVariable("output_buffer")
        print "\t\there 0.2.0"
        self.output_buffer = context.bufferCreate(optix.RT_BUFFER_OUTPUT)
        print "\t\there 0.2.1"
        self.output_buffer.setFormat(optix.RT_FORMAT_UNSIGNED_BYTE4)
        print "\t\there 0.2.2"
        self.output_buffer.setSize2D(self.WIDTH, self.HEIGHT)
        print "\t\there 0.2.3"
        output_buffer.setObject(self.output_buffer)  # TODO:test this

        print "\there 0.3"
        # ray gen prog
        # TODO: make context.createProgramFromPTXFile( string1, string2)
        ray_gen_program = context.programCreateFromPTXFile(self.get_ptx_path("pinhole_camera"), "pinhole_camera")
        print "\t\there 0.3.0"
        context.setRayGenerationProgram(0, ray_gen_program)

        print "\there 0.4"
        variable = context.declareVariable("eye")
        variable.set3f(f1=0, f2=0, f3=5)
        # variable.set3f( 0, 0, 5 )
        variable = context.declareVariable("U")
        variable.set3f(2.88675, 0, 0)
        variable = context.declareVariable("V")
        variable.set3f(0, 2.16506, 0)
        variable = context.declareVariable("W")
        variable.set3f(0, 0, -5)

        print "\there 0.5"
        # exception program
        exception_program = context.programCreateFromPTXFile(self.get_ptx_path("pinhole_camera"), "exception")
        context.setExceptionProgram(0, exception_program)
        variable = context.declareVariable("bad_color")
        variable.set3f(1.0, 1.0, 0.0)

        print "\there 0.6"
        # miss prog
        miss_program = context.programCreateFromPTXFile(self.get_ptx_path("constantbg"), "miss")
        context.setMissProgram(0, miss_program)
        variable = context.declareVariable("bg_color")
        # variable.set3f( 0.3, 0.1, 0.2 )
        variable.set3f(0.3, 0.1, 0.1)

        return context
Esempio n. 2
0
import optix


print 'Testing optix module methods ============================================='
print 'Available devices: {}'.format( optix.deviceGetDeviceCount() )
print 'OptiX version    : {}'.format( optix.getVersion() )

ctx = optix.contextCreate()

print 'OptiX ctx create : {}'.format( ctx )

print dir( optix.Context )
print 'Testing optix module methods'
print 'Testing context methods =================================================='
print 'ctx devices      : {}'.format( ctx.getDeviceCount() )