Defold 1.8.0 has been released

Defold 1.8.0

One of the biggest change in this version is the introduction of the new ‘b2d’ namespace which contains direct access to the Box2D API. This is the first step towards moving our physics APIs into their own extensions, which we will continue working on during this year. Another frequently requested feature that is now available is the introduction of the gui.set and gui.get functions, which is the GUI counterpart of the go.set/get functions. Furthermore, emscripten has now been updated to the latest version (3.1.55). This should enable us to start working on WebGPU support at some point this year.

On the editor side, we have fixed several issues with model rendering. Performance should be better when rendering in the viewport and all known vertex attributes are passed into the vertex shader, which means that you can now preview vertex colors in the editor.

Summary

  • NEW: (#8719) Make maximum amount of text batches configurable via game.project.
  • NEW: (#8758) Add ‘slice’ as a property to get and set slice9 values
  • NEW: (#8732) New function: resource.create_texture_async
  • NEW: (#8712) Added Box2d Lua module
  • NEW: (#5848) Expose allow_sleep and awake Box2D parameters
  • NEW: (#5905) Add option to set IsBullet for Box2D objects
  • NEW: (#8680) Added Apple privacy manifests for iOS and macOS
  • NEW: (#8638) Add gui.get and gui.set
  • NEW: (#8727) Pass all known model scene attributes to shaders in editor viewport
  • NEW: (#8674) Improve resource sync performance
  • NEW: (#6259) Updated to Emscripten 3.1.55
  • FIX: (#8604) Get progress in callback for HTTP requests
  • FIX: (#8664) Fixed issue for DirectInput gamepads with multiple POV’s
  • FIX: (#8657) Add margins to the left and top edges of the atlas.
  • FIX: (#8670) Unpack buffer from argument before setting texture
  • FIX: (#8710) Produce local and world spaced models with correct custom attribute values
  • FIX: (#8757) Migrate texture fields to samplers
  • FIX: (#8698) Fix flickering on vulkan when drawing to a render target
  • FIX: (#8706) Fixed gdc tool when running on OpenGL backends
  • FIX: (#8675) Move experimental vulkan functions to mainline graphics_vulkan library
  • FIX: (#8720) Check response status when fetch wasm for streaming instantiate.
  • FIX: (#8682) Load engine and data concurrently
  • FIX: (#8755) Delete OpenGL textures using the correct context on single threaded graphics backends
  • FIX: (#8751) Fixes misc inconsistencies when setting and getting custom vertex attributes by script
  • FIX: (#8640) Clear the texture data if no buffer is passed in when using resource.create_texture
  • FIX: (#8762) Added more robust shutdown code for our dmJobThread implementation
  • FIX: (#8663) Fix navigating to referencing atlas from missing image build error
  • FIX: (#8694) Editor model rendering optimizations and fixes
  • FIX: (#8725) Add a read timeout when fetching libraries from the editor
  • FIX: (#8754) Support environment-variable replacement for usernames in dependency URLs
  • FIX: (#8769) Fixed broken gizmo manipulations for Model component
  • FIX: (#8787) Enable vulkan backend for Linux platform

Engine

NEW: (#8719) Make maximum amount of text batches configurable via game.project.
Maximum amount of text batches can be configured via game.project property graphics.max_font_batches.

NEW: (#8758) Add ‘slice’ as a property to get and set slice9 values
Added a new property to sprites for getting and setting slice9 parameters. Examples:

local values = go.get("#sprite", "slice")
local value = go.get("#sprite", "slice.x")
go.set("#sprite", "slice", vmath.vector4(1,2,3,4))
go.set("#sprite", "slice.x", 1337)
go.animate("#sprite", "slice", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(96, 96, 96, 96), go.EASING_INCUBIC, 2)
go.animate("#sprite", "slice.x", go.PLAYBACK_LOOP_PINGPONG, 96, go.EASING_INCUBIC, 1)

NEW: (#8732) Added resource.create_texture_async
Added a new resource function to create textures asynchronously: resource.create_texture_async(path, tparams, [buffer], [callback]):

  • path - the path to the resource to create (/main/my_texture.texturec)
  • tparams - texture params, width, height, format and so on
  • [buffer] - optional buffer that contains the texture data. if the buffer isn’t provided, the texture will be created with blank data
  • [callback] - optional callback that will be called when the upload has completed. The callback has the following setup:

function my_callback(self, request_id, result)

  • self - the script where the request was issued
  • request_id - the unique request id that is returned from resource.create_texture_async
  • result - a table containing:
    ‘path’ - the resource path of the texture that was updated

This function will create a new texture resource and upload the data into it in a worker thread. The function will return both a resource path and a request id for the async upload, so that specific requests can be tracked during the lifetime of the app or game. The returned resource path can be used immediately (i.e you can pass it to components with go.set), the initial texture will be a blank 1x1 texture which will later be replaced by the actual texture data.

function my_callback(self, request_id, result)
    -- texture has been updated, do something with it
   self.requests[request_id].loaded = true
   go.set("#model", "texture0", result.path)
end

local t_path, t_request_id = resource.create_texture_async("/main/my_texture.texturec", t_params, my_buffer, my_callback)
self.requests[t_request_id] = { path = t_path, loaded = false }

NEW: (#8712) Added Box2d Lua module
This allows you to get a physics body and manipulate its forces, velocities and other properties.

Example:

local id = factory.create("#factory", position)
local url = msg.url(nil, id, "collisionobject") -- get the collision object in the spawned object
self.body = b2d.get_body(url) -- get the b2body object
b2d.body.dump(self.body) -- debug print

-- add an impulse
local pos = b2d.body.get_position(self.body)
b2d.body.apply_linear_impulse(self.body, vmath.vector3(300,200,0), pos + vmath.vector3(16,16,0))

A full list of functions is available in the reference api for b2d and b2d.body.
Note that this was a first step. Next up is adding the missing structs, e.g. world, joints, fixtures and shapes support.

:warning::warning::warning::warning:

In order to support the feature of removing physics, we have now introduced two app manifest settings. If you are using a custom .appmanifest, and you wish to remove all physics, take note of these changes (or compare with a vanilla app manifest with physics removed):

      excludeLibs: [physics, Box2D, script_box2d]
      excludeSymbols: [ScriptBox2DExt]

:warning::warning::warning::warning:

NEW: (#5405) Expose allow_sleep and awake Box2D parameters

The ability is now possible via the new script api b2d.body.set_awake(body, flag) / b2d.body.is_awake(body)

NEW: (#5905) Add option to set IsBullet for Box2D objects

The ability is now possible via the new script api b2d.body.set_bullet(body, flag) / b2d.body.is_bullet(body)

NEW: (#8680) Added Apple privacy manifests for iOS and macOS
This change adds an Apple Privacy Manifest (PrivacyInfo.xcprivacy) to builtins for both iOS and macOS. The privacy manifest will also be added as a game.project setting for both iOS and macOS. If the project also contains native extensions any privacy manifests used by the extensions or any extension dependencies these will be merged with the project manifest. The merged (or original manifest) will be included in the bundled app.

Including a privacy manifest will be required by Apple when uploading to App Store Connect:

“If you upload an app to App Store Connect that uses required reason API without describing the reason in its privacy manifest file, Apple sends you an email reminding you to add the reason to the app’s privacy manifest. Starting May 1, 2024, apps that don’t describe their use of required reason API in their privacy manifest file aren’t accepted by App Store Connect.”

Source: Describing use of required reason API | Apple Developer Documentation

NEW: (#8638) Add gui.get and gui.set
Gui scripts can now query/set node properties via gui.get and gui.set:

local node = gui.get_node("my_node_id")
local node_pos = gui.get(node, "position")
local node_pos_x = gui.get(node, "position.x")

gui.set(node, "position", vmath.vector3(1, 2, 3))
gui.set(node, "position.x", 1)

We have also added a new property to the gui namespace euler which is linked with the rotation property. When changing one of them, both will change its underlying data. The important change between them is that the rotation property must be set by quaternion values, and the euler property must be set by degree values. You can set a single component of the rotation or the euler properties as usual:

gui.set(node, "rotation.x", math.rad(45))
gui.set(node, "euler.x", 45)

There are no custom script properties available, you can only get and set the already existing node properties:

"position"
"rotation"
"euler"
"scale"
"color"
"outline"
"shadow"
"size"
"fill_angle" (pie)
"inner_radius" (pie)
"slice9" (slice9)

:warning::warning::warning::warning:

Please pay attention! gui.PROP_ROTATIONand gui.set_rotation() now works with quaternions. Therefore, existing code should be fixed to use gui.PROP_EULER and ``gui.set_euler(), or the value used with gui.PROP_ROTATION` should be a quaternion. Please check your existing code and make the necessary changes.

:warning::warning::warning::warning:

FIX: (#8604) Get progress in callback for HTTP requests

Added a new parameter to the option table for the http.request function called ‘report_progress’. When report_progress is true, the amount of bytes sent and/or received for a request will be passed into the callback function:

http.request("http://my-address", "GET",
	function(self, id, response)
		if response.bytes_total ~= nil then
			update_my_progress_bar(self, response.bytes_received / response.bytes_total)
		else
			-- handle response like normal
		end
	end,
	nil, nil, { report_progress = true })

FIX: (#8664) Fixed issue for DirectInput gamepads with multiple POV’s

This fixes an crash when a gamepad has more than one POV.

FIX: (#8657) Add margins to the left and top edges of the atlas.
Fixed an issue where the margin specified for the atlas ignored the top and left edges of the atlas and was added only between images and on the right and the bottom edges of the atlas.

FIX: (#8670) Unpack buffer from argument before setting texture
Fixed an issue when using resource.set_texture with a buffer object that is acquired from a buffer resource. Previously we did not unpack the buffer correctly, which would cause script errors.

FIX: (#8710) Produce local and world spaced models with correct custom attribute values
Fixed an issue where models are using custom attributes with and without mesh colors available in the .glb file:

  • When a model is using a mesh without color data, it should produce the overridden data from the custom vertex attributes
  • When a model is using a mesh with color data, the color data should always take precedence over the custom vertex format

FIX: (#8757) Migrate texture fields to samplers
Fixed an issue in bob when building materials, if the material has specified textures they will not be used in the engine because the texture field is now deprecated. The fix migrates all the textures of a material into samplers instead.

FIX: (#8698) Fix flickering on vulkan when drawing to a render target
Fixed an issue where flickering was happening on the Vulkan and MoltenVK renderers when using a render target.

FIX: (#8706) Fixed gdc tool when running on OpenGL backends

FIX: (#8675) Move experimental vulkan functions to mainline graphics_vulkan library
Removed the experimental vulkan API + library and instead moved all the code into the mainline vulkan library. This should make building the rive extension simpler (due to less dependencies) as well as merging some of the shared functionality later on.

FIX: (#8720) Check response status when fetch wasm for streaming instantiate.
Check if fetch() was successful during wasm loading. Otherwise return Response with null body to trigger fallback logic.

FIX: (#8682) Load engine and data concurrently
Now dmloader.js loads game data and game engine (wasm + js files) concurrently.
:warning::warning::warning::warning:

The default template builtins/manifests/web/engine_template.html has been changed. If you use your own custom template, make sure to update it with these changes. Pay attention to css changes for progress bar and how progress bar animation now handling. Also change how extra_params passed according to new documentation Defold development for the HTML5 platform

:warning::warning::warning::warning:

FIX: (#8755) Delete OpenGL textures using the correct context on single threaded graphics backends
This fixes a memory leak with textures on iOS and Html5

FIX: (#8751) Fixes misc inconsistencies when setting and getting custom vertex attributes by script
We have fixed multiple issues with setting and getting custom attributes on sprites. The functionality overall is more robust now.

FIX: (#8640) Clear the texture data if no buffer is passed in when using resource.create_texture
We now explicitly clear the texture data before uploading it to the GPU texture when using resource.create_texture with no explicit buffer is being used.

FIX: (#8762) Added more robust shutdown code for our dmJobThread implementation
This fixes an issue where it was possible for get a dead lock when shutting down the job thread system.

Editor

NEW: (#8727) Pass all known model scene attributes to shaders in editor viewport
The scene view will now pass all currently supported vertex attributes to the shader when rendering models.

NEW: (#8674) Improve resource sync performance

FIX: (#8663) Fix navigating to referencing atlas from missing image build error
Fixed a regression where double-clicking a build error originating from an .atlas referencing a non-existent image resource would not take you to the referencing .atlas.

FIX: (#8694) Editor model rendering optimizations and fixes

  • Fixed a performance regression in the editor introduced by the recent addition of custom vertex attributes to models.
  • Fixed broken preview of model scene files (.gltf, .dae, etc.). Previously you’d only see the bounding boxes if you opened a .gltf file in the editor.
  • Fixed a memory leak of scene-cache data associated with the OpenGL context used for scene picking hit tests after closing an editor tab.
  • The editor will now share vertex buffers among meshes, as long as they do not use any world-space attributes.
  • The Coordinate Space setting of declared vertex attributes takes precedence, but the Vertex Space setting on the material will be used as the default for any undeclared vertex attributes where it has relevance.
  • The editor will now produce world-space normal attributes correctly, if desired.
  • The editor will no longer produce a broken normal matrix for objects that have a non-uniformly scaled parent.

FIX: (#8725) Add a read timeout when fetching libraries from the editor
Added a timeout when fetching libraries from the editor so it doesn’t block indefinitely if a server stops responding.

FIX: (#8754) Support environment-variable replacement for usernames in dependency URLs
The editor can now inject environment variables into both the username and password of library dependency URLs that use authentication.

FIX: (#8769) Fixed broken gizmo manipulations for Model component

  • Fixed a regression where the move gizmo would translate rotated Models along the wrong axis.
  • Fixed a regression where the manipulator gizmo would not be properly aligned to Model pivot points.

FIX: (#8787) +8803 Enable vulkan backend for Linux platform

We’ve fixed the building of the Vulkan backend for the Linux platform.
:warning:
If you have a custom app manifest, then you need to make sure that it’s updated with the relevant dynamicLibs change for the Linux platform. Here’s the text from the editor when selecting the Vulkan backend:

  x86_64-linux:
    context:
      excludeLibs: [graphics]
      excludeSymbols: [GraphicsAdapterOpenGL]
      symbols: [GraphicsAdapterVulkan]
      libs: [graphics_vulkan, X11-xcb]
      dynamicLibs: [vulkan]
      linkFlags: []
28 Likes

The release occurred a few days ago, but we missed sending out the release notes! :slight_smile:

8 Likes

Incorporating this new feature altered the rotation animation of the GUI buttons in my game and introduced a runtime error. Since it’s not indicated as a breaking change, I consider this to be a bug.

The GUI animation is specified as follows, and in the previous version, the engine interpreted the rotation.z value in euler angles, but now, according to the example above, it should be specified in radians.

gui.animate(block_node, "rotation.z", rotations[index], gui.EASING_LINEAR, 0.1, 0, function() ...

The runtime error arises from the fact that in the previous version, gui.get_rotation returned a vector3 type, which I used with a + operator. However, now it most likely returns a quaternion, resulting in an error when used with the + operator:

local screen_rotation = vmath.vector3()
local current_node = node
...
repeat
    -- calculate screen_rotation
    screen_rotation = screen_rotation + gui.get_rotation(current_node)
ERROR:SCRIPT: modules/system/screen.lua:105: bad argument #2 to '__add' (vector3 expected, got userdata)
    stack traceback:
      [C]:-1: in function __add

So, this code snippets worked flawlessly in version 1.7.0, but in version 1.8.0, it no longer functions correctly.

1 Like

Yeah that’s unfortunate, but it’s clearly marked in the release note as a breaking change, with multiple warnings, so we do not consider it a bug.

1 Like

Wrnings:
1.

3 Likes

Now rotation is in quaternions vector (not radians)

To migrate your code to 1.8.0 you can replace all your rotation.z to euler.z and all should works as before

2 Likes

You’re right, I apologize. I overlooked the part with the yellow exclamation mark, probably due to the late hour or I don’t know, but somehow it didn’t catch my attention. In the release notes, the summary section usually included any breaking changes in the ‘BREAKING CHANGE (#xxxx) …’ format, and I didn’t see that this time.

Thank you everyone for your help!

3 Likes

I overlooked the part with the yellow exclamation mark …

That happens to me too sometimes; I wonder if this has anything to do with it: Banner blindness - Wikipedia

1 Like

Yeah that’s also true, it wasn’t tagged correctly in the task which is on us :slight_smile:

Hi,

I have that in my console now :

WARNING:INPUT: Gamepad map for device 'Logitech Gamepad F310' already registered.

I looked in my game.input binding : No gamepad triggers put. Only Keys (enter and cursor) and mouse (left and wheel up/down).

I never had gamepad in my life.

Maybe of use : Console also said that :

INFO:DLIB: Initialized Remotery (ws://127.0.0.1:17815/rmt)

How that, “from a distance” ?!

:red_circle:Ah, manual say it’s the profiler. I didn’t even know that was a thing.

Due to a mistake, the default gamepad bindings have two copies of the Logitech Gamepad F310 on Linux. This will be fixed in the next version.

Yes, this is profiler. You can open it from the editor

Thanks for your answers. I though for a moment somebody tried to hack me. :kissing_closed_eyes:

Update engine from 1.7.0 to 1.8.0
Android bundle not build(
Pc and web worked

There was problem with shader. If some of varying existed in vp but not existed in fp.
2024-05-03_21-17-29

This is in my shaders so i will fix it)

The build failed for the following reasons:
ERROR assets/materials/grid_floor_1.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR blender_location/materials/pbr-simple.material Location mismatch for fragment shader input 'vuvCoord0': The vertex shader specifies the input at location 4, and location 3 in the fragment shader.
ERROR assets/materials/grid01.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/grid.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/model.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/shadow/shadow_bones.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/grid_wall_1.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/model_3drt_flipped.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/player_3drt.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/model_flip_x.material Location mismatch for fragment shader input 'var_texcoord0': The vertex shader specifies the input at location 0, and location 1 in the fragment shader.
ERROR assets/materials/font-df_world_top.material Location mismatch for fragment shader input 'var_sdf_params': The vertex shader specifies the input at location 4, and location 3 in the fragment shader.
ERROR assets/materials/model_island.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/model_no_shadow.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.
ERROR assets/materials/model_no_cast_shadow.material Location mismatch for fragment shader input 'var_texcoord0_shadow': The vertex shader specifies the input at location 5, and location 0 in the fragment shader.

Also now they should be in same order that in vp.

Hm, the order of the varyings shouldn’t matter :thinking: I’ll have to take a look at that, but otherwise we haven’t made any significant changes in these areas in a very long while, perhaps you made changes in your shaders recently?

1 Like

No i make build for android May 1.

Also i don’t make changes in shaders. I am sure.

For example last changes for font-df_world.fp was 27.11.2023

I have this in my game.project
[shader]
output_spirv = 1

I need this if i use opengl?

I remove this from game.project. And now it worked (order of the varyings shouldn’t matter )

No, that is only needed for the other adapters, but the option is deprecated

1 Like