|
1 | | -== Implementing Transparency in Shadows |
| 1 | += Implementing Transparency in Shadows |
2 | 2 |
|
3 | 3 | *Objective*: Add support for transparent objects in the scene. We will implement a simple alpha test to discard fragments with low alpha values, and replicate this in their corresponding ray traced shadows. |
4 | 4 |
|
5 | 5 | So far we have treated every geometry as opaque. Note however that the leaves are rendered with a texture that uses the alpha channel to define transparency, and currently that is not taken into account, so that we have some dark pixels around the edges of the leaves: |
6 | 6 |
|
7 | 7 | image::../../../images/38_TASK08_alphacut_before.png[] |
8 | 8 |
|
9 | | -=== Task 7: Alpha-cut transparency |
| 9 | +== Task 7: Alpha-cut transparency |
10 | 10 |
|
11 | 11 | To implement alpha-cut transparency, we will discard fragments with low alpha values in the fragment shader. This is a common technique to handle transparent textures without needing complex blending or sorting: |
12 | 12 |
|
@@ -43,7 +43,7 @@ You will see that the shadows for the leaves are now completely missing! This is |
43 | 43 |
|
44 | 44 | Before we do that, let's first inspect the acceleration structures we have built so far, to understand how they are structured and what information is available for each triangle. |
45 | 45 |
|
46 | | -=== Task 8: Inspect the acceleration structures with NVIDIA Nsight Graphics |
| 46 | +== Task 8: Inspect the acceleration structures with NVIDIA Nsight Graphics |
47 | 47 |
|
48 | 48 | RenderDoc does not yet support inspecting Vulkan acceleration structures, but we can use *Nsight Graphics* to verify that our BLAS/TLAS are built correctly. This helps catch mistakes (e.g. wrong geometry counts, offsets) before we rely on them in shaders. |
49 | 49 |
|
@@ -79,7 +79,7 @@ In the new window, you can see the TLAS and its instances: |
79 | 79 |
|
80 | 80 | image::../../../images/38_TASK04_nsight_inspector.png[] |
81 | 81 |
|
82 | | -=== Task 9: Bindless resources and instance look-up table |
| 82 | +== Task 9: Bindless resources and instance look-up table |
83 | 83 |
|
84 | 84 | Until now, we did not need to know what triangle our ray intersected, we only cared about whether it hit something or not. But to implement transparency, we need to know the alpha value of the texture used to shade the point on the triangle we hit. This way we can determine if we hit a transparent pixel and we need to continue the traversal, in case we hit some other opaque triangle behind it on the way towards the light. |
85 | 85 |
|
@@ -169,7 +169,7 @@ StructuredBuffer<InstanceLUT> instanceLUTBuffer; |
169 | 169 |
|
170 | 170 | Now we will see how we can use these resources with ray query to handle transparent intersections. |
171 | 171 |
|
172 | | -=== Task 10: Ray query with alpha test |
| 172 | +== Task 10: Ray query with alpha test |
173 | 173 |
|
174 | 174 | Remember how `Proceed()` advances the state of the `RayQuery` object to the next intersection candidate along the ray? This is where we will implement our alpha test logic. We will check the alpha value of the texture used for shading the triangle we hit, and if it is below a certain threshold, we will continue the traversal to find the next opaque triangle. Once we find it, we 'commit' it, and the traversal will end. |
175 | 175 |
|
@@ -278,7 +278,7 @@ image::../../../images/38_TASK10_alphacut_shadows.png[] |
278 | 278 |
|
279 | 279 | With everything set in place to support transparency in shadows, implementing other effects like reflections is very straightforward! |
280 | 280 |
|
281 | | -=== Navigation |
| 281 | +== Navigation |
282 | 282 | - Previous: xref:./04_TLAS_animation.adoc[TLAS animation] |
283 | 283 | - Next: xref:./06_Reflections.adoc[Reflections] |
284 | 284 |
|
|
0 commit comments