Example #1
0
    def draw(self):

        # Draw
        # ----
        beauty = self.renderer.render(self.scene, self.camera)
        imdraw.texture(beauty, (0, 0, self.width, self.height))
        imdraw.axis(self.camera.projection, self.camera.view)
Example #2
0
    def on_draw():
        # render passes
        depth_map = depth_pass.render(scene.find_meshes(), viewer.camera)

        # render passes to screen
        glDisable(GL_DEPTH_TEST)
        imdraw.texture(depth_map, (0, 0, viewer.width, viewer.height),
                       shuffle=(0, 0, 0, -1))
Example #3
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)
Example #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))
Example #5
0
 def on_draw():
     glDisable(GL_DEPTH_TEST)
     imdraw.texture(tex, (0, 0, viewer.width // 2, viewer.height))
     blurred = blurpass.render(tex, iterations=16)
     imdraw.texture(
         blurred, (viewer.width // 2, 0, viewer.width // 2, viewer.height))
Example #6
0
                program.set_uniform(ssao_program, 'projection',
                                    window.projection_matrix)
                program.set_uniform(
                    ssao_program, 'viewProjectionMatrix',
                    window.projection_matrix * window.view_matrix)

                glActiveTexture(GL_TEXTURE0 + 0)
                glBindTexture(GL_TEXTURE_2D, gPosition)
                glActiveTexture(GL_TEXTURE0 + 1)
                glBindTexture(GL_TEXTURE_2D, gNormal)
                glActiveTexture(GL_TEXTURE0 + 2)
                glBindTexture(GL_TEXTURE_2D, noise_texture)

                program.set_uniform(ssao_program, 'gPosition', 0)
                program.set_uniform(ssao_program, 'gNormal', 1)
                program.set_uniform(ssao_program, 'texNoise', 2)

                imdraw.quad(ssao_program)

        # with fbo.bind(ssao_blur_fbo):
        # 	with program.use(ssao_blur_program):
        # 		glActiveTexture(GL_TEXTURE0+0)
        # 		glBindTexture(GL_TEXTURE_2D, ssao_tex)
        # 		program.set_uniform(ssao_blur_program, 'ssaoInput', 0)
        # 		imdraw.quad(ssao_blur_program)

        imdraw.texture(ssao_tex, (0, 0, window.width, window.height),
                       shuffle=(0, 0, 0, -1))

        window.swap_buffers()
        GLFWViewer.poll_events()
Example #7
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))
Example #8
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))
Example #9
0
 def on_draw():
     imdraw.texture(texA, (0, 0, 200, 200))
     imdraw.texture(texB, (200, 0, 200, 200))
     added = addpass.render(texA, texB)
     imdraw.texture(added, (400, 0, 500, 500))
Example #10
0
	def on_draw():
		imdraw.texture(texA, (0,0,200,200))
		added = clamppass.render(texA, 0.5, 1.0)
		imdraw.texture(added, (400,0,500,500))
Example #11
0
        # Render scene to gBuffer
        # ==============
        with fbo.bind(gBuffer):
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            # glCullFace(GL_BACK)
            with program.use(gbuffer_program):
                program.set_uniform(gbuffer_program, 'material.albedo',
                                    (0.5, 0, 0))
                program.set_uniform(gbuffer_program, 'material.roughness', 0.1)
                program.set_uniform(gbuffer_program, 'projectionMatrix',
                                    window.projection_matrix)
                program.set_uniform(gbuffer_program, 'viewMatrix',
                                    window.view_matrix)
                draw_scene(gbuffer_program, window.projection_matrix,
                           window.view_matrix)

        # Debug
        # -----------------------------------------
        imdraw.texture(shadow_tex, (0, 0, 100, 100), shuffle=(0, 0, 0, -1))
        imdraw.texture(hdr_color_buffers[0], (100, 0, 100, 100))
        imdraw.texture(pingpong_buffer[0], (200, 0, 100, 100))
        imdraw.texture(gPosition, (300, 0, 100, 100))
        imdraw.texture(gNormal, (400, 0, 100, 100))
        imdraw.texture(gAlbedoSpec, (500, 0, 100, 100), shuffle=(0, 1, 2, -1))
        imdraw.texture(gAlbedoSpec, (600, 0, 100, 100), shuffle=(3, 3, 3, -1))

        # swap buffers
        window.swap_buffers()
        GLFWViewer.poll_events()
Example #12
0
 def setup():
     beauty = renderer.render(scene, window.camera)
     imdraw.texture(beauty, (0, 0, window.width, window.height))
Example #13
0
 def on_draw():
     imdraw.texture(tex, (0,0,viewer.width//2,viewer.height))
     toned = tonepass.render(tex, exposure=2.0, gamma=1/2.2)
     imdraw.texture(toned, (viewer.width//2,0,viewer.width//2, viewer.height))
Example #14
0
 def on_draw():
     beauty = renderer.render(scene, viewer.camera)
     imdraw.texture(beauty, (0, 0, 1280, 720))
Example #15
0
    def on_draw():
        # render passes
        gBuffer = geometry_pass.render(scene.find_meshes(), viewer.camera)
        gPosition, gNormal, gAlbedo, gEmission, gRoughness, gMetallic = gBuffer

        # render passes to screen
        glDisable(GL_DEPTH_TEST)
        glDisable(GL_CULL_FACE)
        # glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glClearColor(0.5,0.5,0.5,0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        checkerboard_program = puregl.program.create(
            """#version 330 core
            layout (location=0) in vec3 position;
            layout (location=1) in vec2 uv;
            out vec2 TexCoords;
            void main(){
                TexCoords = uv;
                gl_Position = vec4(position,1.0);
            }
            """,
            """#version 330 core
            in vec2 TexCoords;
            out vec4 FragColor;
            uniform float size;
            uniform vec2 viewportSize;
            float checker(vec2 uv, vec2 repeats){
                float cx = floor(repeats.x * uv.x);
                float cy = floor(repeats.y * uv.y);
                float result = mod(cx + cy, 2.0);
                return sign(result);
            }

            void main(){
                vec4 colorA = vec4(0.6,0.6,0.6,0.5);
                vec4 colorB = vec4(0.4,0.4,0.4,0.5);
                FragColor = mix(colorA, colorB, checker(TexCoords, viewportSize/size));
            }
            """)
        with puregl.program.use(checkerboard_program):
            puregl.program.set_uniform(checkerboard_program, "viewportSize", (viewer.width, viewer.height))
            puregl.program.set_uniform(checkerboard_program, "size", 8.0)
            imdraw.quad(checkerboard_program)

        imdraw.texture(gPosition, (20, 20, viewer.width-40, viewer.height-40), shuffle=(0, 1, 2, 3))

        #
        imdraw.texture(gPosition, (0,0,190, 190), shuffle=(0,1,2,3))
        imdraw.texture(gNormal, (200,0,190, 190), shuffle=(0,1,2,-1))
        imdraw.texture(gAlbedo, (400,0,190, 190), shuffle=(0,1,2,-1))
        imdraw.texture(gEmission, (600,0,190, 190))
        imdraw.texture(gRoughness, (800,0,190, 190), shuffle=(0,0,0,-1))
        imdraw.texture(gMetallic, (1000,0,190, 190), shuffle=(0,0,0,-1))

        imdraw.texture(geometry_pass.gDepth, (  0, 200, 190, 190), shuffle=(0, 0, 0, -1))