CompositeMaterial - A procedural material builder addon for Godot

CompositeMaterial is an addon that allows developers to create and shader dynamic materials that run in Godot natively - no texture baking, but pure shaders, allowing for very dynamic texturing of many objects using a single material.

I’ve been working on this idea for almost a year now. Since then it’s been through a few rewrites, and another one is on the way right now, adding a node-based material builder. I’m intending on posting “devlogs” in this topic for those who are interested.

Here’s a link to the repository: GitHub - mFieldHouses/GodotCompositeMaterial: CompositeMaterial is an addon for Godot which introduces modular procedural material building to the Godot Editor · GitHub
And here’s a link to a little showcase of my progress:

Now for a frequently asked question: why use this over the VisualShader system?

VisualShader gives you very fine-grained control over your shader. That can be good, but that also means having to set up the complete system behind your procedural material. CompositeMaterial provides fewer, higher-level nodes that utilize more complex systems behind the scenes that you don’t have to worry about as a developer. Where most VisualShader nodes translate directly to a GDShader expression, CompositeMaterial nodes call more complicated functions. Think of masks based on position and surface normal, converting depth maps to normal maps, and HSV tuning. CompositeMaterial is built with a focus on making it easy and quick to create dynamic materials. You cannot do everything you can with shaders, but it’s a lot simpler to use.

If you want to try out my plugin, please let me know how your experience was and what you think! Be aware that the current version is in no way finished/polished, so don’t expect the smoothest UX experience.

Here are some more showcases of the procedural material. No baked textures, all pure shaders.

6 Likes

This is an extremely interesting project, but it would be highly advisable to host the demo on a more reputable platform. Not everyone has access to the questionable Reddit.

1 Like

You’re right, I’ll upload my videos to YouTube. Glad to see you’re interested!

I added hybrid triplanar mapping. This mode of triplanar mapping ignores rotation and translation, but does keep scale into account. Where regular global triplanar mapping would’ve caused unwanted shifting of textures when the model moves, hybrid triplanar mapping keeps the textures positioned and rotated locally but scaled globally.

1 Like

Yeah, that sounds really interesting. I think I could use it in my project.

YouTube is a little better — it’s blocked here, but with a little effort, it’s possible to watch it.

1 Like

I implemented proper triplanar mapping. Previously, the material only supported a single UV map value per pixel per texture. That resulted in super hard seams when using triplanar mapping. Now you can set a custom blend scale, and with a bit of extra processing, nobody will notice anything.

This looks great. I think i could use this for the mesh painting technique.

I use triplanar noise masks on my shaders already. I create separate noise on 4 channels in material maker, then use these to mix a good grunge or material variation map.

Ive got a couple of ideas for this …

  1. perhaps baking maps once they are painted ? Does that mess with substance painter a bit?

  2. if 1) then a volumetric noise shader could be useful.

  3. decals and particle collision effects

  4. Splatmap painting for meshes using the paintable texture feature in Godot 4.7

1 Like

Yes, those are interesting suggestions.

I already have a baking tool, although that was made for a precious “iteration” of the material and won’t work with the current state of the material. But it shouldn’t be too much effort to set that up again. What exactly do you have in mind there though, baking the whole materials or just layers?

Regarding decals, I have been thinking about those, and it’d be really nice to have decals that can interact with the material, but I’m not entirely sure on how to implement those.

And I didn’t even know texture painting is coming to Godot, that’s awesome. I was also thinking about that, but seeing that there will be a native solution allows me to focus on other things. That’s great.

I’m not entirely sure what you mean by volumetric noise, how exactly would that work with the material?

The volumetric noise would be a custom noise routine - there are loads of examples on github and shadertoy. Basically its the calculation of a point in a 3 dimensional cloud for each point or texel on the surface.

I would probably bake noise maps, texture painted splatmaps, to textures for a uv2 channel, the option of baking all layers down to a single material might be performant in some scenes.

The decals would be probably something like blenders texture paint clone brush … very useful and would be interesting to do it all directly with godot shader materials.

  • Also maintaining the ability to keep the scene running with procedurals is a great idea saving on memory.
1 Like

Link to the dev release of godot 4.7 if you didnt already have it. If you scroll down on that page you can find the texture paint stuff… basically that is super useful for splatmaps or grunge and detail maps. Theres a link to the demo project.

2 Likes

Looks interesting, but documentation is sparse. What’s the benefit of using this instead of just making a VisualShader, which is documented and I already know how to do?

1 Like

That’s a question I receive a lot. I’ve answered it in the original post so others won’t have to ask the same question again. If anything is unclear, let me know.

1 Like

Volumetric noise seems cool, but I’m not sure how it would fit in with the rest of the material. I’m mainly focusing on hard-surface shading for now, I won’t give volumetric noise a very high priority.

And regarding your last remark, that’s my goal as well. I’m optimising wherever possible to support keeping materials procedural while running, both for potentially saving memory as you stated, but also because generally procedural materials retain a much higher resolution than using baked textures. But that also depends on the base textures used of course.

Hello,

Volumetric noise is another word for 3d noise.

It is not a volume texture. You just run

vec4 noise_value = perlin_noise_3d( pos );

in the shader.

It is a visual quality improvement on triplanar texturing using a 2d noise texture, the important difference is that it just computes the value instead of looking it up.

It would directly replace the triplanar texture function … unless you are using visual shaders…

Oh I understand now, I was thinking of complete depth calculations and rendering out volumes in the shader. That does sound interesting, yes. Especially that you don’t have to look up any textures, but just compute the value. Theoretically infinite resolution.

Yeah although its usually done per texel.

If the volume noise is used as a mask you could probably also use simplex and value noise instead. The use of vec4 could also be swapped for float values if its black and white.

I tried a couple of these functions when i was working on my triplanar shader (i think i ended up with precomputed noise textures and then the shader was implemented using the check box in the standard material and then converting to shader material).

After I implemented AO channels for layers, I decided to work on a set of demo materials to see how the UX feels. I did not make the model, but all the textures are made with CompositeMaterial, running live in Godot.

Here’s a small gif of me changing certain parameters on the metal material. The visor material also uses CompositeMaterial.

ezgif-8623302867f4b599

1 Like