def on_draw(self): self.ctx.enable_only(self.ctx.CULL_FACE, self.ctx.DEPTH_TEST) # Draw the current cube using the last one as a texture self.fbo1.use() self.fbo1.clear(color=(1.0, 1.0, 1.0, 1.0), normalized=True) rotate = Matrix44.from_eulers( (self.time, self.time * 0.77, self.time * 0.01), dtype='f4') translate = Matrix44.from_translation((0, 0, -1.75), dtype='f4') modelview = translate * rotate if self.frame > 0: self.program['use_texture'] = 1 self.fbo2.color_attachments[0].use() self.program['modelview'] = modelview.flatten() self.cube.render(self.program) self.ctx.disable(self.ctx.DEPTH_TEST) # Draw the current cube texture self.use() self.clear() self.fbo1.color_attachments[0].use() self.quad_fs.render(self.quad_program) # Swap offscreen buffers self.fbo1, self.fbo2 = self.fbo2, self.fbo1 self.frame += 1
def render(self, time, frame_time): self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.CULL_FACE) rot = Matrix44.from_eulers((time, time / 2, time / 3)) # Box top left view = Matrix44.from_translation((-5, 2, -10), dtype='f4') self.box_top_left.draw(self.projection, view * rot) # Box top middle view = Matrix44.from_translation((0, 2, -10), dtype='f4') self.box_top_middle.draw(self.projection, view * rot) # Box top right view = Matrix44.from_translation((5, 2, -10), dtype='f4') self.box_top_right.draw(self.projection, view * rot) # Box bottom left view = Matrix44.from_translation((-5, -2, -10), dtype='f4') self.box_bottom_left.draw(self.projection, view * rot) # Box bottom middle view = Matrix44.from_translation((0, -2, -10), dtype='f4') self.box_bottom_middle.draw(self.projection, view * rot) # Box bottom right view = Matrix44.from_translation((5, -2, -10), dtype='f4') self.box_bottom_right.draw(self.projection, view * rot)
def start(args, hkubeApi): try: input = args.get('input')[0] width = input.get('width', 512) height = input.get('height', 512) sleep = input.get('sleep', 5) except Exception as e: width = 512 height = 512 sleep = 5 vbo = ctx.buffer(vertices) vao = ctx.simple_vertex_array(prog, vbo, 'in_vert', 'in_color') fbo = ctx.framebuffer(color_attachments=[ctx.texture((width, height), 4)]) fbo.use() ctx.clear() prog['model'].write(Matrix44.from_eulers((0.0, 0.1, 0.0), dtype='f4')) vao.render(moderngl.TRIANGLES) data = fbo.read(components=3) image = Image.frombytes('RGB', fbo.size, data) image = image.transpose(Image.FLIP_TOP_BOTTOM) in_mem_file = io.BytesIO() image.save(in_mem_file, format='JPEG') time.sleep(sleep) return { 'buffer': in_mem_file.getvalue(), 'size': fbo.size, 'format': 'RGB' }
def generate_lines(obj: Object, camera: Camera, viewport: Polygon, front_brightness: float, back_brightness: float) -> List[Line]: # Create transformation matrix translation = Matrix44.from_translation(obj.translation) rotation = Matrix44.from_eulers(obj.rotation) projection = Matrix44.perspective_projection( camera.fovy, camera.aspect, camera.near, camera.far) cam = matrix44.create_look_at(camera.eye, camera.target, [0, 1.0, 0]) matrix = projection * cam * translation * rotation # Transform vertices, remove hidden faces and get edges for faces # TODO: Make the rendering pipeline more generic vertices = [matrix * vertex for vertex in obj.mesh.vertices] front_faces = [face for face in obj.mesh.faces if cull_face(vertices, face, 'front')] back_faces = [face for face in obj.mesh.faces if cull_face(vertices, face, 'back')] front_edges = find_edges(front_faces, obj.mesh.edges) back_edges = find_edges(back_faces, obj.mesh.edges) # Clip lines lines = edges_to_lines(front_edges, vertices, front_brightness) + \ edges_to_lines(back_edges, vertices, back_brightness) return [clipped for clipped in [clip_line(line, viewport) for line in lines] if clipped is not None]
def render(self, time, frame_time): self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.CULL_FACE) rot = Matrix44.from_eulers((time, time / 2, time / 3)) # Box 1 view = Matrix44.from_translation((-5, 2, -10), dtype='f4') self.box_v3.draw(self.projection, view * rot) # Box 2 view = Matrix44.from_translation((0, 2, -10), dtype='f4') self.box_c3_v3.draw(self.projection, view * rot) # Box 3 view = Matrix44.from_translation((5, 2, -10), dtype='f4') self.box_n3_v3.draw(self.projection, view * rot) # Box 4 view = Matrix44.from_translation((-5, -2, -10), dtype='f4') self.box_t2_v3.draw(self.projection, view * rot) # Box 5 view = Matrix44.from_translation((0, -2, -10), dtype='f4') self.box_t2_c3_v3.draw(self.projection, view * rot) # Box 6 view = Matrix44.from_translation((5, -2, -10), dtype='f4') self.box_t2_n3_v3.draw(self.projection, view * rot)
def tf2matrix4(tf: carla.Transform) -> Matrix44: t = Matrix44.from_translation( [tf.location.x, tf.location.y, tf.location.z]) r = Matrix44.from_eulers([ tf.rotation.roll * math.pi / 180, tf.rotation.pitch * math.pi / 180, tf.rotation.yaw * math.pi / 180 ]) return r * t
def render(self, time: float, frametime: float): rotation = Matrix44.from_eulers((time, time, time), dtype='f4') translation = Matrix44.from_translation((0.0, 0.0, -3.5), dtype='f4') model = translation * rotation self.ctx.enable(moderngl.DEPTH_TEST | moderngl.CULL_FACE) self.prog['m_model'].write(model) self.cube.render(self.prog) self.render_ui()
def on_draw(self): self.clear() self.ctx.enable_only(self.ctx.CULL_FACE, self.ctx.DEPTH_TEST) rotate = Matrix44.from_eulers( (self.time, self.time * 0.77, self.time * 0.01), dtype='f4') translate = Matrix44.from_translation((0, 0, -2.0), dtype='f4') modelview = translate * rotate self.program['modelview'] = modelview.flatten() self.cube.render(self.program)
def render(self, time: float, frametime: float): self.ctx.enable_only(moderngl.CULL_FACE | moderngl.DEPTH_TEST) m_rot = Matrix44.from_eulers(Vector3((time, time, time))) m_trans = matrix44.create_from_translation(Vector3((0.0, 0.0, -3.0))) m_mv = matrix44.multiply(m_rot, m_trans) self.prog['m_model'].write(m_mv.astype('f4').tobytes()) self.prog['m_camera'].write(self.camera.matrix.astype('f4').tobytes()) self.cube.render(self.prog)
def render(self, vertex_values, rotation_values, cam_pos=None): vertex_values, rotation_values = self.sanitize(vertex_values, rotation_values) faces = [f.copy() for f in self.faces_base] if self.scaled: scale_vertices(faces, vertex_values, iiis=self.iiis) vertex_buffers = [] for face in faces: face.calculate_normals() verts = np.dstack([ face.x(), face.y(), face.z(), face.nx(), face.ny(), face.nz() ]) vbo = self.ctx.buffer(verts.astype('f4').tobytes()) vao = self.ctx.simple_vertex_array(self.prog, vbo, 'in_vert', 'in_norm') vertex_buffers.append(vao) self.fbo.clear(0.0, 0.0, 0.0, 0.0) if cam_pos is None: eye = (2, 2, 1) else: eye = cam_pos lookat = Matrix44.look_at( eye, # eye / camera position (0.0, 0.0, 0.0), # lookat (0.0, 0.0, 1.0), # camera up vector ) rotate = np.array(Matrix44.from_eulers(rotation_values)) for key, val in self.misc.items(): self.prog[key].value = tuple( np.matmul(rotate[:3, :3], val).reshape(1, -1)[0]) self.prog['Lights'].value = tuple( np.matmul(rotate[:3, :3], self.base_light).reshape(1, -1)[0]) self.prog['Mvp'].write( (self.proj * lookat * rotate).astype('f4').tobytes()) for vb, color in zip(vertex_buffers, self.colors): self.prog['Color'].value = color vb.render(moderngl.TRIANGLES) return Image.frombytes('RGB', self.fbo.size, self.fbo.read(), 'raw', 'RGB', 0, -1)
def render(self, time, frame_time): self.ctx.enable_only(moderngl.PROGRAM_POINT_SIZE | moderngl.BLEND) self.ctx.blend_func = moderngl.ADDITIVE_BLENDING rotation = Matrix44.from_eulers((time, time / 2 , time / 3), dtype='f4') translation = Matrix44.from_translation((0, 0, -10), dtype='f4') modelview = translation * rotation self.prog['modelview'].write(modelview) self.prog['time'].value = time self.vao.render(mode=moderngl.POINTS)
def render(self, time: float, frametime: float): self.ctx.enable_only(moderngl.CULL_FACE | moderngl.DEPTH_TEST) rotation = Matrix44.from_eulers((time, time, time), dtype='f4') translation = Matrix44.from_translation((0.0, 0.0, -3.5), dtype='f4') modelview = translation * rotation self.prog['m_proj'].write(self.camera.projection.matrix) self.prog['m_model'].write(modelview) self.prog['m_camera'].write(self.camera.matrix) self.cube.render(self.prog)
def render(self, time: float, frametime: float): self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.CULL_FACE) translation = Matrix44.from_translation((0, 0, -1.5)) rotation = Matrix44.from_eulers((0, 0, 0)) model_matrix = translation * rotation camera_matrix = self.camera.matrix * model_matrix self.scene.draw( projection_matrix=self.camera.projection.matrix, camera_matrix=camera_matrix, time=time, )
def create_transformation(self, rotation=None, translation=None): """Convenient transformation method doing rotations and translation""" mat = None if rotation is not None: mat = Matrix44.from_eulers(Vector3(rotation)) if translation is not None: trans = matrix44.create_from_translation(Vector3(translation)) if mat is None: mat = trans else: mat = matrix44.multiply(mat, trans) return mat
def render(self, time: float, frametime: float): self.ctx.enable_only(moderngl.CULL_FACE | moderngl.DEPTH_TEST) m_rot = Matrix44.from_eulers(Vector3((time, time, time))) m_trans = matrix44.create_from_translation(Vector3((0.0, 0.0, -3.0))) m_mv = matrix44.multiply(m_rot, m_trans) self.prog['m_proj'].write(self.camera.projection.tobytes()) self.prog['m_model'].write(m_mv.astype('f4').tobytes()) self.prog['m_camera'].write(self.camera.matrix.astype('f4').tobytes()) self.prog['layer'].value = math.fmod(time, 10) self.prog['texture0'].value = 0 self.texture.use(location=0) self.cube.render(self.prog)
def render(self, time: float, frametime: float): # Rotate/move cube rotation = Matrix44.from_eulers((time, time, time), dtype='f4') translation = Matrix44.from_translation((0.0, 0.0, -3.5), dtype='f4') model = translation * rotation # Render cube to offscreen texture / fbo self.fbo.use() self.fbo.clear() self.ctx.enable(moderngl.DEPTH_TEST | moderngl.CULL_FACE) self.prog['m_model'].write(model) self.cube.render(self.prog) # Render UI to screen self.wnd.use() self.render_ui()
def draw(): """Put the main drawing code in here.""" global luxp chaem.mochae(timedelta) GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) GL.glEnable(GL.GL_TEXTURE_2D) GL.glUseProgram(shaderp) luxp = [sin(lasttime) * 5, cos(lasttime) * 5, 0.0] GL.glUniform3f(GL.glGetUniformLocation(shaderp, 'lightPos'), *luxp) GL.glUniform3f(GL.glGetUniformLocation(shaderp, 'viewpos'), *chaem.pos) rematr() architincture.draw() mmoodd = modelmatrix * matrix.from_scale([0.2, 0.2, 0.2]) * matrix.from_translation(luxp) * \ matrix.from_eulers([lasttime, lasttime, lasttime]) lux.draw(rematr, mmoodd)
def render(self, time=0.0, frametime=0.0, target: moderngl.Framebuffer = None): self.ctx.enable_only(moderngl.CULL_FACE | moderngl.DEPTH_TEST) rotation = Matrix44.from_eulers((time, time, time), dtype='f4') translation = Matrix44.from_translation((0.0, 0.0, -5.0), dtype='f4') modelview = translation * rotation self.view_buffer.write(modelview) with self.scope1: self.vao1.render(mode=moderngl.TRIANGLES) with self.scope2: self.vao2.render(mode=moderngl.TRIANGLES)
def render(self, time=0.0, frametime=0.0, target: moderngl.Framebuffer = None): self.ctx.enable_only(moderngl.CULL_FACE | moderngl.DEPTH_TEST) m_rot = Matrix44.from_eulers(Vector3((time, time, time))) m_trans = matrix44.create_from_translation(Vector3((0.0, 0.0, -5.0))) m_modelview = matrix44.multiply(m_rot, m_trans) self.view_buffer.write(m_modelview.astype('f4').tobytes()) with self.scope1: self.vao1.render(mode=moderngl.TRIANGLES) with self.scope2: self.vao2.render(mode=moderngl.TRIANGLES)
def render(self, time, frametime): # Render background self.ctx.wireframe = False if not self.with_blending: self.ctx.enable_only(moderngl.NOTHING) self.quad_fs.render(self.prog_background) # Handle blend mode toggle if self.with_blending: self.ctx.enable_only(moderngl.BLEND) self.ctx.blend_func = moderngl.ONE, moderngl.ONE else: self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.CULL_FACE) # Render tetrahedral mesh translate = Matrix44.from_translation((0.0, 2.5, -15.0), dtype='f4') rotate = Matrix44.from_eulers((np.radians(180), 0, 0), dtype='f4') scale = Matrix44.from_scale((400, 400, 400), dtype='f4') mat = self.camera.matrix * translate * rotate * scale # All render calls inside this context are timed with self.query: self.alive_texture.use(location=0) self.prog_gen_tetra['alive_texture'].value = 0 self.prog_gen_tetra['threshold'].value = self.threshold self.prog_gen_tetra['color'].value = self.mesh_color self.prog_gen_tetra['m_cam'].write(mat) self.prog_gen_tetra['m_proj'].write(self.camera.projection.matrix) self.geometry.render(self.prog_gen_tetra, mode=moderngl.LINES_ADJACENCY) # Render lines self.ctx.wireframe = True self.alive_texture.use(location=0) self.prog_gen_tetra_lines['alive_texture'].value = 0 self.prog_gen_tetra_lines['threshold'].value = self.threshold self.prog_gen_tetra_lines['color'].value = self.line_color self.prog_gen_tetra_lines['m_cam'].write(mat) self.prog_gen_tetra_lines['m_proj'].write( self.camera.projection.matrix) self.geometry.render(self.prog_gen_tetra_lines, mode=moderngl.LINES_ADJACENCY) self.total_elapsed = self.query.elapsed
def torus_image(): mesh = torus(1, 0.5, 12, 32) w, h = parse_resolution(request.args.get('resolution', '80x50')) aspect = float(request.args.get('aspect', '1')) t = float(request.args.get('t', 0)) light1 = numgl.normalized(np.array([0, 1, 1])) angular_velocity = np.array([1.7, 2, 0]) projection = Matrix44.perspective_projection(60.0, aspect * w / h, 0.1, 10.0) camera = Matrix44.from_translation(np.array( [0, 0, -3])) * Matrix44.from_eulers(t * angular_velocity) with create_context() as ctx: renderer = Renderer(ctx, (w, h), mesh, projection=projection) renderer.render(camera, light1) image = renderer.snapshot() from io import BytesIO with BytesIO() as f: image.save(f, 'png') return Response(f.getvalue(), mimetype='image/png')
def render(self, time, frametime): self.ctx.enable(moderngl.DEPTH_TEST | moderngl.CULL_FACE) translation = Matrix44.from_translation((0, 0, -45 + self.zoom), dtype='f4') rotation = Matrix44.from_eulers((self.y_rot, self.x_rot, 0), dtype='f4') self.modelview = translation * rotation # Render the scene to offscreen buffer self.offscreen.clear() self.offscreen.use() # Render the scene self.geometry_program['modelview'].write(self.modelview) self.geometry_program['projection'].write(self.projection.matrix) self.mesh_texture.use( location=0) # bind texture from obj file to channel 0 self.depth_sampler.use(location=0) self.mesh.render(self.geometry_program) # render mesh self.depth_sampler.clear(location=0) # Activate the window as the render target self.ctx.screen.use() self.ctx.disable(moderngl.DEPTH_TEST) # Render offscreen diffuse layer to screen self.offscreen_diffuse.use(location=0) self.quad_fs.render(self.texture_program) # Render markers if self.num_markers > 0: self.ctx.point_size = 6.0 # Specify fragment size of the markers self.marker_program['modelview'].write(self.modelview) self.marker_program['projection'].write(self.projection.matrix) self.marker_vao.render(self.marker_program, vertices=self.num_markers) self.render_debug()
def create_transformation(self, rotation=None, translation=None): """ Creates a transformation matrix woth rotations and translation. Args: rotation: 3 component vector as a list, tuple, or :py:class:`pyrr.Vector3` translation: 3 component vector as a list, tuple, or :py:class:`pyrr.Vector3` Returns: A 4x4 matrix as a :py:class:`numpy.array` """ mat = None if rotation is not None: mat = Matrix44.from_eulers(Vector3(rotation)) if translation is not None: trans = matrix44.create_from_translation(Vector3(translation)) if mat is None: mat = trans else: mat = matrix44.multiply(mat, trans) return mat
# ------------------------------- # position view point output = head_packet.build( dict(data=[radians(0), radians(90), radians(0), 2, 1, 0])) headset.send(output) answer = headset.recv() count = 0 for swivel in range(0, 960, 2): # location [side, up, forward] matrix1 = Matrix44.from_translation(Vector3([0, 1, 0])) # rotate [pitch, roll, yaw] matrix1 = matrix1 * Matrix44.from_eulers( [radians(0), radians(0), radians(swivel)]) controller1 = controller_packet.build( dict( id=1, orient=matrix1.transpose().reshape(16).tolist(), count=count, pressed=1, touched=1, axis=[0, 0, 0], )) controller.send(controller1) answer = controller.recv() matrix2 = Matrix44.from_translation(Vector3([0, 1.5, 0])) matrix2 = matrix2 * Matrix44.from_eulers(
ctx.enable(moderngl.DEPTH_TEST) fbo = ctx.simple_framebuffer((width, height)) fbo.use() proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0) lookat = Matrix44.look_at( (2, 2, 1), # eye / camera position (0.0, 0.0, 0.0), # lookat (0.0, 0.0, 1.0), # camera up vector ) base_light = np.array((10, 10, 10)) for idx, rot in enumerate(np.arange(0, 3.1, 0.5)): fbo.clear(0.0, 0.0, 0.0, 0.0) rotate = np.array(Matrix44.from_eulers((0, rot, 0))) # this keep the light in place prog['Lights'].value = tuple( np.matmul(rotate[:3, :3], base_light).reshape(1, -1)[0]) # prog['Lights'].value = (10, 10, 10) prog['Mvp'].write((proj * lookat * rotate).astype('f4').tobytes()) for vb, color in zip(vertex_buffers, FACE_COLORS): prog['Color'].value = color vb.render(moderngl.TRIANGLES) img = Image.frombytes('RGB', fbo.size, fbo.read(), 'raw', 'RGB', 0, -1) # plt.subplot(171 + (rot * 2))
], dtype='f4') vbo = ctx.buffer(vertices) # Context.buffer(data=None, reserve=0, dynamic=False) → Buffer # data (bytes) – Content of the new buffer. # reserve (int) – The number of bytes to reserve. # dynamic (bool) – Treat buffer as dynamic. vao = ctx.vertex_array(prog, vbo, 'in_vert', 'in_color') # Context.vertex_array(*args, **kwargs) → VertexArray # program (Program) – The program used when rendering. # content (list) – A list of (buffer, format, attributes). See Buffer Format. # index_buffer (Buffer) – An index buffer. # index_element_size (int) – byte size of each index element, 1, 2 or 4. # skip_errors (bool) – Ignore skip_errors varyings. fbo = ctx.framebuffer(color_attachments=[ctx.texture((512, 512), 4)]) fbo.use() ctx.clear() prog['model'].write(Matrix44.from_eulers((0.0, 0.1, 0.0), dtype='f4')) vao.render(moderngl.TRIANGLES) data = fbo.read(components=3) image = Image.frombytes('RGB', fbo.size, data) image = image.transpose(Image.FLIP_TOP_BOTTOM) import os from motiontools import normpath, dir_of_file output = normpath(dir_of_file(), "output") image.save(normpath(output, 'headless_ubunut18_server.png'))
# SDL_CONTROLLER_BUTTON_A # SDL_CONTROLLER_BUTTON_B # SDL_CONTROLLER_BUTTON_X # SDL_CONTROLLER_BUTTON_Y # SDL_CONTROLLER_BUTTON_BACK # SDL_CONTROLLER_BUTTON_START # SDL_CONTROLLER_BUTTON_DPAD_UP # SDL_CONTROLLER_BUTTON_DPAD_DOWN # SDL_CONTROLLER_BUTTON_DPAD_LEFT # SDL_CONTROLLER_BUTTON_DPAD_RIGHT # Postion controller1 matrix1 = Matrix44.from_translation(Vector3([0.2, 1.5, 0])) matrix1 = matrix1 * Matrix44.from_eulers([ radians((right_pitch * (90 / 32768)) + 90), radians(right_yaw * (90 / 32768)), radians(0) ]) matrix1 = matrix1 * Matrix44.from_translation(Vector3([0, 0.4, 0])) matrix1 = matrix1 * Matrix44.from_eulers([ radians((right_pitch * (45 / 32768)) - 45), radians(right_yaw * (-90 / 32768)), radians(0) ]) controller1 = controller_packet.build( dict(id=1, status=0 if right_visible else 1, orient=matrix1.transpose().reshape(16).tolist(), count=count, pressed=right_buttons,
def rotate(self, *xyz): self._rotation += xyz self._mr = Matrix44.from_eulers(self._rotation)
def set_rotation(self, *xyz): self._rotation = xyz self._mr = Matrix44.from_eulers(self._rotation)
def rot(self): return Matrix44.from_eulers(self.euler())
def render(self, time, frametime): self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.CULL_FACE) self.lightpos = Vector3((math.sin(time) * 20, 15, math.cos(time) * 20), dtype='f4') scene_pos = Vector3((0, 0, 0), dtype='f4') # --- PASS 1: Render shadow map self.offscreen.clear() self.offscreen.use() depth_projection = Matrix44.orthogonal_projection(-20, 20, -20, 20, -20, 40, dtype='f4') depth_view = Matrix44.look_at(self.lightpos, (0, 0, 0), (0, 1, 0), dtype='f4') depth_mvp = depth_projection * depth_view self.shadowmap_program['mvp'].write(depth_mvp) self.shadowmap_program['m_model'].write( Matrix44.from_translation(scene_pos, dtype='f4')) self.floor.render(self.shadowmap_program) self.wall.render(self.shadowmap_program) self.sphere.render(self.shadowmap_program) modelview_blob = Matrix44.from_eulers( (3.0, math.sin(time) * 1.0, math.sin(time) * 1.0), dtype='f4') # modelview_blob = Matrix44.from_eulers((3.0, 1.0, 2.0), dtype='f4') # modelview_blob = Matrix44.from_eulers((0.0, 0.0, 0.0), dtype='f4') self.shadowmap_program['m_model'].write(modelview_blob) self.another_blob.render(self.shadowmap_program) # --- PASS 2: Render scene to screen self.wnd.use() self.basic_light['m_proj'].write(self.camera.projection.matrix) self.basic_light['m_camera'].write(self.camera.matrix) self.basic_light['m_model'].write( Matrix44.from_translation(scene_pos, dtype='f4')) bias_matrix = Matrix44( [[0.5, 0.0, 0.0, 0.0], [0.0, 0.5, 0.0, 0.0], [0.0, 0.0, 0.5, 0.0], [0.5, 0.5, 0.5, 1.0]], dtype='f4', ) self.basic_light['m_shadow_bias'].write( matrix44.multiply(depth_mvp, bias_matrix)) self.basic_light['lightDir'].write(self.lightpos) self.offscreen_depth.use(location=0) self.floor.render(self.basic_light) self.wall.render(self.basic_light) self.sphere.render(self.basic_light) self.basic_light['m_model'].write(modelview_blob) self.another_blob.render(self.basic_light) # Render the sun position self.sun_prog['m_proj'].write(self.camera.projection.matrix) self.sun_prog['m_camera'].write(self.camera.matrix) self.sun_prog['m_model'].write( Matrix44.from_translation(self.lightpos + scene_pos, dtype='f4')) self.sun.render(self.sun_prog)