[x3d-public] does someone have a solution to multiple vertex shader files

Michalis Kamburelis michalis.kambi at gmail.com
Wed Apr 19 16:29:14 PDT 2017


2017-04-19 18:23 GMT+02:00 doug sanden <highaspirations at hotmail.com>:
> Desktop opengl may be trying to set things like gl_ModelViewMatrix, I don't know what its doing.

GLSL (OpenGL or OpenGLES) has a number of predefined gl_Xxx variables,
see https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL) .

Desktop OpenGL sets many additional gl_Xxx parameters. They are
deprecated in GLSL 1.30 (OpenGL 3.0), and actually removed in GLSL
1.40 (OpenGL 3.1). In practice, most of your desktop shaders probably
can use them anyway (regardless of your actual OpenGL version), unless
you explicitly declared a newer GLSL version at the beginning of your
shader code.

The list of deprecated gl_xxx variables is nicely documented in GLSL 1.30 spec:

https://khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.30.pdf

(search for "deprecated"). In later GLSL versions, most of these were
just removed.

> Another idea is to have a uniform called web3dprefix in each shader, which would
> somehow tell us what the prefix is, if that's possible, and then the first uniform we
 > would ask for is the web3dprefix, and then use that to get the
addresses of rest of
> the uniforms.

Standardizing on a prefix (and some attribute names) would be a good step.

But I don't think it's the ultimate solution, without limiting our
implementations. Not all X3D renderers work the same, some may not
pass some information, some may pack some attributes, in order to
deliver them more efficiently to shaders. Do you pass your light
information in prefix_LightParameters0 (with separate
prefix_LightParametersX variables for each light) or as
prefix_LightParameters[0] (with prefix_LightParameters as an array)?
Things like that would need to be standardized, and I'm not sure
whether it would be painless for all implementations:)

I don't really have a perfect answer...

1. One solution is to use X3DVertexAttributeNode to pass all the
information. This is already allowed by the specification, and will be
100% portable. Unfortunately, it's also quite uncomfortable in
non-trivial cases, as you will need to process your X3D files to
duplicate all your attributes (colors, tex coords, normals...) inside
X3DVertexAttributeNode instances.

2. My Effect nodes provide another solution. Although you can access
gl_xxx, fw_xxx variables inside, but the idea is that you should *not*
do it anymore.

  The PLUG_xxx functions should work with only the information they
receive through parameters. If they need to pass something (from
vertex to fragment shader), you can set and read your own varying
variables to do this. E.g. you can use PLUG_vertex_eye_space in the
vertex shader effects to set vertex_eye , which is then accessed by
your fragment shader effects.

Best regards,
Michalis



More information about the x3d-public mailing list