Building a Sync Tool for Blender to Defold

Ok. So this is a yes, and no answer :slight_smile:
Yes there is the ability to export the second set of uv’s as a texture uv asset. Sync tool will do that if you tick the “Second UVs” checkbox.

However, to utilize this you will need a shader that is capable of using it. This is one of the reasons a custom shader and render script will need to be provided. The shader will need to utilize the second stream obviously to render the other textures using it. And of course you need texture samples for that new stream in the shader.

It is not difficult to do this right now. You can export with the sync tool, it will generate all the appropriate data and references, you just need to have a shader suited for it and you replace the shader in the material (use the pbr shader) to your custom one.

I have been working on the concept of using the emission texture slot for things like light maps.

As to whether lightmap or dynamic is better, I suspect it will come down to your needs. Lightmaps are great if the lighting is kinda static like in many indoor situations and you can use dynamic in combo with the lightmap to generate a nice look. Or maybe you are doing outdoors and you really only care about dynamic realtime lighting with dynamic shadows… all depends.

With sync tool the aim is to provide a capability for this possible use, but it wont really provide a rendering solution on how that data is used - theres many ways to tackle lighting models.

3 Likes

Oh. How this is used in Blender - sorry should explain that.
You need to use texture layers for it to work properly. A layer is usually assigned a name, and in the material, when you assign a texture if the object has multiple uv layers you can choose one of them for the texture to use. There are a number of youtube tutorials on this method.

2 Likes

Well, I’ll try to figure it out as best I can. My intention is simple - to diversify the level at least some lighting. I’ll be happy with a baked map of the whole level, as well as multiple dynamic lighting without shadows.

I’ll try to bake a static lighting map for beginning. It looks possible for me and consistent with your plans about the sync tool :+1:

2 Likes

Tested the second UV. Two cubes with different second UVs and a shared lightmap texture.


:slight_smile:

6 Likes

Looking great @astrochili ! Looks like it should be very suitable :slight_smile:

1 Like

Ok. New release (updated above).
A new update is incoming into the Defold engine:

Support for gltf and glb makes the whole sync/export proces much cleaner, quicker and more stable.
I have done a few updates to the export tool - now called Defender (thanks @Dziq and @Klear)

Main updates:

  • New name - Defender :slight_smile:
  • Added a new selection to the export panel to select GLTF and GLB.
    To make use of this you need to be running the new Defold version (see link).
  • Added export changes in the python to produce gltf and glb output files. These technically can be used where ever you want (Unity3D etc)
  • Added fixes to the mesh construction.

I have been working on lighting and a new render system, that I hope to have done soon, but Im not going to put a timeline on it. Things have been too busy lately.

If you have any problems, please raise an issue on github of contact me here or on Discord.

12 Likes

A new release for Defender (1.1.1).
Added new logging system which begins to provide feedback to the user about scene related issues.
Currently supports:

Material type checking
Collection checking (for existence)
Luajit permissions levels (reports where file cannot be executed from).
Outputs log report that can be sent to me.

The main aim of the logging is to catch more and more anomalies that are unsupported in Blender when converting to Defold.

Errors are shown on the Defender panel (up to 8 errors) and a log file is generated where the blender file exists.

8 Likes

More good news on the bug side of things. Thanks to Aronimo and Makaber they hlped track down a nasty little utf8 filename bug. The new release is here:

8 Likes

Hi, thanks for extension.
I am trying to mix it with lightmapper https://github.com/Naxela/The_Lightmapper
But can’t:(

Looks like it not export lightmap texture and lightmap uv.
I am noob in blender so i do not understand why:) I have 2 uv in material.
If you have time, please try a look, mb you can help me:)
boxes_1.zip (192.2 KB)

Are you exporting models in collada(.dea) format? If so defold does not support more than one uv set attribute for this format. glTF format can now be used in defold version 1.3.7 which does support more than one uv set.

1 Like

Thanks. I try collada.
It create mesh and buffers.
I try glb and gltf formats. Not helped.
Looks like it not export second uv and not export image.

My material.

Mb because lightmaper create hdr files?

Looks like i need to try bake in blender not lightmapper:)

Hi, Im not overly familiar with how lightmapper works - I might be able to have a look this weekend. However from the screenshots it looks like a shader node based material generator? Which I dont think will work in the exporter as it is at the moment - it did have some support for this, but it complicated things alot, so it was reduced to support mainly maps only.

With this in mind (I havent tried this) you may be able to output the lightmapper to a texture output, and then assign the texture output to the color (rather than a color variant). I might give this a quick try on the weekend too - because this might allow using node gen, but with some limitations.

Oh. And the exporter does support 2 uv channels, however you will need to have a shader material in Defold that uses the channels correctly.

On this note. Please be patient, because Im building a render pipeline that should:

  • support deferred rendering
  • support builtin custom multipass rendering
  • support a shadows implementation
  • support post render effects like ssao, bloom and more.

This, as you can imagine is a little complicated :slight_smile: And more importantly, I want it to be very Defold compatible so Im putting alot of effort in making sure its project friendly, and editor friendly as well as flexible for people to add their own shader pass setups.

I hope to have an initial build really soon. But Ive been saying that for three months. Life and work gets in the way alot :slight_smile:

All I can say… is I have not forgotten, it is underway and I may even show some screenshots in a matter of days (all things going well).

6 Likes

Thnaks.
I do not know) It generate something by lightmapper blender plugin:)

Now i al looking at blender bake. I think it should worked but i need make experiment:)

This may be a silly question as I don’t know anything about lightmapper (looks very interesting, though) but what would happen if you converted these hdr files into pngs and used those instead?

I have no idea how to do that:)
Also lightmapper uv not exported)

1 Like

Converting you mean? There are online converters, I never use those. For batch converting on the mac, I use xnconvert, for windows irfanview and for linux phatch. Plus, there is also ImageMagik and quite a few other programs. I am on a mac right now, xnconvert and also The Gimp can convert hdr to png, just tried it out. Not sure if the others load hrd files but would be surprised it they didn’t.

Ah, ok. It was just an idea - replace the hdr lightmapper produces with a png in the slight hope this might work.

1 Like

After lightly reading your blender knowledge base document, I would say that this should work with the exporter with a couple of caveats (will test tomorrow):

  1. The PBR Material Shader must be selected for export
  2. The UV channels the lightmaps use must be the second channel, and a lightmap shader must be used in Defold to apply the correct output to the models.

I will look at this tomorrow, and I will provide a simple material for Defold that should support this. The only things Im not certain on, are the Normal formats and the Base Color formats (inputs into the BRDF Principled Shader). They need to be color RGBA/RGB or Texture map (png preferably).
Will post here tomorrow.

1 Like

Ok. Some good news for all :slight_smile:
After tinkering with lightmapper:

I have managed to develop a simple extension within Defender to support exporting baked lightmaps to defold. With this, a new release is available that can support this:

Heres the Blender scene sample:

And the scene exported directly into a Defold project:

To use this new feature a few things needs to happen properly.

  1. LightMapper settings need to include the saving of baked lightmaps.
  2. Once baking for a scene is done, all material shaders nodes need to have the multiply node removed, and then the output of the lightmap attached to the Emission input for the Principled BSDF.
    Example:
  3. Ensure that all base texture UV Channels are set to active.
    Example (Cyan box shows render_active for the base texture):
  4. All materials that need to have a lightmap exported, the material name needs to be modified to end in “_LightMap”.
    Example:
  5. Now export the scene as per normal.

LightMapper Settings:


defold-exporter-4-2022-10-29_23-11

8 Likes

Wow, awesome​:heart_eyes::heart_eyes::heart_eyes:
I will try in monday, big thanks :+1::+1::+1:

2 Likes