shaders
¶
Read shader files.
|
Add a shader callback to the actor. |
|
Link a numpy array with vertex attribute. |
|
Returns the directory component of a pathname |
|
|
|
Join two or more pathname components, inserting ‘/’ as needed. |
|
Set and Replace the shader template with a new one. |
|
Apply your own substitutions to the shader creation process. |
Module: shaders.base
¶
|
Add a shader callback to the actor. |
|
Link a numpy array with vertex attribute. |
|
Enable global warnings. |
|
Set and Replace the shader template with a new one. |
|
Apply your own substitutions to the shader creation process. |
add_shader_callback¶
-
fury.shaders.
add_shader_callback
(actor, callback, priority=0.0)[source]¶ Add a shader callback to the actor.
- Parameters
actor (vtkActor) – Rendered Object
callback (callable) – function or class that contains 3 parameters: caller, event, calldata. This callback will be trigger at each UpdateShaderEvent event.
priority (float, optional) – Commands with a higher priority are called first.
- Returns
id_observer – An unsigned Int tag which can be used later to remove the event or retrieve the vtkCommand used in the observer. See more at: https://vtk.org/doc/nightly/html/classvtkObject.html
- Return type
Examples
add_shader_callback(actor, func_call1) id_observer = add_shader_callback(actor, func_call2) actor.GetMapper().RemoveObserver(id_observer)
Priority calls
test_values = [] def callbackLow(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(0) def callbackHigh(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(999) def callbackMean(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(500) fs.add_shader_callback( actor, callbackHigh, 999) fs.add_shader_callback( actor, callbackLow, 0) id_mean = fs.add_shader_callback( actor, callbackMean, 500) showm.start() # test_values = [999, 500, 0, 999, 500, 0, ...]
attribute_to_actor¶
pjoin¶
-
fury.shaders.
pjoin
(a, *p)¶ Join two or more pathname components, inserting ‘/’ as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.
replace_shader_in_actor¶
shader_to_actor¶
-
fury.shaders.
shader_to_actor
(actor, shader_type, impl_code='', decl_code='', block='valuepass', keep_default=True, replace_first=True, replace_all=False, debug=False)[source]¶ Apply your own substitutions to the shader creation process.
A bunch of string replacements is applied to a shader template. Using this function you can apply your own string replacements to add features you desire
- Parameters
actor (vtkActor) – Object where you want to add the shader code.
shader_type (str) – Shader type: vertex, geometry, fragment
impl_code (str, optional) – shader implementation code, should be a string or filename
decl_code (str, optional) – shader declaration code, should be a string or filename by default None
block (str, optional) – section name to be replaced. vtk use of heavy string replacments to to insert shader and make it flexible. Each section of the shader template have a specific name. For more informations: https://vtk.org/Wiki/Shaders_In_VTK. The possible values are: position, normal, light, tcoord, color, clip, camera, prim_id, valuepass. by default valuepass
keep_default (bool, optional) – keep the default block tag to let VTK replace it with its default behavior. By default True
replace_first (bool, optional) – If True, apply this change before the standard VTK replacements by default True
replace_all (bool, optional) – [description], by default False
debug (bool, optional) – introduce a small error to debug shader code. by default False
add_shader_callback¶
-
fury.shaders.base.
add_shader_callback
(actor, callback, priority=0.0)[source]¶ Add a shader callback to the actor.
- Parameters
actor (vtkActor) – Rendered Object
callback (callable) – function or class that contains 3 parameters: caller, event, calldata. This callback will be trigger at each UpdateShaderEvent event.
priority (float, optional) – Commands with a higher priority are called first.
- Returns
id_observer – An unsigned Int tag which can be used later to remove the event or retrieve the vtkCommand used in the observer. See more at: https://vtk.org/doc/nightly/html/classvtkObject.html
- Return type
Examples
add_shader_callback(actor, func_call1) id_observer = add_shader_callback(actor, func_call2) actor.GetMapper().RemoveObserver(id_observer)
Priority calls
test_values = [] def callbackLow(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(0) def callbackHigh(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(999) def callbackMean(_caller, _event, calldata=None): program = calldata if program is not None: test_values.append(500) fs.add_shader_callback( actor, callbackHigh, 999) fs.add_shader_callback( actor, callbackLow, 0) id_mean = fs.add_shader_callback( actor, callbackMean, 500) showm.start() # test_values = [999, 500, 0, 999, 500, 0, ...]
attribute_to_actor¶
enable_warnings¶
replace_shader_in_actor¶
shader_to_actor¶
-
fury.shaders.base.
shader_to_actor
(actor, shader_type, impl_code='', decl_code='', block='valuepass', keep_default=True, replace_first=True, replace_all=False, debug=False)[source]¶ Apply your own substitutions to the shader creation process.
A bunch of string replacements is applied to a shader template. Using this function you can apply your own string replacements to add features you desire
- Parameters
actor (vtkActor) – Object where you want to add the shader code.
shader_type (str) – Shader type: vertex, geometry, fragment
impl_code (str, optional) – shader implementation code, should be a string or filename
decl_code (str, optional) – shader declaration code, should be a string or filename by default None
block (str, optional) – section name to be replaced. vtk use of heavy string replacments to to insert shader and make it flexible. Each section of the shader template have a specific name. For more informations: https://vtk.org/Wiki/Shaders_In_VTK. The possible values are: position, normal, light, tcoord, color, clip, camera, prim_id, valuepass. by default valuepass
keep_default (bool, optional) – keep the default block tag to let VTK replace it with its default behavior. By default True
replace_first (bool, optional) – If True, apply this change before the standard VTK replacements by default True
replace_all (bool, optional) – [description], by default False
debug (bool, optional) – introduce a small error to debug shader code. by default False