Untitled

mail@pastecode.io avatar
unknown
glsl
a year ago
10 kB
8
Indexable
Never
//**************************************************
// SUP, or Svvvvyungbepis's Uniform Protocol library
//**************************************************

//everything goes through this
uniform vec4 sup_data[];

float 	sup_as_float	(vec4 v) {return v.x;	}
vec2 	sup_as_vec2		(vec4 v) {return v.xy;	}
vec3 	sup_as_vec3		(vec4 v) {return v.xyz;	}
vec4 	sup_as_vec4		(vec4 v) {return v;		}
int 	sup_as_int		(vec4 v) {return int(v.x + 0.5);			}
ivec2 	sup_as_ivec2	(vec4 v) {return ivec2(v.xy + vec2(0.5));	}
ivec3 	sup_as_ivec3	(vec4 v) {return ivec3(v.xyz + vec3(0.5));	}
ivec4 	sup_as_ivec4	(vec4 v) {return ivec4(v + vec4(0.5));		}

#define INDR(P) P

#define SUP_PYTHON_BEGIN
#define SUP_PYTHON_END
#define SUP_VARS_BEGIN
#define SUP_VARS_END
#define SUP_STRUCTS_BEGIN
#define SUP_STRUCTS_END

#define BEG_DECL(STRTYPE, u) 				struct STRTYPE {
#define VAR_DECL(TYPE, NAME, u, u2)			TYPE NAME;
#define END_DECL(STRTYPE, SIZE)				};

#define BEG_GETR(STRTYPE, STRNAME) 			STRTYPE STRNAME(){STRTYPE res;
#define VAR_GETR(u, NAME, STRNAME, u2)		res.NAME = STRNAME ## _ ## NAME();
#define END_GETR(u, u2)						return res;}

#define BEG_ALLC(u, u2)
#define VAR_ALLC(TYPE, NAME, STRNAME, IDX)	TYPE STRNAME ## _ ## NAME(){ return sup_as_ ## TYPE(sup_data[__LINE__ + IDX - 1]); }
#define END_ALLC(u, u2)

#define BEG_SIZE(u, u2)
#define VAR_SIZE(u, u2, u3, u4)
#define END_SIZE(u, SIZE) 					SIZE

//T: type of struct, V: macro version for pattern matching,
//N: name of struct, T0/N0 ...: are type/name pairs for struct members
//******************AUTOGENERATED WITH PYTHON*************************
#define STRMAIN_ARG1(T, V, N, T0, N0) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  END_ ## V(T, 1)
#define STRMAIN_ARG2(T, V, N, T0, N0, T1, N1) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  END_ ## V(T, 2)
#define STRMAIN_ARG3(T, V, N, T0, N0, T1, N1, T2, N2) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  END_ ## V(T, 3)
#define STRMAIN_ARG4(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  END_ ## V(T, 4)
#define STRMAIN_ARG5(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  END_ ## V(T, 5)
#define STRMAIN_ARG6(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  END_ ## V(T, 6)
#define STRMAIN_ARG7(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  END_ ## V(T, 7)
#define STRMAIN_ARG8(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  END_ ## V(T, 8)
#define STRMAIN_ARG9(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  END_ ## V(T, 9)
#define STRMAIN_ARG10(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  END_ ## V(T, 10)
#define STRMAIN_ARG11(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  END_ ## V(T, 11)
#define STRMAIN_ARG12(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10, T11, N11) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  VAR_ ## V(T11, N11, N, 11)  END_ ## V(T, 12)
#define STRMAIN_ARG13(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10, T11, N11, T12, N12) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  VAR_ ## V(T11, N11, N, 11)  VAR_ ## V(T12, N12, N, 12)  END_ ## V(T, 13)
#define STRMAIN_ARG14(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10, T11, N11, T12, N12, T13, N13) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  VAR_ ## V(T11, N11, N, 11)  VAR_ ## V(T12, N12, N, 12)  VAR_ ## V(T13, N13, N, 13)  END_ ## V(T, 14)
#define STRMAIN_ARG15(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10, T11, N11, T12, N12, T13, N13, T14, N14) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  VAR_ ## V(T11, N11, N, 11)  VAR_ ## V(T12, N12, N, 12)  VAR_ ## V(T13, N13, N, 13)  VAR_ ## V(T14, N14, N, 14)  END_ ## V(T, 15)
#define STRMAIN_ARG16(T, V, N, T0, N0, T1, N1, T2, N2, T3, N3, T4, N4, T5, N5, T6, N6, T7, N7, T8, N8, T9, N9, T10, N10, T11, N11, T12, N12, T13, N13, T14, N14, T15, N15) BEG_ ## V(T, N) VAR_ ## V(T0, N0, N, 0)  VAR_ ## V(T1, N1, N, 1)  VAR_ ## V(T2, N2, N, 2)  VAR_ ## V(T3, N3, N, 3)  VAR_ ## V(T4, N4, N, 4)  VAR_ ## V(T5, N5, N, 5)  VAR_ ## V(T6, N6, N, 6)  VAR_ ## V(T7, N7, N, 7)  VAR_ ## V(T8, N8, N, 8)  VAR_ ## V(T9, N9, N, 9)  VAR_ ## V(T10, N10, N, 10)  VAR_ ## V(T11, N11, N, 11)  VAR_ ## V(T12, N12, N, 12)  VAR_ ## V(T13, N13, N, 13)  VAR_ ## V(T14, N14, N, 14)  VAR_ ## V(T15, N15, N, 15)  END_ ## V(T, 16)
//******************AUTOGENERATED WITH PYTHON*************************

#define GETMETA(STRTYPE) 		STRMETA_ ## STRTYPE
#define GETSIZE(STRTYPE) 		INDR(GETMETA(STRTYPE)(SIZE, u))

//These are the only macros you should use:
//and you have to define STRMETA_yourstructtype(V,N) macro urself
#define ui(data_for_python) 
#define STRDECL(STRTYPE) 		GETMETA(STRTYPE)(DECL, ~)
#define VAR(T, N) T N(){ return sup_as_ ## T(sup_data[__LINE__ - 1]); }
#define STR(STRTYPE, STRNAME) 	GETMETA(STRTYPE)(ALLC, STRNAME) GETMETA(STRTYPE)(GETR, STRNAME)
#define ooo(STRTYPE) 			__LINE__ + GETSIZE(STRTYPE) - 1
//////////////////////////////////////////////////////////////////////////////////////////////

/*
	Var params are set in ui("") in SUP_VARS_ block below.
	NEVER USE " DOUBLE QUOTES IN PYTHON, ONLY SINGLE: ' '
	
	for VAR decl: (primitive types)
		location is first arg, its string in form "tabname@containername"
		tabname must begin with agt_, will be autogenerated
		container has to be manually created by user in Touchdesigner
		has default value, of, currently "agt_unspec@C3" or something
		special value ^ (not "^") means take location of previous var
	for STR decl: (structs)
		you never supply location for member variables,
		with structs you only reference location on same line as STR,
		only supplying containername, e.g. ui("C3"), tabname is autogenerated
		has default value of "C3", '^' special value not defined
	
	setting limits, for all or for XYZW individually:
		lims = [from, to, *current]
		lims = [[from, to, *current], *more_lims]
	
	if you dont want default sliders, specify component with:
		tox = color #or xys or radio, but those are preset strings for:
			tox = "sv_radios"
			(or "sv_xys" or "sv_color"...)
		(or just set rad/color param (below), and it will auto-fill this field
		
	for tox = "sv_radios", set values like this: (>means selected by default)
		rad = "a b >c (...)"
		rad = ["a b c ...", *morestrings]
	
	for tox = "sv_color", set values like this:
		color = [1,1,1,1] #its rgba and alpha is optional
		
	-In general, you dont have to provide all values in arrays for XYZW components.
	-Set up context in SUP_PYTHON_ block below, it will be accessible in SUP_VARS_ space
*/

//////////////////////////////////////////////////////////////////////////////////////////////

/*
SUP_PYTHON_BEGIN
################
myred = [1, 0, 0]
################
SUP_PYTHON_END
*/


SUP_STRUCTS_BEGIN
//---------------
#define STRMETA_Kek(V,N) STRMAIN_ARG2(Kek,V,N,\
vec4, 	a, 	ui("color = myred")\
int, 	b)	ui("rad='ry an go sling'")	
STRDECL(Kek)
//-------------
SUP_STRUCTS_END


//absolutely no empty lines allowed or will break ^^
#line 	0
SUP_VARS_BEGIN
		STR(Kek, first) 	ui("C2")
#line	ooo(Kek)
		STR(Kek, second) 	ui("C2")
#line	ooo(Kek)
SUP_VARS_END