Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge objects with some tiling 2d textures. #11

Open
fire opened this issue Aug 18, 2022 · 0 comments
Open

Merge objects with some tiling 2d textures. #11

fire opened this issue Aug 18, 2022 · 0 comments

Comments

@fire
Copy link
Collaborator

fire commented Aug 18, 2022

Context and Problem Statement

Want to reduce draw calls on low end hardware to improve performance.

How much do we want to backport to Godot 4 vs Godot 3 work Lawnjelly has been doing?

This should be implemented using the same API that we settle on with lawnjelly for merging meshes in 3.x. Likely it will be a node that handles automatically merging children at scene load time.

Does webgl2 support texture arrays? We know that webgl2 is slow. Yes. See Mozilla developer network entry reference at the bottom.

Does vulkan require draw call optimization? Does Vulkan benefit from this optimization?

Vulkan benefits a lot less from draw call optimizations, but it can still be helpful in complex scenes. Mesh merging is still highly relevant for GLES3 in 4.0

Can we use specialization constants?

Probably not, as they are not exposed to user-facing code. Right now they are used internally as a way of managing the number of shader permutations. I don't think they will be helpful in this context though.

Automatically generate templates.

Describe the proposed option and how it helps to overcome the problem or limitation

We can reduce draw calls by merging up to 1024? MeshInstance3D with some tiling 2d textures into one MeshInstance3D.

Describe how your proposal will work, with code, pseudo-code, mock-ups, or diagrams

Write a pipeline for the merged objects that store the data needed for a template StandardMaterial3D.

Find a place to store the layer id.

Each layer id is one mesh.

There's a uniform array that is strided with the layer id by the size of the StandardMaterial’s property length stride for properties.

Each float, vec2, vec3, vec4 uniform is replaced by a uniform array stridded by the layer.

Each sampler is replaced by a 2d texture array. 512 - 1024 - 2048 - 4096 texture 2d arrays indexed by a layer id and the texture array type enum.

Question:

How many nearest powers of two Texture Arrays do we want to support?

Support resizing non square textures?

If this enhancement will not be used often, can it be worked around with a few lines of script?

This requires changing Godot Engine shader code and syncing it. The shader does not need to be in the core.

Is there a reason why this should be core and done by us?

Can be a plugin, but can be commonly used. The shader system also constantly changes and it is very tedious to keep the Material shader synced. Should be automatically generated.

References

https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/texStorage3D
https://github.com/WebGLSamples/WebGL2Samples/blob/master/samples/texture_2d_array.html
https://github.com/sinbad/FbxUdimUnpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant