Skip to content

Commit fa70250

Browse files
committed
Reduced number of diffs with "simplex"
1 parent b1f16d7 commit fa70250

File tree

3 files changed

+301
-298
lines changed

3 files changed

+301
-298
lines changed

Shaders/Composition.cs.hlsl

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,28 @@ void main( int2 pixelPos : SV_DispatchThreadId )
9494
specSg = RELAX_BackEnd_UnpackSh( spec, spec1 );
9595
}
9696

97-
if( gResolve && pixelUv.x >= gSeparator )
98-
{
99-
// Regain macro-details
100-
diff.xyz = NRD_SG_ResolveDiffuse( diffSg, N, V, roughness ); // or NRD_SH_ResolveDiffuse( diffSg, N )
101-
spec.xyz = NRD_SG_ResolveSpecular( specSg, N, V, roughness );
97+
// Regain macro-details
98+
diff.xyz = NRD_SG_ResolveDiffuse( diffSg, N, V, roughness ); // or NRD_SH_ResolveDiffuse( diffSg, N )
99+
spec.xyz = NRD_SG_ResolveSpecular( specSg, N, V, roughness );
102100

103-
// Regain micro-details & jittering // TODO: preload N and Z into SMEM
104-
float3 Ne = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 1, 0 ) ] ).xyz;
105-
float3 Nw = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( -1, 0 ) ] ).xyz;
106-
float3 Nn = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, 1 ) ] ).xyz;
107-
float3 Ns = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, -1 ) ] ).xyz;
101+
// Regain micro-details & jittering // TODO: preload N and Z into SMEM
102+
float3 Ne = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 1, 0 ) ] ).xyz;
103+
float3 Nw = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( -1, 0 ) ] ).xyz;
104+
float3 Nn = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, 1 ) ] ).xyz;
105+
float3 Ns = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, -1 ) ] ).xyz;
108106

109-
float Ze = gIn_ViewZ[ pixelPos + int2( 1, 0 ) ];
110-
float Zw = gIn_ViewZ[ pixelPos + int2( -1, 0 ) ];
111-
float Zn = gIn_ViewZ[ pixelPos + int2( 0, 1 ) ];
112-
float Zs = gIn_ViewZ[ pixelPos + int2( 0, -1 ) ];
107+
float Ze = gIn_ViewZ[ pixelPos + int2( 1, 0 ) ];
108+
float Zw = gIn_ViewZ[ pixelPos + int2( -1, 0 ) ];
109+
float Zn = gIn_ViewZ[ pixelPos + int2( 0, 1 ) ];
110+
float Zs = gIn_ViewZ[ pixelPos + int2( 0, -1 ) ];
113111

114-
float2 scale = NRD_SG_ReJitter( diffSg, specSg, V, roughness, viewZ, Ze, Zw, Zn, Zs, N, Ne, Nw, Nn, Ns );
112+
float2 scale = NRD_SG_ReJitter( diffSg, specSg, V, roughness, viewZ, Ze, Zw, Zn, Zs, N, Ne, Nw, Nn, Ns );
115113

116-
diff.xyz *= scale.x;
117-
spec.xyz *= scale.y;
118-
}
119-
else
114+
diff.xyz *= scale.x;
115+
spec.xyz *= scale.y;
116+
117+
// ( Optional ) Unresolved
118+
if( !gResolve || pixelUv.x < gSeparator )
120119
{
121120
diff.xyz = NRD_SG_ExtractColor( diffSg );
122121
spec.xyz = NRD_SG_ExtractColor( specSg );
@@ -125,36 +124,38 @@ void main( int2 pixelPos : SV_DispatchThreadId )
125124
// ( Optional ) AO / SO
126125
diff.w = diffSg.normHitDist;
127126
spec.w = specSg.normHitDist;
127+
128128
// Decode OCCLUSION mode outputs
129129
#elif( NRD_MODE == OCCLUSION )
130130
diff.w = diff.x;
131131
spec.w = spec.x;
132+
132133
// Decode DIRECTIONAL_OCCLUSION mode outputs
133134
#elif( NRD_MODE == DIRECTIONAL_OCCLUSION )
134135
NRD_SG sg = REBLUR_BackEnd_UnpackDirectionalOcclusion( diff );
135136

136-
if( gResolve )
137-
{
138-
// Regain macro-details
139-
diff.w = NRD_SG_ResolveDiffuse( sg, N ).x; // or NRD_SH_ResolveDiffuse( sg, N ).x
137+
// Regain macro-details
138+
diff.w = NRD_SG_ResolveDiffuse( sg, N, V, 1.0 ).x; // or NRD_SH_ResolveDiffuse( sg, N ).x
140139

141-
// Regain micro-details // TODO: preload N and Z into SMEM
142-
float3 Ne = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 1, 0 ) ] ).xyz;
143-
float3 Nw = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( -1, 0 ) ] ).xyz;
144-
float3 Nn = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, 1 ) ] ).xyz;
145-
float3 Ns = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, -1 ) ] ).xyz;
140+
// Regain micro-details // TODO: preload N and Z into SMEM
141+
float3 Ne = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 1, 0 ) ] ).xyz;
142+
float3 Nw = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( -1, 0 ) ] ).xyz;
143+
float3 Nn = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, 1 ) ] ).xyz;
144+
float3 Ns = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos + int2( 0, -1 ) ] ).xyz;
146145

147-
float Ze = gIn_ViewZ[ pixelPos + int2( 1, 0 ) ];
148-
float Zw = gIn_ViewZ[ pixelPos + int2( -1, 0 ) ];
149-
float Zn = gIn_ViewZ[ pixelPos + int2( 0, 1 ) ];
150-
float Zs = gIn_ViewZ[ pixelPos + int2( 0, -1 ) ];
146+
float Ze = gIn_ViewZ[ pixelPos + int2( 1, 0 ) ];
147+
float Zw = gIn_ViewZ[ pixelPos + int2( -1, 0 ) ];
148+
float Zn = gIn_ViewZ[ pixelPos + int2( 0, 1 ) ];
149+
float Zs = gIn_ViewZ[ pixelPos + int2( 0, -1 ) ];
151150

152-
float scale = NRD_SG_ReJitter( sg, sg, 0.0, V, 0.0, viewZ, Ze, Zw, Zn, Zs, N, Ne, Nw, Nn, Ns ).x;
151+
float scale = NRD_SG_ReJitter( sg, sg, V, 1.0, viewZ, Ze, Zw, Zn, Zs, N, Ne, Nw, Nn, Ns ).x;
153152

154-
diff.w *= scale;
155-
}
156-
else
153+
diff.w *= scale;
154+
155+
// ( Optional ) Unresolved
156+
if( !gResolve || pixelUv.x < gSeparator )
157157
diff.w = NRD_SG_ExtractColor( sg ).x;
158+
158159
// Decode NORMAL mode outputs
159160
#else
160161
if( gDenoiserType == DENOISER_RELAX )

0 commit comments

Comments
 (0)