Talk:Uniform (GLSL)

From OpenGL Wiki
Revision as of 15:00, 16 April 2021 by Alfonse (talk | contribs) (→‎Missing definitions for Uniform binders)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Regarding the explanation of the layout on uniform variables created from a structure it seems there is a small mistake on the layout value for the second example, shouldn't it be 7 instead of 2 for manyStructs[0].thirdField ? (0*3 [array] + 2 [struct offset] + 5 [base location]) Here is the corresponding part of the page :

struct MyStruct
  vec2 firstField;
  vec4 secondField;
  mat2 thirdField;

layout(location = 5) uniform MyStruct manyStructs[3];

"manyStructs[0].firstField" will have the location 5. "manyStructs[0].thirdField will have the location 2. "manyStructs[2].secondField" will have the location (2*3 [array] + 1 [struct offset] + 5 [base location]), or 12. And so forth.

In general, when you see small errors like this, you should just edit the page and fix it. It'd probably have taken less time for you to correct than it took to write this. That's why anyone can edit Wiki pages, after all. Alfonse (talk) 05:44, 29 August 2012 (PDT)

Moreover, I've tried to identify the uniform ID from a layout I've created and it seems the members are sorted alphabetically while creating the ID for binding ... what about this ? Should we sort the data in our struct in order to use the previous formula : index*(number of members in struct) + offset + baseLocation

The description given is only true for uniforms that have been given an explicit location. When OpenGL manually assigns a location, it's up to the implementation. And if you're seeing this sorting behavior with explicit assignment, then contact NVIDIA (because they're the only ones thus far who have implemented it) and tell them it's a bug. The best place to do that is in the Drivers sub-forum of the OpenGL forums. Alfonse (talk) 05:44, 29 August 2012 (PDT)

Missing definitions for Uniform binders

There is a reference of the uniforms available since OpenGL4 here: But despite that, it lacks double precision uniform values for matrices such as glUniformMatrix4dv.

That is a problem for us, because we're using double precision transform matrices in our software, and the uniform binding code is generated directly from the reference page.

Any insight? Is there a way to update the reference to include new members?

This is not a problem that the OpenGL Wiki can solve. You're looking for the Khronos GitHub repo for the reference pages. Also, I really wouldn't use a tool that automatically generates anything based on what is in those pages. It would be much better to go to the actual specification .xml files found in the Khronos OpenGL registry page. Alfonse (talk) 14:59, 16 April 2021 (UTC)