Disclaimer: This first part of a series of tutorials is firstly made for pure beginners. More experienced users could find it boring.
A few explanations :
Except for the background, we will need different maps to integrate colours for each object into Godot. The importation of the Cycles shaders to the engine is not supported for now (maybe planned for future versions, see Roadmap changes here) but it is possible to get around this. I explain: If Blender does not export Cycles materials to Godot, Godot will do the needed manipulations to translate. But for it to work, we must in first bake the maps one by one into Blender, and this will be the obtained images (diffuse map, normal map, etc.) which will be imported into Godot as textures.
We could think that in fact, all this could be useless as we will load images and not shaders into Godot. If of course our purpose is still to favour the use of shaders into our project.
Yes… But no. Indeed an option into Godot allow the transformation of Spatial Materials (the images) to Shader Materials in just one click ! I’ll talk about this later. From the first tests made and having saved both versions of the materials, they are apprearing identical on screen. The bonus is that the one or the other are still editable inside Godot, so, with a bit of practice and by knowing how manipulate the numerous options, it is reasonable to think that we could perfectly reproduce the renderings of the Cycles shaders, furthermore, and from what I have seen when I quickly browsed a first time the edition parameters, effects such as glare or blur appears also perfectly reproducible into the resource options.Now that we are done about the general explanation, let’s see more precisely the method I used and for a first part:
Make a HDRI (High Dynamic Range Image) into Blender as background.
To create a HDRI into Blender, I followed the method described by gandalf3 on Blender Stack Exchange :
Create HDR map from render?
Note that It is said :
If you select Cycles as the default renderer, and save as an EXR, your saved file will already be high dynamic range.
Important Note: Make sure the 3D views are set as perspective into Blender while making the needed rendering if procedural materials used. If not , it won’t properly display the background, and so the result file would not work.
Into a part of this other tutorial, I was describing a method to create a nebula wirh Cycles materials. This is one of the obtained environments I will use here as work base for the following chapter.
Set a Panorama Sky into Godot
Open Godot and create a new project (or edit the one you are currently working on)
- 1. Add a WoldEnvironment node
- 2. Into the Inspector, create a New Environment.
- 3. Select Edit
- 4. Go to Background → Mode, then select Sky
- 5. Into Sky, select : New PanoramaSky
- 6. Select Edit
- 7. Drag and drop the *.exr file previously created (we have of course moved this file into the work space of the project) to the field noted as <null>
Save the resource as well as the scene
- 8. In my case, the rendering appeared too much bright, if you experienced the same thing, you can easily modify the contrast and brightness parameters :
Go back into the resource edition panel → Adjustement→ Activate, and modify the needed parameters, the changes will be displayed in real-time into the viewport.
Note: For a detailed list of the available options see Environment and Post-Processing into the Godot Documentation. Don’t forget to save both resource and scene after each modification.
Export → Bake the textures :
As precised into the introduction of this tutorial, the export of Cycles shaders to Godot is not possible for now. But there is still a way to “translate” these same shaders so that Godot integrates them, here is how I proceeded :
First, we must bake the textures and for this I partially used the method described by Aidi Burrows from CG Masters :
Into this video, it is said that a baked image allow the reduction of the rendering time. Aidi indicate that, in his case, it take 1mn + 25 seconds instead of 5 mn + 20 seconds waht is already amazing for a simple mesh like a planet, so we can imagine what it would give for a more complex object !
As reference, I will use the sun created here.
Once baking operations done, we can notice on screen that that colours and Voronoï texture used for the shader are included. Obviously, the emission shader is not, but this one is perfectly reproducible into the game engine.
The export itself:
For this we have to download and install Better Collada into Blender from Github. Indeed, the Collada exporter by default for Blender would not work properly.
Import into Godot
Open the project then load the scene to edit.
Rather than letting * .dae and * .material files, we will re-import the mesh to lighten the number of files, which normally and gradually, should lighten the entire project:
- 1) Select the *.dae file into the resource panel
- 2) Click on the Import tab
- 3) Rename if you want
- 4) Into the Meshes part, go to Storage and select Files
- 5) Click on Reimport
- 6) Drag and drop the obtained *.mesh file into the viewport at a desired place. A new MeshInstance node will be automatically created
Note : Here, the *.mesh is named Icosphère.01 because it’s its actual mesh name into Blender. We can obviously rename all of this without problems (right click or left double-click).
Now, we can absolutely remove *.dae and *.material files as well as the corresponding *.import files (if still any) into the project folder. And by the way, let’s rename the files for more clarification.
- 7) Go into the Inspector → Material, then select New SpatialMaterial
- 8 ) Select Edit
- 9) Drag and drop the diffuse texture (here : yellow sun_diffuse.png ) into the Albedo part and the field noted as « null »
- 10) Then into the Inspector, go up to Flags and activate Unshaded
Save this new resource as *.material file and save the scene. We are now done about the import !
Convert to ShaderMaterial
Nothing more simple :
- 1) Go back to the MeshInstance edition (simply click on the node into the Scene dock)
- 2) Go to Material, then select Convert to ShaderMaterial
We have now a new shader as material, great, but how edit it ?
- 3) Select Edit
- 4) Select Edit
Save this new resource as *.shader file.
Concerning the shaders edition itself, it will maybe be the topic of another tutorial (but no promises).
Of course, the whole procedure would have to be repeated for each added object.