Cleanup: gpu docs

This commit is contained in:
2018-11-20 07:32:49 +11:00
parent 5f21030a81
commit 3c8c976086
12 changed files with 130 additions and 86 deletions

View File

@@ -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')
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')