Hello monkeys!
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
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);
}
As you can see, it’s a very basic MatDef, but still I can’t figure what’s wrong…