Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: rename with prefix or suffix #313

Open
fy0 opened this issue Jul 25, 2023 · 2 comments
Open

feature request: rename with prefix or suffix #313

fy0 opened this issue Jul 25, 2023 · 2 comments

Comments

@fy0
Copy link

fy0 commented Jul 25, 2023

Sometimes, we use include to insert shader fragments, and when processing these fragment files separately, duplicate naming may occur.
We hope to add a unified prefix or suffix to avoid this situation

@laurentlb
Copy link
Owner

I'm not sure how that would work. Do you have collisions with the function names, or with other symbols (e.g. uniforms)?

If it's with function names, how would you call the functions, if they are renamed?

I don't fully understand your use-case, but maybe:

  • you can run Shader Minifier after the processing
  • or you can run Shader Minifier and disable function renaming

@fy0
Copy link
Author

fy0 commented Jul 26, 2023

For example, there are two shader files for include:

// frag_1.glsl
float func1() { return 1.5; }
float calc1() { return func1() * 1.5; }
// frag_2.glsl
float func2() { return 2.0; }
float calc2() { return func2() * 1.5; }

In final fragment shader:

// frag_pbr.glsl
#include <frag_1>
#include <frag_2>

...

The #include can be understood as glsl's syntax, or just replace keyword in string.

When i use Shader Minifier on frag_1 and frag_2, function or vars names will be duplicated:

./shader_minifier.exe --format text --preserve-externals frag_1.glsl -o f1.glsl --no-remove-unused --no-inlining --no-renaming-list calc2,calc1
./shader_minifier.exe --format text --preserve-externals frag_2.glsl -o f2.glsl --no-remove-unused --no-inlining --no-renaming-list calc2,calc1

float c(){return 1.5;}float calc1(){return c()*1.5;}
float c(){return 2.;}float calc2(){return c()*1.5;}

It will be work if add a prefix:

float f1_c(){return 1.5;}float calc1(){return f1_c()*1.5;}
float f2_c(){return 2.;}float calc2(){return f2_c()*1.5;}

It's my case. If there's anything I said unclearly, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants