Defold 1.2.100 has been released

Defold 1.2.100

This release includes some Spine fixes, better multi touch support and some new native extension functionality.

We’ve also done some cleanup in our shaders, with regards to unused constants.

Multi touch

We have reworked the internal handling of touch inputs on devices, and fixed a number of issues along the way. We’ve introduced a new field id in the action.touch table, which allows you to more easily track touches.

Model matrices and built in material changes

Due to CPU batching of rendering primitives, the world space transformation is done on the CPU side. We have removed unused instances of ‘world’ matrices in the built in shaders and materials to avoid confusion and also state in the shaders that positions are in world space. In the process, we also removed som other unused shader varying variables that were transported from vertex to fragment shader.

Spine

We’ve fixed a few issues with our Spine support, regarding keyable draw order and discrete sampling of frames.

buffer Lua API

We’ve added a new Lua module named buffer. This new module allows the user to create and manipulate buffers directly from Lua. Buffers are used to communicate larger data between Lua and native extensions. E.g. camera or video frame buffers. See the documentation for some example on how to set a texture dynamically on a sprite.

Native Extensions

Due to some needed refactoring because of the new buffer module, we had to revise some of the functions exposed in the sdk. We feel it’s much more clean and robust now, and it was necessary for us in order to move forward. Although this feature is still in an alpha stage, we aim to keep our sdk stable. In case you are one of the early adopters, please visit the dmBuffer documentation for the relevant changes.

Documentation

Big thanks to all of you for reporting documentation issues directly on the documentation pages! It works really well. It’s easy to keep track of and fix quickly. If you wish to help, look at the bottom right of the documentation pages, and click the button labelled “Spotted an error?” and submit your issue/suggestion.

Engine

  • DEF-2483 - Added: Added buffer Lua module for creating buffers and manipulating streams
  • DEF-1217 - Fixed: Spine keyable draworder
  • DEF-1688 - Fixed: Fixed issue of not flushing all purchases on Google Play after reconnecting to wifi
  • DEF-2024 - Fixed: Multi touch gave inconsistent input messages
  • DEF-2500 - Fixed: Extensions are now only initialized once
  • DEF-2519 - Fixed: CONSTANT_TYPE_WORLD is set to the identity matrix for model components
  • DEF-2538 - Fixed: When issue of last sound having gain 0, muted all audio
  • DEF-2547 - Fixed: Removed unused shader constants from builtin shaders
  • DEF-2554 - Fixed: Detect configuration change and reenable immersive mode
  • DEF-2558 - Fixed: Fix discrete sampling midpoint calculation in Spine animations
  • DEF-2561 - Fixed: Handling reset keys for spine draw order offsets
  • DEF-2565 - Fixed: Debug rendering for circles in 2D physics
  • DEF-2568 - Fixed: Typo fix for dmGraphics::GetNativeiOSUIWindow

Documentation

  • Added examples for gui scripts
  • Lots of minor fixes
21 Likes

If one were using 3D models, and now the models are not appearing after this update. What does one need to do?

I was using the tutorial code for 3D models, and here is my render script:

function init(self)
    self.tile_pred = render.predicate({"tile"})
    self.gui_pred = render.predicate({"gui"})
    self.detached_gui_pred = render.predicate({"detached_gui"})
    self.text_pred = render.predicate({"text"})
    self.particle_pred = render.predicate({"particle"})
    self.model_pred = render.predicate({"model"})
	
    self.clear_color = vmath.vector4(0, 0, 0, 0)
    self.clear_color.x = sys.get_config("render.clear_color_red", 0)
    self.clear_color.y = sys.get_config("render.clear_color_green", 0)
    self.clear_color.z = sys.get_config("render.clear_color_blue", 0)
    self.clear_color.w = sys.get_config("render.clear_color_alpha", 0)

    self.view = vmath.matrix4()
    
    
end

function update(self)
    -- Set the depth mask which allows us to modify the depth buffer.
    render.set_depth_mask(true)
    -- Clear the color buffer with the clear color value and set the depth buffer to 1.0.
    -- The normal depth values are between 0.0 (near) and 1.0 (far) so maximizing the values
    -- throughout the buffer means that every pixel you draw will be nearer than 1.0 and thus
    -- it will be properly drawn and depth testing will work from thereon.
    render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})

	
    -- Set the viewport to the window dimensions.
    render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
    -- Set the view to the stored view value (can be set by a camera object)
    render.set_view(self.view)

	-- Render 2D space
    render.set_depth_mask(false)
    render.disable_state(render.STATE_DEPTH_TEST)
    render.disable_state(render.STATE_STENCIL_TEST)
    render.enable_state(render.STATE_BLEND)
    render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
    render.disable_state(render.STATE_CULL_FACE)

	 -- Set the projection to orthographic and only render between -1 and 1 Z-depth
    render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1))

    render.draw(self.tile_pred)
    render.draw(self.particle_pred)
 

    -- Render 3D space, but still orthographic
    -- Face culling and depth test should be enabled
    render.enable_state(render.STATE_CULL_FACE)
    --render.set_cull_face(render.FACE_FRONT)
    render.enable_state(render.STATE_DEPTH_TEST)
    render.set_depth_mask(true)
    render.draw_debug3d()
    
		
    render.set_view(vmath.matrix4())
    --render.set_projection(vmath.matrix4_orthographic(0, w, 0, h, -1, 1))
    render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
    
    render.set_view(self.view)
    render.set_projection(self.projection)
    
    render.draw(self.model_pred)
 	render.draw(self.detached_gui_pred)	-- draw the detached gui with the same view and projection as the game object sprites etc
  
	-- Render the GUI last
	
	render.disable_state(render.STATE_CULL_FACE)
    render.disable_state(render.STATE_DEPTH_TEST)
    render.set_view(vmath.matrix4())
    render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
    render.enable_state(render.STATE_STENCIL_TEST)
    render.draw(self.gui_pred)
    render.draw(self.text_pred)
    render.disable_state(render.STATE_STENCIL_TEST)
    render.set_depth_mask(false)
    render.draw_debug2d()
    
end

function on_message(self, message_id, message)
    if message_id == hash("clear_color") then
        self.clear_color = message.color
    elseif message_id == hash("set_view_projection") then
    	-- Camera view and projection arrives here. Store them.
        self.view = message.view
        self.projection = message.projection
    end
end

Do you have any custom material set on your models? Verify they don’t use a world matrix.

1 Like

I think that the materials manual has an example shader that uses the world matrix. I have to fix that.

2 Likes

For the new table of mutli touch inputs (action.touch) only the x and y values are available, but not screen_x and screen_y.

The action object itself still has the screen_x and screen_y value, but it seems to always correspond to the first item in the action.touch table. Can this be added for all items in action.touch?

4 Likes

Very good point, nicely spotted! I’m adding an issue for it; DEF-2582

3 Likes

I deleted the “world” vertex constant from the .material file and code from the .vp file, now it works. Thank you.

5 Likes