-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement KHR_materials_unlit with user extensions
- Loading branch information
Juan Jose Casafranca
committed
Oct 11, 2019
1 parent
1f7720a
commit 03664e0
Showing
2 changed files
with
65 additions
and
7 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
65 changes: 65 additions & 0 deletions
65
addons/io_scene_gltf2/io/exp/extensions/KHR_materials_unlit.py
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,65 @@ | ||
import bpy | ||
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension | ||
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import UserExtensionBase | ||
from io_scene_gltf2.blender.exp import gltf2_blender_get | ||
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import GLTF2ExtensionMaterials | ||
|
||
class GLTF_PT_export_KHR_materials_unlit(bpy.types.Panel): | ||
bl_space_type = 'FILE_BROWSER' | ||
bl_region_type = 'TOOL_PROPS' | ||
bl_label = "KHR_materials_unlit" | ||
bl_parent_id = "GLTF_PT_export_user_extensions" | ||
bl_options = {'DEFAULT_CLOSED'} | ||
|
||
@classmethod | ||
def poll(cls, context): | ||
sfile = context.space_data | ||
operator = sfile.active_operator | ||
if operator.is_draco_available: | ||
return operator.bl_idname == "EXPORT_SCENE_OT_gltf" | ||
|
||
def draw_header(self, context): | ||
sfile = context.space_data | ||
operator = sfile.active_operator | ||
self.layout.prop(operator, "export_KHR_materials_unlit_enabled", text="") | ||
|
||
def draw(self, context): | ||
layout = self.layout | ||
layout.use_property_split = True | ||
layout.use_property_decorate = False # No animation. | ||
|
||
class KHR_materials_unlit(UserExtensionBase): | ||
meta = { | ||
'name': 'KHR_materials_unlit', | ||
'isDraft': False, | ||
'enable': True, | ||
'url': ( | ||
'https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit' | ||
) | ||
} | ||
|
||
enabled = bpy.props.BoolProperty( | ||
name='KHR_materials_unlit_enabled', | ||
description='Enable/disable this extension', | ||
default=True | ||
) | ||
|
||
def export(self, extension_wrapper, export_settings): | ||
|
||
extension = None | ||
if isinstance(extension_wrapper, GLTF2ExtensionMaterials): | ||
blender_material = extension_wrapper.blender_material | ||
if bpy.app.version < (2, 80, 0): | ||
if blender_material.use_shadeless: | ||
extension = Extension("KHR_materials_unlit", {}, False) | ||
else: | ||
if gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Background") is not None: | ||
extension = Extension("KHR_materials_unlit", {}, False) | ||
return extension | ||
|
||
def register_extension(self): | ||
bpy.utils.register_class(GLTF_PT_export_KHR_materials_unlit) | ||
|
||
def properties(self): | ||
return {"enabled": self.enabled} | ||
|