3 class MspGLSceneProperties(bpy.types.Panel):
4 bl_idname = "SCENE_PT_mspgl_properties"
5 bl_label = "MspGL properties"
6 bl_space_type = "PROPERTIES"
7 bl_region_type = "WINDOW"
10 def draw(self, context):
13 self.layout.prop(scene, "scene_type")
14 self.layout.prop(scene, "export_disposition")
16 class MspGLMeshProperties(bpy.types.Panel):
17 bl_idname = "MESH_PT_mspgl_properties"
18 bl_label = "MspGL properties"
19 bl_space_type = "PROPERTIES"
20 bl_region_type = "WINDOW"
24 def poll(cls, context):
25 return context.active_object.type=="MESH"
27 def draw(self, context):
28 mesh = context.active_object.data
30 self.layout.prop(mesh, "winding_test")
31 self.layout.prop(mesh, "smoothing")
32 self.layout.prop(mesh, "use_strips")
34 self.layout.separator()
36 col = self.layout.column()
37 col.label(text="Data selection")
38 col.prop(mesh, "use_lines")
39 col.prop(mesh, "vertex_groups")
40 col.prop(mesh, "max_groups_per_vertex")
42 self.layout.separator()
44 col = self.layout.column()
45 col.label(text="Texturing")
46 col.prop(mesh, "use_uv")
47 col.prop(mesh, "tangent_vecs")
48 col.prop(mesh, "tangent_uvtex")
50 class MspGLObjectProperties(bpy.types.Panel):
51 bl_idname = "OBJECT_PT_mspgl_properties"
52 bl_label = "MspGL properties"
53 bl_space_type = "PROPERTIES"
54 bl_region_type = "WINDOW"
58 def poll(cls, context):
59 return context.active_object.type=="MESH"
61 def draw(self, context):
62 obj = context.active_object
64 self.layout.prop(obj, "compound")
65 self.layout.prop(obj, "lod_for_parent")
66 if obj.lod_for_parent:
67 self.layout.prop(obj, "lod_index")
69 class MspGLMaterialProperties(bpy.types.Panel):
70 bl_idname = "MATERIAL_PT_mspgl_properties"
71 bl_label = "MspGL properties"
72 bl_space_type = "PROPERTIES"
73 bl_region_type = "WINDOW"
74 bl_context = "material"
77 def poll(cls, context):
78 return context.active_object.active_material is not None
80 def draw(self, context):
81 mat = context.active_object.active_material
85 self.layout.prop(mat, "render_mode")
86 if mat.render_mode=='CUSTOM':
87 self.layout.prop(mat, "shader")
88 if mat.shadow_method!='NONE':
89 self.layout.prop(mat, "shadow_shader")
90 elif mat.render_mode=='EXTERNAL':
91 self.layout.prop(mat, "technique")
92 if mat.render_mode=='BUILTIN':
93 self.layout.prop(mat, "receive_shadows")
94 self.layout.prop(mat, "image_based_lighting")
95 self.layout.prop(mat, "array_atlas")
97 self.layout.prop(mat, "array_layer")
98 if mat.render_mode!='EXTERNAL':
99 self.layout.prop(mat, "material_atlas")
100 if mat.render_mode=='CUSTOM':
101 self.layout.separator()
102 self.layout.label(text="Uniform values")
103 self.layout.template_list("MATERIAL_UL_mspgl_uniforms", "", mat, "uniforms", mat, "active_uniform_index")
104 row = self.layout.row()
105 row.operator("material.add_uniform")
106 row.operator("material.remove_uniform")
108 if mat.active_uniform_index<len(mat.uniforms):
109 uniform = mat.uniforms[mat.active_uniform_index]
110 self.layout.prop(uniform, "name")
111 self.layout.prop(uniform, "size")
112 row = self.layout.row(align=True)
113 row.label(text="Values")
114 for i in range(uniform.size):
115 row.prop(uniform, "values", text="", index=i)
117 class MspGLTextureNodeProperties(bpy.types.Panel):
118 bl_idname = "NODE_PT_mspgl_properties"
119 bl_label = "MspGL properties"
120 bl_space_type = "NODE_EDITOR"
121 bl_region_type = "UI"
125 def poll(cls, context):
126 node = context.active_node
127 return node and node.type=='TEX_IMAGE'
129 def draw(self, context):
130 node = context.active_node
134 self.layout.prop(node, "default_filter")
135 if not node.default_filter:
136 self.layout.prop(node, "use_mipmap")
137 self.layout.prop(node, "max_anisotropy")
139 class MspGLLightProperties(bpy.types.Panel):
140 bl_idname = "LIGHT_PT_mspgl_properties"
141 bl_label = "MspGL properties"
142 bl_space_type = "PROPERTIES"
143 bl_region_type = "WINDOW"
147 def poll(cls, context):
148 return context.active_object.type=="LIGHT"
150 def draw(self, context):
151 light = context.active_object.data
154 self.layout.prop(light, "shadow_map_size")
156 class MspGLRenderProperties(bpy.types.Panel):
157 bl_idname = "WORLD_PT_mspgl_properties"
158 bl_label = "MspGL properties"
159 bl_space_type = "PROPERTIES"
160 bl_region_type = "WINDOW"
161 bl_context = "render"
163 def draw(self, context):
164 scene = context.scene
165 self.layout.prop(scene, "use_hdr")
166 if scene.eevee.use_gtao:
167 self.layout.prop(scene, "ao_samples")
169 class MspGLUniform(bpy.types.PropertyGroup):
170 name: bpy.props.StringProperty(name="Name", description="Name of the uniform variable")
171 size: bpy.props.IntProperty(name="Size", description="Number of elements in the uniform", min=1, max=4, default=4)
172 values: bpy.props.FloatVectorProperty(name="Values", description="Values stored in the uniform", size=4)
174 class MspGLUniformList(bpy.types.UIList):
175 bl_idname = "MATERIAL_UL_mspgl_uniforms"
177 def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
179 if self.layout_type=="GRID":
180 layout.label(text="", icon_value=icon)
182 layout.prop(uniform, "name", text="", emboss=False, icon_value=icon)
183 layout.label(text="({})".format(", ".join("{:.3f}".format(v) for v in uniform.values[:uniform.size])))
185 classes = [MspGLSceneProperties, MspGLMeshProperties, MspGLObjectProperties, MspGLMaterialProperties,
186 MspGLTextureNodeProperties, MspGLLightProperties, MspGLRenderProperties, MspGLUniform, MspGLUniformList]
188 def register_properties():
190 bpy.utils.register_class(c)
192 bpy.types.Scene.scene_type = bpy.props.EnumProperty(name="Scene type", description="Type of scene to use for exporting", default="SIMPLE",
193 items=(("SIMPLE", "Simple", "Objects are rendered in no specific order"),
194 ("ORDERED", "Ordered", "Objects are rendered in order by their name"),
195 ("ZSORTED", "Z-sorted", "Objects are rendered in order by their distance from the camera")))
196 bpy.types.Scene.export_disposition = bpy.props.EnumProperty(name="Export disposition", description="What to do with this scene during project export", default="IGNORE",
197 items=(("IGNORE", "Ignore", "The scene won't be exported"),
198 ("CONTENTS", "Contents only", "Objects in the scene will be exported, but not the scene itself"),
199 ("SCENE", "Scene", "The scene will be exported"),
200 ("SEQUENCE", "Sequence", "The scene will be exported along with a rendering sequence")))
201 bpy.types.Scene.use_hdr = bpy.props.BoolProperty(name="High dynamic range", description="Use a range render target with a floating point format", default=False)
202 bpy.types.Scene.ao_samples = bpy.props.IntProperty(name="Ambient occlusion samples", description="Number of samples to use for ambient occlusion", min=8, max=128, default=32)
204 bpy.types.Mesh.winding_test = bpy.props.BoolProperty(name="Winding test", description="Perform winding test to skip back faces")
205 bpy.types.Mesh.smoothing = bpy.props.EnumProperty(name="Smoothing", description="Smoothing method to use", default="MSPGL",
206 items=(("NONE", "None", "No smoothing"),
207 ("BLENDER", "Blender", "Use Blender's vertex normals"),
208 ("MSPGL", "MspGL", "Compute vertex normals internally")))
209 bpy.types.Mesh.use_lines = bpy.props.BoolProperty(name="Include lines", description="Include edges without faces as lines", default=False)
210 bpy.types.Mesh.use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine the mesh's triangles into triangle strips", default=True)
211 bpy.types.Mesh.vertex_groups = bpy.props.BoolProperty(name="Vertex groups", description="Include vertex groups and weights", default=False)
212 bpy.types.Mesh.max_groups_per_vertex = bpy.props.IntProperty(name="Max groups", description="Maximum amount of groups per vertex", min=1, max=4, default=2)
213 bpy.types.Mesh.use_uv = bpy.props.EnumProperty(name="Use UV", description="Use UV coordinates", default="UNIT0",
214 items=(("NONE", "None", "Ignore all UV coordinates"),
215 ("UNIT0", "Unit 0", "Use UV coordinates for unit 0"),
216 ("ALL", "All", "Use all UV coordinates")))
217 bpy.types.Mesh.tangent_vecs = bpy.props.EnumProperty(name="Tangent vectors", description="Compute tangent vectors for vertices", default="AUTO",
218 items=(("NO", "No", "Do not export tangent vectors"),
219 ("AUTO", "Auto", "Automatically determine the need for tangent vectors"),
220 ("YES", "Yes", "Always export tangent vectors")))
221 bpy.types.Mesh.tangent_uvtex = bpy.props.StringProperty(name="Tangent UV layer", description="UV layer to use as basis for tangent vectors", default="")
223 bpy.types.Object.compound = bpy.props.BoolProperty(name="Compound with parent", description="Join this object to its parent when exporting")
224 bpy.types.Object.lod_for_parent = bpy.props.BoolProperty(name="LoD for parent", description="This object is a level of detail for its parent")
225 bpy.types.Object.lod_index = bpy.props.IntProperty(name="LoD index", description="Index of the level of detail", min=1, max=16, default=1)
227 bpy.types.Material.render_mode = bpy.props.EnumProperty(name="Render mode", description="How this material should be rendered", default="BUILTIN",
228 items=(("BUILTIN", "Built-in", "Use built-in shaders"),
229 ("CUSTOM", "Custom shader", "Use a custom shader"),
230 ("EXTERNAL", "External technique", "Use an externally defined technique")))
231 bpy.types.Material.technique = bpy.props.StringProperty(name="Custom technique", description="Name of an external technique to use for rendering")
232 bpy.types.Material.shader = bpy.props.StringProperty(name="Custom shader", description="Name of a custom shader to use for rendering")
233 bpy.types.Material.shadow_shader = bpy.props.StringProperty(name="Custom shadow shader", description="Name of a custom shader to use for shadow pass")
234 bpy.types.Material.receive_shadows = bpy.props.BoolProperty(name="Receive shadows", description="Receive shadows from a shadow map", default=True)
235 bpy.types.Material.image_based_lighting = bpy.props.BoolProperty(name="Image based lighting", description="Use an environment map for ambient lighting", default=False)
236 bpy.types.Material.array_atlas = bpy.props.BoolProperty(name="Texture array atlas", description="The material is stored in a texture array")
237 bpy.types.Material.array_layer = bpy.props.IntProperty("Texture array layer", description="Layer of the texture array atlas to use")
238 bpy.types.Material.material_atlas = bpy.props.BoolProperty(name="Material atlas", description="Make this material part of a material atlas")
239 bpy.types.Material.uniforms = bpy.props.CollectionProperty(type=MspGLUniform, name="Uniform", description="Uniform variables to add to the technique")
240 bpy.types.Material.active_uniform_index = bpy.props.IntProperty("Active uniform index")
242 bpy.types.ShaderNodeTexImage.default_filter = bpy.props.BoolProperty(name="Default filter", description="Let the loading program determine filtering options")
243 bpy.types.ShaderNodeTexImage.use_mipmap = bpy.props.BoolProperty(name="Use mipmaps", description="Use mipmaps (automatically generated) for the texture", default=True)
244 bpy.types.ShaderNodeTexImage.max_anisotropy = bpy.props.FloatProperty(name="Maximum anisotropy", description="Maximum anisotropy to use in texture filtering", min=1, max=16, default=1)
246 def unregister_properties():
248 bpy.utils.unregister_class(c)