You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 1constfloat bar =42.0;
uint baz() {
return42;
}
//!SHARED END
...
//!HOOK MAIN//!BIND HOOKED//!DESC Pass1
...
//!SHARED VARS // Insert shared variable definitionsvec4 hook() {
returnvec4(bar + FOO + baz());
}
//!HOOK MAIN//!BIND HOOKED//!DESC Pass2
...
//!SHARED VARS // Insert shared variable definitionsvec4 hook() {
returnvec4(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?
The text was updated successfully, but these errors were encountered:
agyild
changed the title
Make it possible to declare and define common preprocessor variables, functions, and global variables for all shader passes
Make it possible to declare and define common preprocessor variables, functions, and global variables for multiple shader passes
Feb 25, 2022
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:
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?
The text was updated successfully, but these errors were encountered: