Transparency order problem on png textures
#2
You have found two issue with TransparencySorter:

1) Objects that have bounding box with one component equal to 0 (for example SizeY == 0) are not sorted by camera distance.

2) Materials with ImageBrush are not considered as transparent materials. Currently transparent materials are only materials that have SolidColorBrush with alpha color less than 255 or Material that have Brushes with Opacity < 1.


I will improve that in the next version of Ab3d.PowerToys.

Though I am not yet sure how to know if BitmapImage have some transparent pixels - but I will probably consider all BitmapImages with Bgra32 format as transparent. I will also provide a property that will allow disabling that.

I also plan to further allow customizing the TransparencySorter with changing some methods to be virtual. Also it will be possible to sort a list of 3D models.


But you do not need to wait for a new version. To make the current version (7.6) of TransparencySorter work, you can apply the following two workarounds:

1) Change the Normal of the PlaneVisual3D from default value (0,1,0) to something like Normal="0.0001 0.9999 0" - this will just slightly increase the SizeY value of the bounds so that the object will not be rejected.

2) Set Opacity on ImageBrush to a value lower than 1 - for example to 0.99.

The later will require to use the standard WPF way to define DiffuseMaterial in XAML (instead of using a MaterialConverter that comes with Ab3d.PowerToys). So instead of:

Material="http://www.freeiconspng.com/uploads/bubble-png-9.png"

You will need to define the material like so - I defined it only once in Page.Resources:
Code:
<Page.Resources>
    <DiffuseMaterial x:Key="TransparentMaterial">
        <DiffuseMaterial.Brush>
            <ImageBrush Opacity="0.99">
                <ImageBrush.ImageSource>
                    <BitmapImage UriSource="http://www.freeiconspng.com/uploads/bubble-png-9.png"></BitmapImage>
                </ImageBrush.ImageSource>
            </ImageBrush>
        </DiffuseMaterial.Brush>
    </DiffuseMaterial>
</Page.Resources>

Then the material can be used as:
<visuals:PlaneVisual3D Normal="0.0001 0.9999 0" Material="{StaticResource TransparentMaterial}" BackMaterial="{StaticResource TransparentMaterial}" Size="50 50" CenterPosition="0 40 0"></visuals:PlaneVisual3D>

Note that I have also set the BackMaterial to the same material - this is usually best when showing transparent objects.


After that changes the TransparencySorter will correctly sort the objects.
Andrej Benedik
  


Messages In This Thread
RE: Transparency order problem on png textures - by abenedik - 09-19-2016, 12:31 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)