Ejemplo n.º 1
0
def update_ubo():
    # Upload uniforms data to memory
    data_ptr = hvk.map_memory(api, device, uniforms_mem, 0,
                              sizeof(uniforms_data_type))

    uniforms = uniforms_data_type.from_address(data_ptr.value)
    ubo_data, light, mat = uniforms.ubo, uniforms.light, uniforms.mat

    # UBO
    width, height = window.dimensions()
    ubo_data[0] = Mat4.perspective(radians(60), width / height, 0.1,
                                   256.0)  # Perspective
    ubo_data[1] = Mat4.from_translation(0.0, 0.0, -zoom)  # View
    model = Mat4.from_rotation(rotation[0], (1.0, 0.0, 0))\
                      .rotate(rotation[1], (0.0, 1.0, 0.0))\
                      .rotate(rotation[2], (0.0, 0.0, 1.0))
    ubo_data[2] = model  # Model
    ubo_data[3] = model.invert().transpose()  # Normal

    # Light stuff
    light.viewPos[:3] = view
    light.pos[:3] = light_direction
    light.color = light_color
    light.ambient = light_ambient

    # Material stuff
    material = materials[material_index]
    mat.color = material['color']
    mat.strenght = material['strength']
    mat.shininess = material['shininess']

    hvk.unmap_memory(api, device, uniforms_mem)
Ejemplo n.º 2
0
def update_ubo():
    # Upload uniforms data to memory
    data_ptr = hvk.map_memory(api, device, uniforms_mem, 0,
                              sizeof(uniforms_data_type))

    uniforms = uniforms_data_type.from_address(data_ptr.value)
    ubo_data = uniforms.ubo

    # Perspective
    width, height = window.dimensions()
    ubo_data[0] = Mat4.perspective(radians(60), width / height, 0.1, 256.0)

    # View
    ubo_data[1] = Mat4.from_translation(0.0, 0.0, -zoom)

    # Model
    ubo_data[2] = Mat4.from_rotation(rotation, (0.0, -1.0, 0.5))

    hvk.unmap_memory(api, device, uniforms_mem)
def update_ubo():
    # Upload uniforms data to memory
    data_ptr = hvk.map_memory(api, device, uniforms_mem, 0,
                              sizeof(uniforms_data_type))

    uniforms = uniforms_data_type.from_address(data_ptr.value)
    ubo_data, light = uniforms.ubo, uniforms.light

    # Perspective
    width, height = window.dimensions()
    ubo_data[0] = Mat4.perspective(radians(60), width / height, 0.1, 256.0)

    # View
    ubo_data[1] = Mat4.from_translation(0.0, 0.0, -zoom)

    # Model
    ubo_data[2] = Mat4.from_rotation(rotation, (0.0, -1.0, 0.5))

    # Light stuff
    light.reverseLightDirection[:3] = Vec3.normalize(reverse_light_direction)

    hvk.unmap_memory(api, device, uniforms_mem)