-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOA6: Add bone debug visualisation shader
This adds a visualisation debug shader to show the transformation of the bones in a given draw call, and can be used with something like this: [TextureOverrideBody] hash = 797e7cc8 if ps !== -0.0 $\debug_bones\first = 0 $\debug_bones\last = 72 run = CustomShader\debug_bones\VisualiseBones endif [TextureOverrideBoots] hash = 0cafc908 if ps !== -0.0 $\debug_bones\first = 0 $\debug_bones\last = 27 run = CustomShader\debug_bones\VisualiseBones endif Note that the visualisation is not intuitive - the dots representing the bones are not positioned where you would naively expect. They actually show how far from the origin any region of mesh would be moved, but they are relative to the origin, while the mesh is relative to the mesh.
- Loading branch information
1 parent
110ba39
commit ff7f423
Showing
3 changed files
with
115 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#define colour IniParams[0] | ||
#define first IniParams[1].x | ||
static const float size = 0.004; | ||
|
||
Texture1D<float4> IniParams : register(t120); | ||
Texture2D<float4> StereoParams : register(t121); | ||
|
||
struct vs2gs { | ||
float4 pos : SV_Position; | ||
float node_idx_percent : TEXCOORD; | ||
}; | ||
|
||
struct gs2ps { | ||
float4 pos : SV_Position0; | ||
float node_idx_percent : TEXCOORD; | ||
}; | ||
|
||
#ifdef VERTEX_SHADER | ||
cbuffer Globals : register(b0) | ||
{ | ||
row_major float4x4 mW2P; // Index: 0 1 2 3 Components: 16 | ||
float4x3 mL2W[128]; // Index: 4-387 Components: 1536 | ||
bool bSkin[3]; // Index: 388-390.x Components: 9 | ||
row_major float4x4 mW2Pt; // Index: 391 392 393 394 Components: 16 | ||
row_major float4x4 mW2S[4]; // Index: 395-410 Components: 64 | ||
} | ||
|
||
void main(uint id : SV_VertexID, out vs2gs output) | ||
{ | ||
float4 pos = float4(0,0,0,1); | ||
|
||
output.node_idx_percent = (float)id / 128; | ||
output.pos = mul(float4(mul(pos, mL2W[first + id]), 1), mW2P); | ||
// Running with no depth buffer assigned so driver won't have stereo corrected: | ||
//float4 stereo = StereoParams.Load(0); | ||
//output.pos.x += stereo.x * (output.pos.w - stereo.y); | ||
} | ||
#endif | ||
|
||
#ifdef GEOMETRY_SHADER | ||
[maxvertexcount(6)] | ||
void main(point vs2gs input[1], inout TriangleStream<gs2ps> ostream) | ||
{ | ||
gs2ps output; | ||
|
||
output.node_idx_percent = input[0].node_idx_percent; | ||
if (input[0].pos.w) { | ||
output.pos = float4(input[0].pos) + float4(-size, -size, 0, 0) * input[0].pos.w; | ||
ostream.Append(output); | ||
output.pos = float4(input[0].pos) + float4(+size, -size, 0, 0) * input[0].pos.w; | ||
ostream.Append(output); | ||
output.pos = float4(input[0].pos) + float4(-size, +size, 0, 0) * input[0].pos.w; | ||
ostream.Append(output); | ||
output.pos = float4(input[0].pos) + float4(+size, +size, 0, 0) * input[0].pos.w; | ||
ostream.Append(output); | ||
} | ||
} | ||
#endif | ||
|
||
#ifdef PIXEL_SHADER | ||
void main(gs2ps input, out float4 o0 : SV_Target0, out float depth : SV_Depth) | ||
{ | ||
o0 = colour; // * (0.05 + input.node_idx_percent * 0.95); | ||
// Set output depth to 1 so nothing else will clobber this on the render target | ||
depth = 1; | ||
} | ||
#endif |
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,47 @@ | ||
namespace = debug_bones | ||
|
||
[Constants] | ||
global $iteration = 0 | ||
global $first = 0 | ||
global $last = 128 | ||
|
||
[Present] | ||
$iteration = 0 | ||
|
||
[CustomShaderVisualiseBones] | ||
;max_executions_per_frame = 6 | ||
vs = debug_bones.hlsl | ||
gs = debug_bones.hlsl | ||
ps = debug_bones.hlsl | ||
topology = point_list | ||
;oD = null | ||
local $bak_x = x | ||
local $bak_y = y | ||
local $bak_z = z | ||
local $bak_w = w | ||
local $bak_x1 = x1 | ||
|
||
; Colour: | ||
x = 0 | ||
y = 0 | ||
z = 0 | ||
w = 1 | ||
x1 = $first | ||
if $iteration % 3 == 0 | ||
x = 0.25 | ||
elif $iteration % 3 == 1 | ||
y = 0.25 | ||
elif $iteration % 3 == 2 | ||
z = 0.25 | ||
endif | ||
$iteration = $iteration + 1 | ||
blend = ADD ONE ONE | ||
|
||
if $last >= $first | ||
draw = $last - $first + 1, 0 | ||
endif | ||
x = $bak_x | ||
y = $bak_y | ||
z = $bak_z | ||
w = $bak_w | ||
x1 = $bak_x1 |
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