c - How to define different qualifiers for the different struct members in GLSL? -


i'm using webgl , want use structured code in fragment , vertex shader code, not define them globally, because of sharpened eyes lot of work oop.

and i've got next problem, can't define different qualifiers different struct members.

for e.g.:

struct light {     vec3 normal;     vec3 position;     bool isdirectional;     ... }; 

i can create instance of struct like:

uniform light lightinstance; 

but, you're able see, can define single qualifier.

if try use that:

varying light.normal normalvalue; uniform light.position lightposition; 

then, can't use typedef, memcpy, pointers using glsl. know, should read more glsl , shall it.

but it's rather difficult documentation webgl shading language.

so, question is: want define different qualifiers different members of single struct. possible in glsl (which webgl)? if answer no, elegant way pass it?

reference glsl es.

programming gpu through shading language not same programming cpu c, a gpu not cpu , glsl not c: keywords , constructs missing.

you should consider vertex shader function uniform values global read variables , varying values output values. fragment shader similar, varying values input values , uniform still global read variables.
so global vars not in cpu application , shader complex enough benefit oop, procedural approach still more elegant.

why want have member of structure qualified uniform , member of same structure varying?
light uniform, between values (i.e. vertex attributes) normal member of light (the direction?) interpolated?

this attempt of qualifiers use either means don't understand uniform , varying variable or don't understand struct used in programming.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -