主要内容

modify

R2026b

Modify existing 3D asset using text prompt

Since R2026b

Description

Add-On Required: This feature requires the 3D Asset Processing Library for MATLAB add-on.

outMesh = modify(trellisObj,inMesh,description) modifies an existing 3D asset, inMesh, based on a natural language text instruction, description, using a trellis object, trellisObj, and returns the modified 3D asset, outMesh. The function uses trellisObj to modify the asset texture, geometry, or both, depending on the instruction.

example

outMesh = modify(trellisObj,inMesh,description,Name=Value) specifies one or more options using name-value arguments.

Note

This feature requires Deep Learning Toolbox™ and a GPU with at least 16 GB of memory and a CUDA® compute capability of 7.0 or higher.

Examples

collapse all

Note: This example requires Deep Learning Toolbox and a GPU with at least 16 GB of memory and a CUDA compute capability of 7.0 or higher.

Create a trellis object.

trellisObj = trellis;

Generate a 3D asset to use as the input for texture modification.

meshObj = generateFromText(trellisObj,"A red F1 car",GeometryGenerationGuidanceStrength=8.5,GeometryGenerationSamplingSteps=50,...
    TextureGenerationGuidanceStrength=8.5,TextureGenerationSamplingSteps=50,SimplifyRatio=0.9,TextureSize=1024,Seed=42);

Display the original 3D asset.

show(meshObj)

Save the generated asset to a GLB file, and read it back as a Mesh object.

asset3d.write(meshObj,"f1-car.glb")
inMesh = asset3d.read("f1-car.glb",ReadAs="mesh");

Modify the texture of the asset using a text instruction by using the modify object function of the trellis object.

modifiedMeshObj = modify(trellisObj,inMesh,"Make the car blue color");

Display the modified 3D asset.

show(modifiedMeshObj)

Modify the texture of the same asset using a different text instruction and custom parameters to produce a result that more closely follows your text prompt.

modifiedMeshObj_custom = modify(trellisObj,inMesh,"Apply a camouflage paint pattern with green and brown tones", ...
    TextureGenerationGuidanceStrength=8.0,TextureGenerationSamplingSteps=50,SimplifyRatio=0.9,TextureSize=1024,Seed=42);

Display the 3D asset generated using the custom parameters.

show(modifiedMeshObj_custom)

Input Arguments

collapse all

Trellis 3D asset generator, specified as a trellis object.

Input 3D asset to modify, specified as a Mesh object. To load an existing asset from a file, use the asset3d.read function.

Text instruction for asset modification, specified as a string scalar or character vector. Write a clear and specific instruction describing how you want the appearance of the asset to change.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: modify(trellisObj,inMesh,description,TextureSize=2048,Seed=42) sets the texture resolution to 2048 pixels and fixes the generation seed to 42.

Guidance strength for texture modification, specified as a numeric scalar in the range [0, 10]. Use higher values when you want the modified texture to closely follow the text instruction. If the output contains noise or visual artifacts, reduce this value to enable the model to produce a cleaner result.

Number of sampling steps for texture modification, specified as an integer in the range [1, 50]. Higher values produce more refined and stable textures but increase generation time.

Mesh simplification ratio, specified as a numeric scalar in the range [0, 1]. A value of 0 preserves all vertices in the mesh, which maintains the original geometry during texture modification. Use higher values to reduce the number of vertices in the output mesh. For example, a value of 0.9 removes approximately 90% of the vertices while preserving the overall shape of the asset.

Size of the generated texture image, specified as an integer in the range [512, 2048]. Use higher values to increase the sharpness and detail of textures.

Random seed for generation, specified as a nonnegative integer. By default, the function uses a different random seed each time, which produces a different result for every call. Specify a fixed seed value to ensure repeatability each time you run the function with the same inputs and settings.

Display progress bar during object creation, specified as a logical 1 (true) or 0 (false). By default, the trellis function displays a progress bar while it initializes the object and sets up the model.

Output Arguments

collapse all

Modified 3D asset, returned as a Mesh object. To save the mesh to a file, use the asset3d.write function.

Limitations

macOS does not support generating 3D mesh assets from images or text prompts.

Version History

Introduced in R2026b