[SOLVED] MatDef SDK Editor: error generating shader null

Hello monkeys! :monkey_face:

I’m trying to dive deep into MatDef, ShaderNodes and GLSL. I read all documentation on Wiki about it and saw @nehon video about it, but I still can’t create my own ShaderNode. When I click on “Shader” tab, it gives me the message: error generating shader null. What i’m missing :pensive:

VoxelLighting.j3md

MaterialDef Simple {
    MaterialParameters {
        Color Color
    }
    Technique {
        WorldParameters {
            WorldViewProjectionMatrix
        }
        VertexShaderNodes {
            ShaderNode VoxelLightingVert {
                Definition : VoxelLightingVert : MatDefs/ShaderNodes/VoxelLighting.j3sn
                InputMappings {
                    worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix
                    modelPosition = Global.position.xyz
                }
                OutputMappings {
                    Global.position = projPosition
                }
            }
        }
        FragmentShaderNodes {
            ShaderNode VoxelLightingFrag {
                Definition : VoxelLightingFrag : MatDefs/ShaderNodes/VoxelLighting.j3sn
                InputMappings {
                    color1 = MatParam.Color
                    color2 = Global.color
                }
                OutputMappings {
                    Global.color = outColor
                }
            }
        }
    }
}

VoxelLighting.j3sn

ShaderNodeDefinitions {
    ShaderNodeDefinition VoxelLightingVert {
        Type: Vertex
        Shader GLSL100: MatDefs/ShaderNodes/VoxelLighting/VoxelLighting.vert
        Documentation {
            This node is reponsable for calculating a simple voxel lighting.
            @input modelPosition the vertex position in model space (usually assigned with Attr.inPosition or Global.position)
            @input worldViewProjectionMatrix the World View Projection Matrix transforms model space to projection space.
            @output projPosition Position of the vertex in projection space.(usually assigned to Global.position)
        }
        Input {
            vec3 modelPosition
            mat4 worldViewProjectionMatrix
        }
        Output {
            vec4 projPosition
        }
    }
    ShaderNodeDefinition VoxelLightingFrag {      
	Type: Fragment
	Shader GLSL100: MatDefs/ShaderNodes/VoxelLighting/VoxelLighting.frag
	Documentation {
	    Renders a simple color
	    @input color1 the first color
	    @input color2 the second color            
	    @output outColor the resulting color
	}
	Input {
	    vec4 color1
	    vec4 color2            
	}
	Output {
	    vec4 outColor
	}
    }
}

VoxelLighting.frag

void main(){
    outColor = color1 * color2;
}

VoxelLighting.vert

void main(){ 
    projPosition = worldViewProjectionMatrix * vec4(modelPosition, 1.0);
}

Visual Editor:

As you can see, it’s a very basic MatDef, but still I can’t figure what’s wrong…

Hello, unfortunately the 3.0 editor is really buggy.
I did a ton of bug fixes nad enhancements in master, maybe you could try to build the sdk from it.
Though that implies that you use the master for your project, and it can be unstable.
But we usually try to fix breaking issues as fast as possible.

1 Like

@nehon, thanks for answer. I’ll keep using 3.0 to force myself to learn Shader by hand :stuck_out_tongue:. Anyway, Visual Editor is still usefull to pre-compile my definitions and check typos.

Hehe, well feel free to ask if you have any trouble :wink: