Is that possible to create custom shader and apply it to multiple projects with different textures?

Setting textures in .json files is not so convenient.

If you select an Image Texture node in the shader editor, you can make the texture a parameter in the side bar. You can then set the texture with the Set Material Image Param node, or via Haxe like in this example (have a look at the textureLink() function).

Also, you can create your own material node. Armory even has some custom material nodes that are defined here: https://github.com/armory3d/armory/tree/master/blender/arm/material/arm_nodes and you can create libraries that also register custom material nodes. The only downside of this approach is that there is no way to display the shader in Blender’s viewport until Blender supports custom nodes for Eevee. Using the live patch feature might help you here, it will update the running game on every change in the material editor.

4 Likes

Thanks. Is that like this? But I can’t change color of grass in Shader Editor

You can’t combine the shader editor with custom shaders in .json materials, the nodes are parsed into the vertex and fragment shaders (so using both would create a conflict).

So, if you use nodes, you can apply what I’ve mentioned above. For custom .json shaders you can still set uniforms via Haxe (the same way as it is in the link I posted above). There currently is no logic node to set material uniforms (other than node parameters which don’t apply for custom shaders) but I will implement one soon.

5 Likes

Thanks! So currently you have to create shader then change textures and create variations in Haxe?

Also looking forward to a new workflow

So currently you have to create shader then change textures and create variations in Haxe?

If you already have a custom material (.json) then yes, you’ll need Haxe (for now). If you use cycles nodes, you can use the parameter system I mentioned above and there is no need to use Haxe.

Thanks. I will try custom material way. Looking forward to a new workflow

How exactly would a “new workflow” look to you?

2 Likes

Kinda like Unity and Unreal. Write in code and then apply it to different objects with different textures in editor

So you mean that there should be a way to mark uniforms as parameters that can be set per material in the Blender UI? I’m not sure if Armory exports different Blender materials with the same custom shader as two different materials, but if yes that should be possible.

Apart from that: the current workflow is more or less the same than in Unity (I don’t know how Unreal works with shaders), you write a .json file with all the shader properties (which in Unity is ShaderLab which – to be fair – has a lot more features). But the Blender interface for custom shaders is probably a bit ugly, there is not much automated and it’s badly documented so far.

3 Likes

Yes. Exposing shader interface to Blender can be a problem.
Hope at least some documents can be available to solve it.

1 Like