Depth bias is no longer hardcoded in the shader and can now be customized by setting light_and_shadows.depth_bias or in the sun object. What’s this? To reduce the Peter Panning effect (shadows detaching from objects) in shadow mapping, you need to adjust the shadow bias, a value that offsets the shadow depth. Too high a bias causes Peter Panning, while too low a bias leads to shadow acne.
A new Tinyworld example has been added. It uses tilemap, pixelart textures, billboard sprites and different material variants.
A steady 60 FPS with 4GB RAM and integrated Intel HD Graphics 4600 on a corei5 running Linux. Very nice work! Once I got to around 700 objects, it stuttered briefly to 59 FPS, but then reverted back to 60.
If anyone gets this error with the arena1.collection on main branch, remove the three decor1.go inside walls game object. I’m not sure if this is Linux only issue.
@Dragosha ,
When I run this project on Linux it does run. However I get these warnings:
WARNING:GAMESYS: Material /examples/tinyworld/materials/model_instanced_nearest.materialc has specified a vertex constant named 'mtx_world', but it does not exist or isn't used in any of the shaders.
WARNING:GAMESYS: Material /examples/tinyworld/materials/shadow_mesh/model3.materialc has specified a vertex constant named 'mtx_world', but it does not exist or isn't used in any of the shaders.
Why do these warnings occur? I think that mtx_world is automatically created, and it is used.
Is it to do with set_camera_world() ?
(comment in the readme file noted:-)
Also in the vp:
// When 'mtx_world' and 'mtx_normal' is specified as attributes,
// instanced rendering is automatically triggered.
#ifndef EDITOR
in highp mat4 mtx_world;
in highp mat4 mtx_normal;
#endif
uniform vs_uniforms
{
#ifdef EDITOR
highp mat4 mtx_world;
#endif
highp mat4 mtx_view;
highp mat4 mtx_proj;
highp mat4 mtx_light;
};
Please can someone explain details (or point me at info source, which probably I should of found myself!) of what is occurring with instanced rendering, and why the difference is required in the editor.
This is an amazing example and it opens up a shed load of questions:-)
This is done because the editor currently does not display smooth a large number of models with instancing enabled (the matrix in highp mat4 mtx_world; at the input to the shader as an attribute enables instancing, and this matrix in the uniform block is the opposite disables instancing ). Therefore, instancing in the shader is disabled in the editor, but in realtime it is enabled.
Just ignore these warnings, they don’t affect anything.
Yes, this appears to be a workaround for the fact that the editor currently slows down to a crawl when it attempts to display models that use these matrix attributes. We hope to have this performance degradation fixed really soon, and you should no longer need these #ifdef EDITOR blocks.
An important note regarding the Depth Of Field effect. By default, sprites do not write information to the depth buffer, so the blur effect will not be calculated correctly for them. If you want to add an effect to a scene with sprites, then you need to enable render.set_depth_mask(true) for sprite predicates. For example (this is a render script):
render.set_depth_mask(true) -- sprites/tilemap for correct DepthOField effect should write to the depth buffer
render.draw(predicates.bgtile, draw_options_world)
render.draw(predicates.atile, draw_options_world)
render.draw(predicates.tile, draw_options_world)
render.draw(predicates.particle, draw_options_world)
render.set_depth_mask(false)
render.disable_state(graphics.STATE_DEPTH_TEST)
You also need to enable the discarding of semitransparent pixels in the shader to work correctly. By default, it is commented out in the shader here:
if(color.a < 0.1) discard; the value of the alpha channel after which discard should be made should be selected based on the graphics of the project, how smooth the edges of objects should be, dark or light graphics in general, etc. For pixelart, alpha <1.0 = discard is usually used.
The level editor demo has been updated. It works on a mobile device, but it is recommended to open it on a computer to create your own level.
There are several ready-made templates (selectable in the settings menu).
FXAA, DoF, and all the same features as in the latest version of Light and Shadows.
Editor shortcuts:
Tab - switches between editor and view modes.
SPACE - opens the object palette.
SHIFT switches to moving the object along the Y-axis.
Z, X - moves the object only along the axes.
ALT - clones an object or a group of objects.
Clicking with R held down - draws a road.
After selecting an object on the map, use the mouse wheel (or double-tap on the right side of the touchpad on a MacBook) to quickly change the object from the list. +SHIFT - rotates the object.
Selecting with CTRL - selects a group of objects. You can move a group of objects around the level.
Nothing serious, just updated the billboard shader for sprites. Now they work correctly with any initial size and rotation. Requires a new version of Defold 1.12.3 to work.