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

KHR_texture_procedurals Draft Proposal #2381

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Conversation

kwokcb
Copy link

@kwokcb kwokcb commented Apr 3, 2024

Draft Proposal for KHR_texture_procedurals

  • Specification proposal ready for initial feedback.
  • Draft JSON Schema is still progress.
  • Example assets will be forthcoming in a glTF Sample Assets branch.

@lexaknyazev lexaknyazev marked this pull request as draft April 16, 2024 16:20

## Handling MaterialX glTF PBR Nodes

The glTF PBR node specified within MaterialX exposes a number of input ports which may not map 1:1 with the glTF PBR material
Copy link
Author

Choose a reason for hiding this comment

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

Currently there is no way to do a proper mapping for metallic and roughness. Should a separate mapping for metallic and roughness be proposed. Should the MaterialX glTF PBR node be updated ?


More specifically __only__ nodes defined in the MaterialX specification are supported. This ensures that the procedural graphs can be easily converted to MaterialX and USDShade graphs.

For the first version of this extension nodes which are used to define shading models are not allowed. Please refer to the [resources](#resources) section for links to supported MaterialX node definitions.
Copy link

Choose a reason for hiding this comment

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

For the first version of this extension....
I do not understand this statement - this extension concerns creating images from operators/functions, instead of stored pixel values.
Where do shading models fit into this?

I propose to remove this statement.


### Motivation

Textures represented as procedural graphs provides a way to extend the capabilities of glTF materials beyond what is possible with traditional texture maps. Key objectives includes:
Copy link

Choose a reason for hiding this comment

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

Please reword to:
Images represented as procedural operators or functions provides a way to extend the capabilities of glTF textures beyond what is possible with bitmap based images.


1. **Interoperability**: Adhere to an industry a standard node schema (MaterialX) with a runtime friendly JSON representation.

More specifically __only__ nodes defined in the MaterialX specification are supported. This ensures that the procedural graphs can be easily converted to MaterialX and USDShade graphs.
Copy link

Choose a reason for hiding this comment

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

This ensures that the procedural graphs can be easily converted to MaterialX and USDShade graphs.

I don't see this as the goal for the extension - the goal is to create an agnostic way to store procedural images - that can then be used as texture sources in glTF.


For the first version of this extension nodes which are used to define shading models are not allowed. Please refer to the [resources](#resources) section for links to supported MaterialX node definitions.

2. **Fidelity**: Provide the ability to generate complex patterns, noise, or other effects that currently must be "baked" into texture maps. Provide the ability to provide mappings from one shading model to another without baking in a consistent manner via procedural graphs. Provide the ability to map procedurals graphs to unlit materials. Reduces runtime memory usage by generating patterns / shading programmatically.
Copy link

Choose a reason for hiding this comment

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

I propose something along the lines of:

Provide the ability to generate procedural patterns, noise or other visual effects of sufficiently high fidelity to replace the use of pixel (bitmap) based images.
Reduce the transfer size by generating images, either at load- or run-time.


2. **Fidelity**: Provide the ability to generate complex patterns, noise, or other effects that currently must be "baked" into texture maps. Provide the ability to provide mappings from one shading model to another without baking in a consistent manner via procedural graphs. Provide the ability to map procedurals graphs to unlit materials. Reduces runtime memory usage by generating patterns / shading programmatically.

3. **Editability and Extensibility**: Extend runtime editability by exposing logic and interfaces for procedural graphs as well as providing a means to create new or extend existing node definitions.
Copy link

Choose a reason for hiding this comment

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

This is not the goal of this extension - this extension should simply reference already existing operators/functions and provide a means to store them with a glTF asset.


### Material Binding

To connect a graph `output` to a surface or displacement shader input the procedural extension can be declared within the a texture reference for a given material in the `materials` array.
Copy link

Choose a reason for hiding this comment

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

I propose to simply connect the procedurals to an image in the imagesarray - if this image is created at load time or dynamically created at runtime is up to the implementation.

</details>


### Procedural Definitions
Copy link

Choose a reason for hiding this comment

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

I propose a solution where the procedural image extension uses a set of already declared operators/functions.
These functions are what are available, if need for future additions that will need to be done in a separate extension.

The upside of having pre-declared operators is that its straightforward to do implementation testcases to verify if an implementation is compliant or not.
Ie, for each operator there are a number of testcases that provides input data and are used to validate the output.

The total amount of operators needed is not that large, probably around 20, maybe even less.

Copy link

Choose a reason for hiding this comment

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

For a non complete comparison - have a look at what we specified in the Ikea procedural prototypes
This is not the complete declaration but it's enough to show the differences in design:

https://github.com/idlabs/procedural-image

@rsahlin
Copy link

rsahlin commented Jul 9, 2024

Food for thought!

Perhaps it's better to make this into a vendor extension (remove KHR prefix) and rename to materialx_shader_graph or something to that effect?

That way you would be able to keep the current design, if the extension receives traction it can be made into a KHR extension in the future.

What do you think?

kwokcb and others added 9 commits July 24, 2024 08:26
… comes from the nodes.

Inputs on nodes can be aniated. Further discussion on defails on existing extension required.
Explicit note N:M graph -> material bindings possible.
* KHR_materials_ior: Minor typo: plural instead of singular (#2413)

* Update anisotropy extension spec (#2409)

* Clarify and simplify formula for attenuation. (#2414)

* Add TRACE prefix (#2417)

* Update clearcoat extension spec (#2415)

* Update README. (#2427)

* Add KHR_node_hoverability (#2428)

* Add KHR_node_hoverability
* Resort extension list

* EXT_mesh_gpu_instancing: Suggest extensionRequired usage (#2405)

* Add button/link to glTF Discord (#2429)

As there is a lot more traffic to the Khronos glTF Discord than there is to Slack, a button pointing users to Discord will be helpful.

---------

Co-authored-by: Andreas Atteneder <andreas.atteneder@unity3d.com>
Co-authored-by: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com>
Co-authored-by: Ed Mackey <elm19087@gmail.com>
Co-authored-by: Marco Hutter <javagl@javagl.de>
Co-authored-by: Khronos Group Web Services <webservices@khronosgroup.org>
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: James Riordon <outofcontrol@users.noreply.github.com>
Change max from 4 to 16 for data vector so
3x3 and 4x4 matrices can be supported.
@DennisSmolek
Copy link

Perhaps it's better to make this into a vendor extension (remove KHR prefix) and rename to materialx_shader_graph or something to that effect?

The only thing I think confusing is if this is a procedural texture for generating images to act as textures in existing materials (like your edits suggest) or is this for full procedural MATERIALS.

I will say, they way it is being advertised and promoted in the blogs and talks like Siggraph is as a procedural material, particularly as a channel for MaterialX materials.

One of the major goals listed for 2025 was to maintain good relations/interoperability with USD which uses MaterialX.

The way the extension is written now is different procedural systems could be used, be it other MatX versions or future systems like THREE TSL to generate the graph.

IMO the ship has sailed on this being texture only, and as it's a core goal I think the KHR name would stick. perhaps KHR_procedural_materials or whatever is more appropriate.


PS if this is an old idea discussed elsewhere I apologize, it's hard finding the right channels to discuss these things.

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.

5 participants