-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Describe light culling shader resources.
- Loading branch information
Showing
15 changed files
with
476 additions
and
84 deletions.
There are no files selected for viewing
Submodule combined-shader-language-parser
updated
6 files
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
2 changes: 1 addition & 1 deletion
2
res/engine/shaders/hlsl/light_culling/CalculateGridFrustums.comp.hlsl
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
19 changes: 16 additions & 3 deletions
19
res/engine/shaders/hlsl/light_culling/LightCulling.comp.hlsl
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
#include "../../include/light_culling/LightCulling.glsl" | ||
|
||
/** | ||
* Defines how much threads should be executed in the X and the Y dimensions. | ||
* This macro also defines how much pixels there are in one grid tile. | ||
*/ | ||
#ifndef THREADS_IN_GROUP_XY | ||
_Static_assert(false, "thread count in group - macro not defined"); | ||
#endif | ||
|
||
/** 1 thread per pixel in a tile. 1 thread group per tile. */ | ||
[numthreads(THREADS_IN_GROUP_XY, THREADS_IN_GROUP_XY, 1 )] | ||
void csLightCulling(uint3 dispatchThreadID : SV_DispatchThreadID){ | ||
void csLightCulling(uint3 threadIdInDispatch : SV_DispatchThreadID, uint threadIdInGroup : SV_GroupIndex, uint3 groupIdInDispatch : SV_GroupID){ | ||
// Sources: | ||
// - Presentation "DirectX 11 Rendering in Battlefield 3" (2011) by Johan Andersson, DICE. | ||
// - "Forward+: A Step Toward Film-Style Shading in Real Time", Takahiro Harada (2012). | ||
|
||
// Get depth. | ||
float depth = depthTexture.Load(int3(dispatchThreadID.xy, 0)).r; | ||
// Get depth of this pixel. | ||
float depth = depthTexture.Load(int3(threadIdInDispatch.xy, 0)).r; | ||
|
||
if (threadIdInGroup == 0){ | ||
// Only one thread in the group should initialize group shared variables. | ||
initializeGroupSharedVariables(groupIdInDispatch.x, groupIdInDispatch.y); | ||
} | ||
|
||
// Make sure all group shared writes were finished and all threads from the group reached this line. | ||
GroupMemoryBarrierWithGroupSync(); | ||
} |
318 changes: 305 additions & 13 deletions
318
res/engine/shaders/include/light_culling/LightCulling.glsl
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.