How to use the wgpu.BlendOperation function in wgpu

To help you get started, we’ve selected a few wgpu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almarklein / wgpu-py / tests / test_gui_glfw.py View on Github external
fragment_stage={"module": fshader, "entry_point": "main"},
        primitive_topology=wgpu.PrimitiveTopology.triangle_strip,
        rasterization_state={
            "front_face": wgpu.FrontFace.ccw,
            "cull_mode": wgpu.CullMode.none,
            "depth_bias": 0,
            "depth_bias_slope_scale": 0.0,
            "depth_bias_clamp": 0.0,
        },
        color_states=[
            {
                "format": wgpu.TextureFormat.bgra8unorm_srgb,
                "alpha_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "color_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "write_mask": wgpu.ColorWrite.ALL,
            }
        ],
        vertex_state={"index_format": wgpu.IndexFormat.uint32, "vertex_buffers": [],},
        sample_count=1,
        sample_mask=0xFFFFFFFF,
        alpha_to_coverage_enabled=False,
    )

    swap_chain = device.configure_swap_chain(
github almarklein / wgpu-py / tests / renderutils.py View on Github external
"depth_bias": 0,
            "depth_bias_slope_scale": 0.0,
            "depth_bias_clamp": 0.0,
        },
        color_states=[
            {
                "format": texture_format,
                "alpha_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "color_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "write_mask": wgpu.ColorWrite.ALL,
            }
        ],
        depth_stencil_state=depth_stencil_state,
        vertex_state={
            "index_format": wgpu.IndexFormat.uint32,
            "vertex_buffers": vbo_views,
        },
        sample_count=1,
        sample_mask=0xFFFFFFFF,
        alpha_to_coverage_enabled=False,
    )

    command_encoder = device.create_command_encoder()
github almarklein / wgpu-py / tests / renderutils.py View on Github external
fragment_stage={"module": fshader, "entry_point": "main"},
        primitive_topology=topology,
        rasterization_state={
            "front_face": wgpu.FrontFace.ccw,
            "cull_mode": wgpu.CullMode.none,
            "depth_bias": 0,
            "depth_bias_slope_scale": 0.0,
            "depth_bias_clamp": 0.0,
        },
        color_states=[
            {
                "format": wgpu.TextureFormat.bgra8unorm_srgb,
                "alpha_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "color_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "write_mask": wgpu.ColorWrite.ALL,
            }
        ],
        depth_stencil_state=depth_stencil_state,
        vertex_state={
            "index_format": wgpu.IndexFormat.uint32,
            "vertex_buffers": vbo_views,
        },
        sample_count=1,
        sample_mask=0xFFFFFFFF,
github almarklein / wgpu-py / examples / cube_glfw.py View on Github external
"depth_bias": 0,
        "depth_bias_slope_scale": 0.0,
        "depth_bias_clamp": 0.0,
    },
    color_states=[
        {
            "format": wgpu.TextureFormat.bgra8unorm_srgb,
            "alpha_blend": (
                wgpu.BlendFactor.one,
                wgpu.BlendFactor.zero,
                wgpu.BlendOperation.add,
            ),
            "color_blend": (
                wgpu.BlendFactor.one,
                wgpu.BlendFactor.zero,
                wgpu.BlendOperation.add,
            ),
        }
    ],
    vertex_state={
        "index_format": wgpu.IndexFormat.uint32,
        "vertex_buffers": [
            {
                "array_stride": 4 * 6,
                "step_mode": wgpu.InputStepMode.vertex,
                "attributes": [
                    {
                        "format": wgpu.VertexFormat.float4,
                        "offset": 0,
                        "shader_location": 0,
                    },
                    {
github almarklein / wgpu-py / examples / cube_glfw.py View on Github external
fragment_stage={"module": fshader, "entry_point": "main"},
    primitive_topology=wgpu.PrimitiveTopology.triangle_list,
    rasterization_state={
        "front_face": wgpu.FrontFace.ccw,
        "cull_mode": wgpu.CullMode.back,
        "depth_bias": 0,
        "depth_bias_slope_scale": 0.0,
        "depth_bias_clamp": 0.0,
    },
    color_states=[
        {
            "format": wgpu.TextureFormat.bgra8unorm_srgb,
            "alpha_blend": (
                wgpu.BlendFactor.one,
                wgpu.BlendFactor.zero,
                wgpu.BlendOperation.add,
            ),
            "color_blend": (
                wgpu.BlendFactor.one,
                wgpu.BlendFactor.zero,
                wgpu.BlendOperation.add,
            ),
        }
    ],
    vertex_state={
        "index_format": wgpu.IndexFormat.uint32,
        "vertex_buffers": [
            {
                "array_stride": 4 * 6,
                "step_mode": wgpu.InputStepMode.vertex,
                "attributes": [
                    {
github almarklein / wgpu-py / examples / triangle.py View on Github external
"depth_bias": 0,
            "depth_bias_slope_scale": 0.0,
            "depth_bias_clamp": 0.0,
        },
        color_states=[
            {
                "format": wgpu.TextureFormat.bgra8unorm_srgb,
                "alpha_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
                "color_blend": (
                    wgpu.BlendFactor.one,
                    wgpu.BlendFactor.zero,
                    wgpu.BlendOperation.add,
                ),
            }
        ],
        vertex_state={"index_format": wgpu.IndexFormat.uint32, "vertex_buffers": []},
        sample_count=1,
        sample_mask=0xFFFFFFFF,
        alpha_to_coverage_enabled=False,
    )

    swap_chain = device.configure_swap_chain(
        canvas,
        device.get_swap_chain_preferred_format(canvas),
        wgpu.TextureUsage.OUTPUT_ATTACHMENT,
    )

    def draw_frame():