示例#1
0
    def __init__(self):
        self.width = 1024
        self.height = 768
        self.window = GLFWViewer(self.width, self.height, (0.2, 0.2, 0.2, 1.0))

        self.matcap_img = assets.imread("matcap/jeepster_skinmat2.jpg").astype(
            np.float32) / 255
        # self.matcap_img = assets.imread("container2_axis.png").astype(np.float32)[...,[0,1,2]]/255
        self.matcap_img = np.flip(self.matcap_img, 0)
示例#2
0
    def __init__(self, scene):
        # window
        self.width = 1024
        self.height = 768
        self.window = GLFWViewer(self.width, self.height, (0.2, 0.2, 0.2, 1.0))
        self.camera = PerspectiveCamera(glm.inverse(self.window.view_matrix),
                                        glm.radians(60),
                                        self.width / self.height, 1, 30)
        self.scene = scene

        # assets
        self.environment_image = assets.imread('hdri/Tropical_Beach_3k.hdr')
        self.environment_image = assets.to_linear(self.environment_image)

        # render passes
        self.environment_pass = EnvironmentPass(512, 512)
        self.irradiance_pass = IrradiancePass(32, 32)
        self.prefilter_pass = PrefilterPass()
        self.brdf_pass = BRDFPass(512, 512)
        self.tonemapping_pass = TonemappingPass(self.width, self.height)

        self.geometry_pass = GeometryPass(self.width, self.height,
                                          self.draw_scene_for_geometry)
        dirlight.shadowpass = DepthPass(1024, 1024, GL_FRONT,
                                        self.draw_scene_for_shadows)
        spotlight.shadowpass = DepthPass(1024, 1024, GL_FRONT,
                                         self.draw_scene_for_shadows)
        pointlight.shadowpass = CubeDepthPass(
            512,
            512,
            GL_FRONT,
            near=1,
            far=15,
            draw_scene=self.draw_scene_for_shadows)

        self.lighting_pass = LightingPass(
            self.width, self.height, lights=[dirlight, spotlight, pointlight])
示例#3
0
from OpenGL.GL import *
from editor.render.window import GLFWViewer
import numpy as np
from editor.render.puregl import program

from editor.render import glsl, imdraw
import glm
import logging
logging.basicConfig(
    filename=None,
    level=logging.DEBUG,
    format='%(levelname)s:%(module)s.%(funcName)s: %(message)s')

width, height = 1024, 768
model_matrix = np.identity(4)
window = GLFWViewer(width, height, (0.6, 0.7, 0.7, 1.0))

with window:
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_CULL_FACE)

    while not window.should_close():
        glViewport(0, 0, window.width, window.height)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        with program.use(skybox_program):
            program.set_uniform(skybox_program, 'projection',
                                window.projection_matrix)
            sky_view = glm.mat4(glm.mat3(window.view_matrix))
            program.set_uniform(skybox_program, 'view', sky_view)
            camera_pos = glm.transpose(
                glm.transpose(glm.inverse(window.view_matrix)))[3].xyz