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

Add preprocessor to paths #10275

Open
BastiaanOlij opened this issue Jul 25, 2024 · 2 comments
Open

Add preprocessor to paths #10275

BastiaanOlij opened this issue Jul 25, 2024 · 2 comments

Comments

@BastiaanOlij
Copy link

BastiaanOlij commented Jul 25, 2024

Describe the project you are working on

VR application exported to both stand alone headsets (Android, Mobile renderer) and desktop (PC, Forward+ renderer)

Describe the problem or limitation you are having in your project

I want to set up shaders and materials differently depending on the renderer or platform I'm exporting too without needing code that changes them when the wrong versions have already been compiled on scene loading.

Especially with the new custom shader templates this will become even more of a problem if you wish to target multiple platforms/renderers.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The solution I'm thinking off is adding a preprocessor to paths. We already parse res:// and user:// etc. We could easily extend this logic to parse additional markers.

For instance we could have a path like res://%rendering_method%/textured.gdshader that would be parsed to res://forward_clustered/textured.gdshader.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

We create a static registry where different parts of Godot can register keywords. For instance for the above example to work we would do:

void SceneShaderForwardClustered::init(const String p_defines) {
	DirAccess::register_path_keyword('rendering_method`, `forward_clustered`)

or potentially this code could be in Main::setup and react to a number of keywords we set there (rendering_method, platform, etc.)

In our DirAccess and FileAccess classes we add a parse function for the path that we call at the start of functions like FileAccess::open.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This requires core changes

Is there a reason why this should be core and not an add-on in the asset library?

This requires core changes

@Calinou
Copy link
Member

Calinou commented Jul 25, 2024

I would prefer reusing the remap system as it doesn't see much use currently.

@BastiaanOlij
Copy link
Author

I would prefer reusing the remap system as it doesn't see much use currently.

Yes I would agree, when I wrote this I wasn't aware we had that system but it seems much better suited.

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

No branches or pull requests

2 participants