Repository
<p dir="auto"><span><a href="https://github.com/godotengine/godot" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/godotengine/godot
<p dir="auto"><span><img src="https://images.hive.blog/768x0/https://raw.githubusercontent.com/godotengine/godot/master/logo.png" srcset="https://images.hive.blog/768x0/https://raw.githubusercontent.com/godotengine/godot/master/logo.png 1x, https://images.hive.blog/1536x0/https://raw.githubusercontent.com/godotengine/godot/master/logo.png 2x" />
<p dir="auto">Here is an array of bug fixes/improvements that I have made to the Godot engine in the last two weeks.
<h3>Bug Fixes
<h5>1. Culling: <a href="https://github.com/godotengine/godot/pull/29236" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PR -- <a href="https://github.com/godotengine/godot/issues/27900" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Issue
<p dir="auto">This issue arose in our GLES2 (lower end) backend. When a user gave an object a negative scale, the object was rendered inside out.
<p dir="auto">The fix required doing two things. One was tracking whether the scale was negative or positive. Which is done <a href="https://github.com/godotengine/godot/blob/197b65f32ac811f79bc5599fbfe8cf83914b6873/drivers/gles2/rasterizer_scene_gles2.cpp#L1051" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here.
<p dir="auto">And the other was updating the culling code to accurately flip when needed. Which is done <a href="https://github.com/godotengine/godot/blob/197b65f32ac811f79bc5599fbfe8cf83914b6873/drivers/gles2/rasterizer_scene_gles2.cpp#L1265-L1285" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here.
<p dir="auto">A bonus is that now the culling state only changes when necessary. This should result in slightly improved rendering times especially on complex scenes.
<h5>2. Radiance Map <a href="https://github.com/godotengine/godot/pull/29182" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PR -- <a href="https://github.com/godotengine/godot/issues/21680" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Issue1, <a href="https://github.com/godotengine/godot/issues/27422" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Issue2
<p dir="auto">The next bug came from the way that reflection maps were calculated from the environment map. For some reason, when using HDR environment maps, reflections on objects would look like fireworks were going off (see below).<br /><span>
<img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmSHzcg7zgvGkFeuWtYkthUWCFPHxh24mKTokARfnzP6MU/54962150-27f4d400-4fa7-11e9-9aaf-e1e5bcba1f8a.png" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmSHzcg7zgvGkFeuWtYkthUWCFPHxh24mKTokARfnzP6MU/54962150-27f4d400-4fa7-11e9-9aaf-e1e5bcba1f8a.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmSHzcg7zgvGkFeuWtYkthUWCFPHxh24mKTokARfnzP6MU/54962150-27f4d400-4fa7-11e9-9aaf-e1e5bcba1f8a.png 2x" />
<p dir="auto">It look a lot of searching and experimentation to realize that the issue was with the quality setting. The code for determining quality was accidentally using the mobile setting in place of the desktop setting. For many rendering features Godot defaults to a low-quality version for mobile unless you specify to force high-quality on mobile. In this case, unless you specified to force high-quality on mobile, you would get low-quality even on a desktop that had high-quality enabled.
<p dir="auto">With the improved quality I was able to reduce the default size of the reflection maps (increase rendering speed while decreasing memory usage), while maintaining improved visual quality.
<h5>3. Fog <a href="https://github.com/godotengine/godot/pull/29141" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PR -- <a href="https://github.com/godotengine/godot/issues/26235" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Issue
<p dir="auto">In the GLES2 backend the environmental fog was affecting materials that were set to be "unshaded" including in-editor gizmos. "Unshaded" specifies that environment effects (and light) should not affect the object.
<p dir="auto">The issue here turned out to be that a compile-time define using <code>#ifdef ... #endif was misplaced and was accidentally including fog code when it should not have.
<h5>4. No Depth test + render priority <a href="https://github.com/godotengine/godot/pull/29132" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PR -- <a href="https://github.com/godotengine/godot/issues/29108" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Depth Issue, <a href="https://github.com/godotengine/godot/issues/27739" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Priority Issue
<p dir="auto">This one is actually two bugs combined into one.
<p dir="auto">Bug 1 resulted in objects with a particular setting (no depth test) being drawn behind the background unless they were in front of another object.
<p dir="auto">The solution was to specify that objects drawn without depth testing be drawn after all other opaque objects are drawn (e.g. with the transparent objects). This way they would always be drawn over things like the sky (which is what you expect when you select "no depth test").
<p dir="auto">Bug 2 resulted from the sorting algorithm not correcting taking into account the user set priority of objects. Priority is used to specify the order in which transparent objects are drawn. The solution was just to sort by depth and priority instead of just by depth
<h3>New Features
<p dir="auto"><strong>MultiMeshInstance2D<br /><br />
Related Issues: <a href="https://github.com/godotengine/godot/issues/28304" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">related bug, <a href="https://github.com/godotengine/godot/issues/29407" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">enhancement suggestion<span>
PR: <a href="https://github.com/godotengine/godot/pull/29411" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/godotengine/godot/pull/29411
<p dir="auto">The MultiMeshInstance2D takes advantage of hardware instancing to draw thousands of objects using one draw call. Instead of drawing each mesh one for every instance you can specify all instances in a large array and submit it to the GPU all at once. This significantly speeds up rendering by reducing the amount of CPU time spent on draw calls and reducing the amount of memory transfer between CPU and GPU.
<p dir="auto">The implementation required that I add a new node entirely that can be accessed when using the 2D renderer. The implementation is very similar to the way that the MultiMeshInstance works in 3D and the way MeshInstance2D works in 2D.
<p dir="auto">In order to get it to work I had to fix a couple related bug. One (linked to above), resulted when users compiled without 3D support but still used a MeshInstance2D. In order to fix this, I had to ensure that the Mesh class was included when compiling without 3D.
<p dir="auto">The second related bug was in the shader code. In the shader code there was a variable that did not get properly initialized under some compile conditions. It would have caused the shaders to crash when the program started.
<pre><code>#ifdef USE_INSTANCE_CUSTOM
attribute highp vec4 instance_custom_data;
#endif
...
// if USE_INSTANCE_CUSTOM is false, then the following line would cause the shader to crash
vec4 instance_custom = instance_custom_data;
<pre><code>// therefore, replace with the following as "instance_custom" still needs to be used
#ifdef USE_INSTANCE_CUSTOM
vec4 instance_custom = instance_custom_data;
#else
vec4 instance_custom = vec4(0.0);
#endif
<p dir="auto">The last bug was caused by colors for MultiMeshes not initialized in GLES2 leading objects to be rendered completely black. This was fixed by properly initializing the instance colors using a call to <code>glVertexAttrib
<pre><code>glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, 1.0, 1.0, 1.0, 1.0);
<h4>GitHub Account
<p dir="auto"><span><a href="https://github.com/clayjohn" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/clayjohn
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @helo! Keep up the good work!
Hey, @clayjohn!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
SteemPlus or Steeditor). Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Hi @clayjohn!
Feel free to join our @steem-ua Discord serverYour post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation! Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Congratulations @clayjohn! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!