Hi, I’m trying to use “if” variable expressions in usd so that when selection is made in variantSet “ControlVarset”, it automatically switches variantSet “Light”:
#usda 1.0
(
endTimeCode = 1
framesPerSecond = 24
metersPerUnit = 1
startTimeCode = 1
subLayers = [
@./geo/layer_1.usd@,
@./geo/layer_0.usd@
]
timeCodesPerSecond = 24
upAxis = "Y"
# unsure how to use this expression assignment part, it's from documentation :
expressionVariables = {
string MODEL_VARIANT = "red"
}
)
def Xform "Variants"
{
def Scope "Light" (
variants = {
string LightVar = "`if(${ControlVarset} == 'variant1', 'domelight1', \
if(${ControlVarset} == variant2', 'domelight2', 'domelight4')))`"
}
prepend variantSets = "LightVar"
)
{
variantSet "LightVar" = {
"domelight1" {
def DomeLight "lightMORNING" (
prepend apiSchemas = ["HoudiniViewportGuideAPI"]
)
{
custom rel filters = None
float houdini:guidescale = 1
bool houdini:inviewermenu = 0
color3f inputs:color = (1, 1, 1)
float inputs:diffuse = 1
bool inputs:enableColorTemperature = 0
float inputs:exposure = 0
float inputs:intensity = 350
bool inputs:normalize = 0
float inputs:specular = 1
asset inputs:texture:file = @@
token inputs:texture:format = "automatic"
rel light:filters = None
rel portals = None
matrix4d xformOp:transform = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))
uniform token[] xformOpOrder = ["xformOp:transform"]
}
}
"domelight2" {
def DomeLight "lightDAY" (
prepend apiSchemas = ["HoudiniViewportGuideAPI"]
)
{
custom rel filters = None
float houdini:guidescale = 1
bool houdini:inviewermenu = 0
color3f inputs:color = (1, 1, 1)
float inputs:diffuse = 1
bool inputs:enableColorTemperature = 0
float inputs:exposure = 0
float inputs:intensity = 500
bool inputs:normalize = 0
float inputs:specular = 1
asset inputs:texture:file = @@
token inputs:texture:format = "automatic"
rel light:filters = None
rel portals = None
matrix4d xformOp:transform = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))
uniform token[] xformOpOrder = ["xformOp:transform"]
}
}
}
}
def Scope "Controller" (
variants = {
string ControlVarset = "variant1"
}
prepend variantSets = "ControlVarset"
)
{
variantSet "ControlVarset" = {
"variant1" {
def DomeLight "lightMORNING" (
prepend apiSchemas = ["HoudiniViewportGuideAPI"]
)
{
}
}
"variant2" {
def DomeLight "lightDAY" (
prepend apiSchemas = ["HoudiniViewportGuideAPI"]
)
{
}
}
}
}
}
Is there a way to conditionally switch Light variantSet according to what I set ControlVarset to?
I’m unsure how to apply examples from USD Variable Expressions — Universal Scene Description 24.05 documentation in this scenario.