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

Godot 4.0 support #15

Merged
merged 2 commits into from
Mar 18, 2023
Merged

Godot 4.0 support #15

merged 2 commits into from
Mar 18, 2023

Conversation

thomasgauthier
Copy link
Contributor

@thomasgauthier thomasgauthier commented Mar 9, 2023

Global changes

  • removed type annotations in scripts as it was causing compilation errors
  • changed VisualShaderNode.PORT_TYPE_VECTOR references to VisualShaderNode.PORT_TYPE_VECTOR_3D

Specific changes

addons/shaderV/tools/random/randomGoldNoiseFloat.gdshader

  • removed PI definition as it is now built-in

addons/shaderV/rgba/bloom.gd
addons/shaderV/tools/random/randomGoldNoiseFloat.gd

  • added a semicolon in the generated code

addons/shaderV/rgba/generate_shapes/scanLinesSharp.gd addons/shaderV/rgba/generate_shapes/stripesRandom.gd

  • added cast to float in generated code

addons/shaderV/uv/animated/tilingNoffsetAnimated.gd

  • changed += to = in generated code

Visual shaders

Sobel Edge

  • connected new white constant to output

Color Correction Adjustment

  • added gradient as parameter

Hash Random Vector 2D and Vector2 Compose

  • added VectorDecompose and VectorCompose to preserve blue value of 1 that was the default in 3.x

@thomasgauthier thomasgauthier mentioned this pull request Mar 9, 2023
# Global changes

- removed type annotations in scripts
- changed `VisualShaderNode.PORT_TYPE_VECTOR` references to `VisualShaderNode.PORT_TYPE_VECTOR_3D`

# Specific changes

`addons/shaderV/tools/random/randomGoldNoiseFloat.gdshader`
- removed PI definition as it is now built-in

`addons/shaderV/rgba/bloom.gd`
`addons/shaderV/tools/random/randomGoldNoiseFloat.gd`

- added a semicolon in the generated code

`addons/shaderV/rgba/generate_shapes/scanLinesSharp.gd`
`addons/shaderV/rgba/generate_shapes/stripesRandom.gd`

- added cast to float in generated code

`addons/shaderV/uv/animated/tilingNoffsetAnimated.gd`

- changed `+=` to `=` in generated code

# Visual shaders

## Sobel Edge
- connected new white constant to output

## Color Correction Adjustment
- added gradient as parameter

## Hash Random Vector 2D and Vector2 Compose
- added VectorDecompose and VectorCompose to preserve blue value of 1 that was the default in 3.x
@Ludmuterol
Copy link

Thank you for this! saved me some work though i had another problem. I tried using worley3d with the default values:

  151 | void fragment() {
  152 |  float n_out12p0;
  153 |  float n_out12p1;
  154 | 
  155 |  vec3 n_in12p1 = vec3(0.00000, 0.00000, 0.00000);
  156 |  int n_in12p2 = 5;
  157 |  int n_in12p3 = 1;
  158 |  int n_in12p4 = 0;
  159 |  {
E 160->  vec2 n_out12p0n_out12p1 = _cellular3dNoiseFunc(vec3((UV.xy+n_in12p1.xy)*n_in12p2, n_in12p4), min(max(n_in12p3, 0.0), 1.0));
  161 |  n_out12p0 = n_out12p0n_out12p1.x;
  162 |  n_out12p1 = n_out12p0n_out12p1.y;
  163 |  }
  164 | 
  165 | 
  166 |  COLOR.rgb = vec3(n_out12p0);
  167 | }
  168 | 
  :160 - Invalid arguments to operator '*': 'vec2, int'.
  Shader compilation failed.

I could stop the error from appearing by changing the init func default values to floats.:

func _init():
	set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0))
	set_input_port_default_value(2, 5.0)
	set_input_port_default_value(3, 1.0)
	set_input_port_default_value(4, 0.0)

looking through the other files it seemed like a random choosing between floats and ints as defaults. Is there a reason someone would want to choose an int as a defaultvalue for a VisualShaderNode.PORT_TYPE_SCALAR? or is it just something i happen to be the first one to notice?

@arkology
Copy link
Owner

@thomasgauthier thanks a lot!
Could you please check error @Ludmuterol mentioned? Maybe it will be better to change every default port to float which supposed to be float. I didn't face this problem before so didn't care about this - maybe in 4.0 something was changed in Godot.
Could you also check if it is possible to change .gdshader to .gdshaderinc and change global code section to inclusion of .gdshaderinc file? But if it will break something or take a lot of time I think it could be left as it is now.

@thomasgauthier
Copy link
Contributor Author

thomasgauthier commented Mar 10, 2023

I also had problems with scalar input being treated as ints instead of floats. Changing all relevant inputs to floats explicitly like @Ludmuterol described probably would fix it. I can try this.

@arkology I can do the .gdshaderinc change over the weeked. I'll post updates here.

@thomasgauthier
Copy link
Contributor Author

Just got to this now. 6f5cabf has the .gdshaderinc change and the float problem fixed

@arkology
Copy link
Owner

@thomasgauthier thanks! I'll test it at the weekend and merge into master

Copy link
Owner

@arkology arkology left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly ran through the changes and overall everything looks great! If something is wrong, it can be fixed later, but right now I think it's ready for merge🎉

@arkology arkology merged commit 2e223ad into arkology:master Mar 18, 2023
@arkology
Copy link
Owner

Thanks!

@arkology arkology linked an issue Mar 18, 2023 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Godot 4.0 support
3 participants