Skip to content

Commit

Permalink
Remove unneeded prepass code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Bond committed Sep 25, 2024
1 parent 6e51980 commit de406ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 57 deletions.
30 changes: 9 additions & 21 deletions packages/dev/core/src/Rendering/geometryBufferRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,29 +673,17 @@ export class GeometryBufferRenderer {
}
}

// PrePass
if (this._linkedWithPrePass) {
defines.push("#define PREPASS");
if (this._depthIndex !== -1) {
defines.push("#define DEPTH_INDEX " + this._depthIndex);
defines.push("#define PREPASS_DEPTH");
}
if (this._normalIndex !== -1) {
defines.push("#define NORMAL_INDEX " + this._normalIndex);
defines.push("#define PREPASS_NORMAL");
}
} else {
if (this._enableDepth) {
defines.push("#define DEPTH");
defines.push("#define DEPTH_INDEX " + this._depthIndex);
}
if (this._enableNormal) {
defines.push("#define NORMAL");
defines.push("#define NORMAL_INDEX " + this._normalIndex);
}
// Buffers
if (this._enableDepth) {
defines.push("#define DEPTH");
defines.push("#define DEPTH_INDEX " + this._depthIndex);
}

if (this._enableNormal) {
defines.push("#define NORMAL");
defines.push("#define NORMAL_INDEX " + this._normalIndex);
}

// Buffers
if (this._enablePosition) {
defines.push("#define POSITION");
defines.push("#define POSITION_INDEX " + this._positionIndex);
Expand Down
26 changes: 8 additions & 18 deletions packages/dev/core/src/Shaders/geometry.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,14 @@ void main() {
normalOutput = normalOutput * 0.5 + 0.5;
#endif

#ifdef PREPASS
#ifdef PREPASS_DEPTH
gl_FragData[DEPTH_INDEX] = vec4(vViewPos.z / vViewPos.w, 0.0, 0.0, 1.0);
#endif

#if defined(PREPASS_NORMAL) || defined(PREPASS_WORLD_NORMAL)
gl_FragData[NORMAL_INDEX] = vec4(normalOutput, 1.0);
#endif
#else
#ifdef DEPTH
gl_FragData[DEPTH_INDEX] = vec4(vViewPos.z / vViewPos.w, 0.0, 0.0, 1.0);
#endif
#ifdef NORMAL
gl_FragData[NORMAL_INDEX] = vec4(normalOutput, 1.0);
#endif
#ifdef SCREENSPACE_DEPTH
gl_FragData[SCREENSPACE_DEPTH_INDEX] = vec4(gl_FragCoord.z, 0.0, 0.0, 1.0);
#endif
#ifdef DEPTH
gl_FragData[DEPTH_INDEX] = vec4(vViewPos.z / vViewPos.w, 0.0, 0.0, 1.0);
#endif
#ifdef NORMAL
gl_FragData[NORMAL_INDEX] = vec4(normalOutput, 1.0);
#endif
#ifdef SCREENSPACE_DEPTH
gl_FragData[SCREENSPACE_DEPTH_INDEX] = vec4(gl_FragCoord.z, 0.0, 0.0, 1.0);
#endif

#ifdef POSITION
Expand Down
26 changes: 8 additions & 18 deletions packages/dev/core/src/ShadersWGSL/geometry.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,14 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
#endif

var fragData: array<vec4<f32>, SCENE_MRT_COUNT>;
#ifdef PREPASS
#ifdef PREPASS_DEPTH
fragData[DEPTH_INDEX] = vec4f(input.vViewPos.z / input.vViewPos.w, 0.0, 0.0, 1.0);
#endif

#if defined(PREPASS_NORMAL) || defined(PREPASS_WORLD_NORMAL)
fragData[NORMAL_INDEX] = vec4f(normalOutput, 1.0);
#endif
#else
#ifdef DEPTH
fragData[DEPTH_INDEX] = vec4f(input.vViewPos.z / input.vViewPos.w, 0.0, 0.0, 1.0);
#endif
#ifdef NORMAL
fragData[NORMAL_INDEX] = vec4f(normalOutput, 1.0);
#endif
#ifdef SCREENSPACE_DEPTH
fragData[SCREENSPACE_DEPTH_INDEX] = vec4f(fragmentInputs.position.z, 0.0, 0.0, 1.0);
#endif
#ifdef DEPTH
fragData[DEPTH_INDEX] = vec4f(input.vViewPos.z / input.vViewPos.w, 0.0, 0.0, 1.0);
#endif
#ifdef NORMAL
fragData[NORMAL_INDEX] = vec4f(normalOutput, 1.0);
#endif
#ifdef SCREENSPACE_DEPTH
fragData[SCREENSPACE_DEPTH_INDEX] = vec4f(fragmentInputs.position.z, 0.0, 0.0, 1.0);
#endif

#ifdef POSITION
Expand Down

0 comments on commit de406ef

Please sign in to comment.