mirror of
https://github.com/blender/blender
synced 2026-11-22 03:45:13 +03:00
This commit bumps the `ios` branch from 5.0.0 alpha to 5.1.2 release. I merged v5.0-release first then v5.1-release. So it was a sequential merge. I'm just waiting to the approval of continuing development. The stuff that are missing (those are so close to implement): - #145484 iOS: Keyboard Input Support: https://projects.blender.org/blender/blender/pulls/145484 - #145702 iOS: Add clipboard Image: https://projects.blender.org/blender/blender/pulls/145702 - Fix QOS threading - Expose Downloads - UIScene Migration `make deps` needs to run two times. (still hacky....) OSL occurs racing conditions. Disclaimer: I used AI for searching in Documentation of Deps. So the implementation is by hand. **SACRED PINKY FINGER PROMISE** Pull Request: https://projects.blender.org/blender/blender/pulls/161073
63 lines
1.5 KiB
Python
63 lines
1.5 KiB
Python
"""
|
|
2D Image
|
|
--------
|
|
|
|
To use this example you have to provide an image that should be displayed.
|
|
"""
|
|
import bpy
|
|
import gpu
|
|
from gpu_extras.batch import batch_for_shader
|
|
|
|
IMAGE_NAME = "Untitled"
|
|
image = bpy.data.images[IMAGE_NAME]
|
|
texture = gpu.texture.from_image(image)
|
|
|
|
shader = gpu.shader.from_builtin('IMAGE_SCENE_LINEAR_TO_REC709_SRGB')
|
|
batch = batch_for_shader(
|
|
shader, 'TRI_STRIP',
|
|
{
|
|
"pos": ((100, 100), (200, 100), (100, 200), (200, 200)),
|
|
"texCoord": ((0, 0), (1, 0), (0, 1), (1, 1)),
|
|
},
|
|
)
|
|
|
|
|
|
def draw():
|
|
shader.bind()
|
|
shader.uniform_sampler("image", texture)
|
|
batch.draw(shader)
|
|
|
|
|
|
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
|
|
|
|
"""
|
|
3D Image
|
|
--------
|
|
|
|
Similar to the 2D Image shader, but works with 3D positions for the image vertices.
|
|
To use this example you have to provide an image that should be displayed.
|
|
"""
|
|
import bpy
|
|
import gpu
|
|
from gpu_extras.batch import batch_for_shader
|
|
|
|
IMAGE_NAME = "Untitled"
|
|
image = bpy.data.images[IMAGE_NAME]
|
|
texture = gpu.texture.from_image(image)
|
|
|
|
shader = gpu.shader.from_builtin('IMAGE_SCENE_LINEAR_TO_REC709_SRGB')
|
|
batch = batch_for_shader(
|
|
shader, 'TRIS',
|
|
{
|
|
"pos": ((0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 1, 1), (1, 0, 0), (0, 0, 0)),
|
|
"texCoord": ((0, 0), (0, 1), (1, 1), (1, 1), (1, 0), (0, 0)),
|
|
},
|
|
)
|
|
|
|
|
|
def draw():
|
|
shader.uniform_sampler("image", texture)
|
|
batch.draw(shader)
|
|
|
|
|
|
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
|