alloystorm / dvvr

A versatile character model viewer and motion player that supports a range of model and motion formats including PMX (MMD) & XNALara/XPS models, as well as VMD/BVH motion formats.
http://vrstormlab.com/
76 stars 2 forks source link

Various issues with transparent materials #361

Open AlexECX opened 2 months ago

AlexECX commented 2 months ago

Describe the bug

1. Transparent material with Alpha=1 in PMX, but isn't loaded as transparent in DanceXR

This one is not too bad to workaround, but it would be nice if it worked without tweaks.

These glasses are set to opaque in PMX while still being transparent when rendered in the editor, but are opaque in DanceXR:

image

The current workaround is to set Materials->Transparent Materials to On, manually select the glasses, and set Transparent Materials->Options->Transparent: Force Transparent.

Zip with the problematic component: zipp.zip

Screenshots of transparency in the PMX editor:

image image

2. Material that is transparent in PMX and loaded as transparent in DanceXR, but turns opaque right after loading

Similar to the previous case, except in DanceXR the texture is transparent during the loading animation, but quickly turns opaque right after. This usually happens with materials meant to be hidden/shown using a morph that either changes the opacity or in this case moves it into place. These materials often come with empty space/texture around them that should be transparent.

https://github.com/user-attachments/assets/38ae05d6-3094-4ccf-8a8d-a661ffd9e2ee

Zip with the problematic component: stockings.zip

The current workaround is the same as for the previous case, force as transparent.

3. When 2 variation of the same clothing/material refer to the same texture, one with Alpha=1 (regular underwear) and one with Alpha=0 (the hidden variation).

image image

Zip of the problematic files: dual underwear.zip

This new case has 2 problems:

https://github.com/user-attachments/assets/593e2cb6-e23d-4367-9b1f-0fb538134f27

Expected behavior The transparent part of the materials should be transparent by default

Desktop (please complete the following information):

AlexECX commented 2 months ago

RIP deleted my comment by accident, this will be shorter.

TLDR material that use the same texture but with diff parameters is the problem maybe?

In the case of #2 stockings, the texture is first referred to with no additional parameters (probably what is moved by the UV morph) and then referred to with additional parameters (probably to render only the foot fishnet):

image image

In a new case #3 I'm working with 2 variation of the same clothing/material refer to the same texture, first with Alpha=1 (regular underwear) then Alpha=0 (the hidden variation).

image image

Zip of the problematic files: dual underwear.zip

This new case has 2 problems:

https://github.com/user-attachments/assets/593e2cb6-e23d-4367-9b1f-0fb538134f27

alloystorm commented 2 months ago

Thanks for the upload we'll take a look.

For transparency, the PMX format doesn't really specify which texture is transparent, so we can only rely on the alpha value and the material name to "guess" if a material is suppose to be transparent. That's why when you set opaque to 1 it's not transparent at all. We believe MMD simply treat all materials as transparent, but we don't have that option because in unity transparent materials needs to be sorted properly to appear correct (MMD must have its own rendering technique that does some sort of auto sorting). So currently for some models you need to manually go to the material list to change their transparency mode if the model doesn't look right.

AlexECX commented 2 months ago

For transparency, the PMX format doesn't really specify which texture is transparent, so we can only rely on the alpha value and the material name to "guess" if a material is suppose to be transparent.

Yes and I think for #1 having to manually change the sunglasses to an opacity lower than 1 is fair, I'm not even sure how PMXE does it internally. For #3 tho the material is set to opaque 0, but my guess is since the texture has already been refered to by a different material that is set to opaque 1 it just sets both to opaque?

AlexECX commented 2 months ago

For #3, I tried:

  1. Inverting the order of the materials in the PMX. It did put the alternative underwear on top but still not transparent (even with opacity 0 in PMX)
  2. Deleting the standard underwear material in the PMX. The alternative underwear is still visible with opacity 0, so it seems opacity is secondary to some other parameter.

To try and make sure there is no funny business with the cache between tests, I reset settings, unload the model, empty cache, restart DanceXR, then "Load As External"

AlexECX commented 2 months ago

Updated to version 2024.9

AlexECX commented 1 day ago

Updated to 2024.11 and added case #3 to main post.