Substance Painter
In this start to finish texturing project within Substance Painter we cover all the techniques you need to texture the robot character.
# 1 09-02-2012 , 10:42 PM
Registered User
Join Date: Feb 2012
Posts: 1

"Variable variable names"?

I'm writing an expression to take care of a "chasing lights" effect. Each row of lights has its own surfaceShader, and the expression uses a sine wav to bring the lights' outColor up and down. So far so good.

The problem I'm encountering now is that I want to use a for loop to set each of the surfaceShaders with one expression. The loop works fine, but I have yet to figure out how to use the loop counter to "generate" the surfaceShader name, then feed that into an assignment statement.

Example: let's say I need to assign 1 to outColorR on 5 nodes, named testLight0, testLight1, ..., testLight4. Like this:

for ( $i =0; $i < 5, $i++) {

[?????].outColor = 1;
}

I've tried concatening $i to the end of a "testLight" string with the + operator, and no luck. Any ideas?
All I really need to know is how to turn a string into a reference to a node , I have the rest figured out.

# 2 11-02-2012 , 01:55 AM
mark_slw's Avatar
Lifetime Member
Join Date: Jan 2004
Posts: 99
Could you not use:

eval("testLight" + $i + ".outColor = 1");


Perhaps?

# 3 13-02-2012 , 08:42 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Why not just use a single shader, with a ramp connected to the incandescence, make the white cover a small portion, and have the rest black, and arrange the light UV's along a single line? That way you could just animate the uv placement node's position attribute, and you can create it with a single shader. No need for expressions. Just two keys user added image


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads