def __init__(self, definition, mask=False): super(FractalProgram, self).__init__(read_shader('fractal.vert'), read_shader('fractal.frag')) self.definition = definition # Fill screen with single quad, fragment shader does all the real work self["position"] = [(-1, -1), (-1, 1), (1, 1), (-1, -1), (1, 1), (1, -1)] self['time'] = 0 if mask: self['cameraPos'] = (0.0, 9.0, -12.0) self['cameraLookat'] = (0.0, -3.0, 0.0) else: self['cameraPos'] = (0.0, 6, -9.0) self['cameraLookat'] = (0.0, 0.0, 0.0) self['lightDir'] = normalize(np.array((1, 1, -1.5))) # needs to be normalized self['diffuse'] = (1, 1, 1) self['ambientFactor'] = 0.45 self['resolution'] = [10, 10] self['distanceEstimatorFunction'] = self.definition['distance_estimator'] self['trapFunction'] = random.choice(self.definition['trap_functions']) self['colorTrapFunction'] = random.choice([1]) for param, param_description in self.definition['params'].iteritems(): self[param] = param_description['initial']
def __init__(self, fg=(1,1,1,0), bg=(0,0,0,1)): super(MaskProgram, self).__init__(read_shader('mask.vert'), read_shader('mask.frag')) self["tipColorSelector"] = 0 self["position"] = [(-1, -1), (-1, 1), (1, 1), (-1, -1), (1, 1), (1, -1)] self["foregroundColor"] = fg self["backgroundColor"] = bg self["triangleA"] = (0.00, 1.0) self["triangleB"] = (1.0, 1.0) self["triangleC"] = (0.51, 0.00)
def __init__(self, *args, **kwargs): app.Canvas.__init__(self, *args, **kwargs) self.raw_depth_program = gloo.Program(read_shader('1.vert'), read_shader('skeleton_video.frag')) self.skeleton_program = gloo.Program(read_shader('skeleton_bones.vert'), read_shader('skeleton_bones.frag')) # Fill screen with single quad, fragment shader does all the real work self.raw_depth_program["position"] = [(-1, -1), (-1, 1), (1, 1), (-1, -1), (1, 1), (1, -1)] self.raw_depth_program["frame"] = gloo.Texture2D(shape=(480, 640, 2), format='luminance_alpha') width, height = self.physical_size gloo.set_viewport(0, 0, width, height) self.raw_depth_program['resolution'] = [width, height] # Set uniform and attribute self.skeleton_program['a_position'] = gloo.VertexBuffer() openni2.initialize() nite2.initialize() self.user_tracker = nite2.UserTracker(False) gloo.set_state(clear_color='black', blend=True, blend_func=('src_alpha', 'one_minus_src_alpha')) self._timer = app.Timer('auto', connect=self.update, start=True) self.show()
def __init__(self): super(SkeletonBonesProgram, self).__init__( read_shader("skeleton_bones.vert"), read_shader("skeleton_bones.frag") ) self["a_position"] = gloo.VertexBuffer()