Skip to content

[v7 Beta 10] GData.depth is 0 #698

Open
@JohannesKlauss

Description

@JohannesKlauss

Description of the bug

I am fiddling around with the v7 branch, because the new render pipeline architecture looks super convienent to me. I tried accessing the depth value in GData, but it always returns 0.

To reproduce

  • Use v7.beta-10 & three.js 0.175

  • Set up renderer:

const renderer = new WebGLRenderer({
        powerPreference: "high-performance",
        antialias: false,
        stencil: false,
        depth: false,
        canvas,
      })
  • Create a pass with this shader:
vec4 mainImage(const in vec4 inputColor, const in vec2 uv, const in GData data) {
    return vec4(vec3(data.depth), 1.0);
}
export class OutlineEffect extends Effect {
  constructor(args: ConstructorArgs) {
      super("OutlineEffect")

      this.fragmentShader = fragmentShader

      const uniforms = this.input.uniforms

      uniforms.set('uScale', new Uniform(args.scale || 1))
  }
}
  • Add pass to render pipeline:
renderPipeline = new RenderPipeline(renderer);

    renderPipeline.add(
      new ClearPass(),
      new GeometryPass(scene, camera),
      new DepthCopyPass(),
      new EffectPass(new FXAAEffect(), new OutlineEffect())
    );
  • Canvas is rendered black

Is this already implemented and do I actually need the DepthCopyPass? Because according to the manual the pass sets the depth value automatically.

And since I am already here, I got another question. The v7 manual states:

To sample depth at any location, use readDepth(depthBuffer, uv)

What is depthBuffer refering to? Trying to access gData.depth throws a compilation error: ERROR: 0:284: 'depth' : no such field in structure

Is the whole depth functionality not yet implemented?

Expected behavior

The depth value is set

Library versions used

  • Three: 0.175.0
  • Post Processing: 7.beta-10

Desktop

  • OS: Mac OS 15.3.2 (24D81)
  • Browser: Brave v1.76.82
  • Graphics hardware: Apple M2 Max:

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportUser support and general help

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions