コード例 #1
0
    def on_draw():
        # render passes
        pos = glm.vec3(math.cos(time.time()*2)*3, 1, 3)
        camera360 = Camera360(transform=glm.translate(glm.mat4(1), pos),
                              near=1, 
                              far=10)
        cubedepth_map = cubedepth_pass.render(scene.find_meshes(), camera360)

        # render passes to screen
        glDisable(GL_DEPTH_TEST)
        # imdraw.texture(depth_map, (0, 0, viewer.width, viewer.height), shuffle=(0,0,0,-1))
        imdraw.cubemap(cubedepth_map, (0,0,viewer.width, viewer.height), viewer.camera.projection, viewer.camera.view)
コード例 #2
0
    def on_draw():
        # render passes
        camera360 = Camera360(transform=glm.mat4(1), near=0.1, far=10)

        environment_cubemap = environment_pass.render(environment_texture,
                                                      camera360)

        # render passes to screen
        glEnable(GL_DEPTH_TEST)
        glDisable(GL_CULL_FACE)
        imdraw.texture(environment_texture, (0, 0, 190, 190))
        imdraw.cubemap(environment_cubemap,
                       (0, 0, viewer.width, viewer.height),
                       viewer.camera.projection, viewer.camera.view)
コード例 #3
0
    def on_draw():
        # geometry ass
        gBuffer = geometry_pass.render(scene.find_meshes(), viewer.camera)

        # shadows pass
        for light in scene.find_lights():
            light.shadowmap.render(scene.find_meshes(), light.camera)

        # lighting pass
        hdr_texture = lighting_pass.render(viewer.camera.position,
                                           scene.find_lights(), gBuffer,
                                           irradiance_cubemap,
                                           prefilter_cubemap, brdf_texture)

        # Debug
        # -----
        glDisable(GL_DEPTH_TEST)
        glDisable(GL_CULL_FACE)

        # debug beauty
        imdraw.texture(hdr_texture, (0, 0, viewer.width, viewer.height),
                       shuffle=(0, 1, 2, -1))

        # debug shadows
        for i, light in enumerate(scene.find_lights()):
            if isinstance(light, PointLight):
                imdraw.cubemap(light.shadowmap.texture, (i * 100, 200, 90, 90),
                               viewer.camera.projection,
                               viewer.camera.view,
                               shuffle=(0, 0, 0, -1))
            elif isinstance(light, (SpotLight, DirectionalLight)):
                imdraw.texture(light.shadowmap.texture, (i * 100, 200, 90, 90),
                               shuffle=(0, 0, 0, -1))

        # debug gBuffer
        gPosition, gNormal, gAlbedo, gEmissive, gRoughness, gMetallic = gBuffer
        imdraw.texture(gPosition, (0, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gNormal, (100, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gAlbedo, (200, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gEmissive, (300, 0, 90, 90))
        imdraw.texture(gRoughness, (400, 0, 90, 90), shuffle=(0, 0, 0, -1))
        imdraw.texture(gMetallic, (500, 0, 90, 90), shuffle=(0, 0, 0, -1))

        # debug IBL
        imdraw.texture(environment_texture, (0, 100, 90, 90))
        imdraw.cubemap(environment_cubemap, (100, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(irradiance_cubemap, (200, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(prefilter_cubemap, (300, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.texture(brdf_texture, (400, 100, 90, 90))
コード例 #4
0
    def on_draw():
        global environment_texture, environment_cubemap, irradiance_cubemap, prefilter_cubemap, brdf_texture

        # render passes to screen
        glEnable(GL_DEPTH_TEST)
        glDisable(GL_CULL_FACE)
        imdraw.cubemap(prefilter_cubemap, (0, 0, viewer.width, viewer.height),
                       viewer.camera.projection, viewer.camera.view)

        imdraw.texture(environment_texture, (0, 0, 190, 190))
        imdraw.cubemap(environment_cubemap, (200, 0, 190, 190),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(irradiance_cubemap, (400, 0, 190, 190),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(prefilter_cubemap, (600, 0, 190, 190),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.texture(brdf_texture, (800, 0, 190, 190))
コード例 #5
0
    def on_draw():
        # PREPROCESS
        # - render each shadowmap:
        for light in scene.lights():
            light.shadowmap.render(scene.meshes(), light.camera)

        # DEFERRED
        # - render geometry pass
        gBuffer = geometry_pass.render(scene.meshes(), viewer.camera)

        # - render pbr lighting
        iblBuffer = irradiance_cubemap, prefilter_cubemap, brdfLUT
        hdr_image = lighting_pass.render(gBuffer, environment_cubemap,
                                         iblBuffer, viewer.camera,
                                         scene.lights())

        # FORWARD
        # - copy fbo depth and color
        # skybox_pass.copy_buffer_from(geometry_pass, GL_DEPTH_BUFFER_BIT)
        # skybox_pass.copy_buffer_from(lighting_pass, GL_COLOR_BUFFER_BIT)
        # - render skybox
        # skybox_texture = skybox_pass.render(environment_cubemap, viewer.camera)

        # POST PROCESS

        highlights_texture = clamp_pass.render(hdr_image,
                                               minimum=15.0,
                                               maximum=999)
        # return ldr_texture
        bloom_texture = gaussianblur_pass.render(highlights_texture,
                                                 iterations=8)
        # return blurred_highlights_texture
        with_bloom_texture = add_pass.render(hdr_image, bloom_texture)
        ldr_texture = tonemapping_pass.render(with_bloom_texture,
                                              exposure=0.0,
                                              gamma=2.2)

        # DEBUG
        glDisable(GL_DEPTH_TEST)
        imdraw.texture(ldr_texture, (0, 0, viewer.width, viewer.height))

        # - debug postprocessing
        imdraw.texture(hdr_image, (0, 300, 90, 90))
        imdraw.texture(highlights_texture, (100, 300, 90, 90))
        imdraw.texture(bloom_texture, (200, 300, 90, 90))
        imdraw.texture(with_bloom_texture, (300, 300, 90, 90))

        # - debug gBuffer
        gPosition, gNormal, gDepth, gObjectId, gAlbedo, gEmissive, gRoughness, gMetallic = gBuffer
        imdraw.texture(gPosition, (0, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gNormal, (100, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gDepth, (200, 0, 90, 90), shuffle=(0, 0, 0, -1))
        imdraw.texture(gObjectId, (300, 0, 90, 90), shuffle=(0, 1, 2, -1))

        imdraw.texture(gAlbedo, (400, 0, 90, 90), shuffle=(0, 1, 2, -1))
        imdraw.texture(gEmissive, (500, 0, 90, 90))
        imdraw.texture(gRoughness, (600, 0, 90, 90), shuffle=(0, 0, 0, -1))
        imdraw.texture(gMetallic, (700, 0, 90, 90), shuffle=(0, 0, 0, -1))

        # - debug IBL
        imdraw.texture(environment_texture, (0, 100, 90, 90))
        imdraw.cubemap(environment_cubemap, (100, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(irradiance_cubemap, (200, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.cubemap(prefilter_cubemap, (300, 100, 90, 90),
                       viewer.camera.projection, viewer.camera.view)
        imdraw.texture(brdfLUT, (400, 100, 90, 90))