I came up with the name while I was typing the message
So I’ll wait for you reply then: we can come up with better syntax for all this stuff (and for shader node groups too) and I’ll just make it the way it is good for everyone and will not have to redo it later.
Is there like any chat room or something where it can be discussed live?)
Hi there! So I was busy with more important stuff, but lately I’ve upgraded shader nodes system with shader node packs, they are defined in separate files like that (read comments for more insight):
ShaderNodesPack {
Documentation {
// This section is for humans...
}
Output {
color = TextureSplatting.color
}
Input {
// This section is only for documentation purpose
atlasTileData1
atlasTileData2
atlasTileData3
normal
textureBlend
}
ShaderNode TextureTriplanarCoords {
Definition : TextureTriplanarPreFragment : materials/shaders/generic/texture.triplanar.j3sn
InputMappings {
divider = vec3(4.0, 4.0, 4.0)
textureWorldSpace = WorldSpaceTextureCoord.vec3Var
}
}
// Set up atlas
ShaderNode TextureAtlasLib {
Definition : TextureAtlasLibFragment : materials/shaders/generic/texture.atlas.j3sn
Define : AtlasWrapMode as ATLAS_WRAP_MODE
}
// Read for first texture
ShaderNode TextureAtlasFragment1_1 {
Definition : TextureAtlasFragment : materials/shaders/generic/texture.atlas.j3sn
Define : ATLAS_MAG_MIN_FILTER = 5
InputMappings {
atlasTileData = Input.atlasTileData1 // 'Input' is a special namespace
atlas = MatParam.ColorAtlas
// Curent snp's namespaces can be used as is
texCoord = TextureTriplanarCoords.texCoord1
}
}
// ... And so on, ShaderNode and ShaderCode are allowed in any combination
Include : materials/shaders/OtherShaderNodePack.snp
// Includes are just included 'as is`, no second layer of namespacing is present currently
}
And they can be included in material like that:
FragmentShaderNodes {
ShaderNodesPack TextureTriplanarFrag {
Source : materials/shaders/generic/texture.atlasblend.frag.snp
InputMappings {
atlasTileData1 = TextureTriplanarVert.atlasTileData1
atlasTileData2 = TextureTriplanarVert.atlasTileData2
atlasTileData3 = TextureTriplanarVert.atlasTileData3
textureBlend = TextureTriplanarVert.textureBlend
normal = TextureTriplanarVert.normal
}
}
// ... And so on...
ShaderCode TextureTriplanarFragOutput {
// We can use outputs from SNP as outputs from any other shader nodes
// Notice namespace: it is SNP's name, not name of shader node within SNP
in vec3 color = TextureTriplanarFrag.color.rgb
out vec3 color2 to Global.color.rgb
color2 = color
}
}
I also fixed constants in shader nodes inputs, they do not require Const namespace now (checked by regexp when parsing).
This is a really useful feature I’ve been wishing for!
I have a quite complex shader node I would like to use in different materials. This beats copy-pasting.
Edit: Besides, it’s not possible to copy the generated shader code O_o
Yes. Currently I am rewriting it to support better constants and conditions in shader packs and shader packs in shader packs with proper input-output chaining
I tried to rewrite my shader with this and found that I need a few more things) It will be cool, I guess I’ll share the code after this.
From what I recall Nehon plan was to write a Java API to create shader nodes via code then a visual editor could be created upon this API. Some folks here may have more info on this so.