Skip to content

Commit

Permalink
Add custom output directory to texture converter
Browse files Browse the repository at this point in the history
  • Loading branch information
jdent02 authored and dictoon committed May 30, 2018
1 parent bdf674d commit 01340c5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
Binary file modified docs/_static/screenshots/material_panels/tex_convert.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions docs/panels/material/texture_converter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@ The texture converter is a utility for converting traditional image formats (JPE
- Texture List:
This shows the list of textures in the scene.
- Use Converted Textures:
This tells blenderseed to substitute texture paths with the .tx version during export and rendering.
- Add Textures:
This manually adds a texture entry to the list.
- Remove Textures:
This manually removes the selected texture slot from the list.
- Refresh Textures:
This scans the texture files that are used in the scene and adds them to the list. Entries will not be duplicated if they already exists.
This scans the texture files that are used in the scene and adds them to the list. Entries will not be duplicated if they already exists. Entries will also be removed if they are no longer being used in the scene.
- Convert Textures:
This launches maketx and converts all the textures in the list to .tx versions (if they havent already been converted)
This launches maketx and converts all the textures in the list to .tx versions (if they haven't already been converted).
- Delete Unused .tx Files:
This will delete any converted .tx files that are no longer being used in the scene (if a node is deleted for instance).
- Use Converted Textures:
This tells blenderseed to substitute texture paths with the .tx version during export and rendering.
- Use Custom Output Directory:
This allows you to put the converter .tx textures into a different directory than the original textures.
- Output Directory:
This is where the .tx files will be placed when 'Use Custom Output Directory' is checked.
- Texture:
This is the filepath of the selected entry in the texture list. Clicking on the filepath button will open a file selection window.
- Input Color Space:
This parameter tells maketx what color space the original file is in. If it is anything other than 'linear' the colorspace will be converted during the maketx process. RGB textures such as color or specular color are usually sRGB. Bump maps, normal maps, and other greyscale value maps (roughness, metallness) are usually linear, but this may vary depending on the texture source.
This parameter tells maketx what color space the original file is in. If it is anything other than 'linear' the color space will be converted during the maketx process. RGB textures such as color or specular color are usually sRGB. Bump maps, normal maps, and other grayscale value maps (roughness, metalness) are usually linear, but this may vary depending on the texture source.
- Output Bit Depth:
This allows you to manually specify the bit depth of the .tx file. Leaving it at 'default' will set the bit depth to the same size as the input.
- Additional Commands:
Expand Down
4 changes: 4 additions & 0 deletions operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def execute(self, context):
cmd.insert(-1, '-d {0}'.format(tex.output_depth))
if tex.command_string:
cmd.insert(-1, '{0}'.format(tex.command_string))
if textures.tex_output_use_cust_dir:
tex_name = os.path.basename(filename).split('.')[0]
out_path = os.path.join(textures.tex_output_dir, '{0}.tx'.format(tex_name))
cmd.insert(-1, '-o "{0}"'.format(out_path))
process = subprocess.Popen(" ".join(cmd), cwd=tool_dir, shell=True, bufsize=1)
process.wait()

Expand Down
14 changes: 12 additions & 2 deletions projectwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def __emit_osl_shader_group(self, front_material_name, node_list, material_node,
self.__close_element("shader_group")

def __get_osl_node_params(self, node, scene):
asr_scene_props = scene.appleseed
parameters = {}
parameter_types = node.parameter_types
for key in parameter_types.keys():
Expand All @@ -801,8 +802,17 @@ def __get_osl_node_params(self, node, scene):
parameter = bpy.path.abspath(parameter)
if scene.appleseed.sub_textures is True:
if parameter.endswith(image_extensions):
base_filename = parameter.split('.')
parameter = "{0}.tx".format(base_filename[0])
# Split original image path
image_path_segments = os.path.split(parameter)
# Get raw image name (without extension)
image_name = os.path.splitext(image_path_segments[1])
# Create new image name with .tx extension
new_image_name = "{0}.tx".format(image_name[0])
if asr_scene_props.tex_output_use_cust_dir:
parameter = os.path.join(asr_scene_props.tex_output_dir, new_image_name)
else:
parameter = os.path.join(image_path_segments[0], new_image_name)


if parameter_value == "int checkbox":
parameter_value = "int"
Expand Down
11 changes: 10 additions & 1 deletion properties/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import multiprocessing

import bpy
from .. import util

from .. import util

try:
threads = multiprocessing.cpu_count()
Expand Down Expand Up @@ -88,6 +88,15 @@ def update_stamp(self, context):

# Texture conversion

tex_output_dir = bpy.props.StringProperty(name="tex_output_dir",
description="",
default="",
subtype='DIR_PATH')

tex_output_use_cust_dir = bpy.props.BoolProperty(name="tex_output_use_cust_dir",
description="",
default=False)

sub_textures = bpy.props.BoolProperty(name="sub_textures",
default=False)

Expand Down
4 changes: 4 additions & 0 deletions ui/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,10 @@ def draw(self, context):

layout.prop(asr_scene_props, "del_unused_tex", text="Delete Unused .tx Files", toggle=True)
layout.prop(asr_scene_props, "sub_textures", text="Use Converted Textures", toggle=True)
layout.prop(asr_scene_props, "tex_output_use_cust_dir", text="Use Custom Output Directory", toggle=True)
col = layout.column()
col.enabled = asr_scene_props.tex_output_use_cust_dir
col.prop(asr_scene_props, "tex_output_dir", text="Output Directory")

if textures:
current_set = textures[asr_scene_props.textures_index]
Expand Down

0 comments on commit 01340c5

Please sign in to comment.