CesiumGS / cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
https://cesium.com/platform/cesium-for-unreal/
Apache License 2.0
916 stars 292 forks source link

DitherFade material layer breaks glTF alphaMask rendering #1311

Closed stephLVCim closed 8 months ago

stephLVCim commented 9 months ago

Hello,

I have some glb objects with alphaMode set to "MASK" using png with alpha channel texture, but the texture appear totally opaque in the rendering in Unreal Editor:

image

I tried to change alpha cutoff but without more success.

is alphamode "MASK" supported with 3D tiles 1.1 ?

thanks.

kring commented 9 months ago

It's supposed to be supported, but I think you're correct that it's not working. One problem is that Unreal seemingly doesn't allow us to change the "cutoff" value at runtime. But that aside, it seems like even the default cutoff of 0.5 isn't working. I don't know why, though. If you dig into the materials and can identify the problem, please let us know. Otherwise, we will investigate when we get a chance.

stephLVCim commented 9 months ago

Thanks for your answer,

I think the problem is that the alpha channel of the BaseColor texture needs to be linked to the "Opacity Mask" slot of the material : https://docs.unrealengine.com/5.3/en-US/material-blend-modes-in-unreal-engine/#masked

but I don't see how to do this in code.

Found this : https://forums.unrealengine.com/t/how-to-hook-up-alpha-channel-of-a-texture-in-c/453636 but did not manage to apply it in the cesium-unreal code (and it's perhaps some editor only code ? not runtime).

kring commented 9 months ago

The BaseColor is correctly linked to the Opacity Mask in your default materials. The problem is the DitherFade layer in our default materials. The MLB_DitherFade replaces the opacity mask with the one from the dither. It should multiply instead.

image

As a workaround, you can open MLB_DitherFade included in the Cesium for Unreal plugin and made the changes in the Blueprint above. Or you can open MI_CesiumThreeOverlaysAndClipping and remove the DitherFade layer entirely.

stephLVCim commented 9 months ago

Thanks Kevin,

 modifying the MLB_DitherFade works fine.

 Do you plan to merge this directly in the repository ?

     Stéphane

De : Kevin Ring @.> Envoyé : dimanche 10 décembre 2023 22:39 À : CesiumGS/cesium-unreal @.> Cc : Stéphane Capo @.>; Author @.> Objet : Re: [CesiumGS/cesium-unreal] gltf objects with alphaMode MASK and transparent png (Issue #1311)

The BaseColor is correctly linked to the Opacity Mask in your default materials. The problem is the DitherFade layer in our default materials. The MLB_DitherFade replaces the opacity mask with the one from the dither. It should multiply instead. image.png (view on web)https://github.com/CesiumGS/cesium-unreal/assets/924374/9ef47a43-87a9-4281-a939-7d11bd043d20

As a workaround, you can open MLB_DitherFade included in the Cesium for Unreal plugin and made the changes in the Blueprint above. Or you can open MI_CesiumThreeOverlaysAndClipping and remove the DitherFade layer entirely.

— Reply to this email directly, view it on GitHubhttps://github.com/CesiumGS/cesium-unreal/issues/1311#issuecomment-1849093289, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5Z336PHTVL2NML4RZG3QQDYIYTZBAVCNFSM6AAAAAA77HP7GSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGA4TGMRYHE. You are receiving this because you authored the thread.

kring commented 8 months ago

Yeah, we'd welcome a pull request with that change if you're up for it! It's essential that you use UE 5.1 to edit materials, though, or else they won't be loadable in our minimum supported version.