Defold 1.7.0 has been released

Defold 1.7.0

Release notes

As the version number suggests, in this version we have introduced some breaking changes.
The more important changes are related to texture mip map options, and also the removal of the system_font from the builtins package.
Please read those sections extra carefully.

There is also some “code cleanup” that may strictly be considered a breaking change. It relates to us removing old extension stubs.
It shouldn’t affect anyone, as these extensions have been published to github and been in use for many years.

Summary

  • BREAKING CHANGE: (#8528) More options for min filter in game.projectGraphicsDefault Texture Min Filter
  • BREAKING CHANGE: (#8548) Removed deprecated extensions from the code
  • BREAKING CHANGE: (#8559) Removed system_font.font from builtins
  • BREAKING CHANGE: (#8529) Turn mipmaps off in the default.texture_profiles file in builtins
  • BREAKING CHANGE: (#8553) Removed old deprecated messages
  • NEW: (#8424) Render target as a resource
  • NEW: (#8322) Increased length of debug prints for urls to 256 per part and 512 in total
  • NEW: (#8513) Add missed gui.BLEND_SCREEN constant into gui module
  • NEW: (#8525) Add camera focus message’s wrappers.
  • NEW: (#8562) Set custom vertex data API (Sprites)
  • NEW: (#8577) Add support for enabling a render target resource in render.enable_texture
  • NEW: (#8599) Flip image flag for image.load
  • NEW: (#8521) Add world to local coordinate system conversion API
  • NEW: (#8473) Add editor.delete_directory()
  • NEW: (#8510) Use async engine build in the editor
  • FIX: (#8371) Fix http request timeout usage in HTML5 build
  • FIX: (#8477) Fix issue when profiler show wrong count of GUI.ActiveNodes
  • FIX: (#8486) Fixed an issue where the game wouldn’t start if the iframe didn’t allow gamepad usage (HTML5).
  • FIX: (#8484) Fix multi-buffered render buffers on non-opengl graphics adapters
  • FIX: (#8496) Fixed an issue where attempting to use IndexedDB when it is prohibited prevents game loading in HTML5.
  • FIX: (#8493) Fix for crash caused by ray casting followed by deletion of the object
  • FIX: (#8305) add “Support texture handles in render.enable_texture” mention to API documentation
  • FIX: (#8544) Send sound_done or sound_stopped messages only if the sound is played using msg.post() with the play_id parameter.
  • FIX: (#8551) Fixed an issue where bob.jar did not delete some temporary folders after the bundling process was completed.
  • FIX: (#8552) Support sampler names in render.enable_texture
  • FIX: (#8582) Crash fixes for the GDC tool
  • FIX: (#8567) Fixed rendering of untextured sprites in the editor
  • FIX: (#8569) Added support for sprite to not have a texture assigned
  • FIX: (#8579) Check that texture width and height is valid before creating texture
  • FIX: (#8583) Use correct material tag for mesh components
  • FIX: (#8591) Add retry_count and retry_time settings to the game.project file in the html5 section.
  • FIX: (#8547) Fix issues with physics.set_shape() when Allow Dynamic Transformsis on
  • FIX: (#8561) Fixed the way the HTML5 bundler splits and renames resource files
  • FIX: (#8545) Add arm64-osx platform to manifests
  • FIX: (#8522) Graph successor memory optimizations
  • FIX: (#8531) Hide texture formats and texture compressions from *.textures_profiles that are currently not supported.
  • FIX: (#8563) Properly validate sprite texture assignments
  • FIX: (#8593) Paged atlas preview bugfix

Engine

BREAKING CHANGE: (#8528) More options for min filter in game.projectGraphicsDefault Texture Min Filter
Now, the field Default Texture Min Filter in game.projectGraphics has the same options as materials do.
This is a breaking change for projects that use mipmaps on their textures and the OpenGL graphics backend.

Old behavior was:

  • Options linear and nearest as Default Texture Min Filter meant TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST and TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST respectively.
  • If a texture without mipmaps was used with a material where Min Filter was specified with mipmaps, it used the Mag Filter option instead.

Current behavior:

  • Options linear and nearest as Default Texture Min Filter mean TEXTURE_FILTER_LINEAR and TEXTURE_FILTER_NEAREST respectively.
  • If a texture without mipmaps is used with a material where Min Filter is specified with mipmaps, it simply ignores the mipmaps part of the filter. For example, for TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST, it will be TEXTURE_FILTER_LINEAR, etc.

BREAKING CHANGE: (#8548) Removed deprecated extensions from the code
In this release we’ve removed old extension stubs for facebook, iap, iac, push and webview.
This shouldn’t affect any users, but is only part of an internal code cleanup task.
The actual extensions are found in the github repositories (e.g. GitHub - defold/extension-iap: In-app purchase extension for Defold)

BREAKING CHANGE: (#8559) Removed system_font.font from builtins
This breaking change was implemented to clarify the usage of predefined fonts in builtins. The old system_font.font has been completely removed from the builtins, and two new fonts have been introduced:

  1. builtins/fonts/default.font, which uses the default df material and can serve as a font for the development process.
  2. builtins/fonts/debug/always_on_top.font, which utilizes a special material builtins/fonts/debug/always_on_top_font.material with the debug_text tag. This font is intended to be drawn on top of other elements and is used for debugging purposes (such as the profiler and the draw_debug_text message) as replacement of old system_font.font. Additionally, changes are required in default.render_script, where the old text predicate has been replaced with the debug_text predicate for clarity.

BREAKING CHANGE: (#8529) Turn mipmaps off in the default.texture_profiles file in builtins
This is a breaking change for projects that use default.texture_profiles from the builtins folder.
If you need mipmaps for your textures, ensure you use a custom default.texture_profiles where this option is enabled.

BREAKING CHANGE: (#8553) Removed old deprecated messages
The following messages were removed:

  1. msg.post(url, "request_transform") and "transform_response" – requests the transform from an instance
  2. msg.post(url, "set_tile", ...) – use tilemap.set_tile() instead

NEW: (#8424) Render target as a resource
A new resource type has been added that creates render targets that can be used as a regular texture in the engine.

The .render file has also been refactored to support this new render resource type. You can now add .render_target files into the render prototype resource. In the render_script, you can use these render targets in the same way as before, except that you can now pass in the render resource name when binding the render target:

-- in a render script:
render.set_render_target("my_rt")

A new function has also been added to .script files to get all the metadata about a render target resource:
resource.get_render_target_info(path)

NEW: (#8322) Increased length of debug prints for urls to 256 per part and 512 in total

NEW: (#8513) Add missed gui.BLEND_SCREEN constant into gui module
Added gui.BLEND_SCREEN, which was missing in the documentation as well as in the gui module.

NEW: (#8525) Add camera focus message’s wrappers.
Now it possible to activate/deactivate camera component via camera.acquire_focus/ camera.release_focus.

camera.acquire_focus("/observer#main_camera")
camera.release_focus("/observer#main_camera")

NEW: (#8562) Set custom vertex data API (Sprites)
Added support for setting and getting vertex attributes for sprites via the go.set, go.get and go.animate functions. Similar to shader constants, the attributes has to be specified in the material:

To modify the my_color attribute:

local my_color = go.get("#sprite", "my_color")
my_color.x = my_color.x + 0.5
go.set("#sprite", "my_color", my_color)

Or alternatively, you can use go.animate:

go.animate("#sprite", "my_color", go.PLAYBACK_LOOP_FORWARD, vmath.vector4(1, 0, 0, 1), go.EASING_INBACK, i))

NEW: (#8577) Add support for enabling a render target resource in render.enable_texture
Render script can now enable render targets specified in the Render Resource table in a .render file:

This can now be done by calling render.enable_texture:

-- draw something to a render target:
render.set_render_target("rt_res")
-- do drawing here and unbind RT
render.set_render_target(render.RENDER_TARGET_DEFAULT)

-- set the RT buffer 0 to a sampler and draw something using it
render.enable_texture("my_sampler", "rt_res", render. BUFFER_COLOR0_BIT) 
render.draw(self.my_predicate)

NEW: (#8599) Flip image flag for image.load
image.load and image.load_buffer can now flip images vertically when loading:

image.load_buffer(path, {  flip_vertically = true })
image.load(path, {  flip_vertically = true })

Note that the second argument will now accept an option table, with these arguments:

premultiply_alpha - True if alpha should be premultiplied into the color components. Defaults to `false`.
flip_vertically - True if the image contents should be flipped vertically. Defaults to `false`.

NEW: (#8521) Add world to local coordinate system conversion API
Add new APIs to convert world position and world transform to game object’s coordinate space.
How to use:

   local test_pos = go.get_world_position("/test")
   local child_pos = go.get_world_position("/child")
   local new_position = go.world_to_local_position(test_pos, "/child")
   local test_transform = go.get_world_transform("/test")
   local child_transform = go.get_world_transform("/child")
   local result_transform = go.world_to_local_transform(test_transform, "/child")

FIX: (#8371) Fix http request timeout usage in HTML5 build

  • Fix timeout option usage in http module for HTML5 implementation.
  • Update http module documentation.
  • Wrap HttpRequestAsync arguments with struct.
  • Fix possible memory leak.

FIX: (#8477) Fix issue when profiler show wrong count of GUI.ActiveNodes
Fixed an issue where nodes that aren’t directly disabled, but are disabled because one of their parents is disabled in the tree, were incorrectly counted in GUI.ActiveNodes by the profiler.

FIX: (#8486) Fixed an issue where the game wouldn’t start if the iframe didn’t allow gamepad usage (HTML5).
Fixed the issue where the game doesn’t start if access to gamepads is disallowed by the permissions policy.

FIX: (#8484) Fix multi-buffered render buffers on non-opengl graphics adapters
We have fixed an issue with models when using a multi-buffered render setup. This should have no effect on OpenGL-based rendering, but is important for console and vulkan adapters.

FIX: (#8496) Fixed an issue where attempting to use IndexedDB when it is prohibited prevents game loading in HTML5.
Fixed an issue where, in some rare cases, if IndexedDB usage is restricted, users may encounter the “Assertion failed: IDBFS used, but IndexedDB not supported” error.

FIX: (#8493) Fix for crash caused by ray casting followed by deletion of the object
Fixed a crash that occurs if physics.raycast_async() is called in the on_message() function and then the object is deleted immediately.

FIX: (#8305) add “Support texture handles in render.enable_texture” mention to API documentation
For now there is no mention to support handles except a rendertarget handle:

But since 1.4.6 we have support texture handles:

-- in a regular gameobject script:
local my_texture_info = resource.get_texture_info("/my_atlas.a.texturesetc")
msg.post("@render:", "set_my_texture", { handle = my_texture_info.handle })

-- in a render script:
function update(self, dt)
    render.enable_texture(0, self.my_texture)
end

function on_message(self, message_id, message)
    if message_id == hash("set_my_texture") then
        self.my_texture = message.handle
    end
end

FIX: (#8544) Send sound_done or sound_stopped messages only if the sound is played using msg.post with the play_id parameter.
The sound component will send sound_done and sound_stopped messages only if msg.post() is used with the play_id parameter, as in msg.post("#sound", "play_sound", {play_id = 1}).

FIX: (#8551) Fixed an issue where bob.jar did not delete some temporary folders after the bundling process was completed.
Fixed an issue where, in some cases, bob.jar did not delete temporary folders. This could quickly fill up the disk on a CI machine.

FIX: (#8552) Support sampler names in render.enable_texture
Added support for enabling and disabling a sampler by a string or hash in a render script:

render.enable_texture(unit|name|hash, texture)
render.disable_texture(unit|name|hash, texture)

Previously a texture could only be bound to the renderer by texture units, which could cause issues when certain graphics adapters optimizes away unbound textures. With this new functionality, you can bind the same textures to multiple sampler names, which will be bound to the matching sampler name by the renderer when draw calls are issued:

render.enable_texture("my_global_texture", self.tex0)
render.enable_texture("some_other_sampler", self.tex0)
render.enable_texture("a_third_sampler", self.tex0)

It’s however recommended that you use the same sampler name for all samplers in this case, this example just illustrates that it is possible to do so!

FIX: (#8582) Crash fixes for the GDC tool
Fixed an issue where the GDC tool would crash immediately after starting. This is due to recent changes to our platform layer.

FIX: (#8567) Fixed rendering of untextured sprites in the editor
Untextured sprites now show up in the editor viewport as long as their shader renders something.

FIX: (#8569) Added support for sprite to not have a texture assigned
This fixes an issue where the engine crashed if the sprite had no textures at all.
Now, the UV coordinates will encompass the entire sprite (since it has no atlas).

FIX: (#8579) Check that texture width and height is valid before creating texture
Calling resource.create_texture() with a width and/or height of zero crashed the engine. This change will check that the width and height are valid and throw a Lua error otherwise.

FIX: (#8583) Use correct material tag for mesh components
Fixed an issue where the wrong material tag was using when producing render lists.

FIX: (#8591) Add retry_count and retry_time settings to the game.project file in the html5 section.
Two new settings are available in the game.project file in the html5 section:

  • retry_count: how many attempts the engine makes when trying to download a file.
  • retry_time: pause in seconds before retrying file loading after an error.

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.

FIX: (#8547) Fix issues with physics.set_shape() when Allow Dynamic Transformsis on.
Fix issues with physics.set_shape() which appears when Allow Dynamic Transforms option in game.project is on.

FIX: (#8561) Fixed the way the HTML5 bundler splits and renames resource files
Instead of using names like game.arcd0 , game.arcd1 , game.arci0 for resource files in the HTML5 bundle, this fix keeps the file extension as is and adds filename counters instead: game0.arcd , game1.arcd , game0.arci . This will facilitate the use of custom server settings for files based on their filetype.

FIX: (#8547) Add arm64-osx platform to manifests
Add arm64-osx platform to release/headless manifests.
Fix js-web excludeLibs list.

Editor

NEW: (#8473) Add editor.delete_directory()

NEW: (#8510) Use async engine build in the editor
The editor now uses async build server API. This should help with timeouts for long engine builds caused by big extensions.

FIX: (#8522) Graph successor memory optimizations
Large projects with a lot of connections will now use significantly less memory.

FIX: (#8531) Hide texture formats and texture compressions from *.textures_profiles that are currently not supported.
All the unsupported texture formats and texture compressions are hidden from *.texture_profiles.

FIX: (#8563) Properly validate sprite texture assignments

  • Fixes a regression where you could build the project without properly assigning textures to all samplers in the assigned sprite material.
  • Fixes an issue where the sprite animation dropdown would contain entries for the non-primary atlas if any sampler apart from the first one was assigned first.
  • Mismatches between paged and unpaged materials and textures are now properly reported as build errors for sprites.

FIX: (#8593) Paged atlas preview bugfix

30 Likes

This release has a lot of interesting stuff! Any new features or improvements we can get dealing with OpenGL or shaders are great, like custom vertex attributes on sprites.

7 Likes

I don’t know what you did, but now my sprites look better, not as blurry as in 1.6.4. Thank you

3 Likes

Thank you for this new version! One thing that I’d like to have when updating is to display to which version I’ll be updating. In this case, I’m on 1.6.4, and the update would bring me to 1.7.0, introducing breaking changes. It would be could to display the version and a link to the release notes.

6 Likes

Yeah, we want to show release notes etc as well, but we haven’t gotten to that point.

4 Likes

Another huge release! Congratulations and thank you! :heart: :confetti_ball:

5 Likes

We’ve added a new example for using vertex colors:

For those that use uniforms and (as a result) have many draw calls, can often use the vertex attribute approach to get a single draw call.

6 Likes

image
I have a few questions about this feature:

  1. Is it possible to dynamically change the size of this render target?
  2. Why are the dimensions of the stencil and depth different from the render-target itself?
  3. Where can I connect this render-target except render-script?
1 Like

Yes you can use a rendertarget resource with ∙ render.set_render_target_size(render_target,width,height)

One possibility I can see is when using texture storage for buffer/stencil and wanting to use a lower resolution, optimizing.

You can add them to .render files as resources and texture slots.

2 Likes

Thank you for VertexAttributeColor example! I’m curious, does it possible to do same with GUI elements? no idea how to pass values like go.set(url, "mycolor", vmath.vector4(r, g, b, 1)) to gui node. I’m trying to innovate on this “workaround” case: GUI add tint effect to image.

2 Likes

It is only supported for sprites currently. I’m not sure if we will add it to gui since we want to migrate Gui into the regular gameobject world

7 Likes

Is it possible to read data directly from render target now?

Not yet no, what is the use case? Don’t think I’ve seen a feature request about that :thinking:

One thing I want to be able to do is to easily be able to render scenes and use them in other scenes. So think of units in an RTS like Warcraft 3 where you click a unit and see a 3D portrait in the GUI.

Or Dota Underlords where you have a variety of 3D objects rendering above/within GUI.

1 Like

Yeah, I guess that’s the reason they want to migrate GUI to gameobject world

Usually it’s something that solves using a render target: you render what you need from the needed camera into a render target and then show it in GUI.

RT as resource should help with that.

I think @d954mas has done something like this in his new game.

3 Likes

Yes, i have it. Idea is simple. Draw 3d model in render target. Then use that render target in gui material as texture.

1)Make attlas with model rect.


2)Use this atlas at gui

3)Make a material for that gui.
gui_3drt.fp

varying mediump vec2 var_texcoord0;
varying lowp vec4 var_color;

uniform lowp sampler2D texture_sampler;
uniform lowp sampler2D rt_target;

void main()
{
    lowp vec4 tex0 = texture2D(texture_sampler, var_texcoord0.xy);
    lowp vec4 tex1 = texture2D(rt_target, var_texcoord0.xy);
    //not worked texture_sampler will be discard
    //rt_target now is texture 0. Shoud be texture 1
    //gl_FragColor = tex1;

    //use texture_sampler so texture index not changed.
    gl_FragColor = tex0 * 0.00 + tex1;
}

4)Draw model to render target. Use quad of atlast where that image should be.

function Render:set_3d_rt_atlas(atlas)
	local texture = hash(atlas.texture)
	local texture_info = resource.get_texture_info(texture)
	local w, h = texture_info.width, texture_info.height

	local data_by_id = {}

	for i = 1, #atlas.animations do
		local anim = atlas.animations[i]
		local gem = atlas.geometries[i]
		data_by_id[anim.id] = { animation = anim, geometry = atlas.geometries[i],
								x = gem.uvs[1], y = h - gem.uvs[2], w = anim.width, h = anim.height
		}
	end
	self.gui_3d_rt_atlas = {
		atlas = atlas,
		texture = texture,
		w = w, h = h,
		data_by_id = data_by_id
	}

end

function Render:draw_3d_for_gui()
	if self.gui_3d_rt_atlas then
		local image = self.gui_3d_rt_atlas.data_by_id["player_model"]
		if not self.gui_3d_rt then
			self.gui_3d_rt = create_3d_gui_buffer(self.gui_3d_rt_atlas.w, self.gui_3d_rt_atlas.h)

			self.rt_camera.view = vmath.matrix4_look_at(vmath.vector3(0, 1, 3), vmath.vector3(0, 1, 0), vmath.vector3(0, 1, 0))
			self.rt_camera.projection = vmath.matrix4_perspective(math.rad(60),image.w/image.h,0.01,100)
		end

		render.set_view(self.rt_camera.view)
		render.set_projection(self.rt_camera.projection)

		render.set_render_target(self.gui_3d_rt)
		render.set_viewport(image.x, image.y, image.w, image.h)

		render.enable_state(render.STATE_BLEND)
		render.clear(self.clear_rt)
		render.draw(self.predicates.player_3drt, self.draw_opts_no_frustum)
		render.draw(self.predicates.model_3drt, self.draw_opts_no_frustum)
		render.disable_state(render.STATE_BLEND)

		render.set_viewport(0, 0, self.screen_size.w, self.screen_size.h)
		render.set_view(self.camera_view)
		render.set_view(self.camera_perspective)
		render.set_render_target(render.RENDER_TARGET_DEFAULT)
	end

end

function Render:update()
...
	if self.gui_3d_rt then
		render.enable_state(render.STATE_STENCIL_TEST)
		render.enable_texture("rt_target", self.gui_3d_rt)
	end
	render.draw(self.predicates.gui)
	if self.gui_3d_rt then
		render.disable_texture("rt_target")
		render.disable_state(render.STATE_STENCIL_TEST)
	end
...
end

5)It worked

8 Likes

You can use named samplers now instead of relying to texture unit indices :+1:

5 Likes

Usecases will be more obvious with upcoming compute shaders support, you will need to pass render results to kernel (e.g. render models with textures to render target and pass this color data for raytracing to apply shadows) :thinking:
Actually it can be done reverse way - pass raytracing shadows data to render and combine with textures there… but probably passing normals and positions will speed up the raytraycer - as you need to trace only secondary (reflected) rays… I am not an expert here.