Make it possible to declare and define common preprocessor variables, functions, and global variables for multiple shader passes
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
As of now, if a shader's multiple passes use the same global variables, functions or preprocessor variables, they need to be (re)defined for both shader passes which is redundant and prone to cause bugs. Instead I propose a more elegant and bug-resistant method such as this:
//!SHARED BEGIN
// Anything here is visible to all passes that use shared variables
// Declare and define once, and use it multiple times
#define FOO 1
const float bar = 42.0;
uint baz() {
return 42;
}
//!SHARED END
...
//!HOOK MAIN
//!BIND HOOKED
//!DESC Pass1
...
//!SHARED VARS // Insert shared variable definitions
vec4 hook() {
return vec4(bar + FOO + baz());
}
//!HOOK MAIN
//!BIND HOOKED
//!DESC Pass2
...
//!SHARED VARS // Insert shared variable definitions
vec4 hook() {
return vec4(bar + FOO + baz());
}
Could it work? Maybe by detecting the text block and injecting them into every shader pass pre-compilation? Or do you have a better idea?
Contributor guide
No contributing guide indexed for this repository
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
No file, test, or entry point is named. Start by locating the shader-pass preprocessing path, then determine how shared declarations could reach every pass without duplication; done means a documented shared block is consistently available to all intended passes and is covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100