Skip to content

Commit 07b2406

Browse files
authored
testshade --shader <shadername> <layername> (#763)
`--shader` is like a combination of --layer, and then naming the shader to create an instance of it. The reason I prefer --shader is that when you use it, the command line is almost identical to the shader group serialization. So much nicer! For example: ``` $ testshade -param texturename "grid.tx" \ -shader texturemap tex1 \ -param frequency 4.0 \ -shader noisy noise1 \ -param scale 1.0 \ -shader contrast cont1 \ -shader umixer mix1 \ -connect tex1 out cont1 in \ -connect cont1 out mix1 left \ -connect noise1 out mix1 right \ -g 256 256 -o out noisetex.jpg ``` corresponds very symmetrically to the shader group ``` param string texturename "grid.tx" ; shader texturemap tex1 ; param float frequency 4.0 ; shader noisy noise1 ; param float scale 1.0 ; shader contrast cont1 ; shader umixer mix1 ; connect tex1.out cont1.in ; connect cont1.out mix1.left ; connect noise1.out mix1.right ; ``` whereas, in comparison, using the old --layer notation works, but is a less direct mapping to the serialization format: ``` $ testshade -layer tex1 -param texturename "grid.tx" texturemap \ -layer noise1 -param frequency 4.0 noisy \ -layer cont1 -param scale 1.0 contrast \ -layer mix1 umixer \ -connect tex1 out cont1 in \ -connect cont1 out mix1 left \ -connect noise1 out mix1 right \ -g 256 256 -o out noisetex.jpg ```
1 parent e6f921a commit 07b2406

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/testshade/testshade.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,17 @@ add_shader (int argc, const char *argv[])
227227

228228

229229

230+
static void
231+
action_shaderdecl (int argc, const char *argv[])
232+
{
233+
// `--shader shadername layername` is exactly equivalent to:
234+
// `--layer layername` followed by naming the shader.
235+
layername = argv[2];
236+
add_shader (1, argv+1);
237+
}
238+
239+
240+
230241
// The --expr ARG command line option will take ARG that is a snipped of
231242
// OSL source code, embed it in some boilerplate shader wrapper, compile
232243
// it from memory, and run that in the same way that would have been done
@@ -473,6 +484,8 @@ getargs (int argc, const char *argv[])
473484
"--layer %s", &layername, "Set next layer name",
474485
"--param %@ %s %s", &action_param, NULL, NULL,
475486
"Add a parameter (args: name value) (options: type=%s, lockgeom=%d)",
487+
"--shader %@ %s %s", &action_shaderdecl, NULL, NULL,
488+
"Declare a shader node (args: shader layername)",
476489
"--connect %L %L %L %L",
477490
&connections, &connections, &connections, &connections,
478491
"Connect fromlayer fromoutput tolayer toinput",

0 commit comments

Comments
 (0)