Custom pipeline and material
This commit is contained in:
parent
fc3b002c70
commit
fb96a0460c
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -119,6 +119,7 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
option_no_cycles = bpy.props.BoolProperty(name = "Export Pure Armory", description = "Export pure armory data", default = False)
|
||||
|
||||
shader_references = None
|
||||
pipeline_pass = ''
|
||||
|
||||
def WriteColor(self, color):
|
||||
return [color[0], color[1], color[2]]
|
||||
|
@ -1226,7 +1227,10 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
|
||||
o.material_refs = []
|
||||
for i in range(len(node.material_slots)):
|
||||
self.ExportMaterialRef(node.material_slots[i].material, i, o)
|
||||
if node.custom_material: # Overwrite material slot
|
||||
o.material_refs.append(node.custom_material_name)
|
||||
else: # Export assigned material
|
||||
self.ExportMaterialRef(node.material_slots[i].material, i, o)
|
||||
|
||||
o.particle_refs = []
|
||||
for i in range(len(node.particle_systems)):
|
||||
|
@ -1933,8 +1937,8 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
#o.fov = object.angle_x
|
||||
o.near_plane = object.clip_start
|
||||
o.far_plane = object.clip_end
|
||||
o.frustum_culling = False
|
||||
o.pipeline = "pipeline_resource/forward_pipeline"
|
||||
o.frustum_culling = object.frustum_culling
|
||||
o.pipeline = object.pipeline_path
|
||||
|
||||
if 'Background' in bpy.data.worlds[0].node_tree.nodes: # TODO: parse node tree
|
||||
col = bpy.data.worlds[0].node_tree.nodes['Background'].inputs[0].default_value
|
||||
|
@ -1984,7 +1988,7 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
o.contexts = []
|
||||
|
||||
c = Object()
|
||||
c.id = "forward"
|
||||
c.id = ArmoryExporter.pipeline_pass
|
||||
c.bind_constants = []
|
||||
const1 = Object()
|
||||
const1.id = "diffuseColor"
|
||||
|
@ -2085,12 +2089,12 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
# Merge duplicates and sort
|
||||
defs = sorted(list(set(defs)))
|
||||
# Select correct shader variant
|
||||
o.shader = "forward_resource/forward"
|
||||
o.shader = ArmoryExporter.pipeline_pass + '_resource/' + ArmoryExporter.pipeline_pass
|
||||
ext = ''
|
||||
for d in defs:
|
||||
ext += d
|
||||
o.shader += ext
|
||||
ArmoryExporter.shader_references.append('forward' + ext)
|
||||
ArmoryExporter.shader_references.append(ArmoryExporter.pipeline_pass + ext)
|
||||
else:
|
||||
o.shader = material.custom_shader_name
|
||||
|
||||
|
@ -2163,14 +2167,14 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
self.output.particle_resources.append(o)
|
||||
|
||||
def ExportObjects(self, scene):
|
||||
for objectRef in self.geometryArray.items():
|
||||
self.ExportGeometry(objectRef, scene)
|
||||
for objectRef in self.lightArray.items():
|
||||
self.ExportLight(objectRef)
|
||||
for objectRef in self.cameraArray.items():
|
||||
self.ExportCamera(objectRef)
|
||||
for objectRef in self.speakerArray.items():
|
||||
self.ExportSpeaker(objectRef)
|
||||
for objectRef in self.geometryArray.items():
|
||||
self.ExportGeometry(objectRef, scene)
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
|
@ -2208,6 +2212,11 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
|
||||
self.ProcessSkinnedMeshes()
|
||||
|
||||
# Only one pipeline for scene for now
|
||||
# Used for material shader export
|
||||
if (len(bpy.data.cameras) > 0):
|
||||
ArmoryExporter.pipeline_pass = bpy.data.cameras[0].pipeline_pass
|
||||
|
||||
self.output.nodes = []
|
||||
for object in scene.objects:
|
||||
if (not object.parent):
|
||||
|
|
|
@ -11,8 +11,16 @@ def cb_scene_update(context):
|
|||
edit_obj.geometry_cached = False
|
||||
|
||||
def initObjectProperties():
|
||||
# For geometry
|
||||
bpy.types.Object.geometry_cached = bpy.props.BoolProperty(name="Geometry cached", default=False)
|
||||
bpy.types.Object.instanced_children = bpy.props.BoolProperty(name="Instanced children", default=False)
|
||||
bpy.types.Object.custom_material = bpy.props.BoolProperty(name="Custom material", default=False)
|
||||
bpy.types.Object.custom_material_name = bpy.props.StringProperty(name="Name", default="")
|
||||
# For camera
|
||||
bpy.types.Camera.frustum_culling = bpy.props.BoolProperty(name="Frustum Culling", default=False)
|
||||
bpy.types.Camera.pipeline_path = bpy.props.StringProperty(name="Pipeline Path", default="pipeline_resource/forward_pipeline")
|
||||
bpy.types.Camera.pipeline_pass = bpy.props.StringProperty(name="Pipeline Pass", default="forward")
|
||||
# For material
|
||||
bpy.types.Material.receive_shadow = bpy.props.BoolProperty(name="Receive shadow", default=True)
|
||||
bpy.types.Material.alpha_test = bpy.props.BoolProperty(name="Alpha test", default=False)
|
||||
bpy.types.Material.custom_shader = bpy.props.BoolProperty(name="Custom shader", default=False)
|
||||
|
@ -20,7 +28,7 @@ def initObjectProperties():
|
|||
bpy.types.Material.export_tangents = bpy.props.BoolProperty(name="Export tangents", default=False)
|
||||
|
||||
# Menu in object region
|
||||
class ToolsPropsPanel(bpy.types.Panel):
|
||||
class ObjectPropsPanel(bpy.types.Panel):
|
||||
bl_label = "Cycles Props"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
|
@ -32,6 +40,25 @@ class ToolsPropsPanel(bpy.types.Panel):
|
|||
|
||||
if obj.type == 'MESH':
|
||||
layout.prop(obj, 'instanced_children')
|
||||
layout.prop(obj, 'custom_material')
|
||||
if obj.custom_material:
|
||||
layout.prop(obj, 'custom_material_name')
|
||||
|
||||
# Menu in camera region
|
||||
class DataPropsPanel(bpy.types.Panel):
|
||||
bl_label = "Cycles Props"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "data"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
obj = bpy.context.object
|
||||
|
||||
if obj.type == 'CAMERA':
|
||||
layout.prop(obj.data, 'frustum_culling')
|
||||
layout.prop(obj.data, 'pipeline_path')
|
||||
layout.prop(obj.data, 'pipeline_pass')
|
||||
|
||||
# Menu in materials region
|
||||
class MatsPropsPanel(bpy.types.Panel):
|
||||
|
|
Loading…
Reference in a new issue