In the fancy new versions of OpenGL (3.0 and 4.0 up), built-in vertex attributes like gl_Vertex are being deprecated. The "new way" to actually render anything is to specify your own vertex attributes for position, color, etc., and then bind these custom attributes to buffers.
My question is this: how can one do this without closely coupling the rendering code and the shader? If I write a shader that uses "position" as the vertex position, the host code using the shader has to know that and pass vertex data as "position". If I want to use a different shader that was written to take vertex data in "vertex_pos", I have to either rewrite that shader first, or modify my host code to send vertex data as "vertex_pos" instead.
Is there a set of best-practice names for standard vertex and fragment attributes that all shaders should be using? Or are there Balkanized engine-specific standards, such that a shader written for one engine cannot work on another without modification? Or are there no standards at all, such that, in general, every object needs its own custom rendering code to match its custom shader?
A Shader is a user-defined program designed to run on some stage of a graphics processor. Shaders provide the code for certain programmable stages of the rendering pipeline. They can also be used in a slightly more limited form for general, on-GPU computation.
In its modern form, OpenGL is a cross-platform library for interfacing with programmable GPUs for the purpose of rendering real-time 3d graphics. Its use is common in games, CAD, and data visualization applications.
You can have as many shader objects (shaders loaded into memory and compiled) as you want; only one can be bound (active) at a time. In terms of implementation, in every frame I use glUseProgram(1) and glUseProgram(2) to change shaders?
High-Level Shading Language (HLSL) is arguably the best language for writing shaders, as it's very well supported, separates samplers and textures (unlike GLSL), and has common language features like: namespaces. template generics.
Just keep calling them the old names. If you've got a core profile (i.e. no backwards compatibility) the reserved names of older GLSL specs are freed up declared as unavilable; redeclaring them for binding vertex attributes. Seems to change their availability attribute. In the compatibility profile those variable names are preallocated and binded.
So it boils down to this: Keeping the old naming in the shaders is a convenience and seems to work with the current GLSL compilers. If you want to go safe use the preprocessor to rewrite the gl_
prefix reserved names into an self choosen prefix and bind that one.
First, to answer your question. I am unaware of any such standard naming convention.
But... it is more complicated than attribute names. Hidden under the question is the notion of attribute semantics. Each of the input attributes have some form of semantics that each shader expects.
And what I learned from the fixed gl_ names is that they under-specify their semantics.
It's not clear that a specific nomenclature could be found that really addresses all those issues, but it would be required to make various engines compatible.
More problematic, it's not even obvious that a specific engine (or specific asset) would have the capability to provide specific attributes required by a shader coming from a different engine. What then ?
Those are all reasons why we end up with balkanized shader environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With