Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VertexColorMaterial transparency not blending properly
#1
When an alpha value is applied to colors in SharpEngine's standard VertexColorMaterial it seems to blend wrongly. 

You can see this for yourself by adjusting line 346 in Ab4d.SharpEngine.Samples.Common/Advanced/MultiSceneNodeExample.cs

Is there an option I'm missing to change the blend mode?
#2
Hm, the MultiSceneNodeSample shows that using alpha values smaller than one work correctly. See screenshot:

   

The marked box is created in line 396 (all the colors have alpha value set to 0.3 a few lines above).
The screenshot shows that the objects correctly visible through this box.

Also, is the alpha value in line 364 is changed, this also works correctly.


The blending mode (AlphaBlend or Opaque) and the RenderingLayer (transparent objects are put to Transparent RenderingLayer so they are rendered after all other objects and are also sorted by their distance to the camera) are controlled by the VertexColorMaterial.HasTransparency property.

When the VertexColorMaterial is created by passing an array of colors to the constructor, then the value of  HasTransparency property is automatically calculated by checking individual colors (for alpha < 1). To prevent this check (improve performance) you can also use constructor that also takes hasTransparency parameter.

You can also manually change the value of HasTransparency property.

If you first initialize the VertexColorMaterial with only opaque colors (alpha == 1) and later change the alpha values, then you need to call UpdatePositionColors method for the changes to take effect. If you have not manually set the HasTransparency, then the colors are checked again for any transparent color and  HasTransparency property value is updated.


Anyway, if you have a case when this does not work correctly, please provide some additional information on how to reproduce that and what is expected.
Andrej Benedik
#3
Apologies for the bad example. Here is a better one (see attached zip). This example demonstrates something wrong with the blending of vertex colours. After running the demo, see lines 79-87 in MainWindow.axaml.cs

The problem seems to occur when the vertex colour alpha is less than one and the rgb values are not black.

   

   

Also in the screenshot you attached in your previous post, half of the circle is missing behind the rectangle. This is an instance of the transparency sorting issues which we emailed you about.

Good luck tracking down these bugs and keep up the great work!


Attached Files
.zip   sharpEngineDemo.zip (Size: 96.94 KB / Downloads: 1)
  


Forum Jump:


Users browsing this thread:
abenedik, 1 Guest(s)