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 Vector4 to VisualShader #60175

Merged
merged 1 commit into from Apr 20, 2022

Conversation

Geometror
Copy link
Member

Split from #59970, this PR adds Vector4 to VisualShader without introducing a new variant type. 'Quaternion' is used to transfer data to the shader instead of 'Plane' since its internal structure is more similar to a general Vector4 type (component names: xyzw, 4 floats instead of one normal Vector3 plus the displacement component). Still feels a bit off to use a Quaternion for that, but as #59970 requires more discussion or won't be merged at all, I think its ok for now (also, it can easily be changed).

Closes godotengine/godot-proposals#3761

Detailed changes:

  • Added new Vec4Uniform and Vec4Constant nodes
  • Added Vector4 support to all vector operation nodes
  • Implement conversion between primitive types (behavior consistent with Vector2/Vector3)
  • [While at it] Fix incorrect conversion from vec2 to int

Screenshot_20220412_153436

@Geometror Geometror requested review from a team as code owners April 12, 2022 13:58
@Geometror Geometror changed the title Add Vector4 to Visual Shader Add Vector4 to VisualShader Apr 12, 2022
@Chaosus Chaosus added this to the 4.0 milestone Apr 12, 2022
Copy link
Member

@Chaosus Chaosus left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@Chaosus Chaosus left a comment

Choose a reason for hiding this comment

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

@Geometror
Copy link
Member Author

@Chaosus I overlooked a few things, but they should be fixed now:

  • Fixed vector functions SATURATE, ONE_MINUS, RGB2HSV, HSV2RGB (made the last two invalid for Vector4, same behavior as for Vector2)
  • Fixed vector operation CROSS and REFLECT (made them invalid, since the built-in reflect function does only accept vec3, however this could be changed in another PR as reflect is defined for all dimensions in GLSL and HLSL)
  • Fixed documentation

@Chaosus
Copy link
Member

Chaosus commented Apr 12, 2022

@Geometror Hmm, I think vec4 varyings does not working correctly - check it please:

image

@Geometror
Copy link
Member Author

Missing branch in the get_port_type function used by VisualShaderNodeVaryingSetter/VisualShaderNodeVaryingGetter. Fixed now.

@Chaosus Chaosus self-requested a review April 12, 2022 17:37
Copy link
Member

@Chaosus Chaosus left a comment

Choose a reason for hiding this comment

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

Everything looks correct for me for now. Thanks for this contribution, for good and qualitative work from you as usual.

@reduz
Copy link
Member

reduz commented Apr 13, 2022

Approach looks good to me too, fantastic work!

@Chaosus Chaosus merged commit f4b0c7a into godotengine:master Apr 20, 2022
@Chaosus
Copy link
Member

Chaosus commented Apr 20, 2022

Thanks!

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

Successfully merging this pull request may close these issues.

VisualShader add Vector2 & Vector4 input/output node connections
3 participants