1

My fragment shader contains the following struct variable.

struct Material
{
    vec3 ambient;
    vec3 diffuse;
    vec3 specular;
    float shininess;
};

uniform Material material;
// another uniform
uniform float tmp;

In vispy on using

self.program['material.ambient'] = [1,1,1]
self.program['material.diffuse'] = [1,0.7,1]
self.program['material.specular'] = [0.5,1,1]
self.program['material.shininess'] = 32
self.program['tmp'] = 10

I am getting following errors

WARNING: Value provided for 'material.diffuse', but this variable was not found in the shader program.
WARNING: Value provided for 'material.ambient', but this variable was not found in the shader program.
WARNING: Value provided for 'material.specular', but this variable was not found in the shader program.
WARNING: Value provided for 'material.shininess', but this variable was not found in the shader program.
INFO: Program has unset variables: { 'material.specular', 'material.shininess', 'material.diffuse', 'material.ambient'}

I am using the correct shader program and have linked the right fragment shader. I think vispy dont supports struct types yet, is there any work around by which I can pass these values ?

  • Are you sure those uniforms are actually _active_ in your shader, i.e. do the really affect the output? – derhass Jul 13 '20 at 15:57
  • yes they are active, actually structs are not yet supported in vispy so I had to use the open gl backend to set them up. thanks – Tushar Gupta Jul 14 '20 at 18:11
  • @TusharGupta Did you completely add the functionality to the GL backends to support this? Were you able to make a pull request for it (sorry if I missed it)? – djhoese Sep 30 '20 at 13:54
  • @djhoese Actually instead of structs, I worked my way around with arrays. If there is a struct with members like light, diffusion, opacity. I used arrays like light[100], opacity[100] .. and then referenced them through the index. – Tushar Gupta Sep 30 '20 at 15:58
  • Sounds good. Maybe in the future it will be easier for vispy to support this. If I remember correctly it would take some rewriting of the shader parsing. – djhoese Sep 30 '20 at 19:07

0 Answers0