def setup(self, create_fbos=True): self.spot_depth_t = TextureArray( (self.spot_resolution, self.spot_resolution), self.max_spots, GL_DEPTH_COMPONENT32F) self.sun_depth_t = TextureArray( (self.sun_resolution, self.sun_resolution), self.max_suns, GL_DEPTH_COMPONENT32F) self.point_depth_t = CubeMapArray( (self.point_resolution, self.point_resolution), self.max_points, GL_DEPTH_COMPONENT32F) if create_fbos: self.spot_fbos = [] for i in range(self.spot_depth_t.length): self.spot_fbos.append( RenderTarget([], ArrayLayerTarget(self.spot_depth_t, i))) self.sun_fbos = [] for i in range(self.sun_depth_t.length): self.sun_fbos.append( RenderTarget([], ArrayLayerTarget(self.sun_depth_t, i))) self.point_fbos = [] for i in range(self.point_depth_t.length * 6): self.point_fbos.append( RenderTarget([], ArrayLayerTarget(self.point_depth_t, i)))
def setup(self, create_fbos=True): super().setup(False) self.spot_id_t = TextureArray( (self.spot_resolution, self.spot_resolution), self.max_spots, GL_R32F) self.sun_id_t = TextureArray( (self.sun_resolution, self.sun_resolution), self.max_suns * self.sun_cascades, GL_R32F) self.point_id_t = CubeMapArray( (self.point_resolution, self.point_resolution), self.max_points, GL_R32F) if create_fbos: self.spot_fbos = [] for i in range(self.spot_depth_t.length): self.spot_fbos.append( RenderTarget([ArrayLayerTarget(self.spot_id_t, i)], ArrayLayerTarget(self.spot_depth_t, i))) self.sun_fbos = [] for i in range(self.sun_depth_t.length): self.sun_fbos.append( RenderTarget([ArrayLayerTarget(self.sun_id_t, i)], ArrayLayerTarget(self.sun_depth_t, i))) self.point_fbos = [] for i in range(self.point_depth_t.length * 6): self.point_fbos.append( RenderTarget([ArrayLayerTarget(self.point_id_t, i)], ArrayLayerTarget(self.point_depth_t, i)))
def load(self, pipeline, depth_texture, scene): self.custom_shading_count = 0 for i, light in enumerate(scene.lights): custom_shading_index = -1 if light.parameters['Shader'] is not None: custom_shading_index = self.custom_shading_count self.custom_shading_count += 1 self.data.custom_shading_index[i] = custom_shading_index self.UBO.load_data(self.data) if self.custom_shading_count == 0: return lights = [l for l in scene.lights if l.parameters['Shader'] is not None] tex = self.texture if tex is None or tex.resolution != depth_texture.resolution or tex.length < len(lights): self.texture = TextureArray(depth_texture.resolution, len(lights), GL_RGB32F) self.fbos = [] for i in range(len(lights)): self.fbos.append(RenderTarget([ArrayLayerTarget(self.texture, i)])) for i, light in enumerate(lights): material = light.parameters['Shader'] if material.shader and 'SHADER' in material.shader.keys(): shader = material.shader['SHADER'] pipeline.common_buffer.bind(shader.uniform_blocks['COMMON_UNIFORMS']) pipeline.lights_buffer.bind(shader.uniform_blocks['SCENE_LIGHTS']) shader.textures['IN_DEPTH'] = depth_texture if 'LIGHT_INDEX' in shader.uniforms: shader.uniforms['LIGHT_INDEX'].set_value(i) pipeline.draw_screen_pass(shader, self.fbos[i])