Transparency: Difference between revisions

Created page with "Notes on rendering transparency. Rendering transparent objects is generally more expensive than rendering opaque objects. Opaque objects are rendered front to back with a depth buffer write. This means fragments are calculated and written to by the front-most object. Sorting can even be ignored where performance isn't as crucial. Transparent objects must be sorted back to front and each object rendered in their entirely. ==Ignoring internal transparency== 1. Render the..."
 
 
Line 6: Line 6:


==Ignoring internal transparency==
==Ignoring internal transparency==
1. Render the object opaquely to an intermediate render texture. Then render that texture to the scene.
If you want to render a mesh as if it's opaque and apply transparency:
2. Render to a depth buffer than render with depth test as equal.
 
3. Sort the indices front to back and render with depth write and depth test.
# Render the object opaquely to an intermediate render texture. Then render that texture to the scene.
4. If the mesh is convex, render just the front triangles.
# Render to a depth buffer than render with depth test as equal.
# Sort the indices front to back and render with depth write and depth test.
# If the mesh is convex, render just the front triangles.


Resources:
Resources: