标签:culling order logs second diffuse mos code benefit power
原文:WPF 3D Transparency Depth-Order Sorting
?
Just a quick post here - When making WPF 3D apps, transparency can make for some powerful visual effects. The trouble is that any re-orientation of your scene or the camera will ruin the rendering order of your transparent content to obscure content which should be visible under a transparent surface. Below, we have a little carousel of partially transparent photos rendered on DiffuseMaterials. As per the rendering rules with DiffuseMaterials, only content which is closer to the camera will be rendered. The area highlighted in red is being rendered prematurely, which obscures the background content from being rendered at all.
To get over this issue with transparency, we must re-order the sequence of transparent content rendering, such that we progressively go from content most distant to the camera, to content in closest proximity.
To deal with this, I created a simple helper to handle sorting of models to sort in order of distance to camera. Below, we have the helper method interface - it takes the camera position, a collection of models and a World transform to offset the models by(This would be all of the accumulated parent transforms, except for the transforms on the Models themselves), and sorts?this collection of Models in order of distance to the camera. Here‘s the API from the attached Code, followed by a carousel of depth sorted images:
public static void AlphaSort(Point3D CameraPosition, Model3DCollection Models, Transform3D WorldTransform)
Some performance considerations with Depth-Order Sorting favoring transparency:
This sample is just intended as a quick starting point for folks who want to get some depth sorting on their transparent content. It is not tailored to target 3D tree-walking, and most folks can find optimizations for sorting based on domain specific assumptions about their application in terms of graph representation, caching, and all the other common tricks at an application developer‘s disposal.
WPF 3D Transparency Depth-Order Sorting
标签:culling order logs second diffuse mos code benefit power
原文地址:https://www.cnblogs.com/lonelyxmas/p/9844886.html