-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
209 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
# Texture VFX Control: Blender Add-on | ||
|
||
WIP | ||
This Blender add-on provides with shader-based effects on image/sequence/movie textures. It enables users to perform video composition directly in the 3D space without using the compositor or the sequencer. | ||
|
||
The functionalities of this add-on include: | ||
|
||
- Texture Playback Control | ||
- Setting the speed and loop mode of sequence/movie textures | ||
- VFX Shaders | ||
- Blur | ||
- Chroma Key | ||
- Outline | ||
|
||
|
||
## Requirements | ||
|
||
Blender 3.3+ or Blender 4.0 | ||
|
||
## Installation | ||
|
||
WIP | ||
|
||
## Usage | ||
|
||
WIP | ||
|
||
### Playback Control Driver | ||
|
||
### VFX Shader Node Groups | ||
|
||
## Credits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import bpy | ||
import os | ||
|
||
def get_library_blend_file(): | ||
file_name = '../res/assets.blend' | ||
script_file = os.path.realpath(__file__) | ||
directory = os.path.dirname(script_file) | ||
file_path = os.path.join(directory, file_name) | ||
return file_path | ||
|
||
def append_node_group(node_group_name): | ||
if node_group_name in bpy.data.node_groups: | ||
return bpy.data.node_groups[node_group_name] | ||
|
||
mode = bpy.context.mode | ||
bpy.ops.object.mode_set(mode='OBJECT') | ||
file_path = get_library_blend_file() | ||
inner_path = 'NodeTree' | ||
bpy.ops.wm.append( | ||
filepath=os.path.join(file_path, inner_path, node_group_name), | ||
directory=os.path.join(file_path, inner_path), | ||
filename=node_group_name | ||
) | ||
bpy.ops.object.mode_set(mode=mode) | ||
return bpy.data.node_groups[node_group_name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import bpy | ||
|
||
def add_driver_variable(driver, id, data_path, name, id_type='OBJECT', custom_property = True): | ||
var = driver.variables.new() | ||
var.name = name | ||
var.type = 'SINGLE_PROP' | ||
var.targets[0].id_type = id_type | ||
var.targets[0].id = id | ||
var.targets[0].data_path = f'["{data_path}"]' if custom_property else data_path | ||
|
||
def copy_driver(src, dst): | ||
""" | ||
Copy all attributes of the source driver to an empty destination driver | ||
""" | ||
dst.type = src.type | ||
for src_var in src.variables: | ||
dst_var = dst.variables.new() | ||
dst_var.name = src_var.name | ||
dst_var.type = src_var.type | ||
dst_var.targets[0].id_type = src_var.targets[0].id_type | ||
dst_var.targets[0].id = src_var.targets[0].id | ||
dst_var.targets[0].data_path = src_var.targets[0].data_path | ||
dst.expression = src.expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import bpy | ||
from ..utils.asset import append_node_group | ||
|
||
def get_target_node(node_tree, | ||
filter = lambda node: (node.type == 'TEX_IMAGE' and node.image) | ||
): | ||
""" | ||
Find the shader node to perform operations. | ||
First, check the active node. If it is not qualified, search through all nodes to find the first eligible one | ||
""" | ||
nodes = node_tree.nodes | ||
if nodes.active and filter(nodes.active): | ||
return nodes.active, node_tree | ||
# Search recursively for node groups | ||
elif nodes.active and nodes.active.type=='GROUP' and nodes.active.node_tree: | ||
return get_target_node(nodes.active.node_tree, filter) | ||
else: | ||
for node in nodes: | ||
if filter(node): | ||
return node, node_tree | ||
return None, None | ||
|
||
def add_node_group(node_tree, name, location=(0,0)) -> bpy.types.ShaderNodeGroup: | ||
node = node_tree.nodes.new('ShaderNodeGroup') | ||
node.node_tree = append_node_group(name) | ||
node.location = location | ||
return node | ||
|
||
def add_uv_input(node_tree, location=(0,0)) -> bpy.types.ShaderNodeUVMap: | ||
node = node_tree.nodes.new('ShaderNodeUVMap') | ||
node.location = location | ||
return node |