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

Proximity Fade broken in Compatibility (OpenGL) #89942

Open
lijon opened this issue Mar 27, 2024 · 1 comment · May be fixed by #100220
Open

Proximity Fade broken in Compatibility (OpenGL) #89942

lijon opened this issue Mar 27, 2024 · 1 comment · May be fixed by #100220

Comments

@lijon
Copy link

lijon commented Mar 27, 2024

Tested versions

System information

Godot v4.3.dev5 - macOS 13.6.0 - GLES3 (Compatibility) - Apple M1 Pro - Apple M1 Pro (8 Threads)

Issue description

The Proximity Fade in StandardMaterial3D does not work with Compatibility renderer. The produced code assumes Vulkan Z range 0.0 to 1.0 instead of OpenGL -1.0 to 1.0. The fix is to remap the depth_tex as follows:

// Proximity Fade: Enabled
	float depth_tex = textureLod(depth_texture, SCREEN_UV, 0.0).r;
        depth_tex = depth_tex * 2.0 - 1.0; // <-- For OpenGL
	vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex, 1.0);
	world_pos.xyz /= world_pos.w;
	ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0);

Steps to reproduce

  • Use Compatibility renderer.
  • Add a cube on a plane, or two intersecting cubes, etc.
  • Apply a new standardMaterial3D and enable Proximity Fade.

Minimal reproduction project (MRP)

N/A

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