Default blend state for transparent objects
#2
You are right - DXEngine is using pre-multiplied alpha because this provides correct results when blending transparent pixels (see internet for advantages of using pre-multiplied alpha).

When creating a PhysicallyBasedMaterial in DXEngine you cannot just set the Alpha value (there is no Alpha property as in the StandardMaterial). So you can only change alpha by updating the BaseCalor property (Color4 type). When doing that you must set the color with premultiplied alpha value otherwise you will get a color blend (as you have described). This means that red, green and blue color values must be multiplied by the alpha value. In your case (alpha = 0) you should set the BaseColor = Color4(0, 0, 0, 0). // the last parameter is alpha

I have updated the XML comment for BaseColor property by adding information that the color needs to be alpha pre-multiplied.

Also, I would recommend you to use IsVisible property to hide the object because this will skip rendering hidden objects, while setting alpha to 0 will still render the object.
Andrej Benedik
  


Messages In This Thread
RE: Default blend state for transparent objects - by abenedik - 05-27-2022, 11:29 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)