diff options
Diffstat (limited to 'doc/python_api/examples/gpu.11.py')
-rw-r--r-- | doc/python_api/examples/gpu.11.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/python_api/examples/gpu.11.py b/doc/python_api/examples/gpu.11.py index 61e7a842a59..2f255b7127d 100644 --- a/doc/python_api/examples/gpu.11.py +++ b/doc/python_api/examples/gpu.11.py @@ -3,8 +3,9 @@ Custom Shader for dotted 3D Line -------------------------------- In this example the arc length (distance to the first point on the line) is calculated in every vertex. -Between the vertex and fragment shader that value is automatically interpolated for all points that will be visible on the screen. -In the fragment shader the `sin` of the arc length is calculated. +Between the vertex and fragment shader that value is automatically interpolated +for all points that will be visible on the screen. +In the fragment shader the ``sin`` of the arc length is calculated. Based on the result a decision is made on whether the fragment should be drawn or not. """ import bpy @@ -47,9 +48,11 @@ for a, b in zip(coords[:-1], coords[1:]): arc_lengths.append(arc_lengths[-1] + (a - b).length) shader = gpu.types.GPUShader(vertex_shader, fragment_shader) -batch = batch_for_shader(shader, 'LINE_STRIP', - {"position" : coords, - "arcLength" : arc_lengths}) +batch = batch_for_shader( + shader, 'LINE_STRIP', + {"position": coords, "arcLength": arc_lengths}, +) + def draw(): shader.bind() @@ -58,4 +61,5 @@ def draw(): shader.uniform_float("u_Scale", 10) batch.draw(shader) -bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
\ No newline at end of file + +bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW') |