Are procedural textures possible with shaders?
Asked Answered
B

27

0

Anyone who worked with Blender is familiar with procedural textures in material nodes. I use them all the time to generate stuff like scratches on walls, certain types of metal plates, even wooden floors. This offer more control over an image, infinite patterns that don't repeat, and greatly reduce the size of a project since you don't need to store huge high-res textures.

So I wonder if with shaders or other means it's possible to create realtime textures in Godot and assign them to a material. I'm working on a generator for procedural voxel terrain and could use simple patterns for stone / sand / dirt / grass / etc, ideally with triplanar mapping which might make things a bit trickier. I want sharpness so in the past I tried using 4k textures: They're huge even with dds compression and even then you see them repeating... this alternative would be very helpful.

Is this something possible to do with Godot 4.0? If yes do you have any examples for common patterns, such as noise splats or voronoi bumps or wood bands / rings with distortion? I'd throw in a bonus question as it's likely something I'll want to use: Is it possible to influence the patterns to get different effects based on a value at the location of a vertice in GDScript, so for instance "noise_scale_at_corner *= dictionary_of_position_properties[this_vec3_position]" to get smaller noise on some surfaces?

Backhander answered 20/1, 2022 at 16:17 Comment(0)
T
0

My current project uses procedural texturing almost exclusively. It's all realtime shaders. You basically only need a decent 3d noise function. All effects you mention can be achieved by manipulating and combining it.

Testee answered 20/1, 2022 at 16:22 Comment(0)
T
0

Yes, you can do this in Godot 3.4 no problem.

Transsonic answered 20/1, 2022 at 17:7 Comment(0)
B
0

Wonderful, I shall take a look at this soon. Definitely the best fit for marching cubes terrain and registering different surfaces and materials for use with it. If I can get different effects per 3D point / vertice, it would also save me the worry of having to manually blend textures per cell which would have been a nightmare to code.

Backhander answered 20/1, 2022 at 17:59 Comment(0)
C
0

Hello, which strategy is better for high performance in game engines in general and specifically in Godot and why?

  • texture reading or algorithmic texture (pixel shader)?

Mainly I am trying to understand the process Godot/Game engines handle it. In doc I am seeing a clause where it is encouraged to use algorithmic texture whenever possible. https://docs.godotengine.org/en/stable/tutorials/performance/gpu_optimization.html#reading-textures

  • Is there any optimization strategy needs to be followed while authoring GLSL in Godot?

Thanks for your help in advance!

Congreve answered 8/2, 2022 at 22:2 Comment(0)
L
0

Godot does have a node editor for making shaders. You get similar functions that blender has for it's shaders.

Ladonnalady answered 9/2, 2022 at 9:56 Comment(0)
B
0

Was wondering if there are any Youtube videos or more step-by-step tutorials on exactly how you code a procedural material in Godot 4.0, in such a way that you can extract all the necessary maps (albedo, roughness, normal, parallax, etc) and use them accordingly to get as much detail as possible. I'm mainly going to need this for dirt / gravel / rock which should be easy to get with simple noise... what about a brick pattern to mix it with in order to get bricks though? Would like some detail on how to pretty much do this but in Godot:

Backhander answered 12/2, 2022 at 4:21 Comment(0)
T
0

I would recommend using Material Maker. This is what I am using and it's made in Godot.

https://rodzilla.itch.io/material-maker

Transsonic answered 12/2, 2022 at 5:12 Comment(0)
B
0

Wanted to ask this question separately since I couldn't find a clear answer anywhere. I just got familiar with the visual shader editor which I'm gonna use to make simple procedural textures. I can use an OpenSimplexNoise for fine details like grain which I already did with the base Noise Texture.

What I'm looking for next is an alternating brick pattern to blend it with, usable as both normal and even parallax maps to warp that noise effect over the bricks. What's the simplest way to do this from the shader nodes using builtin functions and texture types? Or if I have to write a custom shader or procedural texture definition, can anyone please offer an example? I'm not looking for other tools if possible, just an explanation on how to generate my own noise patterns from scratch.

In this case I was thinking of using a sine function or two textures blended in different directions. Even if this rather complicated approach works however, I can't do an alternating pattern per row just a grid.

Backhander answered 12/2, 2022 at 16:52 Comment(0)
T
0

I already posted in your original thread, which seemed to ask the same question, and it appears you never even read what I said or responded. In the future, please ask your questions (if they are the same or materially similar) in the original thread and not make 2 or 3 threads asking the same thing. Thanks.

Transsonic answered 12/2, 2022 at 18:15 Comment(0)
B
0

For clarity: I have read and appreciate the answers provided, just that I still can't figure out exactly what I'm looking for yet. Material Maker seems like an interesting tool to generate some materials, but I'm trying to learn how you can code your own simple patterns via shaders from scratch or simple examples.

I was curious if someone could offer a few lines of Godot specific shader code for how you generate a pattern procedurally to obtain a color, which node of the Visual Shader editor you'd plug that into for it to work... or perhaps you can use the existing vector functions to make good patterns with the builtin nodes and OpenSimplexNoise? From there I can probably change the math to get different pattern types... mostly curious about the basics of defining a seamless pattern in code, it's something I didn't get to play with before so I'm a little new to it.

Backhander answered 12/2, 2022 at 19:17 Comment(0)
T
0

Sorry, I didn't mean to be rude, I'd just prefer similar threads from the same author to stay in the same place.

To answer your question, Material Maker was made in Godot. So it's certainly possible to do it manually. I haven't worked with visual shaders much, but from what I understand they work similar to Blender (but more limited) so I imagine there is a way to do it without manual shader programming.

Here is a shader code I found to make a brick, but I think it's probably not the best way (but you can use it as an example to get some ideas): https://godotshaders.com/shader/brick-wall/

And here is how to use the visual shaders, which I believe is the better method:

Transsonic answered 12/2, 2022 at 20:45 Comment(0)
B
0

No worries and thanks, that is very useful! Will need to understand how it works but I have something to work with, hopefully I can get something like that with my own technique. Saw that video today funny enough, it explained how to use the default OpenSimplexNoise and get the base grime at least, already happy with how that works and it even has a builtin option to do the normal map!

Backhander answered 12/2, 2022 at 21:10 Comment(0)
M
0

I'm not sure how similar to substance designer the godot based material maker is vis-a-vis runtime generated procedural textures/shaders. I'd have to give it a more thorough look, though the quick glimpse I gave it a while ago(a month maybe?) left a lot to be desired far as I could tell. And that's before even considering authoring to runtime use. Which is to say I was only really judging the UX/workflow of just creating a texture within it.

edit: In fairness I should make it clear that I've been a long time substance user and Map Zone that preceded it since something like 2005, so I've been spoiled.


I've attached to the post a visualshader node tree that implements a barebone brick mask/texture. Pretty sure I forgot to normalize something somewhere but it looks like bricks enough to get by, so eh, it'll do for now.

Good luck dissecting it tho. I'd have made some use of groups and frames and what not other quality of life features if we had them. Mind, I assembled it in 3.4 so no idea if things are better in the 4.0 alpha land.

Mediate answered 12/2, 2022 at 22:18 Comment(0)
B
0

@Megalomaniak said: I'm not sure how similar to substance designer the godot based material maker is vis-a-vis runtime generated procedural textures/shaders. I'd have to give it a more thorough look, though the quick glimpse I gave it a while ago(a month maybe?) left a lot to be desired far as I could tell. And that's before even considering authoring to runtime use. Which is to say I was only really judging the UX/workflow of just creating a texture within it.

edit: In fairness I should make it clear that I've been a long time substance user and Map Zone that preceded it since something like 2005, so I've been spoiled.


I've attached to the post a visualshader node tree that implements a barebone brick mask/texture. Pretty sure I forgot to normalize something somewhere but it looks like bricks enough to get by, so eh, it'll do for now.

Good luck dissecting it tho. I'd have made some use of groups and frames and what not other quality of life features if we had them. Mind, I assembled it in 3.4 so no idea if things are better in the 4.0 alpha land.

Very nice, thanks! Sadly it doesn't appear to work in 4.0, plugging it into the albedo is pure white color. But at least I know it's possible, maybe I can simplify that somewhat. Am attempting something similar using two gradients, far fewer nodes but no idea how to do the alternation pattern that way.

Backhander answered 12/2, 2022 at 22:44 Comment(0)
M
0

@cybereality said: Sorry, I didn't mean to be rude, I'd just prefer similar threads from the same author to stay in the same place.

I think the most appropriate solution here was to merge the two topics instead, so I've gone ahead and done so.

Mediate answered 12/2, 2022 at 22:57 Comment(0)
M
0

@MirceaKitsune said:

Very nice, thanks! Sadly it doesn't appear to work in 4.0, plugging it into the albedo is pure white color. But at least I know it's possible, maybe I can simplify that somewhat.

make sure to tweak the shader parameters, they default to god knows what. I just shared the graph, not a material it'd be attached to. The shader parameters should be in the inspector.

edit: to be clear tho, it was meant to be a reference point/a learning experience so don't be afraid to open it in version 3 and then rebuild it yourself in 4. Might make for good practice.

Mediate answered 12/2, 2022 at 23:2 Comment(0)
B
0

They default to 0, set them to higher values but nothing happened. With my approach I was able to get somewhere for now... it does what I want just no pattern alteration. I'm also running into the issue of having to generate the normal map from the grayscale image result which I wanted to do in the same nodes, managed to get an acceptable result though I think the normals point the wrong way in places.

Backhander answered 12/2, 2022 at 23:14 Comment(0)
M
0

Heres a screenshot of what it should look like with the parameters dialed in as the inspector shows. I think you just didn't realize that I've set the brick scale value of 1.0 to essentially be max and for the mortar lines to show up at values below 1.0

It's meant to just produce a black and white mask so you can mix mortar and brick materials.

Mediate answered 12/2, 2022 at 23:27 Comment(0)
B
0

Aha, now it's working! Thanks again. Only problem apart from the number of nodes is I can't set a smoothness so the edge is fully sharp... I take it that can't be easily helped, thus I'll have to play around with all available options and see what looks best.

Backhander answered 12/2, 2022 at 23:42 Comment(0)
M
0

Yeah, would need to re-engineer it to not use the step node. But it does basically demonstrate how to get started with producing procedurals out of the UV channels. Once that clicks with you the world is your oister, or something. Not a native English speaker but I seem to recall a turn of phrase along those lines.

Mediate answered 13/2, 2022 at 0:6 Comment(0)
T
0

@Megalomaniak said: I think the most appropriate solution here was to merge the two topics instead, so I've gone ahead and done so.

Okay, thanks.

Transsonic answered 13/2, 2022 at 3:28 Comment(0)
T
0

@Megalomaniak said: I'm not sure how similar to substance designer the godot based material maker is vis-a-vis runtime generated procedural textures/shaders. I'd have to give it a more thorough look, though the quick glimpse I gave it a while ago(a month maybe?) left a lot to be desired far as I could tell.

Material Maker is very powerful. Of course it is a newer program and not as feature rich as Substance (which has been around for longer and has had much more funding) but I don't think Material Maker is limited in any way, or that you can't get good results. Here is an example of the kind of advanced stuff you can do with it.

And it was made with Godot, and supports Godot material formats, meaning you can easily export and iterate on the art and basically update your game within a few seconds, which, IMO, makes it a better solution for use with Godot.

Transsonic answered 13/2, 2022 at 3:32 Comment(0)
M
0

Yeah, as I said I was commenting more on the UX. I do think it has got tremendous potential and I'm not berating it by any means. Just saying that in terms of polish I don't think I'd want to be working with it 8 to 16 hours a day every day in production as it currently stands.

As for the runtime material publishing, all I can see in the docs is:

When exporting for the Godot game engine, Material Maker will generate a .tres file that describes a fully configured SpatialMaterial.

Which doesn't sound like what I'd want. And even if they mean ShaderMaterial I have my doubts, would be better tho.

Honestly the same goes for godot's current state of VisualShaders. I think long term it has a bright future, but it's not currently very nice to work with and I'd rather write shaders in code as it stands. But given some additional major features such as compute shaders and most importantly lots of QoL polish, such as node groups and an easy way to preview any nodes output on the viewport mesh(a la node wrangler and viewer nodes in blender) or frames for commenting sections of your graph I think it'll be great.

Mediate answered 13/2, 2022 at 4:42 Comment(0)
T
0

The export from MaterialMaker is a standard SpatialMaterial. It just automatically sets the textures and parameters, it's not a custom shader. However, you can also just export images and do it yourself if you want.

And in terms of UI/UX, I like MaterialMaker better than Substance. It is a little confusing at first (just like Godot itself) but it is easier to use and once you learn it it's pretty fast to pump stuff out. But it is pretty new and not even on 1.0 yet, so overall it is kind of quirky and rough.

Transsonic answered 13/2, 2022 at 5:53 Comment(0)
M
0

@cybereality said: The export from MaterialMaker is a standard SpatialMaterial. It just automatically sets the textures and parameters, it's not a custom shader. However, you can also just export images and do it yourself if you want.

Ah, there in lies the problem, from my understanding this whole topic is about dynamic runtime adjustable generated texture data not static baked textures. What your video shows being done inside MM is certainly intriguing enough, but the big million dollar question is how do you get that in that same dynamic and fairly adjustable manner into godot or unreal or unity or what have you.

With substance they have their DLL/middleware that can be integrated into a runtime environment to bring in support for the substances authored from designer. The substances remain dynamic and procedural. I'm hoping MM could become that for godot too, at least for godot, since it's made with godot, it could maybe become a plugin/gd extension.

Mediate answered 13/2, 2022 at 12:27 Comment(0)
T
0

I mean, I think it will get there. It's pretty promising, and it's not even on 1.0 version yet. But still early.

Transsonic answered 13/2, 2022 at 12:40 Comment(0)
M
0

Yeah, I'm quite excited to see where it goes. And where the VisualShaders will too. Both are certainly still useful tools already.

Mediate answered 13/2, 2022 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.