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

Vulkan: Depth prepass does not respect cull mode #50124

Closed
Tracked by #56333
GiantBlargg opened this issue Jul 3, 2021 · 3 comments · Fixed by #60214
Closed
Tracked by #56333

Vulkan: Depth prepass does not respect cull mode #50124

GiantBlargg opened this issue Jul 3, 2021 · 3 comments · Fixed by #60214

Comments

@GiantBlargg
Copy link
Contributor

GiantBlargg commented Jul 3, 2021

Godot version

4.0.dev (c1320aa)

System information

Arch Linux, Vulkan, AMD RX 5500 XT (mesa 21.1.3)

Issue description

The depth pre pass always seems to render with backface culling, instead of the culling mode set by the shader. This is visually obvious with frontface culling, but it probably has performance impacts for disabled culling as well.
Screenshot_20210703_061352
Expected (3.3.2):
Screenshot_20210703_220630

Steps to reproduce

Create an opaque material with Cull Mode set to "Front"

Minimal reproduction project

Culling.zip

@Calinou Calinou added this to the 4.0 milestone Jul 3, 2021
@Calinou Calinou changed the title Depth prepass does not respect cull mode Vulkan: Depth prepass does not respect cull mode Jul 3, 2021
@Calinou
Copy link
Member

Calinou commented Jul 3, 2021

@GiantBlargg Can you reproduce this in 3.3.2?

@GiantBlargg
Copy link
Contributor Author

GiantBlargg commented Jul 3, 2021

@Calinou No. This issue is not present in 3.3.2

@GiantBlargg
Copy link
Contributor Author

GiantBlargg commented Jul 4, 2021

The cause seems to be that the shadow material is used for depth pre-pass. In many cases the shadow material is set to the default material which is backface culled.

SceneShaderForwardClustered::MaterialData *material_shadow = nullptr;
void *surface_shadow = nullptr;
if (!p_material->shader_data->uses_particle_trails && !p_material->shader_data->writes_modelview_or_projection && !p_material->shader_data->uses_vertex && !p_material->shader_data->uses_discard && !p_material->shader_data->uses_depth_pre_pass) {
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SHARED_SHADOW_MATERIAL;
material_shadow = (SceneShaderForwardClustered::MaterialData *)storage->material_get_data(scene_shader.default_material, RendererStorageRD::SHADER_TYPE_3D);
RID shadow_mesh = storage->mesh_get_shadow_mesh(p_mesh);
if (shadow_mesh.is_valid()) {
surface_shadow = storage->mesh_get_surface(shadow_mesh, p_surface);
}
} else {
material_shadow = p_material;
}

sdcache->shader_shadow = material_shadow->shader_data;

if (shadow_pass || p_params->pass_mode == PASS_MODE_DEPTH) { //regular depth pass can use these too
material_uniform_set = surf->material_uniform_set_shadow;
shader = surf->shader_shadow;
mesh_surface = surf->surface_shadow;

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.

2 participants