Skip to content

Commit

Permalink
Closes #528, removing the long outdated Composite Normal Textures fun…
Browse files Browse the repository at this point in the history
…ction that doesn't do anything.
  • Loading branch information
tngreene committed Jan 4, 2022
1 parent 00724dd commit f4eacaa
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 316 deletions.
2 changes: 1 addition & 1 deletion io_xplane2blender/xplane_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# The current data model version, incrementing every time xplane_constants, xplane_props, or xplane_updater
# changes. Builds earlier than 3.4.0-beta.5 have and a version of 0.
# When merging, take the higher data model version of the two branches and add one
CURRENT_DATA_MODEL_VERSION = 103
CURRENT_DATA_MODEL_VERSION = 104

# The build number, hardcoded by the build script when there is one, otherwise it is xplane_constants.BUILD_NUMBER_NONE
CURRENT_BUILD_NUMBER = xplane_constants.BUILD_NUMBER_NONE
Expand Down
106 changes: 0 additions & 106 deletions io_xplane2blender/xplane_image_composer.py

This file was deleted.

6 changes: 0 additions & 6 deletions io_xplane2blender/xplane_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,6 @@ class XPlaneSceneSettings(bpy.types.PropertyGroup):
]
)

compositeTextures: bpy.props.BoolProperty(
name = "Compile Normal-Textures",
description = "Will automatically create and use corrected normal textures",
default = True
)

# This list of version histories the .blend file has encountered,
# from the earliest
xplane2blender_ver_history: bpy.props.CollectionProperty(
Expand Down
88 changes: 0 additions & 88 deletions io_xplane2blender/xplane_types/xplane_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
logger,
resolveBlenderPath,
)
from ..xplane_image_composer import (
combineSpecularAndNormal,
getImageByFilepath,
normalWithoutAlpha,
specularToGrayscale,
)
from .xplane_attribute import XPlaneAttribute
from .xplane_attributes import XPlaneAttributes

Expand Down Expand Up @@ -508,88 +502,6 @@ def _init(self):
for attr in self.xplaneFile.options.customAttributes:
self.attributes.add(XPlaneAttribute(attr.name, attr.value))

def _compositeNormalTextureNeedsRecompile(self, compositePath, sourcePaths):
compositePath = resolveBlenderPath(compositePath)

if not os.path.exists(compositePath):
return True
else:
compositeTime = os.path.getmtime(compositePath)

for sourcePath in sourcePaths:
sourcePath = resolveBlenderPath(sourcePath)

if os.path.exists(sourcePath):
sourceTime = os.path.getmtime(sourcePath)

if sourceTime > compositeTime:
return True

return False

def _getCompositeNormalTexture(self, textureNormal, textureSpecular):
normalImage = None
specularImage = None
texture = None
image = None
filepath = None
channels = 4

if textureNormal:
normalImage = getImageByFilepath(textureNormal)

if textureSpecular:
specularImage = getImageByFilepath(textureSpecular)

# only normals, no specular
if normalImage and not specularImage:
filename, extension = os.path.splitext(textureNormal)
filepath = texture = filename + "_nm" + extension
channels = 3

if self._compositeNormalTextureNeedsRecompile(filepath, (textureNormal)):
image = normalWithoutAlpha(normalImage, normalImage.name + "_nm")

# normal + specular
elif normalImage and specularImage:
filename, extension = os.path.splitext(textureNormal)
filepath = texture = filename + "_nm_spec" + extension
channels = 4

if self._compositeNormalTextureNeedsRecompile(
filepath, (textureNormal, textureSpecular)
):
image = combineSpecularAndNormal(
specularImage, normalImage, normalImage.name + "_nm_spec"
)

# specular only
elif not normalImage and specularImage:
filename, extension = os.path.splitext(textureSpecular)
filepath = texture = filename + "_spec" + extension
channels = 1

if self._compositeNormalTextureNeedsRecompile(filepath, (textureSpecular)):
image = specularToGrayscale(specularImage, specularImage.name + "_spec")

if image:
savepath = resolveBlenderPath(filepath)

color_mode = bpy.context.scene.render.image_settings.color_mode
if channels == 4:
bpy.context.scene.render.image_settings.color_mode = "RGBA"
elif channels == 3:
bpy.context.scene.render.image_settings.color_mode = "RGB"
elif channels == 1:
bpy.context.scene.render.image_settings.color_mode = "BW"
image.save_render(savepath, bpy.context.scene)
image.filepath = filepath

# restore color_mode
bpy.context.scene.render.image_settings.color_mode = color_mode

return texture

def get_path_relative_to_dir(self, res_path: str, export_dir: str) -> str:
"""
Returns the resource path relative to the exported OBJ
Expand Down
1 change: 0 additions & 1 deletion io_xplane2blender/xplane_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def empty_layout(layout: bpy.types.UILayout, empty_obj: bpy.types.Object):
def scene_layout(layout: bpy.types.UILayout, scene: bpy.types.Scene):
layout.row().operator("scene.export_to_relative_dir", icon="EXPORT")
layout.row().prop(scene.xplane, "version")
layout.row().prop(scene.xplane, "compositeTextures")

xp2b_ver = xplane_helpers.VerStruct.current()
if (
Expand Down
Binary file removed tests/features/tex/color.png
Binary file not shown.
Binary file removed tests/features/tex/draped.png
Binary file not shown.
Binary file removed tests/features/tex/draped_NML.png
Binary file not shown.
Binary file removed tests/features/tex/normal.png
Binary file not shown.
Binary file removed tests/features/tex/normal_with_alpha.png
Binary file not shown.
Binary file removed tests/features/tex/specular.png
Binary file not shown.
Binary file removed tests/features/texture_composition.test.blend
Binary file not shown.
114 changes: 0 additions & 114 deletions tests/features/texture_composition.test.disabled.py

This file was deleted.

Binary file not shown.
Binary file not shown.

0 comments on commit f4eacaa

Please sign in to comment.