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

Feat: Materials #79

Merged
merged 14 commits into from
May 30, 2023
Merged

Feat: Materials #79

merged 14 commits into from
May 30, 2023

Conversation

mikhail-dcl
Copy link
Collaborator

@mikhail-dcl mikhail-dcl commented May 29, 2023

Closes #37

  • Finalized "textures loading" as they were required for Materials, and the implementation of the latter revealed the flaws of the former
  • Added a group of systems for Materials processing:
    • Created a cache that stores the instances of the Material based on the material data. Potentially it will help if the same material setup is used in a scene, and less likely across scenes
    • Creation of the material "key" is separated from the loading so different systems can consume it
    • "Basic" and "PBR" Material systems are separated
    • Clean-up Material system takes care of Materials which entities are dying
    • Loading material lies in textures promises (entities) creation
    • Constructing material consists of waiting for them, instantiating the final instance and setting all required parameters to the material
    • Apply Material System will apply materials to the renderers but Primitives PR should be merged first
  • A step towards a prod-ready scene setup made:
    • Scenes can be loaded from the folder with their dependencies (like textures)
    • ContentProvider is added to take care of permissions and URLs translation
    • Scene Launcher is modified to support directories instead
    • In the future, the same abstraction setup will be used to load scenes from realms
  • Added an ECS Plugins Concept:
    • Instead of registering everything in the single factory, multiple plugins should be used
    • Each plugin can contain a set of individual non-exposed dependencies that are used inside that plugin only
    • Each plugin registers systems of its scope based on the private and shared dependencies
      • E.g. Material Cache is a private dependency
      • ContentProvider and Entities Map are shared dependencies
      • This structure has a perfect fit as all intersystem communication happens via Components so no other scoped dependencies are necessary to share in any case
  • Refactored Assemblies definition to decrease their number and make the setup simpler

Copy link
Collaborator

@dalkia dalkia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR. Left some comments/questions, but overall it looks good to me

HandleQuery(World);
}

[Query]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ve seen you started using queries without descriptors. Is this intentional? Wouldnt this query all components in the ECS world?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default the types corresponding to the arguments are included to the query, it will not query all entities

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what you are saying, the All descriptor is not necessary when params are present in the method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

if (!entityReference.IsAlive(World))
return;

World.Destroy(entityReference);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about adding a DeleteEntityIntention, and have just one system destroy everything that needs to be destroyed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea, we still don't have a system to destroy entities?! Do we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it further, and I will leave it as is:

  • DeleteEntityIntention is really good for SDK Components as we don't drive their life-cycle
  • Structural changes are expensive and I would like to avoid them when possible
  • In this case, the loading process is fully finished to this moment so we need to read data and destroy the entity, it does not make much sense to postpone it.
  • The clean-up itself is signaled by ForgetLoadingIntent, otherwise clean-up should happen in ConcludeLoadingSystem

# Conflicts:
#	Explorer/Assets/Scenes/SampleScene.unity
#	Explorer/Assets/Scripts/CrdtEcsBridge/Tests/CRDT.ECS.Bridge.Tests.asmdef
#	Explorer/Assets/Scripts/ECS/ComponentsPooling/Tests/ComponentsPooling.Tests.asmdef
#	Explorer/Assets/Scripts/SceneRunner/ECSWorld/ECSWorldFactory.cs
return true;
}

Debug.LogError($"{nameof(SceneContentProvider)}: {url} not found in {nameof(fileToHash)}");
Copy link
Collaborator

@m3taphysics m3taphysics May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss how logging should be handled in the PoC - one major issue now is that we have nothing to distinguish between user error (from the scenes themselves) and errors that we should fix. Leading to millions of partially ignored errors! Ideally for performance we should not even have logging at runtime?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss

@mikhail-dcl
Copy link
Collaborator Author

mikhail-dcl commented May 30, 2023

Known limitation:
#80 - found a solution

Get rid of MaterialsCache as it performed very bad
@mikhail-dcl mikhail-dcl merged commit ec89eaf into main May 30, 2023
@mikhail-dcl mikhail-dcl deleted the materials branch May 30, 2023 20:14
Kinerius pushed a commit that referenced this pull request Feb 20, 2024
* Introduce Materials and textures loading
* Add Scene Content Provider and loading from the directory
* Simplify asm distribution
* Change Launcher to use Directories
* Change default Shader to DCL
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

Successfully merging this pull request may close these issues.

Materials and Textures Loading
3 participants