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

External shaders saved to .gdshader files are not converted by the project upgrade tool #69597

Closed
Calinou opened this issue Dec 5, 2022 · 5 comments · Fixed by #72334
Closed

Comments

@Calinou
Copy link
Member

Calinou commented Dec 5, 2022

Godot version

4.0.beta7

System information

Fedora 36, AMD Radeon RX 6900 XT

Issue description

External shaders saved to .gdshader files are not converted by the 3to4 conversion tool. By contrast, shaders that are built-in to a scene are converted by this tool.

Both built-in and external scripts are correctly converted by 3to4.

Steps to reproduce

  • Create a Godot 3.x project with a built-in shader on a node, and an external shader on another. In both files, use syntax that will be converted, such as uniform sampler2D some_texture : hint_albedo where hint_albedo will be converted by source_color.
  • Upgrade the project using the tool in the Godot 4.0 project manager.
  • Notice how the built-in shader is updated, but not the external shader.

Minimal reproduction project

Before conversion (3.x): test_project_3.zip

After conversion (4.0): test_project_4.zip

@fracteed
Copy link

fracteed commented Dec 6, 2022

I am also getting no materials in the material slot (now surface material override), so they all have to be manually reloaded. Not sure if this has been reported or not?

@Calinou
Copy link
Member Author

Calinou commented Dec 6, 2022

I am also getting no materials in the material slot (now surface material override), so they all have to be manually reloaded. Not sure if this has been reported or not?

Please open a separate issue for this, with MRPs pre-conversion and post-conversion included.

@clayjohn clayjohn moved this from To Assess to Todo in 4.x Priority Issues Jan 26, 2023
@clayjohn
Copy link
Member

CC @qarmin How complex would it be to run the upgrader tool over .gdshader files as well?

@qarmin
Copy link
Contributor

qarmin commented Jan 26, 2023

If I remember correctly, conversions already runs on .shader files and convert them to .gdshader with some simple renames -

static const char *shaders_renames[][2] = {
{ "ALPHA_SCISSOR", "ALPHA_SCISSOR_THRESHOLD" },
{ "CAMERA_MATRIX", "INV_VIEW_MATRIX" },
{ "INV_CAMERA_MATRIX", "VIEW_MATRIX" },
{ "NORMALMAP", "NORMAL_MAP" },
{ "NORMALMAP_DEPTH", "NORMAL_MAP_DEPTH" },
{ "TRANSMISSION", "BACKLIGHT" },
{ "WORLD_MATRIX", "MODEL_MATRIX" },
{ "depth_draw_alpha_prepass", "depth_draw_opaque" },
{ "hint_albedo", "source_color" },
{ "hint_aniso", "hint_anisotropy" },
{ "hint_black", "hint_default_black" },
{ "hint_black_albedo", "hint_default_black" },
{ "hint_color", "source_color" },
{ "hint_white", "hint_default_white" },
{ nullptr, nullptr },
};

So problem is with extension .gdshader.

If this extension is valid in 3.x, then should be added to files that will be checked for conversion here -

if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj"))

@clayjohn
Copy link
Member

Looks like the .gdshader extension is allows in 3.x, so this should be a simple fix #49983

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

Successfully merging a pull request may close this issue.

4 participants