Skip to content

Commit

Permalink
Fix timeCode fps section with feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScheller committed Sep 27, 2023
1 parent d231ef2 commit e1fe27b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
5 changes: 1 addition & 4 deletions code/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,6 @@ def Xform "explosion" (

###### Stage vs Layer TimeSample Scaling ######
from pxr import Sdf, Usd
import os

layer_fps = 25
layer_identifier = "ref_layer.usd"
Expand All @@ -1783,7 +1782,7 @@ def Xform "explosion" (
attr_spec = Sdf.AttributeSpec(prim_spec, "size", Sdf.ValueTypeNames.Double)
for frame in range(1001, 1005):
value = float(frame - 1000)
reference_layer.SetTimeSample(attr_spec.path, frame, value)
reference_layer.SetTimeSample(attr_spec.path, frame * (layer_fps/stage_fps), value)
# FPS Metadata
time_samples = Sdf.Layer.ListAllTimeSamples(reference_layer)
reference_layer.timeCodesPerSecond = layer_fps
Expand All @@ -1794,8 +1793,6 @@ def Xform "explosion" (

# Create stage
stage = Usd.Stage.CreateInMemory()
# With scale
# reference_layer_offset = Sdf.LayerOffset(0, layer_fps/stage_fps)
# Without scale
reference_layer_offset = Sdf.LayerOffset(0, 1)
reference = Sdf.Reference(reference_layer.identifier, "/bicycle", reference_layer_offset)
Expand Down
6 changes: 1 addition & 5 deletions docs/src/core/elements/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ When working with stages, we have the following [loading order of FPS](https://o
1. framesPerSecond from root layer
1. fallback value of 24

These should match the FPS settings of your DCC. The 'framesPerSecond' is intended to be a hint for playback engines (e.g. your DCC/Usdview etc.) to set the FPS to when reading your file. The 'timeCodesPerSecond' describes the actual time sample intent. With the fallback behaviour we can also only specify the 'framesPerSecond' to keep both metadata entries in sync.
These should match the FPS settings of your DCC. The 'framesPerSecond' is intended to be a hint for playback engines (e.g. your DCC/Usdview etc.) to set the FPS to when reading your file. The 'timeCodesPerSecond' describes the actual time sample intent. With the fallback behavior we can also only specify the 'framesPerSecond' to keep both metadata entries in sync.

When working with layers, we have the following [loading order of FPS](https://openusd.org/dev/api/class_sdf_layer.html#a8c7a1ac2e85efa2aa4831123de576b7c):
1. timeCodesPerSecond of layer
Expand All @@ -222,10 +222,6 @@ Therefore when writing layers, we should always write these layer metrics, so th
the original intended FPS were and our caches work FPS independently.
~~~

~~~admonish warning
In the below code example, this doesn't seem to work (at least in Houdini/UsdView), we'll have to verify again with Pixar if this ia a bug, we are doing something wrong here or intended.
~~~

```python
(
timeCodesPerSecond = 24
Expand Down
4 changes: 0 additions & 4 deletions docs/src/production/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Our time samples that are written in the time unit-less `{<frame>: <value> }` fo
timeCodesPerSecond = 24
)
```
~~~admonish warning
If we want to load a let's say 24 FPS cache in a 25 FPS setup, we will have to apply a `Sdf.LayerOffset` when loading in the layer. This way we can move back the sample to the "correct" frame based times by scaling with a factor of 24/25.
~~~

You can find more details about the specific metadata priority and how to set the metadata in our [animation section](../core/elements/animation.html#animationMetadata).

## How is the scene scale unit and up axis handled in USD? <a name="faqSceneScale"></a>
Expand Down

0 comments on commit e1fe27b

Please sign in to comment.