Presentation is loading. Please wait.

Presentation is loading. Please wait.

Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.

Similar presentations


Presentation on theme: "Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15."— Presentation transcript:

1 Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15

2 Today’s Lecture 1.Alpha Sorting Problems 2.Run-time Depth Sorting 3.Hard Flat Particles 4.Depth Particles 5.Soft Particles 6.Depth-Soft Particles 7.Further Possibilities

3 Alpha Sorting Problems Problem is depth buffer ignores transparency –Transparent pixels drawn in nearby polygons “obscure” distant polygons drawn later Avoid problem by drawing polygons from back to front Saw alpha blending in the second year –A very attractive blending technique However, it causes sorting issues –Without resolving these, method is not very useful

4 Run-time Depth Sorting 1 One solution is to sort all alpha blended polys in back-to-front order –Every frame (can be slow) If all polygons face camera (e.g. a particle system): –Sort polygons based on camera-space z distance –Camera space z = CP●Z C CP is vector from camera to poly, Z C is camera z-axis

5 Run-time Depth Sorting 2 Might think to sort on camera-space z again –But distance to which point on the polygon? –Nearest? –Furthest? –Average? Will any of these work? How to sort polys that face in any direction? No, a more complex approach is needed

6 Run-time Depth Sorting 3 First, assume that polygons don’t intersect Then, given two polygons, one of them will be entirely on one side of the plane of the other Identify this polygon, and see if it is on the side nearer the camera or not First step is to get a face normal for each polygon –Reverse normal if it faces away from the camera –Do this prior to sorting

7 Run-time Depth Sorting 4 Join either point of polygon 2 to each of the points of polygon 1 Calculate dot products of these vectors with normal of polygon 2: –Results all +ve: poly 1 is nearer –Results all -ve: poly 1 is further –Results mixed: poly 1 is split by plane of poly 2. So repeat test the other way round (2 nd diagram) –If split both ways, then the polygons are intersecting

8 Run-time Sorting Practicalities Must ensure this sorting is efficient as possible –Sort pointers to polygons not polygon data itself (less to sort) –Retain previous sorting and use a sort algorithm that is good with almost sorted data (e.g. insertion sort) –Don’t sort every frame, only every two or three –Run the sorting concurrently –Reduce density of particle systems based on distance –Use partitions to help: Sort partitions from back to from, then particles in one partition at a time – reducing number polygons in each sort In practice, another technique (not covered here), alpha-to-coverage is often used as an alternative

9 Hard Flat Particles Alpha blending is as useful as other blending methods once the polygons are sorted –Note: just like other blending (additive, multiplicative etc.), we need to render all the opaque polygons first However, all blending methods exhibit hard edges if they intersect other polygons –Makes dense particle systems look poor –Particularly large particles like smoke (indoors is particularly bad)

10 Depth Particles A simple improvement is to give alpha blended particles some depth –Simulated bumpiness, like normal / parallax mapping –Store it in the alpha channel of the texture Adjust the depth used for the depth-buffer by this value –Improves hard edges by making them bumpy Must hand calculate depth value in shader –Not done this before

11 Soft Particles To improve further, note that visual problems mainly occur when a particle intersects with an opaque object We know the opaque objects have already been drawn… –So they are already in depth buffer Can compare depth of particle with depth already in buffer Fade pixels out when the difference is small –Adjust alpha towards 0

12 Depth-Soft Particles This method can be combined with the depth particles idea presented earlier –Or can just be used on flat particles We must do some detailed work with depth buffer –Rather unfamiliar But almost completely removes hard edges where alpha particles intersect solid objects –Can work with other blending modes too

13 Further Possibilities The SoftParticles DirectX10 sample in the DirectX SDK takes this idea a little further –Explores volumetric particles - consider the volume of particle that camera is looking through


Download ppt "Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15."

Similar presentations


Ads by Google