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

Texture_SDF Method in Fragment Shader Not Considering Occlusion from TileMapLayer #91907

Closed
rakles opened this issue May 13, 2024 · 0 comments · Fixed by #92173
Closed

Texture_SDF Method in Fragment Shader Not Considering Occlusion from TileMapLayer #91907

rakles opened this issue May 13, 2024 · 0 comments · Fixed by #92173

Comments

@rakles
Copy link

rakles commented May 13, 2024

Tested versions

  • Reproducible in: v4.3-dev6
  • Not reproducible in v4.3-dev5, 4.2.stable

System information

Windows 11 - Godot v4.3-dev6 - Vulkan (Forward+)

Issue description

When utilizing a TileMap or the newly introduced TileMapLayer along with an Occlusion layer, it appears that the texture_sdf method in the fragment shader lacks information regarding occlusion from the tile map. Notably, while a LightOccluder2D functions as expected.

Interestingly, lighting effects generated by DirectionalLight2D and a CanvasModulate Node still properly interact with these tiles.

Attached are screenshots illustrating the discrepancy between versions:

  • v4.3-dev6: The black rectangle represents the LightOccluder2D, with tiles below it missing.
    image

  • v4.3-dev5: The black rectangle represents the LightOccluder2D, with tiles properly displayed below it.
    image

This issue persists across both the deprecated TileMap and the new TileMapLayer, contrary to expectations based on behavior in older versions.

Steps to reproduce

Create a TileMap / TileMapLayer, add a TileSet and configure it to have an Occlusion Layer.
Add some Tiles to the TileSet and configure them to have a shape on the Occlusion Layer.

Place some tiles in the Viewport.

Add a CanvasLayer Node to the Root Node and add a ColorRect as a Child to it.
Set the ColorRect to cover the Viewport.

Add a new ShaderMaterial to the ColorRect and add a new Shader to it.

Edit the Shader to color the texture_sdf in the fragment.

void fragment() {
	vec2 pos = screen_uv_to_sdf(SCREEN_UV);
	float dist = texture_sdf(pos);

	COLOR = vec4(dist,0.,0.,1.);
}

Minimal reproduction project (MRP)

v6.zip

This sample project has 2 Scenes.

V5Scene.tscn
is for the dev5 version, it uses a TileMap instead of TileMapLayer else it would be impossible to be opened by dev 5

V6Scene.tscn
is almost the same as V5Scene.tscn but uses a TileMapLayer

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