Postprocessing: Shockwave pass - delta undefined in the render loop

Created on 21 Sep 2018  路  4Comments  路  Source: vanruesc/postprocessing

Actually I'm trying ShockWavePass but I had problems to make it work.
I noticed after some inspects that the problem comes from ShockWavePass.js

render(renderer, inputBuffer, outputBuffer, delta, stencilTest) {

        const epicenter = this.epicenter;
        const mainCamera = this.mainCamera;
        const screenPosition = this.screenPosition;

        const shockWaveMaterial = this.shockWaveMaterial;
        const uniforms = shockWaveMaterial.uniforms;
        const center = uniforms.center;
        const radius = uniforms.radius;
        const maxRadius = uniforms.maxRadius;
        const waveSize = uniforms.waveSize;

        this.copyMaterial.uniforms.tDiffuse.value = inputBuffer.texture;
        this.setFullscreenMaterial(this.copyMaterial);

        if(this.active) {

            // Calculate direction vectors.
            mainCamera.getWorldDirection(v);
            ab.copy(mainCamera.position).sub(epicenter);

            // Don't render the effect if the object is behind the camera.
            if(v.angleTo(ab) > HALF_PI) {

                // Scale the effect based on distance to the object.
                uniforms.cameraDistance.value = mainCamera.position.distanceTo(epicenter);

                // Calculate the screen position of the epicenter.
                screenPosition.copy(epicenter).project(mainCamera);
                center.value.x = (screenPosition.x + 1.0) * 0.5;
                center.value.y = (screenPosition.y + 1.0) * 0.5;

                uniforms.tDiffuse.value = inputBuffer.texture;
                this.setFullscreenMaterial(shockWaveMaterial);

            }

            // Update the shock wave radius based on time.
            this.time += delta * this.speed;
            radius.value = this.time - waveSize.value;

            if(radius.value >= (maxRadius.value + waveSize.value) * 2) {

                this.active = false;

            }

        }

        renderer.render(this.scene, this.camera, this.renderToScreen ? null : outputBuffer);

    }

where delta on my code it's undefined.
I made a quick test, set delta = 0.016 ( like a 60fps rate) and everything runs perfectly.
That's weird.

question

All 4 comments

Hi,

I'm guessing that you're not providing the render method of the EffectComposer with a delta value in your main loop. You can use the Clock class from three or calculate the delta time yourself. You could even take page visiblity into account to prevent animation jumps in your application.

The EffectComposer doesn't automatically calculate the delta time because it's supposed to be passive. The user should have full control over important things like the frame delta time.

Do you mean composer.render( Clock.getDelta )? Because actually I'm using only composer.render()

Do you mean composer.render(clock.getDelta())?

Yes, that's what I meant. If you do that, it should work.

Closing, as it seems to be resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emmelleppi picture emmelleppi  路  4Comments

bendxr picture bendxr  路  4Comments

brunoimbrizi picture brunoimbrizi  路  4Comments

Monder87 picture Monder87  路  3Comments

lhamadopagode picture lhamadopagode  路  4Comments