Skip to content

Commit 2597768

Browse files
committed
Fix default gbuffer output
1 parent 702b858 commit 2597768

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/shader-chunks/ShaderChunkExtensions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ export class ShaderChunkExtensions {
7575

7676
// Let non-PBR shaders write default values.
7777

78-
ShaderLib.background.fragmentShader = ShaderLib.background.fragmentShader.replace(
79-
/(#include <tonemapping_fragment>)/,
80-
"#include <pp_default_output_fragment>\n$1"
81-
);
82-
8378
const shaders = [
79+
ShaderLib.background,
8480
ShaderLib.basic,
8581
ShaderLib.lambert,
8682
ShaderLib.phong,
@@ -93,7 +89,7 @@ export class ShaderChunkExtensions {
9389
for(const shader of shaders) {
9490

9591
shader.fragmentShader = shader.fragmentShader.replace(
96-
/(#include <clipping_planes_fragment>)/,
92+
/(^ *void\s+main\(\)\s+{.*)/m,
9793
"$1\n\n#include <pp_default_output_fragment>"
9894
);
9995

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
#include "gbuffer-normal.frag"
2-
#include "gbuffer-occlusion.frag"
3-
#include "gbuffer-roughness.frag"
4-
#include "gbuffer-metalness.frag"
5-
#include "gbuffer-emission.frag"
1+
#ifdef out_Color
2+
3+
out_Color = vec4(0.0);
4+
5+
#endif
6+
7+
#ifdef out_Emission
8+
9+
out_Emission = vec4(0.0);
10+
11+
#endif
12+
13+
#ifdef out_ORM
14+
15+
out_ORM = vec4(0.0);
16+
17+
#endif
18+
19+
#ifdef out_Normal
20+
21+
out_Normal = vec2(0.0);
22+
23+
#endif

0 commit comments

Comments
 (0)