Skip to content

Conversation

@radair6000
Copy link

Updated the code to work on Godot 4.1. Fixes #10
The WAT unit tests were removed as WAT is not available on Godot 4.
Example scenes have been upgraded.

@radair6000 radair6000 marked this pull request as ready for review August 10, 2023 07:58
@Arnklit
Copy link
Owner

Arnklit commented Aug 21, 2023

@radair6000 just wanted to let you know I will be looking this over and merging it as soon as I can. I really appreciate you doing this. I just have to deal with a work deadline and family vacation first.

@radair6000
Copy link
Author

radair6000 commented Aug 22, 2023 via email

@Arnklit Arnklit self-assigned this Oct 1, 2023
@Arnklit
Copy link
Owner

Arnklit commented Oct 1, 2023

Removed the gradient inspector. It was causing me issues as well and I can't be bothered to track it down right now. I also enabled anisotropic texture filtering in the shader as that is no longer done on the texture import in 4.x.

Unfortunately there is another issue in 4.x that we have to track down before this is useful. Skinned meshes currently don't work correctly. it appears the normals used for extruding the hair are incorrect when animating the mesh. I'll try and dig into the code when I can and find the reason. If you @radair6000 have time or interest you can have a look as well.

image

@radair6000
Copy link
Author

Hi again, sorry for the long delay, I have not had time to look at this before now.
I did look at this today, but was not able to fix it.
I think I have eliminated the shader as I reduced it to its bare minimum and the problem still exists.
My only guess is that it is somewhere in fur_helper_methods.generate_mesh_shells (or perhaps generate_combined) as Meshinstance has some changes between 4 and 3.5, but I have not been able to figure it out.

Sorry :(

@Arnklit
Copy link
Owner

Arnklit commented Nov 8, 2023

@radair6000 no worries. Thanks for having a look as well. Yeah I could sort of tell it would not be an easy fix. The proper solution might be to make a compute shader to roll my own skinned mesh. That would be much more efficient and would allow for blend shapes to work.

I'll try and see if there is some other workaround though as the compute shader is definitely a major piece of work.

@Calinou
Copy link

Calinou commented Oct 31, 2025

I gave this PR a try on 4.6.dev2 out of curiosity. The base functionality still works, but test_suite.tscn is missing all fur.

image

There's an existing issue I noticed while testing this PR, as well as a future improvement made possible in Godot 4:

  • The jiggle effect is calculated on the physics step, which makes it look jittery at low physics steps (or on high refresh rate monitors). The weight also depends on physics tick rate, with lower values appearing to have a stronger weight effect. You probably need to use exponential decay to fix this, i.e. turn lerp(speed, 0.0, delta) into lerp(speed, 0.0, 1.0 - exp(-delta)).

Example at 20 physics ticks per second in the Project Settings (remember to restart the editor after changing the value):

20_tps.webm

240 physics ticks per second:

240_tps.webm
  • Alpha to coverage can be made functional by adding alpha_to_coverage to the list of render modes in both shell_fur.gdshader and shell_fur_mobile.gdshader. Additionally, set ALPHA_ANTIALIASING_EDGE = 0.0; just below ALPHA_SCISSOR_THRESHOLD. This provides high-quality antialiasing for alpha scissor transparency (works best when MSAA is enabled; quality depends on the MSAA level).
No alpha to coverage, 8× MSAA Alpha to coverage, no MSAA1 Alpha to coverage, 8× MSAA
Screenshot_20251031_200455 Screenshot_20251031_200517 Screenshot_20251031_200503

(All images zoomed in 2× with nearest-neighbor filtering for better clarity.)

  • Adding the cull_disabled render mode to both shaders makes the fur appearance a bit fuller, especially when viewed from an angle:
Backface culling No backface culling
Screenshot_20251031_201859 Screenshot_20251031_201908

Footnotes

  1. This adds a checkerboard pattern that helps a little, especially if using screen-space AA.

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.

Please. Port it on 4.0

3 participants