Closed hannojg closed 4 months ago
I don't know how you modified Filament for this, but it works just fine when I use twoPassesOneSide. You probably modified Filament/gltiof in the wrong spot. Here it is with an alpha of 0.5:
(note that if your object is double sided, gltfio uses twoPassesTwoSides automatically).
@romainguy I rendered it in the iOS gltf-viewer application, set doubleSided to false and transparency mode to TransparencyMode::TWO_PASSES_ONE_SIDE
. Ifi t helps I can provide a branch with a full reproduction?
It works when I do what you are doing in gltf_viewer.cpp
, make sure there's no asynchronous loading happening. BTW you don't need to set the material instance again on the renderable primitive.
Hm, I haven't modified any other code than the one shown, so I don't understand why its working in your env and not in mine (I load the resources with resourceLoader->loadResources(asset);
, so no async). If it's not asking too much do you mind trying again with this glb?
This is the one I exported from blender with alpha blend, and its not working on iOS / android for me 🤔
Using your asset, with the code changes shown below:
gltf_viewer.cpp
RenderableManager const& rcm = app.engine->getRenderableManager();
Slice<Entity> const renderables{
app.asset->getRenderableEntities(), app.asset->getRenderableEntityCount() };
for (Entity const e: renderables) {
auto ri = rcm.getInstance(e);
size_t const c = rcm.getPrimitiveCount(ri);
for (size_t i = 0; i < c; i++) {
MaterialInstance* const mi = rcm.getMaterialInstanceAt(ri, i);
mi->setDoubleSided(false);
mi->setTransparencyMode(MaterialInstance::TransparencyMode::TWO_PASSES_ONE_SIDE);
Material* ma = const_cast<Material *>(mi->getMaterial());
materials.insert(ma);
}
}
Hm, so weird, I am on the latest changes, added exactly your changes but it's still broken.
Is there any other way how I could check what's different between your and my environment?
Ah wait I am so sorry, I ran the gltf_viewer app from the wrong directory!
I was on an older commit (a few weeks old). And on the latest main it's actually working correctly 🥳 !
// Edit: Thank you so much for taking the time to test Romain Guy!
Sorry for the early excitement @romainguy when I use the ubershader its showing the coin incorrectly:
This feature is not handled by the material itself, so it doesn't matter whether it's the Uber shader or not.
Are you able to reproduce the difference on your end using the -u parameter @romainguy ?
To me it appears I get two different outputs depending on which material provider used:
Enable ubershaders | Disable ubershaders |
![Screenshot 2024-03-21 at 19 55 54](https://github.com/google/filament/assets/16821682/71f6f220-2b5a-4691-ab6a-4894b1b14b06) | ![Screenshot 2024-03-21 at 19 55 43](https://github.com/google/filament/assets/16821682/7b91a393-b24b-420e-b9ac-e61a0e59bb23) |
Describe the bug
I can see the back side / back face of an asset which uses "Alpha blend", although I configured
TransparencyMode::TWO_PASSES_ONE_SIDE
and the asset only is made out of one single mesh.To Reproduce Steps to reproduce the behavior:
coin.glb.txt
tocoin.glb
TransparencyMode::TWO_PASSES_ONE_SIDE
should fix the issue. However it doesn't for this asset, the render output stays the same.Note: I verified that the code setting
TransparencyMode::TWO_PASSES_ONE_SIDE
works, because it works for other assets. It just doesn't seem to work for this asset. I checked the normals of the asset, and they look good to me.Expected behavior A clear and concise description of what you expected to happen.
I expected the coin to show without the back face shining through (especially since alpha is set to value 1), as seen in image step (6).
Screenshots
Logs If applicable, copy full logs from your console here. Please do not use screenshots of logs, copy them as text, use gist or attach an uncompressed file.
No logs.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Also happens on iOS