godotengine / godot-blender-exporter

Addon for Blender to directly export to a Godot Scene
GNU General Public License v2.0
1.16k stars 132 forks source link

support exporting materials with noise nodes #407

Open kalbfled opened 3 years ago

kalbfled commented 3 years ago

The absence of support for noise nodes, which are common in procedural texturing, precludes using this exporter in many cases. Implementing this support, while difficult, would let users avoid the extra step of baking images or having to add another piece of software (i.e. Material Maker) to their pipeline. In turn, perhaps this would help Godot gain wider use.

Material Maker is open source and supports noise. Maybe a good chunk of that code can be repurposed for this exporter.

Jason0214 commented 3 years ago

Copy some comment from https://github.com/godotengine/godot-blender-exporter/issues/158

From @Calinou: To be fair, most games in production bake their textures and don't try to do anything more. Procedural textures are nice, but have a lot of limitations such as run-time performance (or even load times if they're not cached to disk).


Material Maker is open source and supports noise.

Agree that if we do want generating noise at runtime. Then porting existing shader implementations that matches/similar to Blender noise node is the way. Though I am a little concerned about the issue mentioned in https://github.com/godotengine/godot-blender-exporter/issues/407. It would be nicer if someone could do it with MIT licensed shader code (not sure what license "Material Maker" is on) and , if possible, fix the current ShaderMaterial license issue altogether.

Uradamus commented 3 years ago

For what it's worth, you can bake out just about anything in Blender, including the output of procedural texture nodes.

Just set up an emission shader fed into your material output, feed whatever you want to bake into that shader's color input. Add an image texture node to the graph and create a new image of the size you want your map to be, but don't connect the node to anything, but have it selected so the baker knows that is the node you want to bake to. Then make sure your renderer is set to Cycles and use the bake panel on the render properties tab, set the bake type drop down to emit and hit the bake button.

You can then save the resulting image, and now finally plug that unconnected image texture node into the whatever you were previously plugging the procedural texture into on the material's proper shader and plug that shader back into the material output and you can now get rid of the emission shader and anything you had plugged into it and you're ready to export.

You can use this setup to drastically reduce the complexity of your materials by baking out a final result for each channel that wasn't already a single image map.

kalbfled commented 3 years ago

In the time since I opened this ticket, I used Blender+Cycles to render an animation with complex procedural textures, and frames that might take 40 seconds to render with image textures took over 3m45s. The same frames with Blender+Eevee took about 1.2 seconds each.

Now I fully appreciate what @Calinou wrote about performance. Procedural textures in a game would probably be useless for anything non-trivial, although I can still imagine the use case of people rendering animations with a real time renderer (i.e. like people are doing with Unity; I would just use Blender+Eevee).