jMonkeyEngine / jMonkeyEngine/jmonkeyengine
Use interface blocks instead of raw varyings
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
I think it would be a good idea to begin using interface blocks rather than directly using varying/in/out variables to pass data between shader stages.
So instead of this:
out vec3 wPosition;
out vec3 wNormal;
...
wPosition = ...
We would use this:
out VERTEX_OUT {
vec3 wPosition;
vec3 wNormal;
} vsout;
...
vsout.wPosition = ...
Using interface blocks has two advantages. One is that it will make the shader code much more organized, and secondly it will also help immensely with inserting more stages between two existing ones. For example, inserting a geometry shader between PBRLighting.vert and PBRLighting.frag is difficult, if not impossible, because the names of the vertex shader output variables and fragment shader input variables necessarily conflict.
in vec3 wPosition[]; // input from vertex shader
out vec3 wPosition; // output to fragment shader
// cannot publish wPosition to the fragment shader due to name conflict
With interface blocks, this is much easier to do.
in VERTEX_OUT {
vec3 wPosition;
} gsin;
out GEOMETRY_OUT {
vec3 wPosition;
} gsout;
...
gsout.wPosition = gsin.wPosition;
A disadvantage of switching to interface blocks is that it may break compatibility with older OpenGL versions. Perhaps this could be circumvented using #ifdef or declaring seperate shader files for different OpenGL versions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PBRLighting.vert and PBRLighting.frag shaders referenced in the issue and reviewing how their varying/in/out variables are connected. Define the scope of replacing raw varyings with interface blocks, including how older OpenGL versions should remain supported; done means the affected shader stages use the new organization without losing compatibility.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100