Building a Sync Tool for Blender to Defold

Starting to get some cleanup and feature into sync tool again.

  • Fixed major bug with normals not being exported.
  • Added initial second UV stream in buffer definition.
  • Working on pbr setup to support shadow maps as an emission map - ie, emission of 0 is dark(blackout) shadow, 1 (bright) is no shadow. May support other variants of this.

I hope to have much of this wrapped up tomorrow. And just bug fixes going in only. I will be testing a wide array of meshes/models - I’ll be using Khronos’s gltf mesh and anim test library, its a nice set to check against. I’ll put the results up on the github so I can track missing features and problems.

Here’s a little car I did recently (helped me find the normals issue).

Oops. Almost for got. Source:

Attrib:

I really hope we can get Defold close to the Sketchfab renderer . I dont expect exactly (because they are doing some nice multiframe composing) but it should get close… I hope :slight_smile:

9 Likes

What multiframe compositioning? TAA? That should be doable with Defold I think, or what are we missing? :thinking: As far as I remember it’s more or less storing an FBO that contains weighted samples from old frames and then some magic filtering based on object velocities. I’ve converted this project (https://github.com/playdeadgames/temporal) to javascript some time ago and it wans’t too crazy to implement. If it’s the only thing missing to get the sketchfab quality I can definately make an example project based on my old code :slight_smile:

I read an article a while back on their renderer. They do some of their radiosity, shadows and other “ray casting type features” over a number of frames - you can see it when you spin. When it stops it visually improves the render. Thats not really something you want in a realtime game :slight_smile: … but its great for showing off models. :slight_smile:

I’ll dig up the article. I used to do alot of threejs rendering, and sketchfabs renderer always impressed me. But yeah… need to remember use case :slight_smile:

Oh. btw. Def want to build up a way to make a nice render scene. So TAA is def a good idea. Im probably going to make some design docs, because I kinda want a “basic nice renderer” that works within the editor without too many hassles/problems for the use. Ideally something that people can customise to their own needs later. But I kinda want the asset pipe to support the default materials as well - it makes it a little messy. But I have a couple of ideas that should make it work ok.

One soon to be added feature (next week I think) is custom materials. The user can provide custom materials to map to Blender materials, and then it generates the asset set with the correct meshes and go’s with the custom materials - should be quite easy to do, but will allow alot of flexibility for people.

1 Like

That sounds awesome! One thing that has always been missing regards to getting more people into making 3D games with Defold is a set of basic lighting setups that kinda makes everything look good out of the box. Something like unitys universal render pipeline, but simpler. Most people don’t fiddle with the render scripts anyway, so there should be a way to build a setup that you can just hook in I guess. But yeah let us know if there are any show stoppers that we might be able to help out with!

5 Likes

Yes. Exactly what I was thinking - I have lights from Blender coming into the asset pipe, so having a nice/simple lighting thats GTG with a nice pbr and maybe some shadowmaps and possibly global illum (probe lights maybe). A suite of “3d ready to use scene” direct from blender. And that its should look “close” to the blender scene in Eevee - or key render features anyway.

Sorry editing. I had a thought. Do you think a set of render scripts would be ok to bundle? It means I could handle alpha and reflection/cube maps a bit easier too. Hrm… might have to make a thread for this. Dont want to make this too big :slight_smile:

6 Likes

Added this: What do you consider base features for 3D?

4 Likes

More fixes.

  • Found normals were not being set (omg stupid bug - was previously working!)
  • Now auto converts any non PNG texture image to png. Ive tested mainly JPEGs and its working well. May add an option to disable if needed. Conversion takes a little longer if there are many large JPEGs to convert.
  • Many little bugs.

Will check this in tonight. Its getting better. Im going to put a simple reflection map in tonight as well.

10 Likes

With reflection maps, it definitely is starting to get close.

Need to balance the pbr a little (the normal map is a bit strong now). But its ok.
Hrm… just realised… a little mp4 would be nicer… replacing img.

Note: Lights are still not quite right. I hope to have that sorted all out by tomorrow.

9 Likes

good job :grinning:
thx

2 Likes

Thanks @Flavio_Pereira ! I thought I should show it running in the Defold window :slight_smile: … rather than in editor :slight_smile:

Note: Alphas arent working on this car because they mapped the alpha differently in blender. Might try to solve that tonight, to see if I can get fairly “generic” alphas working.

8 Likes

Ok. Its official… there is a proper Blender module available. Only tested on Linux at the moment, but should work on OSX and Win (will test over coming days).

Oh. Please read setup on github. You need to do one additional thing for it to operate properly.

Update: Spoke too soon. Win10 texture paths not right. Fixing…

5 Likes

So now you use custom materials? But what do you mean for “PBR” term? Just environment mapping? Lambert? Cook–Torrance?

@Ivan_Lytkin - Ive always had a simple pbr - it requires not stream additions and just texture samplers. It is a custom material, but doesnt need specific render_script mods.

Its a very simple physically based shader material. Primarily supports the gltf/glb style pbr format - metal, roughness, albedo, reflection, emission and normal map. Its not strictly pbr, because of missing bitangents and a few other features. Light wise it uses a simple GGX with a fresnel. All the code is in the github if you want a look - I dont expect to expand on it too much.

Addition of render script capabilities will mean the support of people supplying their own custom materials. At the moment you can do this by modifying the material-pbrsimple.lua in the addon to your own needs, then when you export that will be used. Next week I hope to make this more “user” friendly though by allowing people to add their own via a panel selection.

I have been testing lots of scenes recently and I like this the most :slight_smile: This is in editor:

Oh. woops. CC plug for the artist on Sketfab. Awesome model, amazing they provide it for free. Just beautiful.

I have high hopes for Defold getting real close to this.

7 Likes

This is really beautiful

2 Likes

Oh just some notes on release-v1.0.1 there are some bugs. Will have a replacement up in the next hour.
Some other points about the simplepbr material:

  • It currently has way too many samplers so this will change, which means alot more work on the Blender side.
  • Dont run the simplepbr on simple GPU hardware - the meshes wont render (mainly due to samplers).
  • The lighting is still needing some love, and so is alpha. But its usable.
  • I need to add some details about how to use Blender materials so the sync works consistently - generally you need to follow gltf export setups.

Complex lighting and shaders are on the way with render script generation, but I think there is quite a bit to figure out how best to make that all work yet.

4 Likes

@dlannan - the light in the scene you just posted: is there a light source or is this all from emission?

1 Like

There are emission on the wall lights, and only 1 light in the scene. The lighting is extremely basic. It uses the same input setup as a model material - single light position. However there are three lighting modifiers that can be applied for specular strength, reflection strength, and ambient levels. These can be ‘tweaked’ to modify the overall look. This is very simple though. Thats why its simplepbr :slight_smile: Its so many default resource and render setups can be supported without modification.

Oh. side note… I didnt try an envmap on the scene. hrm. Let me try.

2 Likes

you say - and such a lovely result, cool!

@dlannan,

sadly, I get an error message when trying to use the tool:

.

Is there something I missed or is it the OS (I am on a mini m1)?

Hrm. Thats a new one :slight_smile: … What OS?
Also, make sure you are using V1.0.2 - the first version wont work on Win10.

I think this is a bug. I’ll do a couple of tests on some other machines I have here. Gimme 10 mins.
Oh. Also, which Blender? > 2.8?

Ok. Latest seems ok on Win10. Did you install via the addon Install method?
The dir variable should be getting set, there are a couple of ways it may not - try saving your scene as a blend scene first.

1 Like