PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.98k stars 1.18k forks source link

usdview: opacity scale does not look correct #2777

Open hybridherbst opened 10 months ago

hybridherbst commented 10 months ago

Description of Issue

While working on some more glTF-USD-conversion topics, I noticed that usdview's output for opacity scale does not match what I would expect. Specifically, it looks like opacity scale does something but not exactly scale the opacity. My understanding would be that with opacity scale going to zero, the material becomes more and more "glass-like".

Steps to Reproduce

  1. Download OpacityScale.zip
  2. View in usdview (does not match my expectation, note the disparity between opacityScale=0 and opacityScale=0.01 and how much of the texture is still visible with 0.01) image
  3. View in Omniverse (this somewhat matches my expectation, minus Omniverse turning things into solids by default instead of thin-film) image
  4. View in iOS QuickLook (upper row is wrong – seems QuickLook doesn't support opacity scale on textures - lower row is correct) IMG_0710

Or am I understanding something wrong and scaling the opacity output of a texture works differently?

System Information (OS, Hardware)

Windows 11, RTX 3060

Package Versions

23.11

jesschimein commented 10 months ago

Filed as internal issue #USD-8901

spiffmon commented 10 months ago

@hybridherbst , UsdPreviewSurface does not support opacity scaling. Rather, there is only an opacityThreshold input. I haven't looked at your assets, so I don't know how you are translating/specifying an opacity scale (are you using UsdUVTexture's scale/bias inputs on the alpha component?)

On the assumption that is what you are doing, I do believe there has been a problem with Storm's handling of specular reflections when opacity is zero... though I thought it was only for MaterialX shading. Pinging @klucknav for more up-to-date info... I see you're testing with 23.11 which is great - thanks!

hybridherbst commented 10 months ago

Thanks @spiffmon! Yes, with opacity scaling I mean providing a UsdUVTexture scale of (1,1,1,alphaScale) on the texture that already has an alpha channel.

hybridherbst commented 8 months ago

Running into this issue again, I still think this kind of material should properly have scaled down opacity, but it doesn't in usdview:

def Material "Material_7"
    {
        def Shader "PreviewSurface"
        {
            uniform token info:id = "UsdPreviewSurface"
            color3f inputs:diffuseColor.connect = </StageRoot/Materials/Material_7/Texture_6_diffuse.outputs:rgb>
            float inputs:opacity.connect = </StageRoot/Materials/Material_7/Texture_6_diffuse.outputs:a>
            int inputs:useSpecularWorkflow = 0
            token outputs:surface
        }

        token outputs:surface.connect = </StageRoot/Materials/Material_7/PreviewSurface.outputs:surface>

        def Shader "uvReader_st"
        {
            uniform token info:id = "UsdPrimvarReader_float2"
            token inputs:varname = "st"
            float2 inputs:fallback = (0.0, 0.0)
            float2 outputs:result
        }

    def Shader "uvReader_st2"
        {
            uniform token info:id = "UsdPrimvarReader_float2"
            token inputs:varname = "st2"
            float2 inputs:fallback = (0.0, 0.0)
            float2 outputs:result
        }

    def Shader "Texture_6_diffuse"
        {
            uniform token info:id = "UsdUVTexture"
            asset inputs:file = @textures/Texture_6_ffffff_0.101960786.png@
        token inputs:sourceColorSpace = "sRGB"
            float2 inputs:st.connect = </StageRoot/Materials/Material_7/uvReader_st.outputs:result>

        float4 inputs:scale = (1, 1, 1, 0.101960786)
        token inputs:wrapS = "repeat"
        token inputs:wrapT = "repeat"
            float outputs:r
            float outputs:g
            float outputs:b
            float3 outputs:rgb
            float outputs:a
        }
    }

Example file: IgnoredOpacityScale.usdz.zip

My workaround is currently applying opacity values to the texture (massively increasing the number of textures in some edge cases).