Пример #1
0
def test_basic_random():
    c = CyRasterizer(width=100, height=100)

    points = np.array([[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]])
    trilist = np.array([[0, 1, 2], [2, 3, 0]])
    colours = np.random.uniform(size=(100, 100, 3))
    tcoords = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])

    rgb_image, float_image, mask = c.rasterize(points, trilist, colours, tcoords)
    
    assert_allclose(rgb_image, colours)
Пример #2
0
def test_basic_random():
    c = CyRasterizer(width=100, height=100)

    # Set the vanilla texture shader
    c.set_shaders(vertex=DEFAULT_VERTEX_SHADER_SRC, fragment=DEFAULT_FRAGMENT_SHADER_SRC)

    points = np.array([[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]])
    trilist = np.array([[0, 1, 2], [2, 3, 0]])
    colours = np.random.uniform(size=(100, 100, 3))
    tcoords = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])

    rgb_image, float_image, mask = c.rasterize(points, trilist, colours, tcoords)

    assert_allclose(rgb_image, colours)
Пример #3
0
def test_basic_random():
    c = CyRasterizer(width=100, height=100)

    # Set the vanilla texture shader
    c.set_shaders(vertex=DEFAULT_VERTEX_SHADER_SRC,
                  fragment=DEFAULT_FRAGMENT_SHADER_SRC)

    points = np.array([[-1, -1, 0], [1, -1, 0], [1, 1, 0], [-1, 1, 0]])
    trilist = np.array([[0, 1, 2], [2, 3, 0]])
    colours = np.random.uniform(size=(100, 100, 3))
    tcoords = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])

    rgb_image, float_image, mask = c.rasterize(points, trilist, colours,
                                               tcoords)

    assert_allclose(rgb_image, colours)
frag_shader = """#version 330
#extension GL_ARB_explicit_attrib_location : require

uniform sampler2D textureImage;
smooth in vec2 tcoord;
smooth in vec3 linearMappingCoord;

layout(location = 0) out vec4 outputColor;
layout(location = 1) out vec3 outputLinearMapping;

void main() {
   outputColor = texture(textureImage, tcoord);
      outputLinearMapping = linearMappingCoord;
      }
"""


import numpy as np
import menpo3d.io as mio
from cyrasterize import CyRasterizer
from cyrasterize import FragmentShader
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
mesh = mio.import_builtin_asset('james.obj')
CyRasterizer()
shader = FragmentShader(frag_shader)
print(shader)