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

unculled backfaces don't throw shadows #547

Closed
JulianGro opened this issue Aug 4, 2023 · 3 comments · Fixed by #820
Closed

unculled backfaces don't throw shadows #547

JulianGro opened this issue Aug 4, 2023 · 3 comments · Fixed by #820
Assignees

Comments

@JulianGro
Copy link
Member

When a model had backface culling disabled, that backface doesn't seem to throw a shadow.

overte-snap-by-JulianGro-on-2023-08-04_14-01-32

@HifiExperiments
Copy link
Member

I just tested this quickly with the "Material Data Creator" from the More app. it creates a cube with the material applied and you can toggle the backface culling near the bottom. all three modes seem to cast shadows correctly. also just generally I'd expect this to work. does this still reproduce? perhaps it's related to the texture with opacity specifically?

@SilverfishVR
Copy link
Contributor

I just tested this quickly with the "Material Data Creator" from the More app. it creates a cube with the material applied and you can toggle the backface culling near the bottom. all three modes seem to cast shadows correctly. also just generally I'd expect this to work. does this still reproduce? perhaps it's related to the texture with opacity specifically?

I think that is because it is a cube, so there is always a front face towards the keylight?

With a true quad (not the one from shapes, it's actually a flat cube) it only shows shadows from one side.
BackfaceShadows

Now if I add a material entity to it an set it to CULL_FRONT it is clear that the shadows do not care if front, back, or both are rendered, only if a front face is facing the keylight:
BackfaceShadows_2

Tested on 2323.11.1 with material entity and GLTF model (quad) set to double sided, same same.

@HifiExperiments
Copy link
Member

ah! ok, thank you! I see the problem:

in RenderShadowTask::build we force the state to CULL_BACK:

        auto state = std::make_shared<gpu::State>();
        state->setCullMode(gpu::State::CULL_BACK);
        state->setDepthTest(true, true, gpu::LESS_EQUAL);

        auto fadeEffect = DependencyManager::get<FadeEffect>();
        initZPassPipelines(*shapePlumber, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());

as opposed to initForwardPipelines/initDeferredPipelines which properly set up pipelines for all possible culling modes in addPlumberPipeline

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

Successfully merging a pull request may close this issue.

3 participants