Skip to content

Commit 2fc629d

Browse files
Merge branch 'flexibleTypes' into 'main'
[REMIX-4384] Supporting Flexible types in components See merge request lightspeedrtx/dxvk-remix-nv!1775
2 parents 8b19262 + c562a63 commit 2fc629d

39 files changed

+2498
-316
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Interpolate
2+
3+
Interpolates a value from an input range to an output range with optional easing\. <br/>Combines normalization \(reverse LERP\), easing, and mapping \(LERP\) into a single component\. <br/><br/>Note input values outside of input range are valid, and that easing can lead to the output value being outside of the output range even when input is inside the input range\.<br/> Inverted ranges \(max < min\) are supported, but the results are undefined and may change without warning\.
4+
5+
## Component Information
6+
7+
- **Name:** `Interpolate`
8+
- **UI Name:** Interpolate
9+
- **Version:** 1
10+
- **Categories:** Transform
11+
12+
## Input Properties
13+
14+
| Property | Display Name | Type | IO Type | Default Value | Optional |
15+
|----------|--------------|------|---------|---------------|----------|
16+
| value | Value | Float | Input | 0\.0 | No |
17+
| inputMin | Input Min | Float | Input | 0\.0 | No |
18+
| inputMax | Input Max | Float | Input | 1\.0 | No |
19+
| clampInput | Clamp Input | Bool | Input | false | Yes |
20+
| easingType | Easing Type | Uint32 | Input | Linear | No |
21+
| shouldReverse | Should Reverse | Bool | Input | false | Yes |
22+
| outputMin | Output Min | NumberOrVector | Input | 0 | No |
23+
| outputMax | Output Max | NumberOrVector | Input | 0 | No |
24+
25+
### Value
26+
27+
The input value to interpolate\.
28+
29+
30+
### Input Min
31+
32+
If \`Value\` equals \`Input Min\`, the output will be \`Output Min\`\.
33+
34+
35+
### Input Max
36+
37+
If \`Value\` equals \`Input Max\`, the output will be \`Output Max\`\.
38+
39+
40+
### Clamp Input
41+
42+
If true, \`value\` will be clamped to the input range\.
43+
44+
45+
### Easing Type
46+
47+
The type of easing to apply\.
48+
49+
Underlying Type: `Uint32`
50+
51+
52+
**Allowed Values:**
53+
54+
- Linear (`Linear`): The float will have a constant velocity\. *(default)*
55+
- Cubic (`Cubic`): The float will change in a cubic curve over time\.
56+
- EaseIn (`EaseIn`): The float will start slow, then accelerate\.
57+
- EaseOut (`EaseOut`): The float will start fast, then decelerate\.
58+
- EaseInOut (`EaseInOut`): The float will start slow, accelerate, then decelerate\.
59+
- Sine (`Sine`): Smooth, natural motion using a sine wave\.
60+
- Exponential (`Exponential`): Dramatic acceleration effect\.
61+
- Bounce (`Bounce`): Bouncy, playful motion\.
62+
- Elastic (`Elastic`): Spring\-like motion\.
63+
64+
### Should Reverse
65+
66+
If true, the easing is applied backwards\. If \`Value\` is coming from a loopFloat component that is using \`pingpong\`, hook this up to \`isReversing\` from that component\.
67+
68+
69+
### Output Min
70+
71+
What a \`Value\` of \`Input Min\` maps to\.
72+
73+
74+
### Output Max
75+
76+
What a \`Value\` of \`Input Max\` maps to\.
77+
78+
79+
## Output Properties
80+
81+
| Property | Display Name | Type | IO Type | Default Value | Optional |
82+
|----------|--------------|------|---------|---------------|----------|
83+
| interpolatedValue | Interpolated Value | NumberOrVector | Output | 0 | No |
84+
85+
### Interpolated Value
86+
87+
The final interpolated value after applying input normalization, easing, and output mapping\.
88+
89+
90+
## Valid Type Combinations
91+
92+
This component supports flexible types. The following type combinations are valid:
93+
94+
| # | clampInput | easingType | inputMax | inputMin | interpolatedValue | outputMax | outputMin | shouldReverse | value |
95+
|---|---|---|---|---|---|---|---|---|---|
96+
| 1 | Bool | Uint32 | Float | Float | Float | Float | Float | Bool | Float |
97+
| 2 | Bool | Uint32 | Float | Float | Float2 | Float2 | Float2 | Bool | Float |
98+
| 3 | Bool | Uint32 | Float | Float | Float3 | Float3 | Float3 | Bool | Float |
99+
| 4 | Bool | Uint32 | Float | Float | Color4 | Color4 | Color4 | Bool | Float |
100+
101+
**Note:** Float3 and Color3 both use the same underlying type (3-component vector). Color4 uses a 4-component vector.
102+
103+
## Usage Notes
104+
105+
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
106+
107+
---
108+
[← Back to Component Index](index.md)
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
# Sphere Light
2-
3-
Override the sphere light properties\.
4-
5-
## Component Information
6-
7-
- **Name:** `SphereLightOverride`
8-
- **UI Name:** Sphere Light
9-
- **Version:** 1
10-
- **Categories:** Act
11-
12-
## Input Properties
13-
14-
| Property | Display Name | Type | IO Type | Default Value | Optional |
15-
|----------|--------------|------|---------|---------------|----------|
16-
| enabled | Enabled | Bool | Input | true | Yes |
17-
| radius | Radius | Float | Input | 0\.0 | Yes |
18-
| target | Target | Prim | Input | None | No |
19-
20-
### Enabled
21-
22-
If true, the overrides will be applied\.
23-
24-
25-
### Radius
26-
27-
The radius of the sphere light\.
28-
29-
30-
### Target
31-
32-
The sphere light to override\.
33-
34-
35-
## Usage Notes
36-
37-
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
38-
39-
---
40-
[← Back to Component Index](index.md)
1+
# \[Non Functional\] Sphere Light
2+
3+
Override the sphere light properties\.
4+
5+
## Component Information
6+
7+
- **Name:** `SphereLightOverride`
8+
- **UI Name:** \[Non Functional\] Sphere Light
9+
- **Version:** 1
10+
- **Categories:** Act
11+
12+
## Input Properties
13+
14+
| Property | Display Name | Type | IO Type | Default Value | Optional |
15+
|----------|--------------|------|---------|---------------|----------|
16+
| enabled | Enabled | Bool | Input | true | Yes |
17+
| radius | Radius | Float | Input | 0\.0 | Yes |
18+
| target | Target | Prim | Input | None | No |
19+
20+
### Enabled
21+
22+
If true, the overrides will be applied\.
23+
24+
25+
### Radius
26+
27+
The radius of the sphere light\.
28+
29+
30+
### Target
31+
32+
The sphere light to override\.
33+
34+
35+
## Usage Notes
36+
37+
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
38+
39+
---
40+
[← Back to Component Index](index.md)

documentation/components/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ This documentation provides detailed information about all available components
1111
| Component | Description | Version |
1212
|-----------|-------------|---------|
1313
| [Rtx Option Layer Action](RtxOptionLayerAction.md) | Controls an RtxOptionLayer by name, allowing dynamic enable/disable, strength adjustment, and thresh\.\.\. | 1 |
14-
| [Sphere Light](SphereLightOverride.md) | Override the sphere light properties\. | 1 |
14+
| [\[Non Functional\] Sphere Light](SphereLightOverride.md) | Override the sphere light properties\. | 1 |
1515

1616
### Transform
1717

1818
| Component | Description | Version |
1919
|-----------|-------------|---------|
2020
| [Animated Float](AnimatedFloat.md) | A single animated float value\. | 1 |
21+
| [Interpolate](Interpolate.md) | Interpolates a value from an input range to an output range with optional easing\. <br/>Combines normaliz\.\.\. | 1 |
2122
| [Interpolate Float](InterpolateFloat.md) | Interpolates a value from an input range to an output range with optional easing\. <br/>Combines normaliz\.\.\. | 1 |
2223
| [Loop Float](LoopFloat.md) | Applies looping behavior to a float value\. Value is unchanged if it is inside the range\.<br/>Component \.\.\. | 1 |
2324

@@ -34,8 +35,8 @@ This documentation provides detailed information about all available components
3435

3536
## Statistics
3637

37-
- **Total Components:** 11
38-
- **Categorized Components:** 11
38+
- **Total Components:** 12
39+
- **Categorized Components:** 12
3940
- **Categories:** 3
4041

4142
---

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ inline const auto kInterpolationTypeEnumValues = RtComponentPropertySpec::EnumPr
7373
};
7474

7575
// Apply interpolation/easing to a normalized time value (0-1)
76-
inline float applyInterpolation(InterpolationType interpolation, float time) {
76+
template<typename T>
77+
inline T applyInterpolation(InterpolationType interpolation, T time) {
7778
switch(interpolation) {
7879
case InterpolationType::Linear:
7980
return time;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
25+
#include "../rtx_graph_component_macros.h"
26+
#include "animation_utils.h"
27+
28+
namespace dxvk {
29+
namespace components {
30+
31+
#define LIST_INPUTS(X) \
32+
X(RtComponentPropertyType::Float, 0.0f, value, "Value", "The input value to interpolate.") \
33+
X(RtComponentPropertyType::Float, 0.0f, inputMin, "Input Min", "If `Value` equals `Input Min`, the output will be `Output Min`.") \
34+
X(RtComponentPropertyType::Float, 1.0f, inputMax, "Input Max", "If `Value` equals `Input Max`, the output will be `Output Max`.") \
35+
X(RtComponentPropertyType::Bool, false, clampInput, "Clamp Input", "If true, `value` will be clamped to the input range.", property.optional = true) \
36+
X(RtComponentPropertyType::Uint32, static_cast<uint32_t>(InterpolationType::Linear), easingType, "Easing Type", \
37+
"The type of easing to apply.", \
38+
property.enumValues = kInterpolationTypeEnumValues) \
39+
X(RtComponentPropertyType::Bool, false, shouldReverse, "Should Reverse", "If true, the easing is applied backwards. If `Value` is coming from a loopFloat component that is using `pingpong`, hook this up to `isReversing` from that component.", property.optional = true) \
40+
X(RtComponentPropertyType::NumberOrVector, 0.0f, outputMin, "Output Min", "What a `Value` of `Input Min` maps to.") \
41+
X(RtComponentPropertyType::NumberOrVector, 1.0f, outputMax, "Output Max", "What a `Value` of `Input Max` maps to.")
42+
43+
#define LIST_STATES(X)
44+
45+
#define LIST_OUTPUTS(X) \
46+
X(RtComponentPropertyType::NumberOrVector, 0.0f, interpolatedValue, "Interpolated Value", "The final interpolated value after applying input normalization, easing, and output mapping.")
47+
48+
// Manually declaring the class to allow for custom applySceneOverrides method
49+
template <RtComponentPropertyType rangePropertyType>
50+
class Interpolate : public RtRegisteredComponentBatch<Interpolate<rangePropertyType>> {
51+
private:
52+
static constexpr RtComponentPropertyType valuePropertyType = RtComponentPropertyType::Float;
53+
static constexpr RtComponentPropertyType inputMinPropertyType = RtComponentPropertyType::Float;
54+
static constexpr RtComponentPropertyType inputMaxPropertyType = RtComponentPropertyType::Float;
55+
static constexpr RtComponentPropertyType clampInputPropertyType = RtComponentPropertyType::Bool;
56+
static constexpr RtComponentPropertyType easingTypePropertyType = RtComponentPropertyType::Uint32;
57+
static constexpr RtComponentPropertyType shouldReversePropertyType = RtComponentPropertyType::Bool;
58+
static constexpr RtComponentPropertyType outputMinPropertyType = rangePropertyType;
59+
static constexpr RtComponentPropertyType outputMaxPropertyType = rangePropertyType;
60+
static constexpr RtComponentPropertyType interpolatedValuePropertyType = rangePropertyType;
61+
REMIX_COMPONENT_BODY(
62+
/* the Component class name */ Interpolate,
63+
/* the UI name */ "Interpolate",
64+
/* the UI categories */ "Transform",
65+
/* the doc string */ "Interpolates a value from an input range to an output range with optional easing. " \
66+
"\nCombines normalization (reverse LERP), easing, and mapping (LERP) into a single component. " \
67+
"\n\nNote input values outside of input range are valid, and that easing can lead to the output value being " \
68+
"outside of the output range even when input is inside the input range." \
69+
"\n Inverted ranges (max < min) are supported, but the results are undefined and may change without warning.",
70+
/* the version number */ 1,
71+
LIST_INPUTS, LIST_STATES, LIST_OUTPUTS
72+
)
73+
void Interpolate::updateRange(const Rc<DxvkContext>& context, const size_t start, const size_t end) {
74+
for (size_t i = start; i < end; i++) {
75+
// Step 1: Normalize input value to 0-1 range (reverse LERP / float_to_strength)
76+
float normalizedValue = m_value[i];
77+
if (m_inputMax[i] == m_inputMin[i]) {
78+
ONCE(Logger::err(str::format("InterpolateFloat: Input Min and Input Max are the same. Setting normalized value to 0.0f. Input Min: ", m_inputMin[i], " Input Max: ", m_inputMax[i])));
79+
normalizedValue = 0.0f; // Avoid division by zero
80+
} else {
81+
if (m_clampInput[i]) {
82+
normalizedValue = clamp(normalizedValue, m_inputMin[i], m_inputMax[i]);
83+
}
84+
normalizedValue = (normalizedValue - m_inputMin[i]) / (m_inputMax[i] - m_inputMin[i]);
85+
}
86+
87+
// cache in a const value to avoid double branch
88+
const bool shouldReverse = m_shouldReverse[i];
89+
90+
// Step 2: Apply easing (ease component logic)
91+
// If should reverse, flip the input value
92+
if (shouldReverse) {
93+
normalizedValue = 1.0f - normalizedValue;
94+
}
95+
96+
// Apply the easing
97+
float easedValue = applyInterpolation(static_cast<InterpolationType>(m_easingType[i]), normalizedValue);
98+
99+
// If should reverse, flip the output back
100+
if (shouldReverse) {
101+
easedValue = 1.0f - easedValue;
102+
}
103+
104+
// Step 3: Map eased value to output range (LERP / strength_to_float)
105+
m_interpolatedValue[i] = lerp(m_outputMin[i], m_outputMax[i], easedValue);
106+
}
107+
}
108+
};
109+
110+
#undef LIST_INPUTS
111+
#undef LIST_STATES
112+
#undef LIST_OUTPUTS
113+
114+
115+
namespace {
116+
// Instantiate all of the typed variants we want to support.
117+
template class Interpolate<RtComponentPropertyType::Float>;
118+
template class Interpolate<RtComponentPropertyType::Float2>;
119+
template class Interpolate<RtComponentPropertyType::Float3>;
120+
template class Interpolate<RtComponentPropertyType::Color4>;
121+
} // namespace
122+
123+
} // namespace components
124+
} // namespace dxvk
125+

0 commit comments

Comments
 (0)