-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PBR Renderer: implemented clearing OIT layers
- Loading branch information
1 parent
f61a2ad
commit 3225fda
Showing
6 changed files
with
161 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
uint PackOITLayer(float Depth, float Transmittance) | ||
{ | ||
// Pack depth into the high 24 bits so that packed values | ||
// can be sorted by depth. | ||
uint D = uint(clamp(Depth, 0.0, 1.0) * 16777215.0); | ||
uint T = uint(clamp(Transmittance, 0.0, 1.0) * 255.0); | ||
return (D << 8u) | T; | ||
} | ||
|
||
uint GetOITLayerDepth(uint Layer) | ||
{ | ||
return Layer >> 8u; | ||
} | ||
|
||
float GetOITLayerTransmittance(uint Layer) | ||
{ | ||
return float(Layer & 0xFFu) / 255.0; | ||
} | ||
|
||
uint GetOITLayerDataOffset(uint2 PixelCoord, uint2 ScreenSize, uint NumLayers) | ||
{ | ||
return (PixelCoord.y * ScreenSize.x + PixelCoord.x) * NumLayers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "OIT.fxh" | ||
#include "BasicStructures.fxh" | ||
|
||
cbuffer cbFrameAttribs | ||
{ | ||
CameraAttribs g_Camera; | ||
} | ||
|
||
RWStructuredBuffer<uint> g_rwOITLayers; | ||
|
||
[numthreads(THREAD_GROUP_SIZE, THREAD_GROUP_SIZE, 1)] | ||
void main(uint3 ThreadID : SV_DispatchThreadID) | ||
{ | ||
uint2 ScreenSize = uint2(g_Camera.f4ViewportSize.x, g_Camera.f4ViewportSize.y); | ||
if (ThreadID.x >= ScreenSize.x || | ||
ThreadID.y >= ScreenSize.y) | ||
return; | ||
|
||
uint Offset = GetOITLayerDataOffset(ThreadID.xy, ScreenSize, uint(NUM_OIT_LAYERS)); | ||
for (uint layer = 0; layer < uint(NUM_OIT_LAYERS); ++layer) | ||
{ | ||
g_rwOITLayers[Offset + layer] = 0xFFFFFFFFu; | ||
} | ||
} |