Tuxer
Tuxer

Reputation: 753

same offset in a shared-type uniform buffer object in OpenGL for 4 different floats

I'm currently programming a phong spot-light shader that uses the new ogl3 feature, ubos. My buffer object in the shader is :

`

Uniform Light {
   vec3 origin; 
   vec3 color; 
   vec3 direction;
   float intensity; 
   float linear_dissipation; 
   float illu_angle; 
   float max_illu_angle;
} Light[8];

`

When I calculate the various offsets via the function

glGetActiveUniformsiv()

my program returns

origin : 0
color : 16
intensity : 48
direction : 32
illu_angle : 48
max_illu_angle : 48
linear_dissipation : 48

I can't use my intensity, illu_angle, max_illu_angle and linear_dissipation variables (well, only one of them :D ).

Upvotes: 0

Views: 329

Answers (1)

MSN
MSN

Reputation: 54594

Given that origin, color, and direction are all aligned on 16 bytes, I assume that OpenGL is combining the last four floats into a single vec4.

Did you actually try using one of them to verify that they are or are not aliased?

Upvotes: 1

Related Questions