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

Handle multiple sets of feature Ids in ModelExperimental #10007

Closed
ptrgags opened this issue Jan 13, 2022 · 0 comments · Fixed by #10018
Closed

Handle multiple sets of feature Ids in ModelExperimental #10007

ptrgags opened this issue Jan 13, 2022 · 0 comments · Fixed by #10018

Comments

@ptrgags
Copy link
Contributor

ptrgags commented Jan 13, 2022

Overview

Right now, ModelExperimental only uses feature IDs for the following:

However, we also want to support the following:

  • consistent method for referencing feature IDs. Each primitive has a list of feature ID sets (some from attributes, some from an implicit range, some from a texture). in the API "feature ID n" or "instance feature ID n" should refer to the n-th entry in these lists of feature IDs
  • multiple feature IDs in custom shaders. This should be seamless, the user shouldn't need to worry about texture reads
  • Longer term, having the feature IDs accessible will be an important prerequisite for GPU Metadata Property Table Packing for 3D Tiles Next #9572 and Model: GPU Styling #9944

Here are some initial notes of things that'll need to be updated. There's likely more details to consider as I implement this.

#9884 should be addressed first, then this issue.

CustomShader

  • Add parsing logic for [fv]sInput.featureIds.(featureId|instanceId)_(\d+)
  • featureId_n corresponds to a position within a primitive's featureIds array
  • instanceId_n corresponds to a position within the instance's featureIds array

FeatureIdPipelineStage

  • Maybe split into a ActiveFeaturePipelineStage and FeatureIdPipelineStage
  • Move this stage earlier in the pipeline
  • Change this stage to process all feature IDs
  • Generate implicit attributes and use a prefix in the shader
  • Add a FeatureIds dynamic struct
  • Attributes: featureIds.(feature|instance)Id_n = a_featureId_m
  • Implicit attributes: featureIds.(feature|instance)Id_n = a_implicitFeatureId_m
  • Textures (FS only): featureIds.(feature|instance)Id_n = floor(texture2D(FEATURE_ID_TEXTURE, FEATURE_ID_TEXCOORD).FEATURE_ID_CHANNEL * 255.0 + 0.5);

CustomShaderPipelineStage

  • Add FeatureIds to vsInput and fsInput
  • Warn if a texture feature ID is used in the vertex shader

ModelExperimental

  • Replace featureIdAttributeIndex, featureIdTextureIndex with featureIdIndex and instanceFeatureIdIndex

ModelExperimentalFS

  • Add a note that Feature feature; is global-scoped because of its use in picking (maybe also wrap in a #ifdef clause?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant