From 207021590f4b05175ef56178f11affeb3d6caac1 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Sat, 1 Jul 2023 00:00:00 +0000 Subject: [PATCH 01/42] Add KHR_interactivity intro --- .github/workflows/CI.yml | 12 + .gitignore | 2 + .../2.0/Khronos/KHR_interactivity/Makefile | 78 ++++++ .../KHR_interactivity/Specification.adoc | 224 ++++++++++++++++++ 4 files changed, 316 insertions(+) create mode 100644 extensions/2.0/Khronos/KHR_interactivity/Makefile create mode 100644 extensions/2.0/Khronos/KHR_interactivity/Specification.adoc diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 43e6e0193b..ebbcd071ee 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -38,3 +38,15 @@ jobs: path: | specification/2.0/Specification.html specification/2.0/Specification.pdf + + - name: Build interactivity extension targets + run: | + cd extensions/2.0/Khronos/KHR_interactivity + make Specification.html + + - name: Archive generated files + uses: actions/upload-artifact@v2 + with: + name: interactivity-outputs + path: | + extensions/2.0/Khronos/KHR_interactivity/Specification.html diff --git a/.gitignore b/.gitignore index 28f450d9dd..cea75e8878 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ specification/2.0/PropertiesReference.adoc specification/2.0/JsonSchemaReference.adoc specification/2.0/Specification.html specification/2.0/Specification.pdf +extensions/2.0/Khronos/**/Specification.html +extensions/2.0/Khronos/**/Specification.pdf diff --git a/extensions/2.0/Khronos/KHR_interactivity/Makefile b/extensions/2.0/Khronos/KHR_interactivity/Makefile new file mode 100644 index 0000000000..e6a471d9b2 --- /dev/null +++ b/extensions/2.0/Khronos/KHR_interactivity/Makefile @@ -0,0 +1,78 @@ +# Copyright 2020 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 + +# Output specification targets +SPEC = Specification +TARGETS = $(SPEC).html $(SPEC).pdf +all: $(TARGETS) + +# Generate the Properties Reference section of the spec from JSON schema. +# This uses 'npx' to minimally install the 'wetzel' tool, if needed. +# When using embedded schemas, SCHEMALINK should be a relative path. + +# Note this Makefile should remain locked to a particular version of +# wetzel, such that the history of changes to the documentation can +# accurately reflect changes to wetzel that impact the output here. +# Please manually upgrade the version as often as needed, without unlocking. + +WETZEL = npx wetzel@0.2.2 +SCHEMALINK = schema +EMBEDSCHEMA = JsonSchemaReference.adoc + +# Base name of the generated properties reference file +PROPREF = PropertiesReference.adoc +# Files generated by wetzel +GENERATED = $(PROPREF) $(EMBEDSCHEMA) +# Schema files to leave out of $(PROPREF) +IGNORESCHEMA = '["gltfchildofrootproperty.schema.json", "gltfid.schema.json", "gltfproperty.schema.json"]' +$(GENERATED): $(wildcard schema/*.json) + $(WETZEL) -n -a=cqo -m=a -p "$(SCHEMALINK)" -e "$(EMBEDSCHEMA)" \ + -i $(IGNORESCHEMA) -c "icon:check[]" -k "**MUST**"\ + schema/glTF.schema.json > $(PROPREF) + +# Spec targets for offline generation +# Requires an up-to-date asciidoctor, asciidoctor-pdf, and +# asciidoctor-mathematical be installed +# We recommend using the following image on dockerhub: +# docker pull khronosgroup/docker-images:asciidoctor-spec +ASCIIDOCTOR = asciidoctor $(ADOCOPTS) +ADOCOPTS = -d book +ADOCHTMLOPTS = -a stylesheet=../../../../specification/2.0/khronos.css -a sectanchors +SPECDEPS = $(SPEC).adoc #$(GENERATED) + +PATCHVERSION = 1 +SPECREVISION = 2.0.$(PATCHVERSION) + +# Spell out ISO 8601 format as not all date commands support --rfc-3339 +SPECDATE = $(shell echo `date -u "+%Y-%m-%d %TZ"`) + +# Generate AsciiDoc attributes for spec remark +# Could use `git log -1 --format="%cd"` to get branch commit date +# This used to be a dependency in the spec html/pdf targets, +# but that's likely to lead to merge conflicts. Just regenerate +# when pushing a new spec for review to the sandbox. +# The dependency on HEAD is per the suggestion in +# http://neugierig.org/software/blog/2014/11/binary-revisions.html +SPECREMARK = from git branch: $(shell echo `git symbolic-ref --short HEAD 2> /dev/null || echo Git branch not available`) \ + commit: $(shell echo `git log -1 --format="%H" 2> /dev/null || echo Git commit not available`) + +ATTRIBOPTS = -a revnumber="$(SPECREVISION)" \ + -a revdate="$(SPECDATE)" \ + -a revremark="$(SPECREMARK)" + +$(SPEC).html: $(SPECDEPS) + $(ASCIIDOCTOR) -b html5 $(ADOCHTMLOPTS) $(ATTRIBOPTS) $(SPEC).adoc -o $@ + +# :allow-url-read: is necessary for the embedded render.githubusers.com +# math images to be processed for the PDF target. See +# https://github.com/asciidoctor/asciidoctor-pdf/issues/369 +# asciidoctor-mathematical leaves intermediate images of equations behing. +# These are removed after creating the PDF. +STEMIMAGES = stem-*.png +$(SPEC).pdf: $(SPECDEPS) + $(ASCIIDOCTOR) -b pdf $(ATTRIBOPTS) -a allow-uri-read -r asciidoctor-pdf \ + -r asciidoctor-mathematical $(SPEC).adoc -o $@ + rm -f $(STEMIMAGES) + +clean: + -rm -f $(GENERATED) $(TARGETS) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc new file mode 100644 index 0000000000..d6527f955d --- /dev/null +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -0,0 +1,224 @@ +// Copyright 2013-2023 The Khronos Group Inc. +// +// SPDX-License-Identifier: CC-BY-4.0 + +// :regtitle: is explained in +// https://discuss.asciidoctor.org/How-to-add-markup-to-author-information-in-document-title-td6488.html += glTF{tmtitle} 2.0 Interactivity Extension Specification +:tmtitle: pass:q,r[^™^] +:regtitle: pass:q,r[^®^] +The Khronos{regtitle} 3D Formats Working Group +:data-uri: +:icons: font +:toc2: +:toclevels: 10 +:sectnumlevels: 10 +:max-width: 100% +:numbered: +:source-highlighter: coderay +:title-logo-image: image:../figures/glTF_RGB_June16.svg[Logo,pdfwidth=4in,align=right] +:docinfo: shared-head +:docinfodir: ../../../../specification/2.0 +:stem: + +// This causes cross references to chapters, sections, and tables to be +// rendered as "Section A.B" (for example) rather than rendering the reference +// as the text of the section title. It also enables cross references to +// [source] blocks as "Listing N", but only if the [source] block has a title. +:xrefstyle: short +:listing-caption: Listing + +ifndef::revdate[] +:toc-placement!: + +[NOTE] +.Note +==== +Khronos posts the AsciiDoc source of the glTF specification to enable community +feedback and remixing under CC-BY 4.0. Published versions of the Specification +are located in the https://www.khronos.org/registry/glTF[glTF Registry]. +==== +endif::[] + +// Table of contents is inserted here +toc::[] + +:leveloffset: 1 + +[[foreword]] += Foreword + +Copyright 2013-2023 The Khronos Group Inc. + +This specification is protected by copyright laws and contains material proprietary +to Khronos. Except as described by these terms, it or any components +may not be reproduced, republished, distributed, transmitted, displayed, broadcast, +or otherwise exploited in any manner without the express prior written permission +of Khronos. + +This specification has been created under the Khronos Intellectual Property Rights +Policy, which is Attachment A of the Khronos Group Membership Agreement available at +https://www.khronos.org/files/member_agreement.pdf. Khronos grants a conditional +copyright license to use and reproduce the unmodified specification for any purpose, +without fee or royalty, EXCEPT no licenses to any patent, trademark or other +intellectual property rights are granted under these terms. Parties desiring to +implement the specification and make use of Khronos trademarks in relation to that +implementation, and receive reciprocal patent license protection under the Khronos +IP Policy must become Adopters under the process defined by Khronos for this specification; +see https://www.khronos.org/conformance/adopters/file-format-adopter-program. + +Some parts of this Specification are non-normative through being explicitly identified as +purely informative, and do not define requirements necessary for compliance and so are +outside the Scope of this Specification. + +Where this Specification includes normative references to external documents, only the +specifically identified sections and functionality of those external documents are in +Scope. Requirements defined by external documents not created by Khronos may contain +contributions from non-members of Khronos not covered by the Khronos Intellectual +Property Rights Policy. + +Khronos makes no, and expressly disclaims any, representations or warranties, +express or implied, regarding this specification, including, without limitation: +merchantability, fitness for a particular purpose, non-infringement of any +intellectual property, correctness, accuracy, completeness, timeliness, and +reliability. Under no circumstances will Khronos, or any of its Promoters, +Contributors or Members, or their respective partners, officers, directors, +employees, agents or representatives be liable for any damages, whether direct, +indirect, special or consequential damages for lost revenues, lost profits, or +otherwise, arising from or in connection with these materials. + +Khronos® and Vulkan® are registered trademarks, and ANARI™, WebGL™, glTF™, NNEF™, OpenVX™, +SPIR™, SPIR‑V™, SYCL™, OpenVG™ and 3D Commerce™ are trademarks of The Khronos Group Inc. +OpenXR™ is a trademark owned by The Khronos Group Inc. and is registered as a trademark in +China, the European Union, Japan and the United Kingdom. OpenCL™ is a trademark of Apple Inc. +and OpenGL® is a registered trademark and the OpenGL ES™ and OpenGL SC™ logos are trademarks +of Hewlett Packard Enterprise used under license by Khronos. ASTC is a trademark of +ARM Holdings PLC. All other product names, trademarks, and/or company names are used solely +for identification and belong to their respective owners. + + +[[introduction]] += Introduction + +[[introduction-general]] +== General + +This document, referred to as the "`glTF Interactivity Extension Specification`" or just the "`Specification`" hereafter, describes the `KHR_interactivity` glTF extension. + +This extension aims to enhance glTF 2.0 by adding the ability to encode behavior and interactivity in 3D assets. + +[NOTE] +.Note +==== +This specification is for single user experiences only and does not deal with any of the complexity involved in multi-user networked experiences. +==== + +[[introduction-conventions]] +== Document Conventions + +The glTF Interactivity Extension Specification is intended for use by both implementers of the asset exporters or converters (e.g., digital content creation tools) and application developers seeking to import or load interactive glTF assets, forming a basis for interoperability between these parties. + +Specification text can address either party; typically, the intended audience can be inferred from context, though some sections are defined to address only one of these parties. + +Any requirements, prohibitions, recommendations, or options defined by <> are imposed only on the audience of that text. + +[[introduction-normative-terminology]] +=== Normative Terminology and References + +The key words **MUST**, **MUST NOT**, **REQUIRED**, **SHALL**, **SHALL NOT**, **SHOULD**, **SHOULD NOT**, **RECOMMENDED**, **MAY**, and **OPTIONAL** in this document are to be interpreted as described in <>. + +These key words are highlighted in the specification for clarity. + +References to external documents are considered normative if the Specification uses any of the normative terms defined in this section to refer to them or their requirements, either as a whole or in part. + +[[introduction-informative-language]] +=== Informative Language + +Some language in the specification is purely informative, intended to give background or suggestions to implementers or developers. + +If an entire chapter or section contains only informative language, its title is suffixed with "`(Informative)`". If not designated as informative, all chapters, sections, and appendices in this document are normative. + +All Notes, Implementation notes, and Examples are purely informative. + +[[introduction-technical-terminology]] +=== Technical Terminology + +TBD + +[[introduction-normative-references]] +=== Normative References + +The following documents are referenced by normative sections of the specification: + +==== External Specifications + +[none] +* [[bcp14]] +Bradner, S., _Key words for use in RFCs to Indicate Requirement Levels_, BCP 14, RFC 2119, March 1997. Leiba, B., _Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words_, BCP 14, RFC 8174, May 2017. + + +[[motivation]] +== Motivation and Design Goals (Informative) + +glTF 2.0 assets are widely used in various industries, including automotive, e-commerce, and gaming. There is a growing demand for adding logic and behavior to glTF assets, particularly in the metaverse. This extension aims to fulfill this demand by providing a portable, easily implementable, safe, and visually accessible solution for adding behavior to glTF assets. The extension is inspired by visual scripting features of leading game engines and aims to deliver a minimum meaningful and extensible feature set. + +=== What Is a Behavior Graph? +A behavior graph is a series of interconnected nodes that represent behaviors and interactions in a 3D asset. It can respond to events and cause changes in the asset's appearance and behavior. + +=== What Problems Can They Solve? +Behavior graphs offer a flexible and multi-functional approach to encoding behavior, making them useful for various applications. For instance, they can be used to create smart assets with behavior and interactions, AR experiences with user interactions, and immersive game levels with dynamic assets and objectives. + +=== What Do They Not Solve? +Behavior graphs are not designed to handle UI presentation or arbitrary scripting. Creating a 3D UI using behavior graphs would be complex, not portable, and not accessible. Similarly, arbitrary scripting is challenging to make safe, portable across platforms, and has a vast surface area. + +=== Comparison with Trigger-Action Lists +Behavior graphs and trigger-action lists are the two common models for representing and executing behaviors in the digital world. Common 3D experience commerce tools use trigger-action lists, while behavior graphs are typically used by high-end game engines. In this section, we will explore the differences and similarities between these two models, and explain why glTF chose to adopt behavior graphs. + +Behavior graphs and trigger-action lists share common features, such as being safe and sandboxed, offering limited execution models controlled by the viewer, and both supporting the “trigger” and “action” node categories. However, there are also significant differences between the two models. Trigger-action lists lack “Queries”, “Logic”, and “Control Flow” nodes, meaning that sophisticated behavior based on queries, logic, or control flow branches is not possible. This lack of functionality greatly affects the ability to create complex behavior and control structures and rules out the implementation of advanced control flow structures in the future. + +On the other hand, behavior graphs are a superset of trigger-action lists, meaning that the former can support everything that trigger-action lists can, and more. Behavior graphs support “Queries”, “Logic” and “Control Flow” nodes, making them more expressive and capable of creating more sophisticated behaviors. This makes behavior graphs the preferred method of choice for high-end game engines, as it offers an identical safety model as trigger-action lists while being more expressive. + +=== Turing Completeness +The execution model and node choices for this extension mean that it is Turing-complete. This means that an implementation of this can execute any computation and it is also hard to predict if it will run forever (e.g. halt or not.) + +While this may present security implications, it is not a major hindrance and can be safely mitigated so that any implementation does not become susceptible to denial of services by badly behaving behavior graphs, whether intention or not. + +The main way to mitigate the risk of non-halting behavior graphs is to limit the amount of time given to them for execution, both in terms of individual time slice as well as overall execution time. + +=== Implementation Limitations +There will be limitations in engines and devices to such as: + +* Number of nodes in the graph +* Number of variables +* Number of custom events +* Number of concurrent pending events/async nodes +* Number of nodes executed per time slice +* Speed of graph execution + +These limitations are not defined in this specification. + + +[[concepts]] += Concepts + +[[concepts-general]] +== Graphs + +A behavior graph is a JSON object containing nodes. It **MAY** also contain custom variables and custom events. + +Behavior graphs are directed graphs with no directed cycles. + +[[nodes]] +== Nodes + +A node is a JSON object, which represents an executable item. A node is executed when its input flow socket is reached by or when one of its output value sockets is requested by the behavior graph engine. The node executes its logic and can then execute any number (including zero) of outgoing flow sockets. + +A node **MAY** have a set of parameters, each of which **MUST** be provided statically in the node object, resolved at runtime through subgraph executions, or have a default value. Nodes **MAY** be configurable through static properties that **MAY** affect the node's behavior and the number of its sockets. + +Node's sockets and configurations are defined by its _type_. Node types should follow `domain/operation` naming pattern. + +=== Sockets + +== Custom Events + +== Variables \ No newline at end of file From 09bd2cfa402a29f3d88ddc78c474368c835db685 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 2 Oct 2023 00:00:00 +0000 Subject: [PATCH 02/42] Add socket descriptions and math nodes --- .../KHR_interactivity/Specification.adoc | 523 +++++++++++++++++- 1 file changed, 516 insertions(+), 7 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index d6527f955d..cef5444c5c 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -157,6 +157,16 @@ The following documents are referenced by normative sections of the specificatio Bradner, S., _Key words for use in RFCs to Indicate Requirement Levels_, BCP 14, RFC 2119, March 1997. Leiba, B., _Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words_, BCP 14, RFC 8174, May 2017. +* [[ieee-754]] +ISO/IEC 60559 +_Floating-point arithmetic_ + + +* [[ecma-262]] +ECMA-262 +_ECMAScript® Language Specification_ + + [[motivation]] == Motivation and Design Goals (Informative) @@ -204,21 +214,520 @@ These limitations are not defined in this specification. [[concepts-general]] == Graphs -A behavior graph is a JSON object containing nodes. It **MAY** also contain custom variables and custom events. +A behavior graph is a JSON object containing _nodes_. It **MAY** also contain custom variables and custom events. Behavior graphs are directed graphs with no directed cycles. [[nodes]] -== Nodes +== Nodes and Sockets + +A _node_ is a JSON object, which represents an executable item. Each node is defined by its _type_ and a set of _sockets_. There are four kinds of sockets. + +_Output value sockets_ represent data initialized by the node or produced during its execution. For example, it could be results of math operations or parts of the node's internal state. Accessing these sockets either triggers computing the return value on the fly by executing the node or returns a value based on the node's internal state. Exact behavior depends on the node's type. + +_Input value sockets_ represent data accessed during the node's execution. For example, it could be arguments of math operations or execution parameters such as iteration count for loop nodes or duration for time-related nodes. These sockets **MUST** either be given a static value in the node object or connected to an output value socket of a different node. The node **MAY** access its input value sockets multiple times during the execution. The runtime **MUST** guarantee that all input value sockets have defined values when the node execution starts. + +_Output flow sockets_ represent "`function pointers`" that the node will call to advance the graph execution. For example, bodies and branches of flow control nodes are output flow sockets that drive further execution when certain condition are fulfilled. Output flow sockets **MAY** be unconnected; in such a case graph execution proceeds as if such sockets are no-ops. + +_Input flow sockets_ represent "`methods`" that could be called on the node. For example, flow control nodes (such as loops and conditions) usually have an `in` input flow socket that starts node's execution. Additional operations **MAY** also be defined such as `reset` for nodes having an internal state. -A node is a JSON object, which represents an executable item. A node is executed when its input flow socket is reached by or when one of its output value sockets is requested by the behavior graph engine. The node executes its logic and can then execute any number (including zero) of outgoing flow sockets. +Nodes **MAY** be configurable through static properties collectively called "`node's configuration`" that **MAY** affect the node's behavior and the number of its sockets, such as the number of cases for a switch-case control flow node. -A node **MAY** have a set of parameters, each of which **MUST** be provided statically in the node object, resolved at runtime through subgraph executions, or have a default value. Nodes **MAY** be configurable through static properties that **MAY** affect the node's behavior and the number of its sockets. +Input and output value sockets have associated data types, e.g., floats, integers, booleans, etc. -Node's sockets and configurations are defined by its _type_. Node types should follow `domain/operation` naming pattern. +Node's sockets and configurations are defined by its _type_. Node types follow `domain/operation` naming pattern. -=== Sockets +A node is executed when its input flow socket is reached by or when one of its output value sockets is requested by another node. Usually, the node executes its dependencies (if any), its own logic, and any number (including zero) of outgoing flow sockets. +[[types]] +== Value Types + +TBD + +[[events]] == Custom Events -== Variables \ No newline at end of file +TBD + +[[variables]] +== Variables + +TBD + +== Node Types + +=== Math Nodes + +In this section, `floatN` is a placeholder for any of `float`, `float2`, `float3`, `float4`, or `float4x4` types. All value sockets of `floatN` types have the same type within a node. + +==== Constants + +===== E + +[cols="1h,1,2"] +|=== +| Type | `math/e` | Euler's number +| Output value sockets | `float value` | 2.718281828459045 +|=== + +===== Pi + +[cols="1h,1,2"] +|=== +| Type | `math/pi` | Ratio of a circle's circumference to its diameter +| Output value sockets | `float value` | 3.141592653589793 +|=== + +==== Arithmetic Nodes + +These all operate component-wise. The description is per component. + +If any input value is _NaN_, the output value is also _NaN_. + +===== Absolute Value + +[cols="1h,1,2"] +|=== +| Type | `math/abs` | Absolute value operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}a, \text{if } a \ge 0.0 \\ -a, \text{if } a < 0.0 \end{cases}] +|=== + +===== Sign + +[cols="1h,1,2"] +|=== +| Type | `math/sign` | Sign operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}-1.0, \text{if } a < 0.0 \\ a, \text{if } a = \pm0.0 \\ 1.0, \text{if } a > 0.0 \end{cases}] +|=== + +===== Truncate + +[cols="1h,1,2"] +|=== +| Type | `math/trunc` | Truncate operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | Integer value equal to the nearest integer to stem:[a] whose absolute value is not larger than the absolute value of stem:[a] +|=== + +If the argument is infinity, it is returned unchanged. + +===== Floor + +[cols="1h,1,2"] +|=== +| Type | `math/floor` | Floor operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | Value equal to the nearest integer that is less than or equal to stem:[a] +|=== + +If the argument is infinity, it is returned unchanged. + +===== Ceil + +[cols="1h,1,2"] +|=== +| Type | `math/ceil` | Ceil operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | Value equal to the nearest integer that is greater than or equal to stem:[a] +|=== + +If the argument is infinity, it is returned unchanged. + +===== Negation + +[cols="1h,1,2"] +|=== +| Type | `math/neg` | Negation operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | stem:[-a] +|=== + +===== Addition + +[cols="1h,1,2"] +|=== +| Type | `math/add` | Addition operation +.2+| Input value sockets +| `floatN a` | First addend +| `floatN b` | Second addend +| Output value sockets +| `floatN value` | Sum, stem:[a + b] +|=== + +===== Subtraction + +[cols="1h,1,2"] +|=== +| Type | `math/sub` | Subtraction operation +.2+| Input value sockets +| `floatN a` | Minuend +| `floatN b` | Subtrahend +| Output value sockets +| `floatN value` | Difference, stem:[a - b] +|=== + +===== Multiplication + +[cols="1h,1,2"] +|=== +| Type | `math/mul` | Multiplication operation +.2+| Input value sockets +| `floatN a` | First factor +| `floatN b` | Second factor +| Output value sockets +| `floatN value` | Product, stem:[a * b] +|=== + +===== Division + +[cols="1h,1,2"] +|=== +| Type | `math/div` | Division operation +.2+| Input value sockets +| `floatN a` | Dividend +| `floatN b` | Divisor +| Output value sockets +| `floatN value` | Quotient, stem:[a / b] +|=== + +===== Remainder + +[cols="1h,1,2"] +|=== +| Type | `math/rem` | Remainder operation +.2+| Input value sockets +| `floatN a` | Dividend +| `floatN b` | Divisor +| Output value sockets +| `floatN value` | latexmath:[a - (b \cdot trunc(\frac{a}{b}))] +|=== + +===== Minimum + +[cols="1h,1,2"] +|=== +| Type | `math/min` | Minimum operation +.2+| Input value sockets +| `floatN a` | First argument +| `floatN b` | Second argument +| Output value sockets +| `floatN value` | Smallest of the arguments +|=== + +===== Maximum + +[cols="1h,1,2"] +|=== +| Type | `math/max` | Maximum operation +.2+| Input value sockets +| `floatN a` | First argument +| `floatN b` | Second argument +| Output value sockets +| `floatN value` | Largest of the arguments +|=== + +===== Clamp + +[cols="1h,1,2"] +|=== +| Type | `math/clamp` | Clamp operation +.3+| Input value sockets +| `floatN a` | Value to clamp +| `floatN b` | Lower boundary +| `floatN c` | Upper boundary +| Output value sockets +| `floatN value` | latexmath:[min(max(a, b), c)] +|=== + +===== Saturate + +[cols="1h,1,2"] +|=== +| Type | `math/saturate` | Saturate operation +| Input value sockets +| `floatN a` | Value to saturate +| Output value sockets +| `floatN value` | latexmath:[clamp(a, 0, 1)] +|=== + +==== Angle and Trigonometry Nodes + +Node parameters specified as angle are assumed to be in units of radians. + +These all operate component-wise. The description is per component. + +If any input value is _NaN_, the output value is also _NaN_. + +===== Degrees-To-Radians + +[cols="1h,1,2"] +|=== +| Type | `math/rad` | Converts degrees to radians +| Input value sockets +| `floatN a` | Value in degrees +| Output value sockets +| `floatN value` | stem:[a * pi / 180.0] +|=== + +===== Radians-To-Degrees + +[cols="1h,1,2"] +|=== +| Type | `math/deg` | Converts radians to degrees +| Input value sockets +| `floatN a` | Value in radians +| Output value sockets +| `floatN value` | stem:[a * 180.0 / pi] +|=== + +===== Sine + +[cols="1h,1,2"] +|=== +| Type | `math/sin` | Sine function +| Input value sockets +| `floatN a` | Angle +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}sin(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +|=== + +===== Cosine + +[cols="1h,1,2"] +|=== +| Type | `math/cos` | Cosine function +| Input value sockets +| `floatN a` | Angle +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}cos(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +|=== + +===== Tangent + +[cols="1h,1,2"] +|=== +| Type | `math/tan` | Tangent function +| Input value sockets +| `floatN a` | Angle +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}tan(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +|=== + +===== Arcsine + +[cols="1h,1,2"] +|=== +| Type | `math/asin` | Arcsine function +| Input value sockets +| `floatN a` | Sine value +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}arcsin(a) \in [-\frac{\pi}{2}; \frac{\pi}{2}\], \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +|=== + +===== Arccosine + +[cols="1h,1,2"] +|=== +| Type | `math/acos` | Arccosine function +| Input value sockets +| `floatN a` | Cosine value +| Output value sockets +| `floatN value` | latexmath:[\begin{cases}arccos(a) \in [0; \pi\], \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +|=== + +===== Arctangent + +[cols="1h,1,2"] +|=== +| Type | `math/atan` | Arctangent function +| Input value sockets +| `floatN a` | Tangent value +| Output value sockets +| `floatN value` | latexmath:[arctan(a) \in [-\frac{\pi}{2}; \frac{\pi}{2}\]] +|=== + +===== Arctangent 2 + +[cols="1h,1,2"] +|=== +| Type | `math/atan2` | Arctangent 2 function +.2+| Input value sockets +| `floatN a` | Y coordinate +| `floatN b` | X coordinate +| Output value sockets +| `floatN value` | Angle between the positive X-axis and the vector from the stem:[(0, 0)] origin to the stem:[(X, Y)] point on a 2D plane +|=== + +Zero and infinity argument values are handled according to <> or <> standards. + +==== Hyperbolic Functions + +These all operate component-wise. The description is per component. + +If any input value is _NaN_, the output value is also _NaN_. + +===== Hyperbolic Sine + +[cols="1h,1,2"] +|=== +| Type |`math/sinh`| Hyperbolic sine function +| Input value sockets +| `floatN a` | Hyperbolic angle value +|Output value sockets +| `floatN value` | latexmath:[\dfrac{e^a-e^{-a}}{2}] +|=== + +===== Hyperbolic Cosine + +[cols="1h,1,2"] +|=== +| Type |`math/cosh`| Hyperbolic cosine function +| Input value sockets +| `floatN a` | Hyperbolic angle value +|Output value sockets +| `floatN value` | latexmath:[\dfrac{e^a+e^{-a}}{2}] +|=== + +===== Hyperbolic Tangent + +[cols="1h,1,2"] +|=== +| Type |`math/tanh`| Hyperbolic tangent function +| Input value sockets +| `floatN a` | Hyperbolic angle value +|Output value sockets +| `floatN value` | latexmath:[\dfrac{e^a-e^{-a}}{e^a+e^{-a}}] +|=== + +===== Inverse Hyperbolic Sine + +[cols="1h,1,2"] +|=== +| Type |`math/asinh`| Inverse hyperbolic sine function +| Input value sockets +| `floatN a` | Hyperbolic sine value +|Output value sockets +| `floatN value` | latexmath:[ln(a+\sqrt{a^2+1})] +|=== + +===== Inverse Hyperbolic Cosine + +[cols="1h,1,2"] +|=== +| Type |`math/acosh`| Inverse hyperbolic cosine function +| Input value sockets +| `floatN a` | Hyperbolic cosine value +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}ln(a+\sqrt{a^2-1}), \text{if } a \ge 1 \\ \mathit{NaN}, \text{if } a < 1\end{cases}] +|=== + +===== Inverse Hyperbolic Tangent + +[cols="1h,1,2"] +|=== +| Type |`math/atanh`| Inverse hyperbolic tangent function +| Input value sockets +| `floatN a` | Hyperbolic tangent value +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}\dfrac{1}{2}ln\dfrac{1+a}{1-a}, \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +|=== + +==== Exponential Functions + +These all operate component-wise. The description is per component. + +If any input value is _NaN_, the output value is also _NaN_. + +===== Exponent + +[cols="1h,1,2"] +|=== +| Type | `math/exp` | Exponent function +| Input value sockets +| `floatN a` | Power value +|Output value sockets +| `floatN value` | stem:[e^a] +|=== + +===== Natural Logarithm + +[cols="1h,1,2"] +|=== +| Type | `math/log` | Natural logarithm function +| Input value sockets +| `floatN a` | Argument value +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}ln(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +|=== + +===== Base-2 Logarithm + +[cols="1h,1,2"] +|=== +| Type | `math/log2` | Base-2 logarithm function +| Input value sockets +| `floatN a` | Argument +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}log_2(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +|=== + +===== Base-10 Logarithm + +[cols="1h,1,2"] +|=== +| Type | `math/log10` | Base-10 logarithm function +| Input value sockets +| `floatN a` | Argument +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}log_{10}(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +|=== + +===== Square Root + +[cols="1h,1,2"] +|=== +| Type | `math/sqrt` | Square root function +| Input value sockets +| `floatN a` | Radicand +|Output value sockets +| `floatN value` | latexmath:[\begin{cases}\sqrt{a}, \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +|=== + +===== Cube Root + +[cols="1h,1,2"] +|=== +| Type | `math/cbrt` | Cube root function +| Input value sockets +| `floatN a` | Radicand +|Output value sockets +| `floatN value` | latexmath:[\sqrt[3\]{a}] +|=== + +===== Power + +[cols="1h,1,2"] +|=== +| Type | `math/pow` | Power function +.2+| Input value sockets +| `floatN a` | Base +| `floatN b` | Exponent +| Output value sockets +| `floatN value` | stem:[a^b] +|=== + +Zero and infinity argument values are handled according to the <> standard. From 151f3add31f25d4475c62d6b3d176a59605a4489 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:00:00 +0000 Subject: [PATCH 03/42] Add vector and more arithmetic nodes; editorial changes --- .../KHR_interactivity/Specification.adoc | 135 +++++++++++++++--- 1 file changed, 118 insertions(+), 17 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index cef5444c5c..d2d20342e1 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -231,7 +231,7 @@ _Output flow sockets_ represent "`function pointers`" that the node will call to _Input flow sockets_ represent "`methods`" that could be called on the node. For example, flow control nodes (such as loops and conditions) usually have an `in` input flow socket that starts node's execution. Additional operations **MAY** also be defined such as `reset` for nodes having an internal state. -Nodes **MAY** be configurable through static properties collectively called "`node's configuration`" that **MAY** affect the node's behavior and the number of its sockets, such as the number of cases for a switch-case control flow node. +Nodes **MAY** be configurable through static properties collectively called "`node's configuration`" that **MAY** affect the node's behavior and the number of its sockets, such as the number of cases for a switch-case control flow node. Input and output value sockets have associated data types, e.g., floats, integers, booleans, etc. @@ -327,7 +327,7 @@ If the argument is infinity, it is returned unchanged. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | Value equal to the nearest integer that is less than or equal to stem:[a] +| `floatN value` | stem:[floor(a)], value equal to the nearest integer that is less than or equal to stem:[a] |=== If the argument is infinity, it is returned unchanged. @@ -340,11 +340,22 @@ If the argument is infinity, it is returned unchanged. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | Value equal to the nearest integer that is greater than or equal to stem:[a] +| `floatN value` | stem:[ceil(a)], value equal to the nearest integer that is greater than or equal to stem:[a] |=== If the argument is infinity, it is returned unchanged. +===== Fraction + +[cols="1h,1,2"] +|=== +| Type | `math/fract` | Fractional operation +| Input value sockets +| `floatN a` | Argument +| Output value sockets +| `floatN value` | stem:[a - floor(a)] +|=== + ===== Negation [cols="1h,1,2"] @@ -464,6 +475,19 @@ If the argument is infinity, it is returned unchanged. | `floatN value` | latexmath:[clamp(a, 0, 1)] |=== +===== Interpolate + +[cols="1h,1,2"] +|=== +| Type | `math/mix` | Linear interpolation operation +.3+| Input value sockets +| `floatN a` | Interpolated value at stem:[0.0] +| `floatN b` | Interpolated value at stem:[1.0] +| `floatN c` | Unclamped interpolation coefficient +| Output value sockets +| `floatN value` | stem:[(1.0 - c) * a + c * b] +|=== + ==== Angle and Trigonometry Nodes Node parameters specified as angle are assumed to be in units of radians. @@ -574,7 +598,7 @@ If any input value is _NaN_, the output value is also _NaN_. Zero and infinity argument values are handled according to <> or <> standards. -==== Hyperbolic Functions +==== Hyperbolic Nodes These all operate component-wise. The description is per component. @@ -587,7 +611,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/sinh`| Hyperbolic sine function | Input value sockets | `floatN a` | Hyperbolic angle value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\dfrac{e^a-e^{-a}}{2}] |=== @@ -598,7 +622,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/cosh`| Hyperbolic cosine function | Input value sockets | `floatN a` | Hyperbolic angle value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\dfrac{e^a+e^{-a}}{2}] |=== @@ -609,7 +633,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/tanh`| Hyperbolic tangent function | Input value sockets | `floatN a` | Hyperbolic angle value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\dfrac{e^a-e^{-a}}{e^a+e^{-a}}] |=== @@ -620,7 +644,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/asinh`| Inverse hyperbolic sine function | Input value sockets | `floatN a` | Hyperbolic sine value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[ln(a+\sqrt{a^2+1})] |=== @@ -631,7 +655,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/acosh`| Inverse hyperbolic cosine function | Input value sockets | `floatN a` | Hyperbolic cosine value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}ln(a+\sqrt{a^2-1}), \text{if } a \ge 1 \\ \mathit{NaN}, \text{if } a < 1\end{cases}] |=== @@ -642,11 +666,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Type |`math/atanh`| Inverse hyperbolic tangent function | Input value sockets | `floatN a` | Hyperbolic tangent value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}\dfrac{1}{2}ln\dfrac{1+a}{1-a}, \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] |=== -==== Exponential Functions +==== Exponential Nodes These all operate component-wise. The description is per component. @@ -659,7 +683,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/exp` | Exponent function | Input value sockets | `floatN a` | Power value -|Output value sockets +| Output value sockets | `floatN value` | stem:[e^a] |=== @@ -670,7 +694,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/log` | Natural logarithm function | Input value sockets | `floatN a` | Argument value -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}ln(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] |=== @@ -681,7 +705,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/log2` | Base-2 logarithm function | Input value sockets | `floatN a` | Argument -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}log_2(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] |=== @@ -692,7 +716,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/log10` | Base-10 logarithm function | Input value sockets | `floatN a` | Argument -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}log_{10}(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] |=== @@ -703,7 +727,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/sqrt` | Square root function | Input value sockets | `floatN a` | Radicand -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\begin{cases}\sqrt{a}, \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] |=== @@ -714,7 +738,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Type | `math/cbrt` | Cube root function | Input value sockets | `floatN a` | Radicand -|Output value sockets +| Output value sockets | `floatN value` | latexmath:[\sqrt[3\]{a}] |=== @@ -731,3 +755,80 @@ If any input value is _NaN_, the output value is also _NaN_. |=== Zero and infinity argument values are handled according to the <> standard. + +==== Vector Nodes + +If any input value is _NaN_, the output value is also _NaN_. + +===== Length + +[cols="1h,1,2"] +|=== +| Type | `math/length` | Vector length +| Input value sockets +| `float{2\|3\|4} a` | Vector +| Output value sockets +| `float value` | Length of stem:[a], e.g., stem:[sqrt(a_x^2 + a_y^2)] for `float2` +|=== + +===== Normalize + +[cols="1h,1,2"] +|=== +| Type | `math/normalize` | Vector normalization +| Input value sockets +| `float{2\|3\|4} a` | Vector +| Output value sockets +| `floatN value` | Vector in the same direction as stem:[a] but with a unit length, e.g., stem:[a/sqrt(a_x^2 + a_y^2)] for `float2` +|=== + +===== Dot Product + +[cols="1h,1,2"] +|=== +| Type | `math/dot` | Dot product +.2+| Input value sockets +| `float{2\|3\|4} a` | First vector +| `float{2\|3\|4} b` | Second vector of the same type as stem:[a] +| Output value sockets +| `float value` | Sum of per-component products of stem:[a] and stem:[b], e.g., stem:[a_x * b_x + a_y * b_y] for `float2` +|=== + +===== Cross Product + +[cols="1h,1,2"] +|=== +| Type | `math/cross` | Cross product +.2+| Input value sockets +| `float3 a` | Vector +| `float3 b` | Vector +| Output value sockets +| `float3 value` | Cross product of stem:[a] and stem:[b], i.e., stem:[(a_y * b_z - a_z * b_y, a_z * b_x - a_x * b_z, a_x * b_y - a_y * b_x)] +|=== + +===== Rotate 2D + +[cols="1h,1,2"] +|=== +| Type | `math/rotate` | 2D rotation +.2+| Input value sockets +| `float2 a` | Vector to rotate +| `float b` | Angle in radians +| Output value sockets +| `float2 value` | Vector stem:[a] rotated counter-clockwise by stem:[b] +|=== + +===== Rotate 3D + +[cols="1h,1,2"] +|=== +| Type | `math/rotate` | 3D rotation +.3+| Input value sockets +| `float3 a` | Vector to rotate +| `float3 b` | Vector representing an axis to rotate around +| `float c` | Angle in radians +| Output value sockets +| `float3 value` | Vector stem:[a] rotated around vector stem:[b] counter-clockwise by stem:[c] +|=== + +If the vector stem:[b] is not unit, rotation results may be undefined. From 47c12faa4907cd9cc7699e5396f22fede4d8335b Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 23 Oct 2023 00:00:00 +0000 Subject: [PATCH 04/42] Add comparison nodes; address feedback --- .../KHR_interactivity/Specification.adoc | 92 ++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index d2d20342e1..434ab10556 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -488,6 +488,94 @@ If the argument is infinity, it is returned unchanged. | `floatN value` | stem:[(1.0 - c) * a + c * b] |=== +==== Comparison Nodes + +If any input value is _NaN_, the output value is false. + +===== Equality + +[cols="1h,1,2"] +|=== +| Type | `math/eq` | Equality operation +.2+| Input value sockets +| `floatN a` | First argument +| `floatN b` | Second argument +| Output value sockets +| `bool value` | True if the input arguments are equal, per-component; false otherwise +|=== + +===== Less Than + +[cols="1h,1,2"] +|=== +| Type | `math/lt` | Less than operation +.2+| Input value sockets +| `float a` | First argument +| `float b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a < b]; false otherwise +|=== + +===== Less Than Or Equal To + +[cols="1h,1,2"] +|=== +| Type | `math/le` | Less than or equal to operation +.2+| Input value sockets +| `float a` | First argument +| `float b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a <= b]; false otherwise +|=== + +===== Greater Than + +[cols="1h,1,2"] +|=== +| Type | `math/gt` | Greater than operation +.2+| Input value sockets +| `float a` | First argument +| `float b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a > b]; false otherwise +|=== + +===== Greater Than Or Equal To + +[cols="1h,1,2"] +|=== +| Type | `math/ge` | Greater than or equal operation +.2+| Input value sockets +| `float a` | First argument +| `float b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a >= b]; false otherwise +|=== + +==== Special Floating-Point Nodes + +===== Is Not a Number + +[cols="1h,1,2"] +|=== +| Type | `math/isnan` | Not a Number check operation +| Input value sockets +| `float a` | Argument +| Output value sockets +| `bool value` | True if stem:[a] is _NaN_; false otherwise +|=== + +===== Is Infinity + +[cols="1h,1,2"] +|=== +| Type | `math/isinf` | Infinity check operation +| Input value sockets +| `float a` | Argument +| Output value sockets +| `bool value` | True if stem:[a] is positive or negative infinity; false otherwise +|=== + ==== Angle and Trigonometry Nodes Node parameters specified as angle are assumed to be in units of radians. @@ -810,7 +898,7 @@ If any input value is _NaN_, the output value is also _NaN_. [cols="1h,1,2"] |=== -| Type | `math/rotate` | 2D rotation +| Type | `math/rotate2d` | 2D rotation .2+| Input value sockets | `float2 a` | Vector to rotate | `float b` | Angle in radians @@ -822,7 +910,7 @@ If any input value is _NaN_, the output value is also _NaN_. [cols="1h,1,2"] |=== -| Type | `math/rotate` | 3D rotation +| Type | `math/rotate3d` | 3D rotation .3+| Input value sockets | `float3 a` | Vector to rotate | `float3 b` | Vector representing an axis to rotate around From 736e6869ab721e493bc6b2bc290e5b0becfff575 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 6 Nov 2023 00:00:00 +0000 Subject: [PATCH 05/42] Add special float constants --- .../Khronos/KHR_interactivity/Specification.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 434ab10556..a9db9fda9a 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -278,6 +278,22 @@ In this section, `floatN` is a placeholder for any of `float`, `float2`, `float3 | Output value sockets | `float value` | 3.141592653589793 |=== +===== Infinity + +[cols="1h,1,2"] +|=== +| Type | `math/inf` | Positive infinity +| Output value sockets | `float value` | _Infinity_ +|=== + +===== Not a Number + +[cols="1h,1,2"] +|=== +| Type | `math/nan` | Not a Number +| Output value sockets | `float value` | _NaN_ +|=== + ==== Arithmetic Nodes These all operate component-wise. The description is per component. From 667fdb1905998b8b8e610df5d202cf3d350c8132 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Tue, 14 Nov 2023 00:00:00 +0000 Subject: [PATCH 06/42] Add matrix and integer nodes; update formatting --- .../KHR_interactivity/Specification.adoc | 626 +++++++++++++++++- 1 file changed, 603 insertions(+), 23 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index a9db9fda9a..01fefba341 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -308,7 +308,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | latexmath:[\begin{cases}a, \text{if } a \ge 0.0 \\ -a, \text{if } a < 0.0 \end{cases}] +| `floatN value` | latexmath:[\begin{cases} + -a & \text{if } a \lt 0 \\ + 0 & \text{if } a = 0 \\ + a & \text{if } a \gt 0 + \end{cases}] |=== ===== Sign @@ -319,7 +323,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | latexmath:[\begin{cases}-1.0, \text{if } a < 0.0 \\ a, \text{if } a = \pm0.0 \\ 1.0, \text{if } a > 0.0 \end{cases}] +| `floatN value` | latexmath:[\begin{cases} + -1 & \text{if } a \lt 0 \\ + a & \text{if } a = \pm0 \\ + +1 & \text{if } a \gt 0 + \end{cases}] |=== ===== Truncate @@ -419,6 +427,12 @@ If the argument is infinity, it is returned unchanged. | `floatN value` | Product, stem:[a * b] |=== +[NOTE] +.Note +==== +For `float4x4` arguments, this operation performs per-component multiplication. +==== + ===== Division [cols="1h,1,2"] @@ -440,7 +454,11 @@ If the argument is infinity, it is returned unchanged. | `floatN a` | Dividend | `floatN b` | Divisor | Output value sockets -| `floatN value` | latexmath:[a - (b \cdot trunc(\frac{a}{b}))] +| `floatN value` | latexmath:[\begin{cases} + \mathit{NaN} & \text{if } a = \pm \infty \text{ or } b = \pm 0 \\ + a & \text{if } a \ne \pm \infty \text{ and } b = \pm \infty \\ + a - (b \cdot trunc(\frac{a}{b})) & \text{otherwise} + \end{cases}] |=== ===== Minimum @@ -474,12 +492,18 @@ If the argument is infinity, it is returned unchanged. | Type | `math/clamp` | Clamp operation .3+| Input value sockets | `floatN a` | Value to clamp -| `floatN b` | Lower boundary -| `floatN c` | Upper boundary +| `floatN b` | First boundary +| `floatN c` | Second boundary | Output value sockets -| `floatN value` | latexmath:[min(max(a, b), c)] +| `floatN value` | latexmath:[min(max(a, min(b, c)), max(b, c))] |=== +[NOTE] +.Note +==== +This operation correctly handles a case when stem:[b] is greater than stem:[c]. +==== + ===== Saturate [cols="1h,1,2"] @@ -488,7 +512,7 @@ If the argument is infinity, it is returned unchanged. | Input value sockets | `floatN a` | Value to saturate | Output value sockets -| `floatN value` | latexmath:[clamp(a, 0, 1)] +| `floatN value` | latexmath:[min(max(a, 0), 1)] |=== ===== Interpolate @@ -497,11 +521,11 @@ If the argument is infinity, it is returned unchanged. |=== | Type | `math/mix` | Linear interpolation operation .3+| Input value sockets -| `floatN a` | Interpolated value at stem:[0.0] -| `floatN b` | Interpolated value at stem:[1.0] +| `floatN a` | Interpolated value at stem:[0] +| `floatN b` | Interpolated value at stem:[1] | `floatN c` | Unclamped interpolation coefficient | Output value sockets -| `floatN value` | stem:[(1.0 - c) * a + c * b] +| `floatN value` | stem:[(1 - c) * a + c * b] |=== ==== Comparison Nodes @@ -608,7 +632,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Value in degrees | Output value sockets -| `floatN value` | stem:[a * pi / 180.0] +| `floatN value` | stem:[a * pi / 180] |=== ===== Radians-To-Degrees @@ -619,7 +643,7 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Value in radians | Output value sockets -| `floatN value` | stem:[a * 180.0 / pi] +| `floatN value` | stem:[a * 180 / pi] |=== ===== Sine @@ -630,7 +654,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Angle | Output value sockets -| `floatN value` | latexmath:[\begin{cases}sin(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + sin(a) & \text{if } a \ne \pm\infty \\ + \mathit{NaN} & \text{if } a = \pm\infty + \end{cases}] |=== ===== Cosine @@ -641,7 +668,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Angle | Output value sockets -| `floatN value` | latexmath:[\begin{cases}cos(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + cos(a) & \text{if } a \ne \pm\infty \\ + \mathit{NaN} & \text{if } a = \pm\infty + \end{cases}] |=== ===== Tangent @@ -652,7 +682,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Angle | Output value sockets -| `floatN value` | latexmath:[\begin{cases}tan(a), \text{if } a \ne \pm\infty \\ \mathit{NaN}, \text{if } a = \pm\infty\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + tan(a) & \text{if } a \ne \pm\infty \\ + \mathit{NaN} & \text{if } a = \pm\infty + \end{cases}] |=== ===== Arcsine @@ -663,7 +696,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Sine value | Output value sockets -| `floatN value` | latexmath:[\begin{cases}arcsin(a) \in [-\frac{\pi}{2}; \frac{\pi}{2}\], \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + arcsin(a) \in [-\frac{\pi}{2}; \frac{\pi}{2}\] & \text{if } \|a\| \le 1 \\ + \mathit{NaN} & \text{if } \|a\| \gt 1 + \end{cases}] |=== ===== Arccosine @@ -674,7 +710,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Cosine value | Output value sockets -| `floatN value` | latexmath:[\begin{cases}arccos(a) \in [0; \pi\], \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + arccos(a) \in [0; \pi\] & \text{if } \|a\| \le 1 \\ + \mathit{NaN} & \text{if } \|a\| \gt 1 + \end{cases}] |=== ===== Arctangent @@ -760,7 +799,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Hyperbolic cosine value | Output value sockets -| `floatN value` | latexmath:[\begin{cases}ln(a+\sqrt{a^2-1}), \text{if } a \ge 1 \\ \mathit{NaN}, \text{if } a < 1\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + ln(a+\sqrt{a^2-1}) & \text{if } a \ge 1 \\ + \mathit{NaN} & \text{if } a \lt 1 + \end{cases}] |=== ===== Inverse Hyperbolic Tangent @@ -771,7 +813,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Hyperbolic tangent value | Output value sockets -| `floatN value` | latexmath:[\begin{cases}\dfrac{1}{2}ln\dfrac{1+a}{1-a}, \text{if } \|a\| \le 1 \\ \mathit{NaN}, \text{if } \|a\| > 1\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + \dfrac{1}{2}ln\dfrac{1+a}{1-a} & \text{if } \|a\| \lt 1 \\ + \pm\infty & \text{if } a = \pm1 \\ + \mathit{NaN} & \text{if } \|a\| \gt 1 + \end{cases}] |=== ==== Exponential Nodes @@ -799,7 +845,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Argument value | Output value sockets -| `floatN value` | latexmath:[\begin{cases}ln(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + ln(a) & \text{if } a \gt 0 \\ + -\infty & \text{if } a = 0 \\ + \mathit{NaN} & \text{if } a \lt 0 + \end{cases}] |=== ===== Base-2 Logarithm @@ -810,7 +860,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | latexmath:[\begin{cases}log_2(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + log_2(a) & \text{if } a \gt 0 \\ + -\infty & \text{if } a = 0 \\ + \mathit{NaN} & \text{if } a \lt 0 + \end{cases}] |=== ===== Base-10 Logarithm @@ -821,7 +875,11 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Argument | Output value sockets -| `floatN value` | latexmath:[\begin{cases}log_{10}(a), \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + log_{10}(a) & \text{if } a \gt 0 \\ + -\infty & \text{if } a = 0 \\ + \mathit{NaN} & \text{if } a \lt 0 + \end{cases}] |=== ===== Square Root @@ -832,7 +890,10 @@ If any input value is _NaN_, the output value is also _NaN_. | Input value sockets | `floatN a` | Radicand | Output value sockets -| `floatN value` | latexmath:[\begin{cases}\sqrt{a}, \text{if } a \ge 0 \\ \mathit{NaN}, \text{if } a < 0\end{cases}] +| `floatN value` | latexmath:[\begin{cases} + \sqrt{a} & \text{if } a \ge 0 \\ + \mathit{NaN} & \text{if } a \lt 0 + \end{cases}] |=== ===== Cube Root @@ -936,3 +997,522 @@ If any input value is _NaN_, the output value is also _NaN_. |=== If the vector stem:[b] is not unit, rotation results may be undefined. + +===== Transform + +[cols="1h,1,2"] +|=== +| Type | `math/transform` | Vector transformation +.2+| Input value sockets +| `float4 a` | Vector to transform +| `float4x4 b` | Transformation matrix +| Output value sockets +| `float4 value` | Transformed vector +|=== + +==== Matrix Nodes + +===== Transpose + +[cols="1h,1,2"] +|=== +| Type | `math/transpose` | Transpose operation +| Input value sockets +| `float4x4 a` | Matrix to transpose +| Output value sockets +| `float4x4 value` | Matrix that is the transpose of stem:[a] +|=== + +===== Determinant + +[cols="1h,1,2"] +|=== +| Type | `math/determinant` | Dot product +| Input value sockets +| `float4x4 a` | Matrix +| Output value sockets +| `float value` | Determinant of stem:[a] +|=== + +===== Inverse + +[cols="1h,1,2"] +|=== +| Type | `math/inverse` | Inverse operation +| Input value sockets +| `float4x4 a` | Matrix to inverse +| Output value sockets +| `float4x4 value` | Matrix that is the inverse of stem:[a] +|=== + +===== Multiplication + +[cols="1h,1,2"] +|=== +| Type | `math/matmul` | Matrix multiplication operation +.2+| Input value sockets +| `float4x4 a` | First matrix +| `float4x4 b` | Second matrix +| Output value sockets +| `float4x4 value` | Matrix product +|=== + +==== Integer Arithmetic Nodes + +All inputs to these nodes are two's complement 32-bit signed integers. + +===== Absolute Value + +[cols="1h,1,2"] +|=== +| Type | `math/abs` | Absolute value operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | latexmath:[\begin{cases} + -a & \text{if } a \lt 0 \\ + a & \text{if } a \ge 0 + \end{cases}] +|=== + +As this node is defined in terms of the negation node (see below), the absolute value of `-2147483648` is `-2147483648`. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +Math.abs(a)|0 +---- +==== + +===== Sign + +[cols="1h,1,2"] +|=== +| Type | `math/sign` | Sign operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | latexmath:[\begin{cases} + -1 & \text{if } a \lt 0 \\ + 0 & \text{if } a = 0 \\ + +1 & \text{if } a \gt 0 + \end{cases}] +|=== + +===== Negation + +[cols="1h,1,2"] +|=== +| Type | `math/neg` | Negation operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | stem:[-a] +|=== + +Negating `-2147483648` **MUST** return `-2147483648`. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +(-a)|0 +---- +==== + +===== Addition + +[cols="1h,1,2"] +|=== +| Type | `math/add` | Addition operation +.2+| Input value sockets +| `int a` | First addend +| `int b` | Second addend +| Output value sockets +| `int value` | Sum, stem:[a + b] +|=== + +Arithmetic overflow **MUST** wrap around, for example: + +[source] +---- +2147483647 + 1 == -2147483648 +---- + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +(a + b)|0 +---- +==== + +===== Subtraction + +[cols="1h,1,2"] +|=== +| Type | `math/sub` | Subtraction operation +.2+| Input value sockets +| `int a` | Minuend +| `int b` | Subtrahend +| Output value sockets +| `int value` | Difference, stem:[a - b] +|=== + +Arithmetic overflow **MUST** wrap around, for example: + +[source] +---- +-2147483648 - 1 == 2147483647 +---- + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +(a - b)|0 +---- +==== + +===== Multiplication + +[cols="1h,1,2"] +|=== +| Type | `math/mul` | Multiplication operation +.2+| Input value sockets +| `int a` | First factor +| `int b` | Second factor +| Output value sockets +| `int value` | Product, stem:[a * b] +|=== + +Arithmetic overflow **MUST** wrap around, for example: + +[source] +---- + 2147483647 * 2147483647 == 1 + +-2147483648 * (-1) == -2147483648 +---- + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +Math.imul(a, b) +---- +==== + +===== Division + +[cols="1h,1,2"] +|=== +| Type | `math/div` | Division operation +.2+| Input value sockets +| `int a` | Dividend +| `int b` | Divisor +| Output value sockets +| `int value` | latexmath:[\begin{cases} + \frac{a}{b} & \text{if } b \ne 0 \\ + 0 & \text{if } b = 0 + \end{cases}] +|=== + +The quotient **MUST** be truncated towards zero. + +Arithmetic overflow is defined as follows: +[source] +---- +-2147483648 / (-1) == -2147483648 +---- + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +(a / b)|0 +---- +==== + +===== Remainder + +[cols="1h,1,2"] +|=== +| Type | `math/rem` | Remainder operation +.2+| Input value sockets +| `int a` | Dividend +| `int b` | Divisor +| Output value sockets +| `int value` | latexmath:[\begin{cases} + a - (b \cdot trunc(\frac{a}{b})) & \text{if } b \ne 0 \\ + 0 & \text{if } b = 0 + \end{cases}] +|=== + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +(a % b)|0 +---- +==== + +===== Minimum + +[cols="1h,1,2"] +|=== +| Type | `math/min` | Minimum operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `int value` | Smallest of the arguments +|=== + +===== Maximum + +[cols="1h,1,2"] +|=== +| Type | `math/max` | Maximum operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `int value` | Largest of the arguments +|=== + +===== Clamp + +[cols="1h,1,2"] +|=== +| Type | `math/clamp` | Clamp operation +.3+| Input value sockets +| `int a` | Value to clamp +| `int b` | First boundary +| `int c` | Second boundary +| Output value sockets +| `int value` | latexmath:[min(max(a, min(b, c)), max(b, c))] +|=== + +[NOTE] +.Note +==== +This operation correctly handles a case when stem:[b] is greater than stem:[c]. +==== + +==== Integer Comparison Nodes + +All inputs to these nodes are two's complement 32-bit signed integers. + +===== Equality + +[cols="1h,1,2"] +|=== +| Type | `math/eq` | Equality operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `bool value` | True if the input arguments are equal; false otherwise +|=== + +===== Less Than + +[cols="1h,1,2"] +|=== +| Type | `math/lt` | Less than operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a < b]; false otherwise +|=== + +===== Less Than Or Equal To + +[cols="1h,1,2"] +|=== +| Type | `math/le` | Less than or equal to operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a <= b]; false otherwise +|=== + +===== Greater Than + +[cols="1h,1,2"] +|=== +| Type | `math/gt` | Greater than operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a > b]; false otherwise +|=== + +===== Greater Than Or Equal To + +[cols="1h,1,2"] +|=== +| Type | `math/ge` | Greater than or equal operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `bool value` | True if stem:[a >= b]; false otherwise +|=== + +==== Integer Bitwise Nodes + +All inputs to these nodes are two's complement 32-bit signed integers. + +===== Bitwise NOT + +[cols="1h,1,2"] +|=== +| Type | `math/not` | Bitwise NOT operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | `~a` +|=== + +===== Bitwise AND + +[cols="1h,1,2"] +|=== +| Type | `math/and` | Bitwise AND operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `int value` | `a & b` +|=== + +===== Bitwise OR + +[cols="1h,1,2"] +|=== +| Type | `math/or` | Bitwise OR operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `int value` | `a \| b` +|=== + +===== Bitwise XOR + +[cols="1h,1,2"] +|=== +| Type | `math/xor` | Bitwise XOR operation +.2+| Input value sockets +| `int a` | First argument +| `int b` | Second argument +| Output value sockets +| `int value` | `a ^ b` +|=== + +===== Right Shift + +[cols="1h,1,2"] +|=== +| Type | `math/asr` | Right Shift +.2+| Input value sockets +| `int a` | Value to be shifted +| `int b` | Number of bits to shift by +| Output value sockets +| `int value` | `a >> b` +|=== + +Only the lowest 5 bits of stem:[b] are considered, i.e., its effective range is [0, 31]. The result **MUST** be truncated to 32 bits and interpreted as a two's complement signed integer. The most significant bit of stem:[a] **MUST** be propagated. + +===== Left Shift + +[cols="1h,1,2"] +|=== +| Type | `math/lsl` | Left Shift +.2+| Input value sockets +| `int a` | Value to be shifted +| `int b` | Number of bits to shift by +| Output value sockets +| `int value` | `a << b` +|=== + +Only the lowest 5 bits of stem:[b] are considered, i.e., its effective range is [0, 31]. The result **MUST** be truncated to 32 bits and interpreted as a two's complement signed integer. + +===== Count Leading Zeros + +[cols="1h,1,2"] +|=== +| Type | `math/clz` | Count leading zeros operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | Number of leading zero bits in stem:[a] +|=== + +If stem:[a] is 0, the operation returns 32; if stem:[a] is negative, the operation returns 0. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +Math.clz32(a) +---- +==== + +===== Count Trailing Zeros + +[cols="1h,1,2"] +|=== +| Type | `math/ctz` | Count trailing zeros operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | Number of trailing zero bits in stem:[a] +|=== + +If stem:[a] is 0, the operation returns 32. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +a ? (31 - Math.clz32(a & -a)) : 32; +---- +==== + +===== Count One Bits + +[cols="1h,1,2"] +|=== +| Type | `math/popcnt` | Count set bits operation +| Input value sockets +| `int a` | Argument +| Output value sockets +| `int value` | Number of set bits in stem:[a] +|=== + +If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation returns 32. From 4b7b4fea804ceabec22a17645ca6d71277aae150 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jan 2024 00:00:00 +0000 Subject: [PATCH 07/42] Add a note about math/tan return values --- .../2.0/Khronos/KHR_interactivity/Specification.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 01fefba341..57a9cc2512 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -688,6 +688,13 @@ If any input value is _NaN_, the output value is also _NaN_. \end{cases}] |=== +[NOTE] +.Note +==== +Since stem:[a] cannot exactly represent latexmath:[\pm\frac{\pi}{2}], this function does not return infinity. +The closest representable argument values would likely produce latexmath:[\pm16331239353195370]. +==== + ===== Arcsine [cols="1h,1,2"] From 866ea7f86bab716f2d0869c8285ecddcdbd054e4 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 26 Feb 2024 00:00:00 +0000 Subject: [PATCH 08/42] Add flow nodes --- .../KHR_interactivity/Specification.adoc | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 57a9cc2512..15ff4042c0 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1523,3 +1523,239 @@ a ? (31 - Math.clz32(a & -a)) : 32; |=== If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation returns 32. + +=== Control Flow Nodes + +==== Sync Nodes + +===== Sequence + +[cols="1h,1,2"] +|=== +| Type | `flow/sequence` | Sequentially activate all connected output flows +| Input flow sockets +| `in` | The entry flow into this node +| Output flow sockets +| `` | The `i`-th output flow, `i` is a non-negative integer decimal number less than or equal to 2147483647. +|=== + +This node has no internal state. + +When the `in` input flow is activated: + +1. Let a temporary variable `index` be -1. +2. Let a temporary variable `maxIndex` be the maximum output flow name value. +3. If `index` is less than `maxIndex`: +.. increment `index` by 1; +.. activate the output flow named `` if it exists and is connected; +.. goto step 3. + +===== Branch + +[cols="1h,1,2"] +|=== +| Type | `flow/branch` | Branch the execution flow based on a condition +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `bool condition` | Value selecting the branch taken +.2+| Output flow sockets +| `true` | The flow to be activated if the `condition` input value is true +| `false` | The flow to be activated if the `condition` input value is false +|=== + +This node has no internal state. + +The `condition` input value is evaluated each time the node is executed. + +===== Switch + +[cols="1h,1,2"] +|=== +| Type | `flow/switch` | Conditionally route the execution flow to one of the outputs +| Configuration +| `int[] cases` | The cases on which to perform the switch on; values **MUST** be unique integers +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `int selection` | The value on which the switch operates +.2+| Output flow sockets +| `` | The `i`-th output flow, `i` is an integer decimal number; it **MUST** be present in the `cases` configuration +| `default` | The output flow used when the `selection` input value is not present in the `cases` configuration +|=== + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate the `selection` input value. +2. If the `cases` configuration array does not contain the `selection` input value: +.. activate the `default` output flow if it is connected. +3. If the `cases` configuration array contains the `selection` input value: +.. activate the output flow named `` if it is connected. + +===== While Loop + +[cols="1h,1,2"] +|=== +| Type | `flow/while` | Repeatedly activate the output flow based on a condition +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `bool condition` | Loop condition +.2+| Output flow sockets +| `loopBody` | The flow to be activated while the `condition` input value is true +| `completed` | The flow to be activated once the `condition` input value is false +|=== + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate the `condition`. The `condition` **MUST NOT** statically evaluate to true, otherwise the node is invalid. +2. If the `condition` is true, +.. activate the `loopBody` output flow; +.. after completion of the `loopBody` output flow, goto step 1. +3. If the `condition` is false, +.. activate the `completed` output flow. + +===== For Loop + +[cols="1h,1,2"] +|=== +| Type | `flow/for` | Repeatedly activate the output flow based on an incrementing index value +| Configuration +| `int initialIndex` | The index value before the loop starts +| Input flow sockets +| `in` | The entry flow into this node +.2+| Input value sockets +| `int startIndex` | The start index of the loop +| `int endIndex` | The end index of the loop +.2+| Output flow sockets +| `loopBody` | The flow to be activated if the `index` value is less than the `endIndex` input value +| `completed` | The flow to be activated if the `index` value is greater than or equal to the `endIndex` input value +| Output value sockets +| `int index` | The current index value if the node has ever been activated, `initialIndex` otherwise +|=== + +The internal state of this node consists of one 32-bit signed integer value `index` initialized to `initialIndex`. + +When the `in` input flow is activated: + +1. Evaluate the `startIndex` input value. +2. Set `index` to `startIndex`. +3. Evaluate the `endIndex` input value. +4. If `index` is less than the `endIndex` input value, +.. activate the `loopBody` output flow; +.. after completion of the `loopBody` output flow, increment the `index` value by 1; +.. goto step 3. +5. If the `index` value is greater than or equal to the `endIndex` input value, +.. activate the `completed` output flow. + +===== Do N + +[cols="1h,1,2"] +|=== +| Type | `flow/doN` | Activate the output flow no more than N times +.2+| Input flow sockets +| `in` | The entry flow into this node +| `reset` | When this flow is activated, the `currentCount` value is reset to 0 +| Input value sockets +| `int n` | Maximum number of times the `out` output flow is activated +| Output flow sockets +| `out` | The flow to be activated if the `currentCount` value is less than the `n` input value +| Output value sockets +| `int currentCount` | The current execution count +|=== + +The internal state of this node consists of one 32-bit signed integer value `currentCount` initialized to 0. + +When the `reset` input flow is activated: + +1. Reset `currentCount` to 0. + +When the `in` input flow is activated: + +1. Evaluate the `n` input value. +2. If `currentCount` is less than `n`, +.. increment `currentCount` by 1; +.. activate the `out` output flow. + +===== Multi Gate + +[cols="1h,1,2"] +|=== +| Type | `flow/multiGate` | Route the execution flow to one of the outputs sequentially or randomly +.3+| Configuration +| `int outputFlows` | The number of output flows, **MUST** be greater than 0 +| `bool isRandom` | If set to true, output flows are executed in random order, picking a random not used output flow each time until all are done +| `bool loop` | If set to true, the outputs will repeat in a loop continuously after all are done +.2+| Input flow sockets +| `in` | The entry flow into this node +| `reset` | When this flow is activated, the `lastIndex` value is reset to -1 and all outputs are marked as not used +| Output flow sockets +| `` | The `i`-th output flow, `i` is a non-negative integer decimal number less than the `outputFlows` configuration value +| Output value sockets +| `int lastIndex` | The index of the last used output; `-1` if the node has not been activated +|=== + +The internal state of this node consists of one 32-bit signed integer value `lastIndex` initialized to -1 and a map of booleans with all values initialized to false representing used output flows. The size of the boolean map is equal to the number of connected output flows, i.e., unconnected output flows are ignored. + +When the `reset` input flow is activated: + +1. Reset the `lastIndex` value to -1. +2. Mark all connected output flows as not used in the boolean map. + +When the `in` input flow is activated: + +1. If the `isRandom` input value is false, +.. let `i` be the smallest connected not used output flow index according to the boolean map or -1 if all flows are marked as used. +2. If the `isRandom` input value is true, +.. let `i` be a random not used connected output flow index according to the boolean map or -1 if all flows are marked as used. +3. If `i` is greater than -1, +.. mark the `i`-th output as used in the boolean map; +.. set the `lastIndex` value to `i`; +.. activate the output flow `i`. +4. If `i` is equal to -1 and the `loop` input value is true, +.. mark all connected output flows as not used in the boolean map; +.. if the `isRandom` input value is false, +... set `i` to the smallest connected output flow index; +.. if the `isRandom` input value is true, +... set `i` be a random connected output flow index; +.. mark the `i`-th output flow as used in the boolean map; +.. set the `lastIndex` value to `i`; +.. activate the output flow `i`. + +===== Wait All + +[cols="1h,1,2"] +|=== +| Type | `flow/waitAll` | Activate the output flow when all input flows have been activated at least once. +| Configuration +| `int inputFlows` | The number of input flows, **MUST** be greater than 0 +.2+| Input flow sockets +| `` | The `i`-th input flow, `i` is a non-negative integer decimal number less than the `inputFlows` configuration value +| `reset` | When this flow is activated, all input flows are marked as unused +.2+| Output flow sockets +| `out` | The flow to be activated after every input flow activation except the last missing input +| `completed` | The flow to be activated when the last missing input flow is activated +| Output value sockets +| `int remainingInputs` | The number of not yet activated input flows +|=== + +The internal state of this node consists of one 32-bit signed integer value `remainingInputs` initialized to the number of connected input flows not including the `reset` input flow and a map of booleans with all values initialized to false representing used input flow sockets. The size of the boolean map is equal to the initial `remainingInputs` value. + +When the `reset` input flow is activated: + +1. Reset `remainingInputs` to the number of connected input flows not including the `reset` input flow. +2. Mark all connected input flows as not used in the boolean map. + +When any of the `` input flows is activated: + +1. If the ``-th input flow is not marked as used in the boolean map: +.. mark the ``-th input flow as used in the boolean map. +.. decrement the `remainingInputs` value by 1; +2. If the `remainingInputs` value is zero: +.. activate the `completed` output flow. +3. If the `remainingInputs` value is not zero: +.. activate the `out` output flow. From f69bfb1391f7f528a81b06c51dea698ad5577de6 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 4 Mar 2024 00:00:00 +0000 Subject: [PATCH 09/42] Address feedback --- .../KHR_interactivity/Specification.adoc | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 15ff4042c0..081887776b 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1536,19 +1536,12 @@ If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation retu | Input flow sockets | `in` | The entry flow into this node | Output flow sockets -| `` | The `i`-th output flow, `i` is a non-negative integer decimal number less than or equal to 2147483647. +| `` | One or more output flows; their names are purely informative |=== This node has no internal state. -When the `in` input flow is activated: - -1. Let a temporary variable `index` be -1. -2. Let a temporary variable `maxIndex` be the maximum output flow name value. -3. If `index` is less than `maxIndex`: -.. increment `index` by 1; -.. activate the output flow named `` if it exists and is connected; -.. goto step 3. +When the `in` input flow is activated, all output flows are activated one by one in the order they are defined in JSON. ===== Branch @@ -1574,16 +1567,20 @@ The `condition` input value is evaluated each time the node is executed. |=== | Type | `flow/switch` | Conditionally route the execution flow to one of the outputs | Configuration -| `int[] cases` | The cases on which to perform the switch on; values **MUST** be unique integers +| `int[] cases` | The cases on which to perform the switch on; values **MUST** be unique 32-bit signed integers; at least one value **MUST** be present | Input flow sockets | `in` | The entry flow into this node | Input value sockets | `int selection` | The value on which the switch operates .2+| Output flow sockets -| `` | The `i`-th output flow, `i` is an integer decimal number; it **MUST** be present in the `cases` configuration -| `default` | The output flow used when the `selection` input value is not present in the `cases` configuration +| `` | The output flow, `case` is an integer decimal number present in the `cases` configuration array +| `default` | The output flow used when the `selection` input value is not present in the `cases` configuration array |=== +The node has one or more `` output flow sockets named as decimal integers equal to the elements of the `cases` configuration array. Encoded as JSON strings, these output flow socket names **MUST** contain only decimal integers (ASCII characters `0x30 ... 0x39`) and optionally a leading minus sign (ASCII character `0x2D`); other characters and leading zeros are not allowed. + +For example, if the `cases` configuration array is `[-1, 0, 1]`, the output socket names are exactly `"-1"`, `"0"`, and `"1"`. + This node has no internal state. When the `in` input flow is activated: @@ -1686,45 +1683,46 @@ When the `in` input flow is activated: [cols="1h,1,2"] |=== | Type | `flow/multiGate` | Route the execution flow to one of the outputs sequentially or randomly -.3+| Configuration -| `int outputFlows` | The number of output flows, **MUST** be greater than 0 +.2+| Configuration | `bool isRandom` | If set to true, output flows are executed in random order, picking a random not used output flow each time until all are done | `bool loop` | If set to true, the outputs will repeat in a loop continuously after all are done .2+| Input flow sockets | `in` | The entry flow into this node | `reset` | When this flow is activated, the `lastIndex` value is reset to -1 and all outputs are marked as not used | Output flow sockets -| `` | The `i`-th output flow, `i` is a non-negative integer decimal number less than the `outputFlows` configuration value +| `` | One or more output flows; their names are purely informative | Output value sockets | `int lastIndex` | The index of the last used output; `-1` if the node has not been activated |=== -The internal state of this node consists of one 32-bit signed integer value `lastIndex` initialized to -1 and a map of booleans with all values initialized to false representing used output flows. The size of the boolean map is equal to the number of connected output flows, i.e., unconnected output flows are ignored. +The internal state of this node consists of one 32-bit signed integer value `lastIndex` initialized to -1 and an array of booleans with all values initialized to false representing used output flows. The size of the boolean array is equal to the number of output flows. + +The output flows are ordered as they are defined in JSON. When the `reset` input flow is activated: 1. Reset the `lastIndex` value to -1. -2. Mark all connected output flows as not used in the boolean map. +2. Mark all output flows as not used in the boolean array. When the `in` input flow is activated: -1. If the `isRandom` input value is false, -.. let `i` be the smallest connected not used output flow index according to the boolean map or -1 if all flows are marked as used. -2. If the `isRandom` input value is true, -.. let `i` be a random not used connected output flow index according to the boolean map or -1 if all flows are marked as used. +1. If the `isRandom` configuration value is false, +.. let `i` be the smallest not used output flow index according to the boolean array or -1 if all output flows are marked as used. +2. If the `isRandom` configuration value is true, +.. let `i` be a random not used output flow index according to the boolean array or -1 if all output flows are marked as used. 3. If `i` is greater than -1, -.. mark the `i`-th output as used in the boolean map; +.. mark the output flow with index `i` as used in the boolean array; .. set the `lastIndex` value to `i`; -.. activate the output flow `i`. -4. If `i` is equal to -1 and the `loop` input value is true, -.. mark all connected output flows as not used in the boolean map; -.. if the `isRandom` input value is false, -... set `i` to the smallest connected output flow index; -.. if the `isRandom` input value is true, -... set `i` be a random connected output flow index; -.. mark the `i`-th output flow as used in the boolean map; +.. activate the output flow with index `i`. +4. If `i` is equal to -1 and the `loop` configuration value is true, +.. mark all output flows as not used in the boolean array; +.. if the `isRandom` configuration value is false, +... set `i` to 0; +.. if the `isRandom` configuration value is true, +... set `i` to a random output flow index; +.. mark the output flow with index `i` as used in the boolean array; .. set the `lastIndex` value to `i`; -.. activate the output flow `i`. +.. activate the output flow with index `i`. ===== Wait All @@ -1732,7 +1730,7 @@ When the `in` input flow is activated: |=== | Type | `flow/waitAll` | Activate the output flow when all input flows have been activated at least once. | Configuration -| `int inputFlows` | The number of input flows, **MUST** be greater than 0 +| `int inputFlows` | The number of input flows, **MUST** be greater than 0 and less than or equal to 2147483647 .2+| Input flow sockets | `` | The `i`-th input flow, `i` is a non-negative integer decimal number less than the `inputFlows` configuration value | `reset` | When this flow is activated, all input flows are marked as unused @@ -1743,6 +1741,10 @@ When the `in` input flow is activated: | `int remainingInputs` | The number of not yet activated input flows |=== +The node has one or more input flow sockets named as sequential non-negative decimal integers depending on the `inputFlows` configuration value. Encoded as JSON strings, these input flow socket names contain only decimal integers (ASCII characters `0x30 ... 0x39`); other characters and leading zeros are not allowed. + +For example, if `inputFlows` is 3, the input socket names are `"0"`, `"1"`, and `"2"` exactly. + The internal state of this node consists of one 32-bit signed integer value `remainingInputs` initialized to the number of connected input flows not including the `reset` input flow and a map of booleans with all values initialized to false representing used input flow sockets. The size of the boolean map is equal to the initial `remainingInputs` value. When the `reset` input flow is activated: From 29e8accb02bc75bc19bca9bc81cbac002d772b25 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 4 Mar 2024 00:00:00 +0000 Subject: [PATCH 10/42] Add flow/throttle --- .../KHR_interactivity/Specification.adoc | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 081887776b..6ca8b3fcb1 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1761,3 +1761,44 @@ When any of the `` input flows is activated: .. activate the `completed` output flow. 3. If the `remainingInputs` value is not zero: .. activate the `out` output flow. + +===== Throttle + +[cols="1h,1,2"] +|=== +| Type | `flow/throttle` | Activate the output flow unless it has been activated less than a certain time ago +.2+| Input flow sockets +| `in` | The entry flow into this node +| `reset` | When this flow is activated, the output flow throttling state is reset +| Input value sockets +| `float duration` | The time, in seconds, to wait after an output flow activation before allowing subsequent output flow activations +.2+| Output flow sockets +| `out` | The flow to be activated if the output flow is not currently throttled +| `err` | The flow to be activated if the `duration` input value is negative, infinite, or NaN +| Output value sockets +| `float lastRemainingTime` | The remaining throttling time, in seconds, at the moment of the last valid activation of the input flow or NaN if the input flow has never been activated with a valid `duration` input value +|=== + +The internal state of this node consists of an uninitialized _timestamp_ value of an implementation-defined high-precision type and a floating-point `lastRemainingTime` value initialized to NaN. + +When the `reset` input flow is activated: + +1. Reset the `lastRemainingTime` value to NaN. + +When the `in` input flow is activated: + +1. Evaluate the `duration` input value. +2. If the `duration` input value is NaN, infinite, or negative, +.. activate the `err` output flow and skip the next steps. +3. If the `lastRemainingTime` value is not NaN: +.. Let `elapsed` be a non-negative difference, in seconds, between the _timestamp_ and the current time. +.. If the `duration` input value is less than or equal to the `elapsed` value, +... set the _timestamp_ value to the current time; +... set the `lastRemainingTime` value to zero; +... activate the `out` output flow. +.. If the `duration` input value is greater than the `elapsed` value, +... set the `lastRemainingTime` value to the positive difference, in seconds, between the `duration` and `elapsed` values. +4. If the `lastRemainingTime` value is NaN, +.. set the _timestamp_ value to the current time; +.. set the `lastRemainingTime` value to zero; +.. activate the `out` output flow. From 6ebb25f15e5cce60047f119b950196e8a8f1dbdd Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 4 Mar 2024 00:00:00 +0000 Subject: [PATCH 11/42] Add flow/delay --- .../KHR_interactivity/Specification.adoc | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 6ca8b3fcb1..26a8b981de 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1779,7 +1779,7 @@ When any of the `` input flows is activated: | `float lastRemainingTime` | The remaining throttling time, in seconds, at the moment of the last valid activation of the input flow or NaN if the input flow has never been activated with a valid `duration` input value |=== -The internal state of this node consists of an uninitialized _timestamp_ value of an implementation-defined high-precision type and a floating-point `lastRemainingTime` value initialized to NaN. +The internal state of this node consists of an uninitialized _timestamp_ value of an implementation-defined high-precision time type and a floating-point `lastRemainingTime` value initialized to NaN. When the `reset` input flow is activated: @@ -1802,3 +1802,33 @@ When the `in` input flow is activated: .. set the _timestamp_ value to the current time; .. set the `lastRemainingTime` value to zero; .. activate the `out` output flow. + +==== Async Nodes + +===== Delay + +[cols="1h,1,2"] +|=== +| Type | `flow/delay` | Schedule the output flow activation after a certain delay +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `float duration` | The duration, in seconds, to delay +.3+| Output flow sockets +| `out` | The flow to be activated if the `duration` value is valid +| `err` | The flow to be activated if the `duration` value is invalid +| `completed` | The flow to be activated after the delay +|=== + +The internal state of this node consists of an _activationTime_ value of an implementation-defined high-precision time type initialized to epoch. + +When the `in` input flow is activated: + +1. Evaluate the `duration` input value. +2. If the `duration` input value is NaN, infinite, or negative, +.. activate the `err` output flow and skip the next steps. +3. Let _currentTime_ be an implementation-defined high-precision time value representing the current time. +4. If the _activationTime_ value is less than the _currentTime_ value, +.. set the _activationTime_ value to the sum of the _currentTime_ value and the `duration` input value converted to the same implementation-specific high-precision time type; +.. schedule the `completed` output flow activation at the _activationTime_ time. +5. Activate the `out` output flow. From c63a37fda2d75e224e8291eaf03f2d0732f2dad4 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:00:00 +0000 Subject: [PATCH 12/42] Address feedback --- .../Khronos/KHR_interactivity/Specification.adoc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 26a8b981de..48d91b6f73 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1685,7 +1685,7 @@ When the `in` input flow is activated: | Type | `flow/multiGate` | Route the execution flow to one of the outputs sequentially or randomly .2+| Configuration | `bool isRandom` | If set to true, output flows are executed in random order, picking a random not used output flow each time until all are done -| `bool loop` | If set to true, the outputs will repeat in a loop continuously after all are done +| `bool isLoop` | If set to true, the outputs will repeat in a loop continuously after all are done .2+| Input flow sockets | `in` | The entry flow into this node | `reset` | When this flow is activated, the `lastIndex` value is reset to -1 and all outputs are marked as not used @@ -1714,7 +1714,7 @@ When the `in` input flow is activated: .. mark the output flow with index `i` as used in the boolean array; .. set the `lastIndex` value to `i`; .. activate the output flow with index `i`. -4. If `i` is equal to -1 and the `loop` configuration value is true, +4. If `i` is equal to -1 and the `isLoop` configuration value is true, .. mark all output flows as not used in the boolean array; .. if the `isRandom` configuration value is false, ... set `i` to 0; @@ -1813,22 +1813,20 @@ When the `in` input flow is activated: | Input flow sockets | `in` | The entry flow into this node | Input value sockets -| `float duration` | The duration, in seconds, to delay +| `float duration` | The duration, in seconds, to delay the `completed` output flow activation .3+| Output flow sockets | `out` | The flow to be activated if the `duration` value is valid | `err` | The flow to be activated if the `duration` value is invalid | `completed` | The flow to be activated after the delay |=== -The internal state of this node consists of an _activationTime_ value of an implementation-defined high-precision time type initialized to epoch. +This node has no internal state. When the `in` input flow is activated: 1. Evaluate the `duration` input value. 2. If the `duration` input value is NaN, infinite, or negative, .. activate the `err` output flow and skip the next steps. -3. Let _currentTime_ be an implementation-defined high-precision time value representing the current time. -4. If the _activationTime_ value is less than the _currentTime_ value, -.. set the _activationTime_ value to the sum of the _currentTime_ value and the `duration` input value converted to the same implementation-specific high-precision time type; -.. schedule the `completed` output flow activation at the _activationTime_ time. +3. Let _activationTime_ be an implementation-defined high-precision time value equal to the sum of the current time value and the `duration` input value converted to the same time type. +4. Schedule the `completed` output flow activation at the _activationTime_ time. 5. Activate the `out` output flow. From 48851d2fed3a43dad3286011312df28e492eae8a Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:00:00 +0000 Subject: [PATCH 13/42] Mention flow/delay activations limit --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 48d91b6f73..f75f35de00 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1830,3 +1830,5 @@ When the `in` input flow is activated: 3. Let _activationTime_ be an implementation-defined high-precision time value equal to the sum of the current time value and the `duration` input value converted to the same time type. 4. Schedule the `completed` output flow activation at the _activationTime_ time. 5. Activate the `out` output flow. + +The graph execution **MAY** be terminated when the amount of pending activations exceeds an implementation-defined value. From 86bf6938fc5b4e51ebe77bc30686cd790436f298 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:00:00 +0000 Subject: [PATCH 14/42] Add pointer/get and pointer/set --- .../KHR_interactivity/Specification.adoc | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index f75f35de00..979b73ef88 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1832,3 +1832,83 @@ When the `in` input flow is activated: 5. Activate the `out` output flow. The graph execution **MAY** be terminated when the amount of pending activations exceeds an implementation-defined value. + +=== State Manipulation Nodes + +==== Object Model Access + +===== Pointer Get + +[cols="1h,1,2"] +|=== +| Type | `pointer/get` | Get an object model property value +| Configuration +| `string pointer` | The JSON pointer or JSON pointer template +| Input value sockets +| `int ` | The JSON pointer template path segment to be substituted at runtime +.2+| Output value sockets +| `T value` | The resolved property value +| `bool isValid` | True if the property value can be resolved, false otherwise +|=== + +This node gets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. + +[NOTE] +.Examples +==== +The `pointer` configuration value `"/nodes/0/scale"` is valid; its output value socket is of `float3` type. + +The `pointer` configuration value `"/myProperty"` is invalid because this path is not defined. +==== + +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. + +[NOTE] +.Example +==== +If the `pointer` configuration value is `"/nodes/{myId}/scale"`, the node has the `myId` input value socket, which value denotes the node index. +==== + +This node has no internal state. + +If the pointer or the pointer template with all its substitutions applied can be resolved, the `value` output value is the resolved property value and the `isValid` output value is true. + +If the pointer or the pointer template with all its substitutions applied cannot be resolved, the `value` output value is the default value for its type and the `isValid` output value is false. + +[NOTE] +.Note +==== +Unresolvable pointers include those with negative or out-of-bounds array indices and/or non-existent JSON objects. +==== + +===== Pointer Set + +[cols="1h,1,2"] +|=== +| Type | `pointer/set` | Set an object model property value +| Configuration +| `string pointer` | The JSON pointer or JSON pointer template +| Input flow sockets +| `in` | The entry flow into this node +.2+| Input value sockets +| `int ` | The JSON pointer template path segment to be substituted at runtime +| `T value` | The new property value +.2+| Output flow sockets +| `out` | The flow to be activated if the JSON pointer can be resolved +| `err` | The flow to be activated if the JSON pointer cannot be resolved +|=== + +This node sets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. + +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If the pointer or the pointer template with all its substitutions applied can be resolved, +.. set the resolved property to the `value` input value; +.. activate the `out` output flow. +3. If the pointer or the pointer template with all its substitutions applied cannot be resolved, +.. activate the `err` output flow. From 71860b812a57ce38b9957fca45176c528ca9433a Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:00:00 +0000 Subject: [PATCH 15/42] Add variable/get and variable/set --- .../KHR_interactivity/Specification.adoc | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 979b73ef88..b860b0528d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1835,6 +1835,48 @@ The graph execution **MAY** be terminated when the amount of pending activations === State Manipulation Nodes +==== Custom Variable Access + +===== Variable Get + +[cols="1h,1,2"] +|=== +| Type | `variable/get` | Get a custom variable value +| Configuration +| `int variable` | The custom variable index +| Output value sockets +| `T value` | The custom variable value +|=== + +This node gets a custom variable value using the variable index provided by the `variable` configuration value. The type `T` is determined by the referenced variable. The variable index **MUST** be non-negative and less than the total number of custom variables, otherwise the node is invalid. + +This node has no internal state. + +===== Variable Set + +[cols="1h,1,2"] +|=== +| Type | `variable/set` | Set a custom variable value +| Configuration +| `int variable` | The custom variable index +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `T value` | The new variable value +| Output flow sockets +| `out` | The flow to be activated after the value is set +|=== + +This node sets a custom variable value using the variable index provided by the `variable` configuration value and the `value` input value. The type `T` is determined by the referenced variable. The variable index **MUST** be non-negative and less than the total number of custom variables, otherwise the node is invalid. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate the `value` input value. +2. Set the custom variable with the `variable` configuration value index to the `value` input value. +3. Activate the `out` output flow. + ==== Object Model Access ===== Pointer Get From ffd99ef31a97166e939387f94a5dd4b458a5f94c Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 25 Mar 2024 00:00:00 +0000 Subject: [PATCH 16/42] Adjust flow/throttle error condition --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index b860b0528d..e574d79207 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1788,7 +1788,7 @@ When the `reset` input flow is activated: When the `in` input flow is activated: 1. Evaluate the `duration` input value. -2. If the `duration` input value is NaN, infinite, or negative, +2. If the `duration` input value is NaN, infinite, negative, or not convertible into an implementation-specific time type used for the internal _timestamp_ value, .. activate the `err` output flow and skip the next steps. 3. If the `lastRemainingTime` value is not NaN: .. Let `elapsed` be a non-negative difference, in seconds, between the _timestamp_ and the current time. From 3260039fc8ff93b843fd5e2eb2d99d124d1f4338 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 25 Mar 2024 00:00:00 +0000 Subject: [PATCH 17/42] Update delay nodes --- .../KHR_interactivity/Specification.adoc | 64 +++++++++++++++---- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index e574d79207..8fb57d3f93 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1803,35 +1803,77 @@ When the `in` input flow is activated: .. set the `lastRemainingTime` value to zero; .. activate the `out` output flow. -==== Async Nodes +==== Delay Nodes -===== Delay +===== Set Delay [cols="1h,1,2"] |=== -| Type | `flow/delay` | Schedule the output flow activation after a certain delay -| Input flow sockets -| `in` | The entry flow into this node +| Type | `flow/setDelay` | Schedule the output flow activation after a certain delay +.2+| Input flow sockets +| `in` | The entry flow into this node +| `cancel` | When this flow is activated, all delayed activations scheduled by this node are cancelled | Input value sockets | `float duration` | The duration, in seconds, to delay the `completed` output flow activation +| Output value sockets +| `int lastDelayIndex` | The delay index assigned during the last successful node execution .3+| Output flow sockets | `out` | The flow to be activated if the `duration` value is valid | `err` | The flow to be activated if the `duration` value is invalid | `completed` | The flow to be activated after the delay |=== -This node has no internal state. +The internal state of this node consists of an integer `lastDelayIndex` value initialized to -1 and a dynamic array of activation indices scheduled by the node. This array is initially empty and its maximum size is implementation-specific. + +The internal state of an execution graph having one or more `flow/setDelay` nodes includes a dynamic array of activation indices scheduled from all such nodes. This array is initially empty and its maximum size is implementation-specific. When the `in` input flow is activated: 1. Evaluate the `duration` input value. -2. If the `duration` input value is NaN, infinite, or negative, +2. If the `duration` input value is NaN, infinite, negative, or not convertible into an implementation-specific time type, .. activate the `err` output flow and skip the next steps. -3. Let _activationTime_ be an implementation-defined high-precision time value equal to the sum of the current time value and the `duration` input value converted to the same time type. -4. Schedule the `completed` output flow activation at the _activationTime_ time. -5. Activate the `out` output flow. +3. If scheduling a new activation exceeds any implementation-specific limit, +.. activate the `err` output flow and skip the next steps. +4. Let _activationTime_ be an implementation-defined high-precision time value equal to the sum of the current time value and the `duration` input value converted to the same time type. +5. If _activationTime_ is not valid according to implementation-specific validation rules, e.g., it exceeds an internal threshold value, +.. activate the `err` output flow and skip the next steps. +6. Set `lastDelayIndex` to a positive value representing the delayed flow activation being scheduled. This value **MUST** be unique across all previous activations of all `flow/setDelay` nodes of the graph. +7. Push the value of `lastDelayIndex` to the graph and node arrays of activation indices. +8. Schedule the following actions at the _activationTime_ time: +.. Removal of the activation index value from both arrays of activation indices. +.. Activation of the `completed` output flow. +9. Activate the `out` output flow. + +When the `cancel` input flow is activated: + +1. Set the `lastDelayIndex` value to -1. +2. For each activation index value in the node's array of activation indices: +.. Remove this activation index value from the node's and the graph's arrays of activation indices. +.. Cancel the corresponding scheduled activation. + +===== Cancel Delay + +[cols="1h,1,2"] +|=== +| Type | `flow/cancelDelay` | Cancel a previously scheduled output flow activation +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `int delayIndex` | The index value of the scheduled activation to be cancelled +| Output flow sockets +| `out` | The flow to be activated after executing this node +|=== + +This node has no internal state but its execution **MAY** affect internal states of other nodes and the graph. + +When the `in` input flow is activated: + +1. Evaluate the `delayIndex` input value. +2. Remove this activation index value from all arrays of activation indices if it exists. +3. Cancel the corresponding scheduled activation if it exists. +4. Activate the `out` output flow. -The graph execution **MAY** be terminated when the amount of pending activations exceeds an implementation-defined value. +Non-positive or not existing delay index values **MUST NOT** cause any runtime errors. === State Manipulation Nodes From 18e12ccef0b2eed7e80f2fb7db8550511cb9f391 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 1 Apr 2024 00:00:00 +0000 Subject: [PATCH 18/42] Clarify delay limits --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 8fb57d3f93..bcd2cb47d3 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1827,6 +1827,8 @@ The internal state of this node consists of an integer `lastDelayIndex` value in The internal state of an execution graph having one or more `flow/setDelay` nodes includes a dynamic array of activation indices scheduled from all such nodes. This array is initially empty and its maximum size is implementation-specific. +Implementations **MUST** be aware of their effective limit on the maximum supported `duration` input value to avoid any implicit behavior changes, e.g., due to numeric overflows; exceeding such value **MUST** lead to the `err` output flow activation as described below. + When the `in` input flow is activated: 1. Evaluate the `duration` input value. From e73bc71c91a82b994b46b3c140e6b9ed0a6be33b Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 8 Apr 2024 00:00:00 +0000 Subject: [PATCH 19/42] Clarify invalid values for pointer/set --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index bcd2cb47d3..457177e25d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1988,6 +1988,8 @@ This node sets a glTF Asset Object Model value using the provided JSON pointer. The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. +If the `value` input value is not valid for the resolved property, the effective property value becomes implementation-defined and subsequent `pointer/get` evaluations of the property **MAY** return any value of the corresponding type until the property is updated with a valid value. + This node has no internal state. When the `in` input flow is activated: From 38e690fd69b02e7b1d5f74c4cd001c64192b9a39 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 8 Apr 2024 00:00:00 +0000 Subject: [PATCH 20/42] Add boolean arithmetic nodes --- .../KHR_interactivity/Specification.adoc | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 457177e25d..dcf1d1c8ce 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1524,6 +1524,55 @@ a ? (31 - Math.clz32(a & -a)) : 32; If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation returns 32. +==== Boolean Arithmetic Nodes + +===== Equality + +[cols="1h,1,2"] +|=== +| Type | `math/eq` | Equality operation +.2+| Input value sockets +| `bool a` | First argument +| `bool b` | Second argument +| Output value sockets +| `bool value` | True if and only if both stem:[a] and stem:[b] have the same value; false otherwise +|=== + +===== Boolean NOT + +[cols="1h,1,2"] +|=== +| Type | `math/not` | Boolean NOT operation +| Input value sockets +| `bool a` | Argument +| Output value sockets +| `bool value` | True if stem:[a] is false; false if stem:[a] is true +|=== + +===== Boolean AND + +[cols="1h,1,2"] +|=== +| Type | `math/and` | Boolean AND operation +.2+| Input value sockets +| `bool a` | First argument +| `bool b` | Second argument +| Output value sockets +| `bool value` | True if and only if both stem:[a] and stem:[b] are true; false otherwise +|=== + +===== Boolean OR + +[cols="1h,1,2"] +|=== +| Type | `math/or` | Boolean OR operation +.2+| Input value sockets +| `bool a` | First argument +| `bool b` | Second argument +| Output value sockets +| `bool value` | False if and only if both stem:[a] and stem:[b] are false; true otherwise +|=== + === Control Flow Nodes ==== Sync Nodes From 8fbc8667760ad2afa81f75bf644b738886c231ce Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 8 Apr 2024 00:00:00 +0000 Subject: [PATCH 21/42] Add type conversion nodes --- .../KHR_interactivity/Specification.adoc | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index dcf1d1c8ce..f970da937d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1573,6 +1573,145 @@ If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation retu | `bool value` | False if and only if both stem:[a] and stem:[b] are false; true otherwise |=== +=== Type Conversion Nodes + +==== Boolean Conversion Nodes + +===== Boolean to Integer + +[cols="1h,1,2"] +|=== +| Type | `type/boolToInt` | Boolean to integer conversion +| Input value sockets +| `bool a` | Argument +| Output value sockets +| `int value` | stem:[1] if stem:[a] is true; stem:[0] otherwise +|=== + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +a|0 +---- +==== + +===== Boolean to Float + +[cols="1h,1,2"] +|=== +| Type | `type/boolToFloat` | Boolean to float conversion +| Input value sockets +| `bool a` | Argument +| Output value sockets +| `float value` | stem:[1] if stem:[a] is true; stem:[0] otherwise +|=== + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- ++a +---- +==== + +==== Integer Conversion Nodes + +===== Integer to Boolean + +[cols="1h,1,2"] +|=== +| Type | `type/intToBool` | Integer to boolean conversion +| Input value sockets +| `int a` | Argument +| Output value sockets +| `bool value` | True if stem:[a] is not equal to zero; false otherwise +|=== + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +!!a +---- +==== + +===== Integer to Float + +[cols="1h,1,2"] +|=== +| Type | `type/intToFloat` | Integer to float conversion +| Input value sockets +| `int a` | Argument +| Output value sockets +| `float value` | Floating-point value equal to stem:[a] +|=== + +Since floating-point values have double precision, this conversion **MUST** be lossless. + +This operation **MUST NOT** produce negative zero. + +[NOTE] +.Note +==== +This operation is no-op in ECMAScript. +==== + +==== Float Conversion Nodes + +===== Float to Boolean + +[cols="1h,1,2"] +|=== +| Type | `type/floatToBool` | Float to boolean conversion +| Input value sockets +| `float a` | Argument +| Output value sockets +| `bool value` | False if stem:[a] is NaN or equal to zero; true otherwise +|=== + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +!!a +---- +==== + +===== Float to Integer + +[cols="1h,1,2"] +|=== +| Type | `type/floatToInt` | Float to integer conversion +| Input value sockets +| `float a` | Argument +| Output value sockets +| `int value` | Integer value produced as described below +|=== + +1. If the stem:[a] input value is zero, infinite, or NaN, return zero and skip the next steps. +2. Let stem:[t] be stem:[a] with its fractional part removed by rounding towards zero. +3. Let stem:[k] be a value of the same sign as stem:[t] such that its absolute value is less than stem:[2^32] and stem:[k] is equal to stem:[t - q * 2^32] for some integer stem:[q]. +4. If stem:[k] is greater than or equal to stem:[2^31], return stem:[k - 2^32]; otherwise return stem:[k]. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +a|0 +---- +==== + === Control Flow Nodes ==== Sync Nodes From b681b0a4963b8f7418057cd0d2904f6bddec40d8 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 8 Apr 2024 00:00:00 +0000 Subject: [PATCH 22/42] Add math/select node --- .../KHR_interactivity/Specification.adoc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index f970da937d..c8cede8c2f 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -592,7 +592,7 @@ If any input value is _NaN_, the output value is false. | `bool value` | True if stem:[a >= b]; false otherwise |=== -==== Special Floating-Point Nodes +==== Special Nodes ===== Is Not a Number @@ -616,6 +616,21 @@ If any input value is _NaN_, the output value is false. | `bool value` | True if stem:[a] is positive or negative infinity; false otherwise |=== +===== Select + +[cols="1h,1,2"] +|=== +| Type | `math/select` | Conditional selection operation +.3+| Input value sockets +| `bool condition` | Value selecting the value returned +| `T a` | Positive selection option +| `T b` | Negative selection option +| Output value sockets +| `T value` | stem:[a] if the the `condition` input value is true; stem:[b] otherwise +|=== + +The type `T` represents any type. It **MUST** be the same for the output value socket and the input value sockets stem:[a] and stem:[b], otherwise the node is invalid. + ==== Angle and Trigonometry Nodes Node parameters specified as angle are assumed to be in units of radians. From 9e000b926e3f8ecd4b6f5f96f63f1bc1aa916ee4 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 15 Apr 2024 00:00:00 +0000 Subject: [PATCH 23/42] Add boolean XOR --- .../2.0/Khronos/KHR_interactivity/Specification.adoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index c8cede8c2f..37961dee36 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1588,6 +1588,18 @@ If stem:[a] is 0, the operation returns 0; if stem:[a] is -1, the operation retu | `bool value` | False if and only if both stem:[a] and stem:[b] are false; true otherwise |=== +===== Boolean XOR + +[cols="1h,1,2"] +|=== +| Type | `math/xor` | Boolean XOR operation +.2+| Input value sockets +| `bool a` | First argument +| `bool b` | Second argument +| Output value sockets +| `bool value` | True if and only if stem:[a] is not equal to stem:[b]; false otherwise +|=== + === Type Conversion Nodes ==== Boolean Conversion Nodes From de89f6acff79748503bbdb0d99ad50c332c8a812 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Apr 2024 00:00:00 +0400 Subject: [PATCH 24/42] Add vector and matrix combine/extract nodes --- .../KHR_interactivity/Specification.adoc | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 37961dee36..13d0982830 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -1032,6 +1032,76 @@ If the vector stem:[b] is not unit, rotation results may be undefined. | `float4 value` | Transformed vector |=== +===== Combine + +[cols="1h,1,2"] +|=== +| Type | `math/combine2` | Combine two floats into a two-component vector +.2+| Input value sockets +| `float a` | First component +| `float b` | Second component +| Output value sockets +| `float2 value` | Vector +|=== + +[cols="1h,1,2"] +|=== +| Type | `math/combine3` | Combine three floats into a three-component vector +.3+| Input value sockets +| `float a` | First component +| `float b` | Second component +| `float c` | Third component +| Output value sockets +| `float3 value` | Vector +|=== + +[cols="1h,1,2"] +|=== +| Type | `math/combine4` | Combine four floats into a four-component vector +.4+| Input value sockets +| `float a` | First component +| `float b` | Second component +| `float c` | Third component +| `float d` | Fourth component +| Output value sockets +| `float4 value` | Vector +|=== + +===== Extract + +[cols="1h,1,2"] +|=== +| Type | `math/extract2` | Extract two floats from a two-component vector +| Input value sockets +| `float2 a` | Vector +.2+| Output value sockets +| `float 0` | First component +| `float 1` | Second component +|=== + +[cols="1h,1,2"] +|=== +| Type | `math/extract3` | Extract three floats from a three-component vector +| Input value sockets +| `float3 a` | Vector +.3+| Output value sockets +| `float 0` | First component +| `float 1` | Second component +| `float 2` | Third component +|=== + +[cols="1h,1,2"] +|=== +| Type | `math/extract4` | Extract four floats from a four-component vector +| Input value sockets +| `float4 a` | Vector +.4+| Output value sockets +| `float 0` | First component +| `float 1` | Second component +| `float 2` | Third component +| `float 3` | Fourth component +|=== + ==== Matrix Nodes ===== Transpose @@ -1079,6 +1149,58 @@ If the vector stem:[b] is not unit, rotation results may be undefined. | `float4x4 value` | Matrix product |=== +===== Combine + +[cols="1h,1,2"] +|=== +| Type | `math/combine4x4` | Combine 16 floats into a 4x4 matrix +.16+| Input value sockets +| `float a` | First row, first column element +| `float b` | Second row, first column element +| `float c` | Third row, first column element +| `float d` | Fourth row, first column element +| `float e` | First row, second column element +| `float f` | Second row, second column element +| `float g` | Third row, second column element +| `float h` | Fourth row, second column element +| `float i` | First row, third column element +| `float j` | Second row, third column element +| `float k` | Third row, third column element +| `float l` | Fourth row, third column element +| `float m` | First row, fourth column element +| `float n` | Second row, fourth column element +| `float o` | Third row, fourth column element +| `float p` | Fourth row, fourth column element +| Output value sockets +| `float4x4 value` | Matrix +|=== + +===== Extract + +[cols="1h,1,2"] +|=== +| Type | `math/extract4x4` | Extract 16 floats from a 4x4 matrix +| Input value sockets +| `float4x4 a` | Matrix +.16+| Output value sockets +| `float 0` | First row, first column element +| `float 1` | Second row, first column element +| `float 2` | Third row, first column element +| `float 3` | Fourth row, first column element +| `float 4` | First row, second column element +| `float 5` | Second row, second column element +| `float 6` | Third row, second column element +| `float 7` | Fourth row, second column element +| `float 8` | First row, third column element +| `float 9` | Second row, third column element +| `float 10` | Third row, third column element +| `float 11` | Fourth row, third column element +| `float 12` | First row, fourth column element +| `float 13` | Second row, fourth column element +| `float 14` | Third row, fourth column element +| `float 15` | Fourth row, fourth column element +|=== + ==== Integer Arithmetic Nodes All inputs to these nodes are two's complement 32-bit signed integers. From 6867635d2ce89f22720e7e43daecb35cba4544c5 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 13 May 2024 00:00:00 +0000 Subject: [PATCH 25/42] Add pointer/interpolate --- .../KHR_interactivity/Specification.adoc | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 13d0982830..2a327aebd2 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2333,7 +2333,85 @@ When the `in` input flow is activated: 1. Evaluate all input values. 2. If the pointer or the pointer template with all its substitutions applied can be resolved, +.. if the _pointer interpolation state dynamic array_ (defined below) contains an entry with the same resolved JSON Pointer value, remove it from the array; .. set the resolved property to the `value` input value; .. activate the `out` output flow. 3. If the pointer or the pointer template with all its substitutions applied cannot be resolved, .. activate the `err` output flow. + +===== Pointer Interpolate + +[cols="1h,1,2"] +|=== +| Type | `pointer/interpolate` | Interpolate an object model property value +| Configuration +| `string pointer` | The JSON pointer or JSON pointer template +| Input flow sockets +| `in` | The entry flow into this node +.5+| Input value sockets +| `int ` | The JSON pointer template path segment to be substituted at runtime +| `T value` | The target property value +| `float duration` | The time, in seconds, in which the property **SHOULD** reach the target value +| `float2 p1` | Control point P1 +| `float2 p2` | Control point P2 +.3+| Output flow sockets +| `out` | The flow to be activated if the JSON pointer can be resolved and the input values are valid +| `err` | The flow to be activated if the JSON pointer cannot be resolved or the input values are invalid +| `done` | The flow to be activated when the property reaches the target value +|=== + +This node interpolates and updates the specified glTF Asset Object Model property multiple times over the specified duration using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined or if it is integer or boolean, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. + +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. + +If the `value` input value or any intermediate interpolated value are not valid for the resolved property, the effective property value becomes implementation-defined and subsequent `pointer/get` evaluations of the property **MAY** return any value of the corresponding type until the property is updated with a valid value. + +This node has no internal state. + +When a node of this type is used in the behavior graph, the global graph state includes an implementation-defined _pointer interpolation state dynamic array_ each element of which contains the following data: + +- The resolved JSON Pointer to the Object Model property being interpolated +- Implementation-defined high precision timestamp value representing the interpolation start time +- Interpolation duration value converted to the implementation-defined high precision time type +- Object Model property value at the time of the successful node activation +- Information needed for cubic Bézier spline evaluation derived from the node's input values +- Target property value +- Implementation-specific pointer to the `done` output flow of the node that has added this entry + +This array is initially empty and its maximum size is implementation-specific. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If the pointer or the pointer template with all its substitutions applied cannot be resolved, +.. activate the `err` output flow and skip the next steps. +3. If the `duration` input value is NaN, infinite, negative, or not convertible into an implementation-specific time type used for the internal interpolation start time value, +.. activate the `err` output flow and skip the next steps. +4. If any component of the `p1` or `p2` input values is NaN or infinite or if any of the first components of these input values is negative or greater than 1, +.. activate the `err` output flow and skip the next steps. +5. If starting a new pointer interpolation exceeds any implementation-specific limit, +.. activate the `err` output flow and skip the next steps. +6. If the _pointer interpolation state dynamic array_ contains an entry with the same resolved JSON Pointer value, +.. remove it from the array. +7. Using the implicitly-defined end points stem:[P_0 (0, 0)] and stem:[P_3 (1, 1)] together with the control points stem:[P_1] and stem:[P_2] provided via the input values construct a cubic Bézier easing function for the stem:[[0, 1]] input range. +8. Add a new entry to the _pointer interpolation state dynamic array_ filling it with the required information based on the evaluated input values. +9. Activate the `out` output flow. + +On each asset animation update, for each entry in the _pointer interpolation state dynamic array_: + +1. Compute the current input progress position _t_ as the time passed since the interpolation start divided by the interpolation's duration. +2. If _t_ is less than or equal to zero +.. skip the next steps. +3. If _t_ is NaN or greater than or equal to 1, +.. set the Object Model property to the target value; +.. remove the current entry from the _pointer interpolation state dynamic array_; +.. activate the `done` output flow linked to the current entry +.. skip the next steps. +4. Using the cubic Bézier spline information, compute the output progress position _q_ based on the _t_ value. This step implies that latexmath:[t \in [0; 1\]]. +5. Set the linked Object Model property to the new value computed as a linear interpolation between the original and the target property values using the output progress position _q_ as the interpolation coefficient. + +If the Object Model property is a quaternion, spherical linear interpolation expression **SHOULD** be used. + +Intermediate output progress values **MAY** be less than zero or greater than one. From 32fd17093c4f50e3cbf0277f2ad4dbc9cafd4be1 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 13 May 2024 00:00:00 +0000 Subject: [PATCH 26/42] Typo fixes --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 2a327aebd2..10226559d7 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2203,7 +2203,7 @@ When the `cancel` input flow is activated: | `out` | The flow to be activated after executing this node |=== -This node has no internal state but its execution **MAY** affect internal states of other nodes and the graph. +This node has no internal state but its execution **MAY** affect internal states of other nodes and the graph. When the `in` input flow is activated: @@ -2380,8 +2380,6 @@ When a node of this type is used in the behavior graph, the global graph state i This array is initially empty and its maximum size is implementation-specific. -This node has no internal state. - When the `in` input flow is activated: 1. Evaluate all input values. From 19630ba47dd3a33fe04be19001bc28b5df2483d9 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 13 May 2024 00:00:00 +0000 Subject: [PATCH 27/42] Adjust min/max/clamp node descriptions --- .../KHR_interactivity/Specification.adoc | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 10226559d7..2431b2fc09 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -473,6 +473,18 @@ For `float4x4` arguments, this operation performs per-component multiplication. | `floatN value` | Smallest of the arguments |=== +For the purposes of this node, negative zero is less than positive zero. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +Math.min(a, b) +---- +==== + ===== Maximum [cols="1h,1,2"] @@ -485,6 +497,18 @@ For `float4x4` arguments, this operation performs per-component multiplication. | `floatN value` | Largest of the arguments |=== +For the purposes of this node, negative zero is less than positive zero. + +[NOTE] +.Note +==== +This is implementable in ECMAScript via the following expression: +[source,js] +---- +Math.max(a, b) +---- +==== + ===== Clamp [cols="1h,1,2"] @@ -498,6 +522,8 @@ For `float4x4` arguments, this operation performs per-component multiplication. | `floatN value` | latexmath:[min(max(a, min(b, c)), max(b, c))] |=== +This node relies on `math/min` and `math/max` nodes defined above. + [NOTE] .Note ==== From a369436ac6d1024ca95c457841b4b0aea004527a Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:00:00 +0000 Subject: [PATCH 28/42] Add animation control nodes --- .../KHR_interactivity/Specification.adoc | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 2431b2fc09..04c1f3206e 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2439,3 +2439,134 @@ On each asset animation update, for each entry in the _pointer interpolation sta If the Object Model property is a quaternion, spherical linear interpolation expression **SHOULD** be used. Intermediate output progress values **MAY** be less than zero or greater than one. + +==== Animation Control Nodes + +===== Animation Play + +[cols="1h,1,2"] +|=== +| Type | `animation/start` | Start playing an animation +| Input flow sockets +| `in` | The entry flow into this node +.4+| Input value sockets +| `int animation` | Animation index +| `float startTime` | Start time +| `float endTime` | End time +| `float speed` | Speed multiplier +.3+| Output flow sockets +| `out` | The flow to be activated if the input values are valid +| `err` | The flow to be activated if any of the input values is invalid +| `completed` | The flow to be activated after the animation ends +|=== + +This node starts playing an animation using the specified input values. + +For the purposes of the Animation Control Nodes the concept of glTF animations is extended to unambiguously map any _requested input timestamp_ stem:[r] to the _effective input timestamp_ stem:[t] present in the glTF animation data as follows. + +1. Let stem:[T] be the maximum value of all animation sampler input accessors of the animation. Then, the stored animation data defines the animated property values for all _effective input timestamps_ in the stem:[[0, T]] range. +2. Let stem:[r] be a scalar value on a timeline infinite in both directions, from negative infinity to positive infinity. +3. If stem:[T] is not equal to zero, let stem:[s] be the current iteration number computed as follows: +latexmath:[s=\begin{cases} + \left\lceil \dfrac{r-T}{T} \right\rceil & \text{if } r \gt 0 \\ + \left\lfloor \dfrac{r}{T} \right\rfloor & \text{if } r \le 0 \\ + \end{cases}] +4. Now for each _requested input timestamp_ stem:[r], the corresponding _effective input timestamp_ is +latexmath:[t=\begin{cases} + r - s * T & \text{if } T \ne 0 \\ + 0 & \text{if } T=0 \\ + \end{cases}] + +This node has no internal state. + +When a node of this type is used in the behavior graph, the global graph state includes an implementation-defined _animation state dynamic array_ each element of which contains the following data: + +- Animation index +- Start time value +- End time value +- Stop time value (see `animation/stopAt`) +- Speed value +- Implementation-specific creation timestamp value associated with the system time when this entry was added +- Implementation-specific _end completion_ pointer to the `completed` output flow of the node that has added this entry +- Implementation-specific _stop completion_ pointer to the `completed` output flow of the node that has scheduled its stopping (see `animation/stopAt`) + +This array is initially empty; its maximum size is implementation-specific. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If the `animation` input value is negative or greater than or equal to the number of glTF animations in the asset, +.. activate the `err` output flow and skip the next steps. +3. If the `startTime` or `endTime` input values are NaN or if the `startTime` input value is infinite, +.. activate the `err` output flow and skip the next steps. +4. If the `speed` input value is NaN, infinite, or less than or equal to zero, +.. activate the `err` output flow and skip the next steps. +5. If starting a new animation exceeds any implementation-specific limit, +.. activate the `err` output flow and skip the next steps. +6. If the _animation state dynamic array_ contains an entry with the same animation index, +.. remove it from the array; the previously set `completed` flows **MUST NOT** be activated. +7. Add a new entry to the _animation state dynamic array_ filling it with the required information based on the evaluated input values. The stop time value **MUST** be set to the end time value and the stop completion pointer **MUST** be set to null. +8. Activate the `out` output flow. + +On each asset animation update, for each entry in the _animation state dynamic array_: + +1. TBD + +===== Animation Stop + +[cols="1h,1,2"] +|=== +| Type | `animation/stop` | Immediately stop a playing animation +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `int animation` | Animation index +.2+| Output flow sockets +| `out` | The flow to be activated if the animation index is valid +| `err` | The flow to be activated if the animation index is invalid +|=== + +This node stops a playing animation. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If the `animation` input value is negative or greater than or equal to the number of glTF animations in the asset, +.. activate the `err` output flow and skip the next steps. +3. If the _animation state dynamic array_ exists and contains an entry with the same animation index, +.. remove it from the array and stop the playing animation. The animated properties **MUST** keep their current values and the previously associated `completed` flows **MUST NOT** be activated. +4. Activate the `out` output flow. + +===== Animation Stop At + +[cols="1h,1,2"] +|=== +| Type | `animation/stopAt` | Schedule stopping a playing animation +| Input flow sockets +| `in` | The entry flow into this node +.2+| Input value sockets +| `int animation` | Animation index +| `float stopTime` | Stop time +.3+| Output flow sockets +| `out` | The flow to be activated if the input values are valid +| `err` | The flow to be activated if any of the input values is invalid +| `completed` | The flow to be activated after the animation stops +|=== + +This node stops a playing animation. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If the `animation` input value is negative or greater than or equal to the number of glTF animations in the asset, +.. activate the `err` output flow and skip the next steps. +3. If the `stopTime` input value is NaN, +.. activate the `err` output flow and skip the next steps. +4. If the _animation state dynamic array_ exists and does contain an entry with the same animation index, +.. update the entry's stop completion pointer to the `completed` output flow of this node; +.. update the entry's stop time to the `stopTime` input value. +5. Activate the `out` output flow. From 4685e06e548591e359d26b3f8d0e0b53d1b7d656 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:00:00 +0000 Subject: [PATCH 29/42] Add lifecycle nodes --- .../KHR_interactivity/Specification.adoc | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 04c1f3206e..77895fa627 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2570,3 +2570,36 @@ When the `in` input flow is activated: .. update the entry's stop completion pointer to the `completed` output flow of this node; .. update the entry's stop time to the `stopTime` input value. 5. Activate the `out` output flow. + +=== Event Nodes + +==== Lifecycle Event Nodes + +===== On Start + +[cols="1h,1,2"] +|=== +| Type | `event/onStart` | Start event +| Output flow sockets +| `out` | The flow to be activated when the start event happens +|=== + +This node is activated when all glTF asset resources are loaded and ready for rendering and interactions. + +This node has no internal state. + +===== On Tick + +[cols="1h,1,2"] +|=== +| Type | `event/onTick` | Tick event +.2+| Output value sockets +| `float timeSinceStart` | Relative time in seconds since the graph execution start +| `float timeSinceLastTick` | Relative time in seconds since the last tick occurred +| Output flow sockets +| `out` | The flow to be activated when the tick event happens +|=== + +This node is activated when a tick occurs. There will be at most one tick per rendered frame, which **SHOULD** align with frame time, but there are no guarantees of time elapsed between ticks. + +The internal state of this node consists of two floating-point time values initialized to NaN. They **MUST** be set to their effective values before the `out` output flow is activated. From 09f1f1d15627e80d2b9b384383a65ff36f35808d Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:00:00 +0000 Subject: [PATCH 30/42] Add custom event nodes --- .../KHR_interactivity/Specification.adoc | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 77895fa627..4b94f03a63 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2603,3 +2603,50 @@ This node has no internal state. This node is activated when a tick occurs. There will be at most one tick per rendered frame, which **SHOULD** align with frame time, but there are no guarantees of time elapsed between ticks. The internal state of this node consists of two floating-point time values initialized to NaN. They **MUST** be set to their effective values before the `out` output flow is activated. + +==== Custom Event Nodes + +===== Receive + +[cols="1h,1,2"] +|=== +| Type | `event/receive` | Receive a custom event +| Configuration +| `int event` | The custom event index +| Output value sockets +| `` | Output values defined by the custom event +|=== + +This node is activated when a custom event specified by the `event` configuration value occurs. The types, names, and semantics of the output value sockets are defined by the custom event index. + +The `event` configuration value **MUST** be non-negative and less than the total number of custom event definitions, otherwise the node is invalid. + +This node has no internal state. + +===== Send + +[cols="1h,1,2"] +|=== +| Type | `event/send` | Send a custom event +| Configuration +| `int event` | The custom event index +| Input flow sockets +| `in` | The entry flow into this node +| Input value sockets +| `` | Input values defined by the custom event +.2+| Output flow sockets +| `out` | The flow to be activated after sending the event +| `err` | The flow to be activated if any of the input values is invalid +|=== + +This node sends a custom event specified by the `event` configuration value. The types, names, and validation rules of the input value sockets are defined by the custom event index. + +The `event` configuration value **MUST** be non-negative and less than the total number of custom event definitions, otherwise the node is invalid. + +This node has no internal state. + +When the `in` input flow is activated: + +1. Evaluate all input values. +2. If any of them is invalid, activate the `err` output flow and skip the next step. +3. Activate the `out` output flow. From 22fececa79b3cebb6e8c97357d8f5316731e865e Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:00:00 +0000 Subject: [PATCH 31/42] Add more intro sections --- .../KHR_interactivity/Specification.adoc | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 4b94f03a63..6d12810981 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -240,19 +240,60 @@ Node's sockets and configurations are defined by its _type_. Node types follow ` A node is executed when its input flow socket is reached by or when one of its output value sockets is requested by another node. Usually, the node executes its dependencies (if any), its own logic, and any number (including zero) of outgoing flow sockets. [[types]] -== Value Types +== Types -TBD +All value sockets and configurations are strictly typed. + +Implementations of this extension **MUST** support the following type signatures. + +[[value-types]] +=== Value Types + +The following types are supported for value sockets. + +bool:: +a boolean value + +float:: +a double precision <> floating-point scalar value + +float2:: +a two-component vector of *float* values + +float3:: +a three-component vector of *float* values + +float4:: +a four-component vector of *float* values + +float4x4:: +a 4x4 matrix of *float* values + +int:: +a two's complement 32-bit signed integer scalar value + +[[configuration-types]] +=== Configuration Types + +Node configurations **MAY** use all of the value types and these two additional types. + +int[]:: +an array of *int* values + +string:: +a UTF-8 string value [[events]] == Custom Events -TBD +A behavior graph **MAY** define custom events for interacting with external execution environments and/or creating asynchronous loops. Although semantics of custom events is application-specific, their declarations **MUST** include value socket type information to ensure graph's type safety. [[variables]] -== Variables +== Custom Variables -TBD +A behavior graph **MAY** define custom variables. A variable **MAY** be declared simultaneously with its initial value, otherwise the variable **MUST** be initialized to the type-specific default. + +Custom variables **MUST** retain their values until the graph execution is terminated. == Node Types From 63f5d3d75188f3785be4ed72638a1bfb67d5df7b Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 17 Jun 2024 00:00:00 +0000 Subject: [PATCH 32/42] Add JSON syntax --- .../KHR_interactivity/Specification.adoc | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 6d12810981..22f04edf1d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2691,3 +2691,224 @@ When the `in` input flow is activated: 1. Evaluate all input values. 2. If any of them is invalid, activate the `err` output flow and skip the next step. 3. Activate the `out` output flow. + += JSON Syntax + +== General + +A `KHR_interactivity` extension object is added to the root-level `extensions` property. It contains four arrays corresponding to four interactivity concepts: `types`, `events`, `variables`, and `nodes`. As with the core glTF spec, if a JSON array is empty, it **MUST** be omitted from the asset. + +```json +{ + "asset": { + "version": "2.0" + }, + "extensionsUsed": ["KHR_interactivity"], + "extensions": { + "KHR_interactivity": { + "types": [ + // + ], + "events": [ + // + ], + "variables": [ + // + ], + "nodes": [ + // + ] + } + } +} +``` + +== Types + +The `types` array defines mappings between graph-local type indices and the recognized type signatures. + +The following example defines type `0` as *float2*, type `1` as *int*, and type `2` as *float*: + +```json +"types": [ + { + "signature": "float2" + }, + { + "signature": "int" + }, + { + "signature": "float" + } +] +``` + +The signature value **MUST** be one of the value types defined in this extension specification or `"custom"`. In the latter case, the type semantic **MUST** be provided by an additional extension. + +Non-custom signature **MUST NOT** appear more than once. + +== Events + +The `events` array defines external identifiers and value socket types for custom events. + +The following example defines a custom "`checkout`" event with an external identifier and one value socket: + +```json +"events": [ + { + "id": "checkout", + "values": [ + { + "id": "variant", + "type": 1 + } + ] + } +] +``` + +The event ID value is an application-specific event identifier recognized by the execution environment. If the `id` property is undefined, the event is considered internal to the graph. + +The `values` array defines IDs and type indices of the sockets associated with the event. If the array is undefined, the event has no associated value sockets. + +== Variables + +The `variables` array defines custom variables with their types and optional initialization values. + +The following example defines a custom variable with its initial value: + +```json +"variables": [ + { + "type": 0, + "value": [0.5, 0.5] + } +] +``` + +The `type` value defines the index of the variable type. + +The `value` array, if present, defines the initial variable value. The following table defines array size and default values for all value types defined in this extension. + +[cols="1,1,2", options="header"] +|=== +| Type | Array size | Default value +| `bool` | 1 | Boolean false +| `float` | 1 | Floating-point zero +| `float2` | 2 | Two floating-point zeros +| `float3` | 3 | Three floating-point zeros +| `float4` | 4 | Four floating-point zeros +| `float4x4` | 16 | Sixteen floating-point zeros +| `int` | 1 | Integer zero +|=== + +If the variable type is custom, the `value` property is defined by the extension defining the custom type. + +== Nodes + +The `nodes` array defines the behavior graph. + +Each element of the `nodes` array represents a node instance, i.e., it specifies node's type, configuration, sources of input value sockets, and pointers of the output flow sockets. + +Input value sockets **MAY** have inline constant values; in this case, the value socket type **MUST** be defined. + +Inline values and configurations use JSON arrays similarly to the initial variable values. + +The following example instantiates a `math/add` node that has both its input value sockets filled with inline integer values. + +```json +"nodes": [ + { + "type": "math/add", + "values": [ + { + "id": "a", + "value": [1], + "type": 1 + }, + { + "id": "b", + "value": [2], + "type": 1 + } + ] + } +] +``` + +The following example instantiates three nodes. The `math/sub` node has both its input value sockets connected to output value sockets of two other nodes: `math/pi` and `math/e`. + +```json +"nodes": [ + { + "type": "math/pi" + }, + { + "type": "math/e" + }, + { + "type": "math/sub", + "values": [ + { + "id": "a", + "node": 0, + "socket": "value" + }, + { + "id": "b", + "node": 1, + "socket": "value" + } + ] + } +] +``` + +The following example instantiates two nodes. The `variable/set` node sets a custom variable with index `0` when the start event happens. + +```json +"variables": [ + { + "type": 1 + } +], +"nodes": [ + { + "type": "variable/set", + "configuration": [ + { + "id": "variable", + "value": [0] + } + ], + "values": [ + { + "id": "value", + "value": [1], + "type": 1 + } + ] + }, + { + "type": "event/onStart", + "flows": [ + { + "id": "out", + "node": 0, + "socket": "in" + } + ] + } +] +``` + +The `type` property is required; it defines semantics and validation of the `configuration`, `values`, and `flows` arrays. + +The same `id` value **MUST NOT** be used more than once within each of the `configuration`, `values`, and `flows` arrays. + +If the node type has configuration, the `configuration` array **MUST** provide all configuration parameters as inline values. + +If the node type has input value sockets, the `values` array **MUST** connect all input value sockets to other nodes or fill them with inline values. Additionally, for each element of the `values` array: + +- `value` and `node` properties **MUST NOT** be defined at the same time; +- if `value` is defined, `type` **MUST** also be defined. From 4177adfbc3f543136e2c7d4ea210202d11d46550 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 24 Jun 2024 00:00:00 +0000 Subject: [PATCH 33/42] Initialize floating-point variables to NaN --- .../2.0/Khronos/KHR_interactivity/Specification.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 22f04edf1d..4bc29a5fb8 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2794,11 +2794,11 @@ The `value` array, if present, defines the initial variable value. The following |=== | Type | Array size | Default value | `bool` | 1 | Boolean false -| `float` | 1 | Floating-point zero -| `float2` | 2 | Two floating-point zeros -| `float3` | 3 | Three floating-point zeros -| `float4` | 4 | Four floating-point zeros -| `float4x4` | 16 | Sixteen floating-point zeros +| `float` | 1 | Floating-point NaN +| `float2` | 2 | Two floating-point NaNs +| `float3` | 3 | Three floating-point NaNs +| `float4` | 4 | Four floating-point NaN +| `float4x4` | 16 | Sixteen floating-point NaNs | `int` | 1 | Integer zero |=== From 21e1b4c0b9de6c53424262c60797ed5793e0ec16 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 24 Jun 2024 00:00:00 +0000 Subject: [PATCH 34/42] Update custom event nodes --- .../KHR_interactivity/Specification.adoc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 4bc29a5fb8..f4deb00478 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2656,13 +2656,17 @@ The internal state of this node consists of two floating-point time values initi | `int event` | The custom event index | Output value sockets | `` | Output values defined by the custom event +| Output flow sockets +| `out` | The flow to be activated when the custom event happens |=== This node is activated when a custom event specified by the `event` configuration value occurs. The types, names, and semantics of the output value sockets are defined by the custom event index. The `event` configuration value **MUST** be non-negative and less than the total number of custom event definitions, otherwise the node is invalid. -This node has no internal state. +The internal state of this node consists of all output value sockets initialized to type-default values, i.e., NaN for floating-point types, zero for integers, and false for bools. + +The output value sockets **MUST** be updated before activating the `out` output flow. ===== Send @@ -2675,12 +2679,17 @@ This node has no internal state. | `in` | The entry flow into this node | Input value sockets | `` | Input values defined by the custom event -.2+| Output flow sockets +| Output flow sockets | `out` | The flow to be activated after sending the event -| `err` | The flow to be activated if any of the input values is invalid |=== -This node sends a custom event specified by the `event` configuration value. The types, names, and validation rules of the input value sockets are defined by the custom event index. +This node sends a custom event specified by the `event` configuration value. The types and names of the input value sockets are defined by the custom event index. + +[NOTE] +.Note +==== +If the graph needs to know whether the event has been received and/or processed by an external environment, the latter could send another event in response. +==== The `event` configuration value **MUST** be non-negative and less than the total number of custom event definitions, otherwise the node is invalid. @@ -2689,7 +2698,7 @@ This node has no internal state. When the `in` input flow is activated: 1. Evaluate all input values. -2. If any of them is invalid, activate the `err` output flow and skip the next step. +2. Send the custom event. 3. Activate the `out` output flow. = JSON Syntax From 83aa69ccd6aa837e44506a56f4c69c70db22c34b Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 24 Jun 2024 00:00:00 +0000 Subject: [PATCH 35/42] Align async output flow socket names --- .../KHR_interactivity/Specification.adoc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index f4deb00478..5e0cfa7259 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2218,13 +2218,13 @@ When the `in` input flow is activated: | `in` | The entry flow into this node | `cancel` | When this flow is activated, all delayed activations scheduled by this node are cancelled | Input value sockets -| `float duration` | The duration, in seconds, to delay the `completed` output flow activation +| `float duration` | The duration, in seconds, to delay the `done` output flow activation | Output value sockets | `int lastDelayIndex` | The delay index assigned during the last successful node execution .3+| Output flow sockets | `out` | The flow to be activated if the `duration` value is valid | `err` | The flow to be activated if the `duration` value is invalid -| `completed` | The flow to be activated after the delay +| `done` | The flow to be activated after the delay |=== The internal state of this node consists of an integer `lastDelayIndex` value initialized to -1 and a dynamic array of activation indices scheduled by the node. This array is initially empty and its maximum size is implementation-specific. @@ -2247,7 +2247,7 @@ When the `in` input flow is activated: 7. Push the value of `lastDelayIndex` to the graph and node arrays of activation indices. 8. Schedule the following actions at the _activationTime_ time: .. Removal of the activation index value from both arrays of activation indices. -.. Activation of the `completed` output flow. +.. Activation of the `done` output flow. 9. Activate the `out` output flow. When the `cancel` input flow is activated: @@ -2498,7 +2498,7 @@ Intermediate output progress values **MAY** be less than zero or greater than on .3+| Output flow sockets | `out` | The flow to be activated if the input values are valid | `err` | The flow to be activated if any of the input values is invalid -| `completed` | The flow to be activated after the animation ends +| `done` | The flow to be activated after the animation ends |=== This node starts playing an animation using the specified input values. @@ -2528,8 +2528,8 @@ When a node of this type is used in the behavior graph, the global graph state i - Stop time value (see `animation/stopAt`) - Speed value - Implementation-specific creation timestamp value associated with the system time when this entry was added -- Implementation-specific _end completion_ pointer to the `completed` output flow of the node that has added this entry -- Implementation-specific _stop completion_ pointer to the `completed` output flow of the node that has scheduled its stopping (see `animation/stopAt`) +- Implementation-specific _end completion_ pointer to the `done` output flow of the node that has added this entry +- Implementation-specific _stop completion_ pointer to the `done` output flow of the node that has scheduled its stopping (see `animation/stopAt`) This array is initially empty; its maximum size is implementation-specific. @@ -2545,7 +2545,7 @@ When the `in` input flow is activated: 5. If starting a new animation exceeds any implementation-specific limit, .. activate the `err` output flow and skip the next steps. 6. If the _animation state dynamic array_ contains an entry with the same animation index, -.. remove it from the array; the previously set `completed` flows **MUST NOT** be activated. +.. remove it from the array; the previously set `done` flows **MUST NOT** be activated. 7. Add a new entry to the _animation state dynamic array_ filling it with the required information based on the evaluated input values. The stop time value **MUST** be set to the end time value and the stop completion pointer **MUST** be set to null. 8. Activate the `out` output flow. @@ -2577,7 +2577,7 @@ When the `in` input flow is activated: 2. If the `animation` input value is negative or greater than or equal to the number of glTF animations in the asset, .. activate the `err` output flow and skip the next steps. 3. If the _animation state dynamic array_ exists and contains an entry with the same animation index, -.. remove it from the array and stop the playing animation. The animated properties **MUST** keep their current values and the previously associated `completed` flows **MUST NOT** be activated. +.. remove it from the array and stop the playing animation. The animated properties **MUST** keep their current values and the previously associated `done` flows **MUST NOT** be activated. 4. Activate the `out` output flow. ===== Animation Stop At @@ -2593,7 +2593,7 @@ When the `in` input flow is activated: .3+| Output flow sockets | `out` | The flow to be activated if the input values are valid | `err` | The flow to be activated if any of the input values is invalid -| `completed` | The flow to be activated after the animation stops +| `done` | The flow to be activated after the animation stops |=== This node stops a playing animation. @@ -2608,7 +2608,7 @@ When the `in` input flow is activated: 3. If the `stopTime` input value is NaN, .. activate the `err` output flow and skip the next steps. 4. If the _animation state dynamic array_ exists and does contain an entry with the same animation index, -.. update the entry's stop completion pointer to the `completed` output flow of this node; +.. update the entry's stop completion pointer to the `done` output flow of this node; .. update the entry's stop time to the `stopTime` input value. 5. Activate the `out` output flow. From d873db60ddb663036d4ff724d3f45d8508e9cc47 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 24 Jun 2024 00:00:00 +0000 Subject: [PATCH 36/42] Clarify flow/multiGate randomness --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 5e0cfa7259..7ca07e3c0a 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2128,6 +2128,8 @@ When the `in` input flow is activated: .. set the `lastIndex` value to `i`; .. activate the output flow with index `i`. +When the `isRandom` and `isLoop` configuration values are true, the output flow activation order **SHOULD** be randomized on each loop iteration. + ===== Wait All [cols="1h,1,2"] From 86409f3685ff125e8d83ab00255ecc175b663914 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:00:00 +0000 Subject: [PATCH 37/42] Fix typo --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 7ca07e3c0a..6c3135d302 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -191,7 +191,7 @@ On the other hand, behavior graphs are a superset of trigger-action lists, meani === Turing Completeness The execution model and node choices for this extension mean that it is Turing-complete. This means that an implementation of this can execute any computation and it is also hard to predict if it will run forever (e.g. halt or not.) -While this may present security implications, it is not a major hindrance and can be safely mitigated so that any implementation does not become susceptible to denial of services by badly behaving behavior graphs, whether intention or not. +While this may present security implications, it is not a major hindrance and can be safely mitigated so that any implementation does not become susceptible to denial of services by badly behaving behavior graphs, whether intentional or not. The main way to mitigate the risk of non-halting behavior graphs is to limit the amount of time given to them for execution, both in terms of individual time slice as well as overall execution time. From 4834fcd00c05230947b8c682833a2aa6222f027f Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:00:00 +0000 Subject: [PATCH 38/42] Clarify input value sockets for pointer nodes --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 6c3135d302..9bb96ec36d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2337,7 +2337,7 @@ When the `in` input flow is activated: | Configuration | `string pointer` | The JSON pointer or JSON pointer template | Input value sockets -| `int ` | The JSON pointer template path segment to be substituted at runtime +| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) .2+| Output value sockets | `T value` | The resolved property value | `bool isValid` | True if the property value can be resolved, false otherwise @@ -2383,7 +2383,7 @@ Unresolvable pointers include those with negative or out-of-bounds array indices | Input flow sockets | `in` | The entry flow into this node .2+| Input value sockets -| `int ` | The JSON pointer template path segment to be substituted at runtime +| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) | `T value` | The new property value .2+| Output flow sockets | `out` | The flow to be activated if the JSON pointer can be resolved @@ -2418,7 +2418,7 @@ When the `in` input flow is activated: | Input flow sockets | `in` | The entry flow into this node .5+| Input value sockets -| `int ` | The JSON pointer template path segment to be substituted at runtime +| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) | `T value` | The target property value | `float duration` | The time, in seconds, in which the property **SHOULD** reach the target value | `float2 p1` | Control point P1 From e33a3bc8a33455469a4c7128aa2197fea54d64de Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:00:00 +0000 Subject: [PATCH 39/42] Clarify configuration value types --- .../2.0/Khronos/KHR_interactivity/Specification.adoc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 9bb96ec36d..8929159422 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2821,7 +2821,15 @@ The `nodes` array defines the behavior graph. Each element of the `nodes` array represents a node instance, i.e., it specifies node's type, configuration, sources of input value sockets, and pointers of the output flow sockets. -Input value sockets **MAY** have inline constant values; in this case, the value socket type **MUST** be defined. +Input value sockets **MAY** have inline constant values; in this case, the value socket type **MUST** be explicitly defined. + +Configuration values are always implicitly typed based on the node's type. + +[NOTE] +.Rationale +==== +Some nodes have configuration values of array and/or string types that cannot be expressed with the explicit types defined in this Specification. +==== Inline values and configurations use JSON arrays similarly to the initial variable values. From fbcf6968e19ad6a29024f31b5659fe78df9b5a4c Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:00:00 +0000 Subject: [PATCH 40/42] Clarify pointer nodes for not mutable pointers --- extensions/2.0/Khronos/KHR_interactivity/Specification.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 8929159422..5a7643f4ae 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2390,7 +2390,7 @@ Unresolvable pointers include those with negative or out-of-bounds array indices | `err` | The flow to be activated if the JSON pointer cannot be resolved |=== -This node sets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. +This node sets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. @@ -2429,7 +2429,7 @@ When the `in` input flow is activated: | `done` | The flow to be activated when the property reaches the target value |=== -This node interpolates and updates the specified glTF Asset Object Model property multiple times over the specified duration using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined or if it is integer or boolean, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. +This node interpolates and updates the specified glTF Asset Object Model property multiple times over the specified duration using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, if it is integer or boolean, or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. From 11339a0b5e1b14a7072fee342fcdeafa33f40ed6 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:00:00 +0000 Subject: [PATCH 41/42] Add active camera pointers --- .../KHR_interactivity/Specification.adoc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index 5a7643f4ae..f7a8151c0d 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2703,6 +2703,29 @@ When the `in` input flow is activated: 2. Send the custom event. 3. Activate the `out` output flow. +== Extending glTF Object Model + +This Specification defines additional glTF Object Model pointers for use with `pointer/*` nodes. + +=== Active Camera Information + +In some viewers, such as, but not limited to, augmented reality viewers and virtual reality viewers, the viewer implementation gives the user direct control over a virtual camera. This virtual camera **MAY** be controlled by user head movements, by movements of the user's phone with their hands, or by mouse, keyboard or touch input on a laptop, or by other means. It is useful for interactivity to be able to react to the position of this virtual camera. + +This Specification defines the “active camera” as the camera transformation that ought to be reacted to by interactivity. When there is only one camera being displayed to the user the implementation **SHOULD** use this camera as the “active camera”. When there are multiple cameras being controlled by the user, the implementation **MAY** select one such camera or construct a synthetic camera to use as the “active camera” (for example the midpoint of two stereoscopic camera positions). When zero cameras are being controlled by the user but views from one or more cameras are being displayed to the user, the implementation **SHOULD** select one of the cameras that is being displayed as the “active camera”. + +The `position` read-only property represents the “active camera” position in the global space. The `rotation` read-only property represents the “active camera” rotation quaternion; the identity quaternion corresponds to the camera orientation defined in the glTF 2.0 Specification. + +An implementation **MAY** provide no “active camera” data, for example for privacy reasons or if no cameras are being displayed to the user. If the “active camera” position is unavailable, the `position` property **MUST** be set to all NaNs; if the “active camera” rotation is unavailable, the `rotation` property **MUST** be set to all NaNs. + +The following pointers represent the read-only properties defined in this section. + +[options="header",cols="50%,15%"] +|=== +| Pointer | Type +| `/activeCamera/rotation` | `float4` +| `/activeCamera/position` | `float3` +|=== + = JSON Syntax == General From 220ca407a2ce1f8463855803778edf73a885b7e9 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:00:00 +0000 Subject: [PATCH 42/42] Clarify pointer nodes validity --- .../KHR_interactivity/Specification.adoc | 68 +++++++++++-------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc index f7a8151c0d..ae0a5f1bbe 100644 --- a/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc +++ b/extensions/2.0/Khronos/KHR_interactivity/Specification.adoc @@ -2335,34 +2335,38 @@ When the `in` input flow is activated: |=== | Type | `pointer/get` | Get an object model property value | Configuration -| `string pointer` | The JSON pointer or JSON pointer template +| `string pointer` | The JSON Pointer or JSON Pointer template | Input value sockets -| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) +| `int ` | Zero or more JSON Pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) .2+| Output value sockets | `T value` | The resolved property value | `bool isValid` | True if the property value can be resolved, false otherwise |=== -This node gets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. +This node gets a glTF Asset Object Model value using the provided JSON Pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the pointer string has invalid syntax or if the type of the referenced property cannot be statically determined, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. [NOTE] .Examples ==== -The `pointer` configuration value `"/nodes/0/scale"` is valid; its output value socket is of `float3` type. +The `pointer` configuration value `"/nodes/1024/scale"` is valid even if the `nodes` array does not have enough elements; the type `T` is `float3`; the output values are set as described below. -The `pointer` configuration value `"/myProperty"` is invalid because this path is not defined. +The `pointer` configuration value `"/nodes/-1/scale"` is invalid because `-1` is not a valid array element reference according to the JSON Pointer standard. + +The `pointer` configuration value `"/myProperty"` is invalid because this path is not defined in the glTF Asset Object Model. ==== -The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime by converting each `` input value to a base-10 string representation. All input values **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. [NOTE] .Example ==== -If the `pointer` configuration value is `"/nodes/{myId}/scale"`, the node has the `myId` input value socket, which value denotes the node index. +If the `pointer` configuration value is `"/nodes/{myId}/scale"`, the behavior graph node has the `myId` input value socket, which value denotes the glTF node index. ==== This node has no internal state. +If any of the input values is negative, the `value` output value is the default value for its type and the `isValid` output value is false. + If the pointer or the pointer template with all its substitutions applied can be resolved, the `value` output value is the resolved property value and the `isValid` output value is true. If the pointer or the pointer template with all its substitutions applied cannot be resolved, the `value` output value is the default value for its type and the `isValid` output value is false. @@ -2370,7 +2374,7 @@ If the pointer or the pointer template with all its substitutions applied cannot [NOTE] .Note ==== -Unresolvable pointers include those with negative or out-of-bounds array indices and/or non-existent JSON objects. +When the `isValid` output value is false, it means that the pointer string could be resolved in principle, i.e., it represents a known glTF property and its type can be determined, but the property does not exist in the current asset. For example, an array index is out of bounds or an optional JSON object, e.g., an extension, does not exist at that location. Refer to the glTF Asset Object Model Specification for the JSON Pointer resolution rules. ==== ===== Pointer Set @@ -2379,20 +2383,20 @@ Unresolvable pointers include those with negative or out-of-bounds array indices |=== | Type | `pointer/set` | Set an object model property value | Configuration -| `string pointer` | The JSON pointer or JSON pointer template +| `string pointer` | The JSON Pointer or JSON Pointer template | Input flow sockets | `in` | The entry flow into this node .2+| Input value sockets -| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) +| `int ` | Zero or more JSON Pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) | `T value` | The new property value .2+| Output flow sockets -| `out` | The flow to be activated if the JSON pointer can be resolved -| `err` | The flow to be activated if the JSON pointer cannot be resolved +| `out` | The flow to be activated if the JSON Pointer can be resolved +| `err` | The flow to be activated if the JSON Pointer cannot be resolved |=== -This node sets a glTF Asset Object Model value using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. +This node sets a glTF Asset Object Model value using the provided JSON Pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the pointer string has invalid syntax, if the type of the referenced property cannot be statically determined, or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. -The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime by converting each `` input value to a base-10 string representation. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. If the `value` input value is not valid for the resolved property, the effective property value becomes implementation-defined and subsequent `pointer/get` evaluations of the property **MAY** return any value of the corresponding type until the property is updated with a valid value. @@ -2401,11 +2405,13 @@ This node has no internal state. When the `in` input flow is activated: 1. Evaluate all input values. -2. If the pointer or the pointer template with all its substitutions applied can be resolved, +2. If any of the pointer segment input values is negative, +.. activate the `err` output flow and skip the next steps. +3. If the pointer or the pointer template with all its substitutions applied can be resolved, .. if the _pointer interpolation state dynamic array_ (defined below) contains an entry with the same resolved JSON Pointer value, remove it from the array; .. set the resolved property to the `value` input value; .. activate the `out` output flow. -3. If the pointer or the pointer template with all its substitutions applied cannot be resolved, +4. If the pointer or the pointer template with all its substitutions applied cannot be resolved, .. activate the `err` output flow. ===== Pointer Interpolate @@ -2414,24 +2420,24 @@ When the `in` input flow is activated: |=== | Type | `pointer/interpolate` | Interpolate an object model property value | Configuration -| `string pointer` | The JSON pointer or JSON pointer template +| `string pointer` | The JSON Pointer or JSON Pointer template | Input flow sockets | `in` | The entry flow into this node .5+| Input value sockets -| `int ` | Zero or more JSON pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) +| `int ` | Zero or more JSON Pointer template path substitutions to be evaluated at runtime; input value socket names correspond to the pointer's path segments wrapped with curly braces (`{}`) | `T value` | The target property value | `float duration` | The time, in seconds, in which the property **SHOULD** reach the target value | `float2 p1` | Control point P1 | `float2 p2` | Control point P2 .3+| Output flow sockets -| `out` | The flow to be activated if the JSON pointer can be resolved and the input values are valid -| `err` | The flow to be activated if the JSON pointer cannot be resolved or the input values are invalid +| `out` | The flow to be activated if the JSON Pointer can be resolved and the input values are valid +| `err` | The flow to be activated if the JSON Pointer cannot be resolved or the input values are invalid | `done` | The flow to be activated when the property reaches the target value |=== -This node interpolates and updates the specified glTF Asset Object Model property multiple times over the specified duration using the provided JSON pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the type of the pointer cannot be statically determined, if it is integer or boolean, or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. +This node interpolates and updates the specified glTF Asset Object Model property multiple times over the specified duration using the provided JSON Pointer. The type `T` is determined by the pointer string according to the glTF Asset Object Model Specification. If the pointer string has invalid syntax, if the type of the referenced property cannot be statically determined, if it is integer or boolean, or if the referenced property is not mutable, the node is invalid. Pointers containing `extras` properties are out of scope of this specification but **MAY** be supported by implementations. -The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime using the input values. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. +The pointer string **MAY** be a template pointer string, i.e., it **MAY** contain path segments substituted at runtime by converting each `` input value to a base-10 string representation. All input values used for path segment substitutions **MUST** be of `int` type. Path segments, if used, **MUST** substitute only array indices in the pointer templates as listed in the glTF Asset Object Model Specification. If the `value` input value or any intermediate interpolated value are not valid for the resolved property, the effective property value becomes implementation-defined and subsequent `pointer/get` evaluations of the property **MAY** return any value of the corresponding type until the property is updated with a valid value. @@ -2452,19 +2458,21 @@ This array is initially empty and its maximum size is implementation-specific. When the `in` input flow is activated: 1. Evaluate all input values. -2. If the pointer or the pointer template with all its substitutions applied cannot be resolved, +2. If any of the pointer segment input values is negative, .. activate the `err` output flow and skip the next steps. -3. If the `duration` input value is NaN, infinite, negative, or not convertible into an implementation-specific time type used for the internal interpolation start time value, +3. If the pointer or the pointer template with all its substitutions applied cannot be resolved, +.. activate the `err` output flow and skip the next steps. +4. If the `duration` input value is NaN, infinite, negative, or not convertible into an implementation-specific time type used for the internal interpolation start time value, .. activate the `err` output flow and skip the next steps. -4. If any component of the `p1` or `p2` input values is NaN or infinite or if any of the first components of these input values is negative or greater than 1, +5. If any component of the `p1` or `p2` input values is NaN or infinite or if any of the first components of these input values is negative or greater than 1, .. activate the `err` output flow and skip the next steps. -5. If starting a new pointer interpolation exceeds any implementation-specific limit, +6. If starting a new pointer interpolation exceeds any implementation-specific limit, .. activate the `err` output flow and skip the next steps. -6. If the _pointer interpolation state dynamic array_ contains an entry with the same resolved JSON Pointer value, +7. If the _pointer interpolation state dynamic array_ contains an entry with the same resolved JSON Pointer value, .. remove it from the array. -7. Using the implicitly-defined end points stem:[P_0 (0, 0)] and stem:[P_3 (1, 1)] together with the control points stem:[P_1] and stem:[P_2] provided via the input values construct a cubic Bézier easing function for the stem:[[0, 1]] input range. -8. Add a new entry to the _pointer interpolation state dynamic array_ filling it with the required information based on the evaluated input values. -9. Activate the `out` output flow. +8. Using the implicitly-defined end points stem:[P_0 (0, 0)] and stem:[P_3 (1, 1)] together with the control points stem:[P_1] and stem:[P_2] provided via the input values construct a cubic Bézier easing function for the stem:[[0, 1]] input range. +9. Add a new entry to the _pointer interpolation state dynamic array_ filling it with the required information based on the evaluated input values. +10. Activate the `out` output flow. On each asset animation update, for each entry in the _pointer interpolation state dynamic array_: