mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #4649 from tokejepsen/feature/OP-3926_gpu-cache
This commit is contained in:
commit
9f61b72546
7 changed files with 178 additions and 19 deletions
|
|
@ -1,5 +1,9 @@
|
|||
import os
|
||||
|
||||
import maya.cmds as cmds
|
||||
|
||||
from openpype.hosts.maya.api.pipeline import containerise
|
||||
from openpype.hosts.maya.api.lib import unique_namespace
|
||||
from openpype.pipeline import (
|
||||
load,
|
||||
get_representation_path
|
||||
|
|
@ -11,19 +15,15 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
"""Load Alembic as gpuCache"""
|
||||
|
||||
families = ["model", "animation", "proxyAbc", "pointcache"]
|
||||
representations = ["abc"]
|
||||
representations = ["abc", "gpu_cache"]
|
||||
|
||||
label = "Import Gpu Cache"
|
||||
label = "Load Gpu Cache"
|
||||
order = -5
|
||||
icon = "code-fork"
|
||||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
|
||||
import maya.cmds as cmds
|
||||
from openpype.hosts.maya.api.pipeline import containerise
|
||||
from openpype.hosts.maya.api.lib import unique_namespace
|
||||
|
||||
asset = context['asset']['name']
|
||||
namespace = namespace or unique_namespace(
|
||||
asset + "_",
|
||||
|
|
@ -42,10 +42,9 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
c = colors.get('model')
|
||||
if c is not None:
|
||||
cmds.setAttr(root + ".useOutlinerColor", 1)
|
||||
cmds.setAttr(root + ".outlinerColor",
|
||||
(float(c[0])/255),
|
||||
(float(c[1])/255),
|
||||
(float(c[2])/255)
|
||||
cmds.setAttr(
|
||||
root + ".outlinerColor",
|
||||
(float(c[0]) / 255), (float(c[1]) / 255), (float(c[2]) / 255)
|
||||
)
|
||||
|
||||
# Create transform with shape
|
||||
|
|
@ -74,9 +73,6 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
loader=self.__class__.__name__)
|
||||
|
||||
def update(self, container, representation):
|
||||
|
||||
import maya.cmds as cmds
|
||||
|
||||
path = get_representation_path(representation)
|
||||
|
||||
# Update the cache
|
||||
|
|
@ -96,7 +92,6 @@ class GpuCacheLoader(load.LoaderPlugin):
|
|||
self.update(container, representation)
|
||||
|
||||
def remove(self, container):
|
||||
import maya.cmds as cmds
|
||||
members = cmds.sets(container['objectName'], query=True)
|
||||
cmds.lockNode(members, lock=False)
|
||||
cmds.delete([container['objectName']] + members)
|
||||
|
|
|
|||
65
openpype/hosts/maya/plugins/publish/extract_gpu_cache.py
Normal file
65
openpype/hosts/maya/plugins/publish/extract_gpu_cache.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import json
|
||||
|
||||
from maya import cmds
|
||||
|
||||
from openpype.pipeline import publish
|
||||
|
||||
|
||||
class ExtractGPUCache(publish.Extractor):
|
||||
"""Extract the content of the instance to a GPU cache file."""
|
||||
|
||||
label = "GPU Cache"
|
||||
hosts = ["maya"]
|
||||
families = ["model", "animation", "pointcache"]
|
||||
step = 1.0
|
||||
stepSave = 1
|
||||
optimize = True
|
||||
optimizationThreshold = 40000
|
||||
optimizeAnimationsForMotionBlur = True
|
||||
writeMaterials = True
|
||||
useBaseTessellation = True
|
||||
|
||||
def process(self, instance):
|
||||
cmds.loadPlugin("gpuCache", quiet=True)
|
||||
|
||||
staging_dir = self.staging_dir(instance)
|
||||
filename = "{}_gpu_cache".format(instance.name)
|
||||
|
||||
# Write out GPU cache file.
|
||||
kwargs = {
|
||||
"directory": staging_dir,
|
||||
"fileName": filename,
|
||||
"saveMultipleFiles": False,
|
||||
"simulationRate": self.step,
|
||||
"sampleMultiplier": self.stepSave,
|
||||
"optimize": self.optimize,
|
||||
"optimizationThreshold": self.optimizationThreshold,
|
||||
"optimizeAnimationsForMotionBlur": (
|
||||
self.optimizeAnimationsForMotionBlur
|
||||
),
|
||||
"writeMaterials": self.writeMaterials,
|
||||
"useBaseTessellation": self.useBaseTessellation
|
||||
}
|
||||
self.log.debug(
|
||||
"Extract {} with:\n{}".format(
|
||||
instance[:], json.dumps(kwargs, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
cmds.gpuCache(instance[:], **kwargs)
|
||||
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
||||
representation = {
|
||||
"name": "gpu_cache",
|
||||
"ext": "abc",
|
||||
"files": filename + ".abc",
|
||||
"stagingDir": staging_dir,
|
||||
"outputName": "gpu_cache"
|
||||
}
|
||||
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
self.log.info(
|
||||
"Extracted instance {} to: {}".format(instance.name, staging_dir)
|
||||
)
|
||||
|
|
@ -412,7 +412,7 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
self.log.debug("{}".format(op_session.to_data()))
|
||||
op_session.commit()
|
||||
|
||||
# Backwards compatibility
|
||||
# Backwards compatibility used in hero integration.
|
||||
# todo: can we avoid the need to store this?
|
||||
instance.data["published_representations"] = {
|
||||
p["representation"]["_id"]: p for p in prepared_representations
|
||||
|
|
|
|||
|
|
@ -930,6 +930,21 @@
|
|||
},
|
||||
"ExtractLook": {
|
||||
"maketx_arguments": []
|
||||
},
|
||||
"ExtractGPUCache": {
|
||||
"enabled": false,
|
||||
"families": [
|
||||
"model",
|
||||
"animation",
|
||||
"pointcache"
|
||||
],
|
||||
"step": 1.0,
|
||||
"stepSave": 1,
|
||||
"optimize": true,
|
||||
"optimizationThreshold": 40000,
|
||||
"optimizeAnimationsForMotionBlur": true,
|
||||
"writeMaterials": true,
|
||||
"useBaseTessellation": true
|
||||
}
|
||||
},
|
||||
"load": {
|
||||
|
|
|
|||
|
|
@ -1025,6 +1025,65 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"key": "ExtractGPUCache",
|
||||
"label": "Extract GPU Cache",
|
||||
"checkbox_key": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "enabled",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"key": "families",
|
||||
"label": "Families",
|
||||
"type": "list",
|
||||
"object_type": "text"
|
||||
},
|
||||
{
|
||||
"key": "step",
|
||||
"label": "Step",
|
||||
"type": "number",
|
||||
"decimal": 4,
|
||||
"minimum": 1
|
||||
},
|
||||
{
|
||||
"key": "stepSave",
|
||||
"label": "Step Save",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
},
|
||||
{
|
||||
"key": "optimize",
|
||||
"label": "Optimize Hierarchy",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"key": "optimizationThreshold",
|
||||
"label": "Optimization Threshold",
|
||||
"type": "number",
|
||||
"minimum": 1
|
||||
},
|
||||
{
|
||||
"key": "optimizeAnimationsForMotionBlur",
|
||||
"label": "Optimize Animations For Motion Blur",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"key": "writeMaterials",
|
||||
"label": "Write Materials",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"key": "useBaseTessellation",
|
||||
"label": "User Base Tesselation",
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ just one instance of this node type but if that is not so, validator will go thr
|
|||
instances and check the value there. Node type for **VRay** settings is `VRaySettingsNode`, for **Renderman**
|
||||
it is `rmanGlobals`, for **Redshift** it is `RedshiftOptions`.
|
||||
|
||||
:::info getting attribute values
|
||||
If you do not know what an attributes value is supposed to be, for example for dropdown menu (enum), try changing the attribute and look in the script editor where it should log what the attribute was set to.
|
||||
:::
|
||||
|
||||
### Model Name Validator
|
||||
|
||||
`ValidateRenderSettings`
|
||||
|
|
@ -110,6 +106,35 @@ or Deadlines **Draft Tile Assembler**.
|
|||
This is useful to fix some specific renderer glitches and advanced hacking of Maya Scene files. `Patch name` is label for patch for easier orientation.
|
||||
`Patch regex` is regex used to find line in file, after `Patch line` string is inserted. Note that you need to add line ending.
|
||||
|
||||
### Extract GPU Cache
|
||||
|
||||

|
||||
|
||||
- **Step** Specifies how often samples are taken during file creation. By default, one sample of your object's transformations is taken every frame and saved to the Alembic file.
|
||||
|
||||
For example, a value of 2 caches the transformations of the current object at every other frame of the Cache Time Range.
|
||||
|
||||
- **Step Save** Specifies which samples are saved during cache creation. For example, a value of 2 specifies that only every other sample specified by the Step # frame(s) option is saved to your Alembic file.
|
||||
|
||||
- **Optimize Hierarchy** When on, nodes and objects in a selected hierarchy are consolidated to maximize the performance of the cache file during playback.
|
||||
- **Optimization Threshold** (Available only when Optimize Hierarchy is on.) Specifies the maximum number of vertices contained in a single draw primitive. The default value of 40000 may be ideal for most Maya supported graphics cards. When set to the default value, after optimization, each object in the GPU cache file(s) will have no more than 40000 vertices. This value can be set higher depending on the memory available on your system graphics card.
|
||||
|
||||
- **Optimize Animations for Motion Blur** When on, objects with animated transform nodes display with motion blur when the cache is played back in Viewport 2.0 render mode. See Viewport 2.0 options.
|
||||
|
||||
Maya first determines if the GPU cache includes animation data. If the GPU cache is static and does not contain animation data, Maya does not optimize the GPU cache for motion blur.
|
||||
|
||||
:::note Motion Blur does not support Cached Playback.
|
||||
:::
|
||||
|
||||
- **Write Materials** When on, Maya exports the Lambert and Phong materials from source geometry to the GPU Cache file. These materials display when the GPU-cached file is played back in Viewport 2.0.
|
||||
|
||||
GPU-cached objects support all the high-quality lighting and shading effects provide by the Viewport 2.0 rendering mode. See Viewport 2.0 options.
|
||||
|
||||
:::note Lambert and Phong materials do not display on GPU-cached files when they are played back in scene view's High Quality Rendering or Default Quality Rendering modes.
|
||||
:::
|
||||
|
||||
- **Use Base Tessellation** Exports geometry with base tessellation and no smoothing applied. If this setting is turned off, the extractor will export geometry with the current Smooth Mesh Preview setting applied.
|
||||
|
||||
### Extract Playblast Settings (review)
|
||||
These settings provide granular control over how the playblasts or reviews are produced in Maya.
|
||||
|
||||
|
|
|
|||
BIN
website/docs/assets/maya-admin_gpu_cache.png
Normal file
BIN
website/docs/assets/maya-admin_gpu_cache.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Loading…
Add table
Add a link
Reference in a new issue