]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a property in Blender for a custom shadow shader
authorMikko Rasa <tdb@tdb.fi>
Thu, 6 May 2021 10:20:24 +0000 (13:20 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 6 May 2021 10:32:46 +0000 (13:32 +0300)
Since a shadow map doesn't have color output, it's useful to specify a
cheaper shader which only does vertex transformations.

blender/io_mspgl/export_material.py
blender/io_mspgl/properties.py

index d62276f76221bbcf3d89ea3e78aadc6040fd8599..2d85b10f3c7c4b26aa9e45803b0ca2af7d9134eb 100644 (file)
@@ -32,7 +32,13 @@ def create_technique_resource(material, resources):
 
        if material.shadow_method!='NONE':
                st = Statement("pass", "shadow")
-               st.sub.append(Statement("shader", "_occluder.glsl.shader"))
+               if material.render_mode=='CUSTOM':
+                       shader = material.shadow_shader or material.shader
+                       if shader.endswith(".glsl"):
+                               shader += ".shader"
+                       st.sub.append(Statement("shader", shader))
+               else:
+                       st.sub.append(Statement("shader", "_occluder.glsl.shader"))
                tech_res.statements.append(st)
 
        return tech_res
index 9d46e1286c723374f7a9b94a7ba7ea0ee5104d70..532528b89b747b8adbaa75a02b0f6e13614c4205 100644 (file)
@@ -85,6 +85,8 @@ class MspGLMaterialProperties(bpy.types.Panel):
                self.layout.prop(mat, "render_mode")
                if mat.render_mode=='CUSTOM':
                        self.layout.prop(mat, "shader")
+                       if mat.shadow_method!='NONE':
+                               self.layout.prop(mat, "shadow_shader")
                elif mat.render_mode=='EXTERNAL':
                        self.layout.prop(mat, "technique")
                if mat.render_mode=='BUILTIN':
@@ -225,7 +227,8 @@ def register_properties():
                        ("CUSTOM", "Custom shader", "Use a custom shader"),
                        ("EXTERNAL", "External technique", "Use an externally defined technique")))
        bpy.types.Material.technique = bpy.props.StringProperty(name="Custom technique", description="Name of an external technique to use for rendering")
-       bpy.types.Material.shader = bpy.props.StringProperty(name="Custom shader", description="Name of an external technique to use for rendering")
+       bpy.types.Material.shader = bpy.props.StringProperty(name="Custom shader", description="Name of a custom shader to use for rendering")
+       bpy.types.Material.shadow_shader = bpy.props.StringProperty(name="Custom shadow shader", description="Name of a custom shader to use for shadow pass")
        bpy.types.Material.receive_shadows = bpy.props.BoolProperty(name="Receive shadows", description="Receive shadows from a shadow map", default=True)
        bpy.types.Material.image_based_lighting = bpy.props.BoolProperty(name="Image based lighting", description="Use an environment map for ambient lighting", default=False)
        bpy.types.Material.array_atlas = bpy.props.BoolProperty(name="Texture array atlas", description="The material is stored in a texture array")