Hi, I’m trying to use variable expressions in my usd so selecting one variant switches several lights on/off.
I’m using https://openusd.org/release/user_guides/variable_expressions.html#expression-function-reference as reference.
I’d like to use my var TIMEOFDAY so that once a variant is selected eg. “domelight1” - it sets TIMEOFDAY as “morning” and that turns of specific lights on stage. When I choose “domelight3”, I’d like specific multiple night lights to turn on. I’m having a difficult time with applying the if conditional:
#usda 1.0
(
endTimeCode = 1
framesPerSecond = 24
metersPerUnit = 1
startTimeCode = 1
subLayers = [
@./geo/layer_1.usd@,
@./geo/layer_0.usd@
]
timeCodesPerSecond = 24
upAxis = "Y"
expressionVariables = {
string TIMEOFDAY = "evening"
string[] TimesOfDayList = ["morning", "day", "evening"]
}
)
def Xform "Variants"
{
def Scope "Light" (
variants = {
string LightVar = "domelight1"
}
prepend variantSets = "LightVar"
)
{
variantSet "LightVar" = {
"domelight1" {
string TIMEOFDAY = "morning"
def DomeLight 'if(eq("morning", ${TIMEOFDAY}), "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"]
}
}
"domelight3" {
def DomeLight "lightEVENING" (
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"]
}
}
}
}
}
this produces an error:
2024-05-29 09:41:56 [Error] [omni.usd] Runtime Error (secondary thread): in textFileFormatYyerror at line 3162 of pxr/usd/sdf/textFileFormat.yy -- 'if(eq("morning", ${TIMEOFDAY}), "lightMORNING")' is not a valid prim name at ''if(eq("morning", ${TIMEOFDAY}), "lightMORNING")'' in </Variants/Light{LightVar=domelight1}> on line 33 in file (...)Main.usda
How do I use the conditionals or edit my usd to handle turning mutltiple lights on/off based on variant selection?