Search - User list
Full Version: Defining lots of parameters
Root » Technical Discussion » Defining lots of parameters
archie
Hello everybody!

I have a small technical question.
“v_layered” shader is a great example of how to initialize lots of similar parameters.
Unfortunately it does not give an answer how to initialize #pragma directives corresponding to this parameters. The shader itself contains #include “layered.pragma” but I can’t find the file layered.pragma.
How can I get this?
I have a lot of similar parameters described via #define, but need to add elegant #pragma for them and cannot understand how to do that.
Brute force is not good here because of really great number of those parameters.
archie
Hello again!
Perhaps did not explain this task clear enough.

For example, we have a surface shader.
And we know that there exists repeating block of parameters, that repeats e.g. N times.
In order not to duplicate this parameters in shader arguments we write this block as follows:

#define BLOCK_PARMS(prefix) \
string myVar1##prefix = <value>; \
int myVar2##prefix = < value >; \
float myVar3##prefix = < value >; \
string myVar4##prefix = < value >; \
……..
int myVar<N>##prefix = < value >;

next we call it N times:


surface
myShader (
BLOCK_PARMS (1)
BLOCK_PARMS (2)
…..
BLOCK_PARMS (<N>)
)
{
……
}

And everything is great! But how can one create parameter pragmas for UI since they are also the same?
Now it looks like for every block I need to manually duplicate pragma blocks and change prefix N times:

/* Block 1 */
#pragma label myVar1<prefix> “My Var 1”
#pragma hint myVar1<prefix> image
#pragma label myVar2<prefix> “My Var 2”
#pragma hint myVar2<prefix> toggle
#pragma label myVar3<prefix> “My Var 3”
#pragma range myVar3<prefix> 0 5
….
#pragma label myVar<N><prefix> “My Var <N>”
#pragma group “<Prefix>” myVar1
….
#pragma group “<Prefix>” myVar<N>

/* Block 2 */
#pragma label myVar1<prefix> “My Var 1”
#pragma hint myVar1<prefix> image
#pragma label myVar2<prefix> “My Var 2”
#pragma hint myVar2<prefix> toggle
#pragma label myVar3<prefix> “My Var 3”
#pragma range myVar3<prefix> 0 5
….
#pragma label myVar<N><prefix> “My Var <N>”
#pragma group “<Prefix>” myVar1
….
#pragma group “<Prefix>” myVar<N>
…………………..
/* Block N */
#pragma label myVar1<prefix> “My Var 1”
#pragma hint myVar1<prefix> image
#pragma label myVar2<prefix> “My Var 2”
#pragma hint myVar2<prefix> toggle
#pragma label myVar3<prefix> “My Var 3”
#pragma range myVar3<prefix> 0 5
….
#pragma label myVar<N><prefix> “My Var <N>”
#pragma group “<Prefix>” myVar1
….
#pragma group “<Prefix>” myVar<N>

I really dislike it because it’s very ugly and not compact at all. Are there any other ways? Has anyone faced this?
In the beginning I was mentioning “v_layered” shader as an example. It can’t be that they duplicated this block 16 times.
Such a huge pragmas block for UI! There is layered.pragma mentioned but can’t find this file.

Just want to get an answer like “yes, everything is bad and you have to duplicate this lots of times” or “everything is fine, you just have to do this and that” and show some example
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB