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

[4.0 beta11] GeometryInstance3D transparency parameter hide mesh with value over 0.0 #71249

Closed
jmb462 opened this issue Jan 11, 2023 · 5 comments · Fixed by #71124
Closed

[4.0 beta11] GeometryInstance3D transparency parameter hide mesh with value over 0.0 #71249

jmb462 opened this issue Jan 11, 2023 · 5 comments · Fixed by #71124

Comments

@jmb462
Copy link
Contributor

jmb462 commented Jan 11, 2023

Godot version

4.0 beta 11

System information

Windows10

Issue description

When setting GeometryInstance3D transparency parameter to a value higher than zero, mesh do not appear anymore if material transparency is not enabled.

Worked fine in beta10 even if material was not set to transparent.

Not sure if it's a regression or a bug fix...

Steps to reproduce

  1. Add a MeshInstance3D with a Box shape
  2. Change the transparency setting in GeometryInstance3D

Mesh disappears.

Beta 11 :

transp_bug

Beta 10 :

transp_bugb10

Minimal reproduction project

transparency_bug.zip

@clayjohn
Copy link
Member

I noticed this as well. There is already a PR fixing it that just needs to be merged #71124

@fracteed
Copy link

fracteed commented May 6, 2023

@clayjohn I am not sure if this feature is intended to work on the mobile and opengl renderers or not? Can be hard to find this sort of info, and I didn't want to open up a new issue if it is a known limitation.

@clayjohn
Copy link
Member

clayjohn commented May 6, 2023

@fracteed it should work on all rendering backends

@fracteed
Copy link

fracteed commented May 6, 2023

@clayjohn I have tried it on a few pc's and it only works in 4.0.2 on the forward+ renderer. Do you want me to open up another issue?

@clayjohn
Copy link
Member

clayjohn commented May 6, 2023

@clayjohn I have tried it on a few pc's and it only works in 4.0.2 on the forward+ renderer. Do you want me to open up another issue?

Yes please. I took a quick look and it looks like it just hasn't been implemented. It would be nice to have an issue to track it. It should not be a lot of work to implement as the implementation can be copied directly from the clustered renderer.

Code for reference

float fade_alpha = 1.0;
if (inst->fade_near || inst->fade_far) {
float fade_dist = inst->transform.origin.distance_to(p_render_data->scene_data->cam_transform.origin);
// Use `smoothstep()` to make opacity changes more gradual and less noticeable to the player.
if (inst->fade_far && fade_dist > inst->fade_far_begin) {
fade_alpha = Math::smoothstep(0.0f, 1.0f, 1.0f - (fade_dist - inst->fade_far_begin) / (inst->fade_far_end - inst->fade_far_begin));
} else if (inst->fade_near && fade_dist < inst->fade_near_end) {
fade_alpha = Math::smoothstep(0.0f, 1.0f, (fade_dist - inst->fade_near_begin) / (inst->fade_near_end - inst->fade_near_begin));
}
}
fade_alpha *= inst->force_alpha * inst->parent_fade_alpha;
flags = (flags & ~INSTANCE_DATA_FLAGS_FADE_MASK) | (uint32_t(fade_alpha * 255.0) << INSTANCE_DATA_FLAGS_FADE_SHIFT);

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

Successfully merging a pull request may close this issue.

3 participants