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

Allow selection of different materials based on metadata properties #771

Open
nithinp7 opened this issue Mar 2, 2022 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@nithinp7
Copy link
Contributor

nithinp7 commented Mar 2, 2022

Can be built as part of #698 or as a separate PR.

We should try to build an editor tool to auto-generate the basic outline of a metadata-styling material based on the metadata of tiles currently visible in the editor. The following steps would be needed:

  • A way to report unique metadata schema classes of currently visible tiles from a tileset.
  • For each selected, unique metadata schema class, users should be able to select specific properties that they want access to in the material.
  • This selection will be named and a material layer can be generated that resolves all the required property values into variables. This generated shader would sample the feature id texture / feature attribute to get the feature id and then use the feature id to index into the needed encoded property arrays to get the needed property values. The initially requested property values will now be ready to use in shader variables of the appropriate types.
  • Users can then edit the generated material layer with custom styling logic using the requested variables. The material layer would then be added to the tileset's custom material, with a key like "Metadata".

From what I can tell, so far this seems achievable. But this would only allow for a single styling of the metadata for an entire tileset. In reality we may have heterogeneous metadata throughout a tileset and wish (or be compelled) to style parts of the tileset differently from others. Additionally, with complicated effects like reflection, displacement, and translucency that could potentially be driven by metadata, it may be best to only apply these effects on tiles that need them. So here's a further extension of the above idea to enable that:

  • Different combinations of schema classes can be used to generate different materials, the schema to material mappings can exist in an atlas of sorts. Later when loading tiles, when a particular combination of metadata classes appear together, the corresponding material can be chosen and instantiated from the atlas.
  • Combining this material atlas idea with the existing material layers system may be a bit awkward, since each material in the atlas will need all the other same non-metadata-related material layers. Maybe we can resolve that with another automatic editor-time step that adds each auto-generated metadata layer onto a copy of a base material with existing non-metadata layers, before inserting into the metadata material atlas.

Reference for creating materials from C++:
https://isaratech.com/ue4-programmatically-create-a-new-material-and-inner-nodes/

CC: @kring what do you think? We can discuss more offline and update this issue.

@kring
Copy link
Member

kring commented May 9, 2022

The first four dot points were implemented in #698. The last two have not yet been implemented. I'll update the issue title accordingly.

@kring kring added the enhancement New feature or request label May 9, 2022
@kring kring changed the title Autogenerate metadata materials Allow selection of different materials based on metadata properties May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants