Skip to content

Commit 0a6a03b

Browse files
Adds unit tests for transform components
Fixes some issues that came up while writing the tests: * counter gets a default value * interpolate float has been replaced by remap * loop tooltip updated * ray_mesh_intersection should be in the Sense category Also updated the documentation a bit.
2 parents f37fab3 + 94670f7 commit 0a6a03b

File tree

22 files changed

+4072
-359
lines changed

22 files changed

+4072
-359
lines changed

documentation/RemixLogic.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ By connecting Components in different ways, you can create sophisticated behavio
1212

1313
**Important:** Components must be connected in a way that has a clear starting point and doesn't create loops - each Component can only use information from Components that come before it in the chain.
1414

15+
# Creating Graphs
16+
17+
This page is primarily intended for people who wish to create their own custom components in c++. If this is your first introduction to Remix Logic, you should probably see the [Remix Toolkit documentation](https://docs.omniverse.nvidia.com/kit/docs/rtx_remix/latest/docs/howto/learning-logic.html) for a high level overview and graph creation tutorials.
18+
1519
# Component List
1620

1721
Documentation for each component is available here: [Component List](components/index.md)
1822

1923
# Types of Components
2024

21-
There are three major categories of components:
25+
There are four major categories of components:
2226

2327
## Sense Components
2428

@@ -53,29 +57,28 @@ These components alter the renderable state.
5357
* Swap which replacements are applied to a given mesh hash
5458
* Alter the time multiplier (pausing or slowing all animations)
5559

56-
# Creating Graphs
60+
## Const Components
5761

58-
Graph creation should be done in the Remix Toolkit. The graph editor there is still in development.
62+
These components simply output a single constant value of a given type. This can be useful for sharing a value between multiple components, but primarily exist as a way to set properties with a flexible type.
5963

6064
# Component Data Types
6165

6266
The component system supports the following data types as defined in `rtx_graph_types.h`:
6367

6468
| Type | C++ Type | Description | Example Values |
6569
|------|----------|-------------|----------------|
66-
| `Bool` | `uint8_t` | True or False boolean values (stored as uint8_t for variant compatibility) | `true`, `false` |
67-
| `Float` | `float` | A number, including decimal places. Single precision floating point | `1.0f`, `-3.14f` |
70+
| `Bool` | `uint32_t` | True or False boolean values (stored as uint8_t for variant compatibility) | `true`, `false` |
71+
| `Float` | `float` | A number, including decimal places. Single precision floating point | `1.0`, `-3.14` |
6872
| `Float2` | `Vector2` | 2D vector of floats | `Vector2(1.0f, 2.0f)` |
6973
| `Float3` | `Vector3` | 3D vector of floats | `Vector3(1.0f, 2.0f, 3.0f)` |
70-
| `Color3` | `Vector3` | RGB color (3D vector) | `Vector3(1.0f, 0.5f, 0.0f)` |
71-
| `Color4` | `Vector4` | RGBA color (4D vector) | `Vector4(1.0f, 0.5f, 0.0f, 1.0f)` |
72-
| `Uint32` | `uint32_t` | A positive whole number | `42`, `1000` |
74+
| `Float4` | `Vector4` | 3D vector of floats | `Vector4(1.0f, 2.0f, 3.0f)` |
75+
| `Enum` | `uint32_t` | A selection from a limited list of options | `InterpolationType::Linear`, `LoopingType::Loop` |
7376
| `String` | `std::string` | Some text | `"hello"`, `"world"` |
7477
| `AssetPath` | `std::string` | Path to an asset file | `"textures/myfile.dds"` |
75-
| `Hash` | `uint64_t` | 64-bit hash value | `0x123456789ABCDEF0ULL` |
76-
| `Prim` | `uint32_t` | USD prim identifier | `101`, `102` |
77-
| `Number` | `std::variant<float, int32_t, uint32_t, uint64_t>` | Flexible numeric type (resolved at load time) | `1.0f`, `42` |
78-
| `NumberOrVector` | `std::variant<float, Vector2, Vector3, Vector4, int32_t, uint32_t, uint64_t>` | Flexible numeric or vector type (resolved at load time) | `1.0f`, `Vector2(1.0f, 2.0f)` |
78+
| `Hash` | `uint64_t` | 64-bit hash value | `0x123456789ABCDEF0` |
79+
| `Prim` | `PrimTarget` | Identifies another object - a mesh, light, material, particle effect, graph, etc. | `</RootNode/meshes/mesh_123456789ABCDEF0/mesh>` |
80+
| `NumberOrVector` | `std::variant<float, Vector2, Vector3, Vector4>` | Flexible numeric or vector type (resolved at load time) | `1.0f`, `Vector2(1.0f, 2.0f)` |
81+
| `Any` | `std::variant<...>` | Flexible type that supports all non-flexible types | `1.0f`, `true`, `"textures/myfile.dds"` |
7982

8083
Components with flexible types may not accept all combinations of those types - i.e. you cannot check if a Float is greater than a Vector3.
8184

@@ -134,6 +137,9 @@ Available options include:
134137
* `property.optional` - Whether the component functions without this property being set
135138
* `property.oldUsdNames` - For backwards compatibility when renaming properties
136139
* `property.enumValues` - For displaying as an enum in the UI
140+
* `property.isSettableOutput` - Used for `const` components, use this on an Input property to create an output property which can be set in the toolkit's property panel.
141+
* `property.treatAsColor` - If set on a Float3 or Float4, this indicates to the toolkit that a color picking widget should be displayed for this property.
142+
* `property.allowedPrimTypes` - Allows for filtering of `Prim` properties, if the target must be of a specific type (i.e. `PrimType::UsdGeomMesh` or `PrimType::OmniGraph`)
137143

138144
### Enum Values Example
139145

documentation/components/Counter.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Counter
22

3-
Counts up by a value every frame when a condition is true\.<br/><br/>Increments a counter by a specified value every frame that the input bool is true\. Useful for tracking how many frames a condition has been active\.
3+
Counts up by a value every frame when a condition is true\.<br/><br/>Increments a counter by a specified value every frame that the input bool is true\. Use \`Starting Value\` to set the initial counter value\. Useful for tracking how many frames a condition has been active\.
44

55
## Component Information
66

@@ -15,6 +15,7 @@ Counts up by a value every frame when a condition is true\.<br/><br/>Increments
1515
|----------|--------------|------|---------|---------------|----------|
1616
| increment | Increment | Bool | Input | false | No |
1717
| incrementValue | Increment Value | Float | Input | 1\.0 | Yes |
18+
| defaultValue | Starting Value | Float | Input | 0\.0 | No |
1819

1920
### Increment
2021

@@ -26,6 +27,11 @@ When true, the counter increments by the increment value each frame\.
2627
The value to add to the counter each frame when increment is true\.
2728

2829

30+
### Starting Value
31+
32+
The initial value of the counter when the component is created\.
33+
34+
2935
## State Properties
3036

3137
| Property | Display Name | Type | IO Type | Default Value | Optional |

documentation/components/InterpolateFloat.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

documentation/components/Loop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The value with looping applied\.
6161

6262
### Is Reversing
6363

64-
True if the value is in the reverse phase of ping pong looping\. If passing \`loopedValue\` to an \`interpolateFloat\` component, hook this up to \`shouldReverse\` from that component\.
64+
True if the value is in the reverse phase of ping pong looping\. If passing \`loopedValue\` to a \`Remap\` component, hook this up to \`shouldReverse\` from that component\.
6565

6666

6767
## Valid Type Combinations

documentation/components/RayMeshIntersection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Tests if a ray intersects with a mesh\.<br/><br/>Performs a ray\-mesh intersecti
77
- **Name:** `RayMeshIntersection`
88
- **UI Name:** Ray Mesh Intersection
99
- **Version:** 1
10-
- **Categories:** Transform
10+
- **Categories:** Sense
1111

1212
## Input Properties
1313

documentation/components/Remap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Remap
22

3-
Smoothly maps a value from one range to another range with customizable easing curves\.<br/><br/>Remaps a value from an input range to an output range with optional easing\. Values will be normalized \(mapped from input range to 0\-1\), eased \(changed from linear to some curve\), then mapped \(0\-1 value to output range\)\.<br/><br/>Note: Input values outside of input range are valid, and easing can lead to the output value being outside of the output range even when input is inside the input range\.<br/><br/>Inverted ranges \(max < min\) are supported, but the results are undefined and may change without warning\.
3+
Smoothly maps a value from one range to another range with customizable easing curves\.<br/><br/>Remaps a value from an input range to an output range with optional easing\. Values will be normalized \(mapped from input range to 0\-1\), eased \(changed from linear to some curve\), then mapped \(0\-1 value to output range\)\.<br/><br/>Note: Input values outside of input range are valid, and easing can lead to the output value being outside of the output range even when input is inside the input range\.<br/><br/>Inverted ranges \(max < min\) are supported\.
44

55
## Component Information
66

documentation/components/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ This documentation provides detailed information about all available components
3636
| [Equal To](EqualTo.md) | Returns true if A is equal to B, false otherwise\.<br/><br/>For floating point values, this performs exact eq\.\.\. | 1 |
3737
| [Floor](Floor.md) | Rounds a value down to the previous integer\.<br/><br/>Returns the largest integer less than or equal to the \.\.\. | 1 |
3838
| [Greater Than](GreaterThan.md) | Returns true if A is greater than B, false otherwise\. | 1 |
39-
| [Interpolate Float](InterpolateFloat.md) | Smoothly maps a value from one range to another range with customizable easing curves\.<br/><br/>Interpolates\.\.\. | 1 |
4039
| [Invert](Invert.md) | Outputs 1 minus the input value\.<br/><br/>Calculates 1 \- input\. Useful for inverting normalized values \(e\.g\.\.\.\. | 1 |
4140
| [Less Than](LessThan.md) | Returns true if A is less than B, false otherwise\. | 1 |
4241
| [Loop](Loop.md) | Wraps a number back into a range when it goes outside the boundaries\.<br/><br/>Applies looping behavior to a\.\.\. | 1 |
@@ -45,7 +44,6 @@ This documentation provides detailed information about all available components
4544
| [Multiply](Multiply.md) | Multiplies two values together\.<br/><br/>Vector \* Number will multiply all components of the vector by the n\.\.\. | 1 |
4645
| [Normalize](Normalize.md) | Normalizes a vector to have length 1\.<br/><br/>Divides the vector by its length to produce a unit vector \(le\.\.\. | 1 |
4746
| [Previous Frame Value](PreviousFrameValue.md) | Outputs the value from the previous frame\.<br/><br/>Stores the input value and outputs it on the next frame\.\.\.\. | 1 |
48-
| [Ray Mesh Intersection](RayMeshIntersection.md) | Tests if a ray intersects with a mesh\.<br/><br/>Performs a ray\-mesh intersection test\. Currently supports bo\.\.\. | 1 |
4947
| [Remap](Remap.md) | Smoothly maps a value from one range to another range with customizable easing curves\.<br/><br/>Remaps a val\.\.\. | 1 |
5048
| [Round](Round.md) | Rounds a value to the nearest integer\.<br/><br/>Rounds to the nearest whole number\. For example: 1\.4 becomes\.\.\. | 1 |
5149
| [Select](Select.md) | Selects between two values based on a boolean condition\.<br/><br/>If the condition is true, outputs Input A\.\.\.\. | 1 |
@@ -66,6 +64,7 @@ This documentation provides detailed information about all available components
6664
| [Light Hash Checker](LightHashChecker.md) | Detects if a specific light is currently active in the scene\.<br/><br/>Checks if a specific light hash is pr\.\.\. | 1 |
6765
| [Mesh Hash Checker](MeshHashChecker.md) | Detects if a specific mesh is currently being drawn in the scene\.<br/><br/>Checks if a specific mesh hash wa\.\.\. | 1 |
6866
| [Mesh Proximity](MeshProximity.md) | Measures how far a point is from a mesh's bounding box\. This can be used to determine if the camera \.\.\. | 1 |
67+
| [Ray Mesh Intersection](RayMeshIntersection.md) | Tests if a ray intersects with a mesh\.<br/><br/>Performs a ray\-mesh intersection test\. Currently supports bo\.\.\. | 1 |
6968
| [Read Bone Transform](ReadBoneTransform.md) | Reads the transform \(position, rotation, scale\) of a bone from a skinned mesh\.<br/><br/>Extracts the transfo\.\.\. | 1 |
7069
| [Read Transform](ReadTransform.md) | Reads the transform \(position, rotation, scale\) of a mesh or light in world space\.<br/><br/>Extracts the tra\.\.\. | 1 |
7170
| [Rtx Option Layer Sensor](RtxOptionLayerSensor.md) | Reads the state of a configuration layer\.<br/><br/>Outputs whether a given RtxOptionLayer is enabled, along \.\.\. | 1 |
@@ -102,8 +101,8 @@ This documentation provides detailed information about all available components
102101

103102
## Statistics
104103

105-
- **Total Components:** 69
106-
- **Categorized Components:** 69
104+
- **Total Components:** 68
105+
- **Categorized Components:** 68
107106
- **Categories:** 5
108107

109108
---

src/dxvk/rtx_render/graph/components/counter.h

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,58 @@ namespace components {
2929

3030
#define LIST_INPUTS(X) \
3131
X(RtComponentPropertyType::Bool, false, increment, "Increment", "When true, the counter increments by the increment value each frame.") \
32-
X(RtComponentPropertyType::Float, 1.0f, incrementValue, "Increment Value", "The value to add to the counter each frame when increment is true.", property.optional = true)
32+
X(RtComponentPropertyType::Float, 1.0f, incrementValue, "Increment Value", "The value to add to the counter each frame when increment is true.", property.optional = true) \
33+
X(RtComponentPropertyType::Float, 0.0f, defaultValue, "Starting Value", "The initial value of the counter when the component is created.")
3334

3435
#define LIST_STATES(X) \
3536
X(RtComponentPropertyType::Float, 0.0f, count, "", "The current counter value.")
3637

3738
#define LIST_OUTPUTS(X) \
3839
X(RtComponentPropertyType::Float, 0.0f, value, "Value", "The current counter value.")
3940

40-
REMIX_COMPONENT( \
41-
/* the Component name */ Counter, \
42-
/* the UI name */ "Counter", \
43-
/* the UI categories */ "Transform", \
44-
/* the doc string */ "Counts up by a value every frame when a condition is true.\n\n" \
45-
"Increments a counter by a specified value every frame that the input bool is true. " \
46-
"Useful for tracking how many frames a condition has been active.", \
47-
/* the version number */ 1, \
48-
LIST_INPUTS, LIST_STATES, LIST_OUTPUTS);
41+
42+
// Manually declaring the class to allow for custom initialize method
43+
class Counter : public RtRegisteredComponentBatch<Counter> {
44+
private:
45+
REMIX_COMPONENT_GENERATE_PROP_TYPES(LIST_INPUTS, LIST_STATES, LIST_OUTPUTS)
46+
REMIX_COMPONENT_BODY(
47+
/* the Component class name */ Counter,
48+
/* the UI name */ "Counter",
49+
/* the UI categories */ "Transform",
50+
/* the doc string */ "Counts up by a value every frame when a condition is true.\n\n"
51+
"Increments a counter by a specified value every frame that the input bool is true. "
52+
"Use `Starting Value` to set the initial counter value. "
53+
"Useful for tracking how many frames a condition has been active.",
54+
/* the version number */ 1,
55+
LIST_INPUTS, LIST_STATES, LIST_OUTPUTS,
56+
/* optional arguments: */
57+
spec.initialize = initialize; // Initialize callback to set initial value
58+
)
59+
void updateRange(const Rc<DxvkContext>& context, const size_t start, const size_t end) final {
60+
for (size_t i = start; i < end; i++) {
61+
if (m_increment[i]) {
62+
m_count[i] += m_incrementValue[i];
63+
}
64+
65+
m_value[i] = m_count[i];
66+
}
67+
}
68+
69+
// Static wrapper for the initialize callback
70+
static void initialize(const Rc<DxvkContext>& context, RtComponentBatch& batch, const size_t index) {
71+
static_cast<Counter&>(batch).initializeInstance(context, index);
72+
}
73+
void initializeInstance(const Rc<DxvkContext>& context, const size_t index) {
74+
// Set the initial counter value based on the default value
75+
m_count[index] = m_defaultValue[index];
76+
m_value[index] = m_count[index];
77+
}
78+
};
4979

5080
#undef LIST_INPUTS
5181
#undef LIST_STATES
5282
#undef LIST_OUTPUTS
5383

54-
void Counter::updateRange(const Rc<DxvkContext>& context, const size_t start, const size_t end) {
55-
for (size_t i = start; i < end; i++) {
56-
if (m_increment[i]) {
57-
m_count[i] += m_incrementValue[i];
58-
}
59-
60-
m_value[i] = m_count[i];
61-
}
62-
}
63-
6484
} // namespace components
6585
} // namespace dxvk
6686

0 commit comments

Comments
 (0)